Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2690595pxu; Mon, 7 Dec 2020 12:58:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQJw+lcwGh/fSxJbnspdkf+5Xih369B3o7V6fxJX8r1egqFkvIAHLYnOXCUsjOtz/r0WX6 X-Received: by 2002:a17:906:339a:: with SMTP id v26mr20255184eja.107.1607374728032; Mon, 07 Dec 2020 12:58:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607374728; cv=none; d=google.com; s=arc-20160816; b=SLy7tESazqcN5HD3PXxOnfefV7K4zwWwMT8A56znW6NjHGOjivvTrtXNP6zmoUni50 vnsb7VEjWqOUH7CGvtksEXNFnVPnOPfHIKMfMTpaydveCauMntRvXJG/4iiB/mkoEp5s AH0G3MazZlQdHvuqaZjw+Ko4tNxGFYQY/2yGqn9dcazqqjUIwoGjtPm9vrd8JupPqsbF TNy1d9nfWJF9VdCCx6vTspMsgOutPyIrjdM2ataVbfoJUjr2h95JYhD4idyD+nMnZFQb nq7AbCTJPht+r2pyL9tpVJGNFdIIbGIFpCWbWGLIzU8oL8x5PfKGZTHHMtiP4HH8xLmn TjFA== 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:dkim-signature; bh=8YG17SSVuJgwGIpcMzN3dn+GzIecfAXIsWVzJqr65Eo=; b=K7HtVWqb0w+DjXsYByMSRsseFpcmZdAaGJ47u4ARGUT8o1yTgpl6QP3hrB6p07pldF JSJqDrQHD1sgKEiPgiN/KEbVxs2ohQEXGS5TSvh5Hw1uxkFpUPowC2LWLHbuyRs+imuk 69ILmqUz5Emvr8C/A4CcDWx6nZg1Yfw+RaEKRI2tH5Ft3UDLUlc2Jp8h8lrsblAPR9t4 XVYgqRRm2+ZrjzdwPn/1o2S8D+V6Fg3kNNSCZiivOzoeAFC/SIktnlzFYm5fx0KUAwfP gckDkKSuWeVE8Rbppzj0anw0RMDDaYObAkDSwYNC9sMvlWLj1JhVqmJH69MUFk09xAUX w4Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=bx3a+7hn; 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 me7si7411079ejb.11.2020.12.07.12.58.21; Mon, 07 Dec 2020 12:58:48 -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; dkim=pass header.i=@ziepe.ca header.s=google header.b=bx3a+7hn; 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 S1726270AbgLGU4V (ORCPT + 99 others); Mon, 7 Dec 2020 15:56:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726203AbgLGU4U (ORCPT ); Mon, 7 Dec 2020 15:56:20 -0500 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E0D4C061749 for ; Mon, 7 Dec 2020 12:55:34 -0800 (PST) Received: by mail-qt1-x842.google.com with SMTP id y15so2913770qtv.5 for ; Mon, 07 Dec 2020 12:55:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=8YG17SSVuJgwGIpcMzN3dn+GzIecfAXIsWVzJqr65Eo=; b=bx3a+7hnV5LT/kqYVdT/TYircF3A/nA6pobjdaX4CXPT71sS2M93+H8cYoE6NRq6nH dbDaA+ipjTXrMvbdOKldYE6u2IP2g1UFYHdInsXPkJkdZspLGr1BBViziQOQ8vh4d1Au WzYlv0B/WATw0N7iLClEkCdZEEY8CtaH+vnF302zpZjthE27WyJGlJrel1OQT9j5goqS ph5UqukiK0DmRvBFW1Zrn3tZQOTFt+ck/1GGKwP3H5QNi7f3p+Brc9Ev70bpJ20oQh3d bKzauvvdfKl1IverjIvLAIhXIqTLFBBRrfJgka5QmvsH37rncm3b/1k0YIlv5Ehoas9R zF0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=8YG17SSVuJgwGIpcMzN3dn+GzIecfAXIsWVzJqr65Eo=; b=EGkhMKnW8yf1ck/Toacd8BzXRolvMjuOmFlJZv1qx8Txo5TTsSaRXZp0gJoFRhCnP9 PCLgmYU0cXaumdkLJHdUUXmTU0zU13SRyrctSiDeFK3z7ZJfsduZaStPugeSodfbDTWi Qz2ohx0USBD536h5YilYg7EzhpYmTC8OSIKG6l17+FLBIdunHIpRoT4uQstA8s41JNSv Mkfbq0+7EDfsFCnVq7qp2/6eWDS3rTJnf2smq7XgLgQYSNT+G6RlbDq/FZU3BlVbDdZj GD/6dePzpaUKqDYyK5Dk8fSjqtf4s1CSOmogv1xAETKA2aC3bs0t2AHES3AkDy5OvRRa j99A== X-Gm-Message-State: AOAM532Pk1sXbGU32wKfhnBb5wFoc3ZVr9knqosAattyZHKgBM6325mt pGWK171IeCt0sS/mmDo6ohTk2A== X-Received: by 2002:a05:622a:182:: with SMTP id s2mr25463960qtw.147.1607374533698; Mon, 07 Dec 2020 12:55:33 -0800 (PST) Received: from ziepe.ca (hlfxns017vw-142-162-115-133.dhcp-dynamic.fibreop.ns.bellaliant.net. [142.162.115.133]) by smtp.gmail.com with ESMTPSA id w7sm12573425qkd.92.2020.12.07.12.55.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Dec 2020 12:55:32 -0800 (PST) Received: from jgg by mlx with local (Exim 4.94) (envelope-from ) id 1kmNXg-007fV6-3E; Mon, 07 Dec 2020 16:55:32 -0400 Date: Mon, 7 Dec 2020 16:55:32 -0400 From: Jason Gunthorpe To: Thomas Gleixner Cc: LKML , Alexandre Belloni , 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: <20201207205532.GJ5487@ziepe.ca> 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 On Sun, Dec 06, 2020 at 10:46:17PM +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(-) > > +++ 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; So the old value is clearly wrong for CMOS, and I have a strong feeling this was an error and it should have been -NSEC_PER_SEC/2 I have no idea if CMOS behavior or 0s behavior is more common in the rtclib drivers, but it seems since nobody noticed the huge offset mistake in 3 years it doesn't actually really matter. Reviewed-by: Jason Gunthorpe Jason