Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp293154pxu; Fri, 11 Dec 2020 02:28:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJww65/rZ831/5krjUyh5TlEouN419H18Z6xm2qRjY8Nt2rMNjsoAAfXwiVP6hgz8YebssaC X-Received: by 2002:aa7:d7d2:: with SMTP id e18mr11380085eds.256.1607682483173; Fri, 11 Dec 2020 02:28:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607682483; cv=none; d=google.com; s=arc-20160816; b=yC+y9ggW2ekMvvj0VHRwPqvF8HKb5J5NPMBwy9fRheVfOu8mypIQZUj9zKH55uBE0J SsVKJ7lLYPjEUTgBy/NhB6HjrWvJzaDJtNJH6NBKbV+4lbf/ASrZnBakjZfVmRfui7KG X3+ekmjeyDox+ZFF9Bf0qQNqDVVuSxfyEXJQcM2hjcvvB2A54rvI8nHtfVuyB6CQB1vX iAabaO8ZLbbHlgX9L/LPRVIAhot4G9Fk/dGF96cuYmPK18uepo3eowuaDbwm8+Mb2WGY pAKL/ZQrSMu5mxUOL6DKPekfS6eRTmbEOkFHXF0o+WWr/CGImBebOuhgiUxic3CnAFw1 T7PQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=AmNZBbmII7G5/8vVWWjCjbZ2RHV0bPYyqOZO9ej3BeA=; b=GP0AJ4hBKY4hRtD9zJmLnbPt2hne5k//1EqQEWtw9oegOcsSHf6De0j52y7o9U4d/0 a8VH7c78IJTLuBtYaC6INPFsq62uNBpAfPypn7iN2mGwWCzpryWyBn5gIhxSX0S0AfZI a5nkH5dVplOi72Y/doUthZ83L2MvhYRjhJlyClE9tWEwZmfcCNf562zauuo3u35fHfpa XCizTPXt1qTCj+AcjSu3nJ0vYKI9OgX4A+duoXO8M8071c5SvyBYiXXdIwuBPXCU7KYB m/w9eTzGB31S9LUsb8k3udM/nplVZeo1lnrCYt4LnxgQJ5Jzu1iQLaHxwBfkR9if8wvG 78bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si4193554ejd.532.2020.12.11.02.27.40; Fri, 11 Dec 2020 02:28:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387807AbgLKAAf (ORCPT + 99 others); Thu, 10 Dec 2020 19:00:35 -0500 Received: from relay1-d.mail.gandi.net ([217.70.183.193]:31781 "EHLO relay1-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389587AbgLJX7w (ORCPT ); Thu, 10 Dec 2020 18:59:52 -0500 X-Originating-IP: 86.194.74.19 Received: from localhost (lfbn-lyo-1-997-19.w86-194.abo.wanadoo.fr [86.194.74.19]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 0C1D1240006; Thu, 10 Dec 2020 23:59:08 +0000 (UTC) Date: Fri, 11 Dec 2020 00:59:08 +0100 From: Alexandre Belloni To: Thomas Gleixner Cc: LKML , Jason Gunthorpe , Miroslav Lichvar , John Stultz , Prarit Bhargava , Alessandro Zummo , linux-rtc@vger.kernel.org, Peter Zijlstra Subject: Re: [patch 4/8] rtc: core: Make the sync offset default more realistic Message-ID: <20201210235908.GA1781038@piout.net> References: <20201206214613.444124194@linutronix.de> <20201206220541.960333166@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201206220541.960333166@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 06/12/2020 22:46:17+0100, Thomas Gleixner wrote: > The offset which is used to steer the start of an RTC synchronization > update via rtc_set_ntp_time() is huge. The math behind this is: > > tsched twrite(t2.tv_sec - 1) t2 (seconds increment) > > twrite - tsched is the transport time for the write to hit the device. > > t2 - twrite depends on the chip and is for most chips one second. > > The rtc_set_ntp_time() calculation of tsched is: > > tsched = t2 - 1sec - (t2 - twrite) > > The default for the sync offset is 500ms which means that twrite - tsched > is 500ms assumed that t2 - twrite is one second. > > This is 0.5 seconds off for RTCs which are directly accessible by IO writes > and probably for the majority of i2C/SPI based RTC off by an order of > magnitude. Set it to 10ms which should bring it closer to reality. > > The default can be adjusted by drivers (rtc_cmos does so) and could be > adjusted further by a calibration method which is an orthogonal problem. > > Signed-off-by: Thomas Gleixner > --- > drivers/rtc/class.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > --- a/drivers/rtc/class.c > +++ b/drivers/rtc/class.c > @@ -201,7 +201,7 @@ static struct rtc_device *rtc_allocate_d > device_initialize(&rtc->dev); > > /* Drivers can revise this default after allocating the device. */ > - rtc->set_offset_nsec = NSEC_PER_SEC / 2; > + rtc->set_offset_nsec = 10 * NSEC_PER_MSEC; I did retest, on a slow 100kHz i2c bus, with a fairly inconvenient RTC, The maximum offset to set the RTC was 4845533ns so I'd say 10ms is too large. Should we make that 5ms ? Apart from that, on the series, you can add my Acked-by: Alexandre Belloni -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com