From patchwork Mon Jun 18 14:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 138961 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4012203lji; Mon, 18 Jun 2018 07:20:05 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLbLeVBULZuozz0Egf+YSvclBx32McaH/1d+xVh5cbTgiYE2Sql6ypTKROkHswejPHy0u7V X-Received: by 2002:a17:902:5488:: with SMTP id e8-v6mr14228281pli.137.1529331605259; Mon, 18 Jun 2018 07:20:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529331605; cv=none; d=google.com; s=arc-20160816; b=Gz3sa5Gi0eXeDv4v7pKWfD/k9HuVXVQicmijYCdN8RPmXqcXS1Be9pHeAMgy+sWbms U9NobN2X2VeSHfBcmsK5wpYGrtXnv3fSTOnc40uXMVtY1meDdEtC8B1Rl6mJN+PGZf/5 4aerTYoq7yqygxfHYLGO77HJOlQhd2jYvObvD/jXaooedN8F19BrdvvZ4jLGdvzhlQOy nT9Cw5X9eoMep/QIU9it/I/mC/VnCxsYixH/9Bdojq/RtUUivIbSFVH2qCEr4jrenxa5 gG0OWN2bpVPrKEagD9N6uyujUjlehTZC3BUD1AYZSU9Lhobjg8U8r0nIOuAK72DIcnYB kTqw== 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=tkmhL5dDZ5b8rXC2HyecI5p9wG8MtSmqp0pcjMZiwRQ=; b=YU3HWg2xe88flCwH/1uGIlRypeKLaK+rnSTU7SkjKB/ctvKAR91h34HgNDAlaPb/yO yPDyfbOgrxoYhok1uGG+v8oGf4e1beZOGlgsLeccx9lBAAf94bx2qguBo6xCc34VlFit VWcuUG+uNZHKLn1JyYnlFxVFQq95EaHaZCsd8VT8vEzAaiX6kKQpvK5ny8a637wovYwh YXhAFFP/IF/QXUWf1h5SzPexPiEGqilOC24Wx/ekoLU+cofvZSbOL1yR7XmtN0tQZVsz WWn/Mhmvl7qLJhCTHXuGUVGnJVhX0kXLNtOysbwnk5WS4ZlNf+dFQXKTzn7Iv5NLHU4F g5Eg== 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 v5-v6si12238179pgq.32.2018.06.18.07.20.04; Mon, 18 Jun 2018 07:20:05 -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 S934787AbeFROUC (ORCPT + 30 others); Mon, 18 Jun 2018 10:20:02 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:52413 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934284AbeFROUB (ORCPT ); Mon, 18 Jun 2018 10:20:01 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0LgKx6-1fyQJn1XkK-00njHZ; Mon, 18 Jun 2018 16:19:35 +0200 From: Arnd Bergmann To: Stefan Richter Cc: y2038@lists.linaro.org, Arnd Bergmann , Hector Martin , Mark Rutland , Ingo Molnar , "Paul E. McKenney" , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] firewire: ohci: stop using get_seconds() for BUS_TIME Date: Mon, 18 Jun 2018 16:19:24 +0200 Message-Id: <20180618141933.3404739-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:fsiBvUI1XEghixXicUguhIpsjFL9E36Kf1V0WZCOVr9DFsr3mY8 PxvdZ6Z5oMxg7CB+tZwqyzoiMFP3UeANfigRh5n9mEWeown2di1kYOYpLWsszfZqXGwYxIX d2/QCq4ME4lPrUA3F9PlHUHpYc90ZPTd5hRfMSP0Z+Eh6r/U/2VdvBcI6xajzC7OoQKKt/i vsnOSptbPc3sciDqkdpfw== X-UI-Out-Filterresults: notjunk:1; V01:K0:DLJ/MaAMXIc=:CLSqRq4CtglwyyGHSEwFmW g93Nu3r4bCgvdJ7aZk12MG7j1ophzcVLNwxD58+KDKEmlPz0yBfKXgEE/f2yzoPhzrI0/P/3z x5gswKv5wfjDj2vKD4ZNzY62cbYX9LVLrz1h7cewqnKGL7RIDTZk2TvbuGWacdoNiF2BKk6Eu EudNs4YVpRo+HPCHSmO8goXPsrmizrNEWOyc5PrYNufaEH/cC2NqQDAGv3VhCZVLOlOqtRQqu 0JeePHrqMSvrg4iFHnSCHMiQh/RIrkpMB35X0xwdfnYegWORWw6Xl1KA836AsQ3ekqWsiURwv od6VcHC7qI3YvGWh5fLE9jbLiO3BEQ25CC3S8AoqakVOY8x0QnWl7E2G+ZbIl4N4soSJGZjH6 PFquNM6F+fTgtcAT8suiGiwks2xD7Fpg7lW9NgFBjYKEGhy5o+qdH3U1MbjsbGiya5BPZxIaZ 6qUb1OB4PB29fYxd89q7xHVCro90hIHo7tpAtGWO22FOzkaAENEICcZ4YbUC59gFEVZU2I7V4 ZiB1DH+ZJPBuCy6Z46Fgqec5fdietrQmUGfdwrSCeE430Xemd3mjtYBP471L/AATCi40n/+Qx vMnm2lI8nsNOyNQ6M961huRcoi4+susa3E3O4GHPGN4QJwOv4r97R9SjNi4x/3VwFWACxPKvt Xgxr2b2n/5Y1IdSW01eNRPe7teBy8V03RrrgoZCuVo5LYMYy5UAFWahjZLJ3uZqGIUg0= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ohci driver uses the get_seconds() function to implement the 32-bit CSR_BUS_TIME register. This was added in 2010 commit a48777e03ad5 ("firewire: add CSR BUS_TIME support"). As get_seconds() returns a 32-bit value (on 32-bit architectures), it seems like a good fit for that register, but it is also deprecated because of the y2038/y2106 overflow problem, and should be replaced throughout the kernel with either ktime_get_real_seconds() or ktime_get_seconds(). I'm using the latter here, which uses monotonic time. This has the advantage of behaving better during concurrent settimeofday() updates or leap second adjustments and won't overflow a 32-bit integer, but the downside of using CLOCK_MONOTONIC instead of CLOCK_REALTIME is that the observed values are not related to external clocks. If we instead need UTC but can live with clock jumps or overflows, then we should use ktime_get_real_seconds() instead, retaining the existing behavior. Signed-off-by: Arnd Bergmann --- drivers/firewire/ohci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.9.0 Reviewed-By: Clemens Ladisch diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 45c048751f3b..5125841ea338 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c @@ -1765,7 +1765,7 @@ static u32 update_bus_time(struct fw_ohci *ohci) if (unlikely(!ohci->bus_time_running)) { reg_write(ohci, OHCI1394_IntMaskSet, OHCI1394_cycle64Seconds); - ohci->bus_time = (lower_32_bits(get_seconds()) & ~0x7f) | + ohci->bus_time = (lower_32_bits(ktime_get_seconds()) & ~0x7f) | (cycle_time_seconds & 0x40); ohci->bus_time_running = true; }