Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4805677imm; Mon, 18 Jun 2018 23:35:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIBaA3tAA83ecb2NwR3QSZkJ6pS09N/Hfr8vExTTBBnv68tZRXQsmaneq47HJ5ClGDwzntP X-Received: by 2002:a17:902:904c:: with SMTP id w12-v6mr8124015plz.34.1529390148211; Mon, 18 Jun 2018 23:35:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529390148; cv=none; d=google.com; s=arc-20160816; b=07wASs/HxrGCy55mTDkiN39yB4qn8EPPVfDh+okecG/zTHUKaRgWK6E2zoe+nlmIYb gmP9THphf59j7f3CLdJ6ANkmSnz1C9Pa5VArt3NrTM7ouUkEwKNNFtYdoIG9kEn8Psbt 7ZVgURB+FEgEj771phOOsBXOLgHl4LnX/sb87D+QhEB6zDSf45epChtwgL7mYAxpX9Eg vH38oAWDvHLgzkOIvnk1F6x4tPxk/n47JMCnF4wMRffxWnYv+/hrRXse/9jj2hM6/7lW FNkcEvhjbMsMjlvhyQ9tyNCy9Th4gFO9ad1UXnpV1nu9TPRlVXhdHvRC7uwTq4WB2ArO OZ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=hCvceavnRMX4q5WSmoDQ/wMb3kW7xkpoFP8CdHQ3YpA=; b=JKFRaxPRj7wnZGeD3vdzhrrf1be/S6xp5spp5MwNe0aj51BF9/yPWv3T4SpgP+pH60 /wo6ydpATfEpGmJHb1Ya64cfU0f11LTsKyk0jsdM3gTKX9r8wo5zoJYk4Y337qJq0zxS bUMgGrMQ+5lvy2dHZ0fChGWkz8F66xUIpjeXBIK+PBV+sbBrL7eDDk/AnMuhLTSdxYhn eSMYk3CVoy2nasqbsUR5Y5MM6JD2ld5nYMKZJ3R9C2dBFrPPVNS4QKA7Tgo0hs5c8e0l v9XKHBhINP06Jkvi8TD3e1VZ9hA4yvbsrWAJoFYcS+maPdVs8/JNTEPWWIE2fQK9ZXPN 81PA== 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 t80-v6si16244333pfe.59.2018.06.18.23.35.34; Mon, 18 Jun 2018 23:35:48 -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 S1756161AbeFSGen (ORCPT + 99 others); Tue, 19 Jun 2018 02:34:43 -0400 Received: from webclient5.webclient5.de ([136.243.32.184]:44195 "EHLO webclient5.webclient5.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751166AbeFSGem (ORCPT ); Tue, 19 Jun 2018 02:34:42 -0400 X-Greylist: delayed 485 seconds by postgrey-1.27 at vger.kernel.org; Tue, 19 Jun 2018 02:34:42 EDT Received: from [10.1.2.4] (unknown [94.101.37.79]) by webclient5.webclient5.de (Postfix) with ESMTPSA id F22755582405; Tue, 19 Jun 2018 08:26:34 +0200 (CEST) Subject: Re: [PATCH] firewire: ohci: stop using get_seconds() for BUS_TIME To: Arnd Bergmann , Stefan Richter Cc: Mark Rutland , linux1394-devel@lists.sourceforge.net, y2038@lists.linaro.org, Hector Martin , linux-kernel@vger.kernel.org, "Paul E. McKenney" , Ingo Molnar References: <20180618141933.3404739-1-arnd@arndb.de> From: Clemens Ladisch Message-ID: <355fd76d-0196-55b8-20f5-9b3136507690@ladisch.de> Date: Tue, 19 Jun 2018 08:26:43 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180618141933.3404739-1-arnd@arndb.de> Content-Type: text/plain; charset=us-ascii Content-Language: en-US Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.99.4 at webclient5 X-Virus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arnd Bergmann wrote: > 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 Reviewed-By: Clemens Ladisch > --- > drivers/firewire/ohci.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > 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; > }