From patchwork Fri Jul 13 15:06:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 141904 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp916108ljj; Fri, 13 Jul 2018 08:07:13 -0700 (PDT) X-Google-Smtp-Source: AAOMgpenNpr29SbnqRERzCQ+sGTLmN5CbABM404ykyyWLQrLaG4Ve5K06v/39w2GuTXyORXLjAhL X-Received: by 2002:a17:902:6686:: with SMTP id e6-v6mr6796103plk.35.1531494433416; Fri, 13 Jul 2018 08:07:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531494433; cv=none; d=google.com; s=arc-20160816; b=Nh5wTQ0/+3j9uBaQ6SrHqeJnJyyDEFnnfnP/Ei4vZPxopY4mSHlSX0H97Ck2wgXw03 09lrU2rnv4KwtC3E3r/hSwqwSx624qcFEOihOMhoRLaNZlKMnTH4JYlm18LSR/aZcDsY s8to6c7h/73Koc5H3DU0uUGz2UHCv1Y4kvrJ74ghXSOqovjJQV1JLqcS72McTJKT4qUm nisaN/KlR/LWGjq8SwXVDfrBfW5SRaRNnEIfclIoW7ohyQvIxfXV71uWeCI++8MbaYu7 03aQJZEuJtyAqzfoNOzv2q4VHT5qTOQqEgKFEkG3oQr3px5qviQlKLCgWo5aV46zcUAL WbRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=RjenYDLOugWDRg5mGBavPGdW6NRYg6xGDuJF8kJG8yA=; b=pSHEiDCtyW76JHPc5E7y71Gkvlp27sEOD0jUHIAW+2YowZ14qwafuwAjTOWvqHGrDk x9AEaHu4ZXFz6hhhEuPYa+6ZUKTb934A/3N0ne2E4BcjaNhyfCMpxs6mzFqwNe32+V1B xoy8hjZTEEQ7NofgiMJsNyxkKyzcsNq+L3EYwSaaVZXTqbL5jh+akZSY5Vbre6ESf7y9 vnd1ghoj2OtNIuWLV5Xka8PGeZub7V2SPoKOB6uavKIwp3OEHKoqaWO16iSAcYPRYegS YJlanGbDHqKep34IIXUUzACrrEXX5tkpjUavJ0Zk0NPIVw2Qw88eDdZ23pCmjVViGelU h/GA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t1-v6si10232950pgg.643.2018.07.13.08.07.12; Fri, 13 Jul 2018 08:07:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731261AbeGMPWL (ORCPT + 31 others); Fri, 13 Jul 2018 11:22:11 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:43507 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729653AbeGMPWK (ORCPT ); Fri, 13 Jul 2018 11:22:10 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue102 [212.227.15.145]) with ESMTPA (Nemesis) id 0MarjW-1fKgeh47kg-00KNwG; Fri, 13 Jul 2018 17:07:06 +0200 From: Arnd Bergmann To: Rob Springer , John Joseph , Ben Chan , Greg Kroah-Hartman Cc: Arnd Bergmann , Simon Que , devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: gasket remove current_kernel_time usage Date: Fri, 13 Jul 2018 17:06:37 +0200 Message-Id: <20180713150703.3156256-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:G6aoTFHleRaNKcwQWEDvwO22CVEaxZ5qNc1H3XM69Gdpkih8ho6 QQUTd7KcgsV/gEvtcLaeJThIdj3UkD+/A5jnTJ1oHqb7Op2MZICkBWZjPyz4E38VLys3uDr waQf++4J+XIRdmUk69BUl/etQRViLMGaAiCbC4kJmQzFtIw4VE6paJytFz97f9+eXB0iQ0u QzLiEN95Ga1C/TaetiaPA== X-UI-Out-Filterresults: notjunk:1; V01:K0:ZqKHunGeb54=:Yb3dO8hAcyOPkV0I6Woyl/ WctPkZC0njZYoc/WwoMOeI21Qj5JvAgA9dSZd+rfxWrNQPAwdYntmaUETC6oV4PCrKjlmg2uQ w6V0CKy0JxHMCVKrkGELwNXC3CJ2Q6aUVHHf7nuN0nXFx8bAMys+W2FvtddItrSjfUFGBJvOo SVUWdE6/iPeRBATmqx/yhXnkPdj4itwwjnHq/+T68zMWnEQxZX0tJUkdjFJGj4ff63rYglnm4 8OG/pN32Xf5IbJXb7P+556CxIipDQ69X6s1zVznfQZy814q2IvndkAfCWAX9ZJWS3dju5SUZO OyaCFzB4PypG1G0WChz8l1AGNNlVAKfqDAsJKg9QnlpMUVpqqSNFjl+bG7Kf9Ewv+mbtJz7/T pBLIqBj7xYJ+vfQdV1cIDfELsQogcHXkmMUwMhGI4X2tf2GdmqVcsH3BJ6im5vEeeDkGCtZY2 gMM4pStZ+EJwVzKbmF4ABIyp9BAjSUUgNjMppSPrUWuLFaQITuVyQpw+gVdYgxnDnB7M1eFNP CBKlRneUbss3/R/N6RMhce4YY5tdqMdLf6gDdM2FwdWnvXI19s6RG0gcMwDm3Hk69qxD/T4ve C/OsZMaOJpr005vxMJJrln3yCoewF5GTjdjfOnIk3hqAiROaKUoG5HL/vCVRtxOegjzmfr45D YaXzk298/ZNuWMKxbu9gb2Gp3XhDg6UpCxkTDjCluEkywgixSZtk4YuNFPrCZFPpFHDY= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A new user of the deprecated current_kernel_time() function has appeared here. This code won't work correct during leap seconds or a concurrent settimeofday() call, and it probably doesn't do what the author intended even for the normal case, as it passes a timeout in nanoseconds but reads the time using a jiffies-granularity accessor. I'm changing it to ktime_get_ns() here, which simplifies the logic, and uses a high-res clocksource. This is a bit slower, but that probably doesn't matter in a busy-wait loop. Note: it also doesn't matter in the current version, as there are no callers of this function. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Arnd Bergmann --- drivers/staging/gasket/gasket_core.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) -- 2.9.0 Reported-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/staging/gasket/gasket_core.c b/drivers/staging/gasket/gasket_core.c index 45914ebc8f44..248c99a841a9 100644 --- a/drivers/staging/gasket/gasket_core.c +++ b/drivers/staging/gasket/gasket_core.c @@ -2090,19 +2090,14 @@ int gasket_wait_sync( u64 timeout_ns) { u64 reg; - struct timespec start_time, cur_time; - u64 diff_nanosec; + u64 start_time, diff_nanosec; int count = 0; reg = gasket_dev_read_64(gasket_dev, bar, offset); - start_time = current_kernel_time(); + start_time = ktime_get_ns(); while ((reg & mask) != val) { count++; - cur_time = current_kernel_time(); - diff_nanosec = (u64)(cur_time.tv_sec - start_time.tv_sec) * - 1000000000LL + - (u64)(cur_time.tv_nsec) - - (u64)(start_time.tv_nsec); + diff_nanosec = ktime_get_ns() - start_time; if (diff_nanosec > timeout_ns) { gasket_log_error( gasket_dev,