Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1974648pxu; Sun, 6 Dec 2020 14:10:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxmswAxhtwclouxVoCPZOk6mUgnCzD1ryb8hzt5QljF3UMdXWb9HV7sS5XG1nxLzjJqYNub X-Received: by 2002:a17:906:c046:: with SMTP id bm6mr15819363ejb.436.1607292620820; Sun, 06 Dec 2020 14:10:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607292620; cv=none; d=google.com; s=arc-20160816; b=EwIPZtPmywI4mdHC9rgjDXcQQoZGn7yQBaMyPLdLd2W24QkpPxicKJKft13EVHmqld A0/KMTnpI2A4cA4hzJrPreZUm8tfF7cJCIiefsYhmDFxBZhUoh88wyQYOtKPAANzE5su PuSciKhSLZf8h+YiPP1nUkxQtBGvH3TrkdTBhEzD6w4Jh9HDLyoF6Jef74P47T7q1Xi1 b+Vqr9N9hSD0ZTGeLdx47ZEr6Ggugh5a3x2Z7jn5TvYFHfEBQ4snY9UcZac6yR5BcZD9 1mEB77YlvXpdlLNHfl333OO2JWDBCshqau/pbT5vMgOeJ2qa2FHIiRQR4q0kYaYHX8Q/ oJhA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:subject:cc:to:from:date:dkim-signature:dkim-signature :message-id; bh=JG5dX8xGxOTL3ExdOYCuqriVX+SU7EFieMrumJ4D7go=; b=J0cwPxw1RQUxrkHv5FIGV94Zvi7j5tFZWJXanfiRwIBKwW8Y10bw6vuhcMMMKen8Ha xnGEYKGVDV7juspwRvMAhzywfdBc5b3vA2SLFCrl8wMOTzWpoqXhkdlNtH0b67FZGoor s6FGmIql2Qxl7bPDu2LJgoigep+hJxAUvFiRhwN1nCHrvAyyuZ6D0C+mbOFEmDPBByx0 a8TKdKdjfDLTgTQbeVi3qoYx+R+Vf89RTVhipEBi5+MISRk3nsZlnh9ReznPXOJH2SnO EyDXIsEpbnxCDfDGN6WKUJ5y5dKgMbSzN45YUayy+xx5pBusrr2Hbs8QRqsMFWZPZL6X N6MQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1yt0rAw5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u8si5202439eje.57.2020.12.06.14.09.54; Sun, 06 Dec 2020 14:10:20 -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=@linutronix.de header.s=2020 header.b=1yt0rAw5; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728281AbgLFWH1 (ORCPT + 99 others); Sun, 6 Dec 2020 17:07:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728209AbgLFWHZ (ORCPT ); Sun, 6 Dec 2020 17:07:25 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C801CC0613D2; Sun, 6 Dec 2020 14:06:44 -0800 (PST) Message-Id: <20201206220541.960333166@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1607292403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=JG5dX8xGxOTL3ExdOYCuqriVX+SU7EFieMrumJ4D7go=; b=1yt0rAw5r4jAAAYP4JglAWnUu37bvxnZ5aUsA6KyotcDIZV/kNt0+KPyKgHun7XAkDfDBE mmTUXRqtgKhgwcX31IWEcf0ZKGHBBw9WyLBCWw6HGXcwMGULSlrzM/SldiAgSHkGdUbFeb eBSe7Sa7U7MvADVMIfMJnyWoQIpNk8H2UQfiJhCS8gF6sjDkC++8lOi67hryAf7FUBsmbF OeRsjXKwcr9hwauBX5kWKC+A0wF9z0hH+aXofSC+Ddv09M22Nfvb92q58HncqBWHlNFiOC udJSJK9584QGotK7IdsOwLbe87fCv0KB+MCR/mm0MpY6LtWuifmqhApH3tcrbw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1607292403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: references:references; bh=JG5dX8xGxOTL3ExdOYCuqriVX+SU7EFieMrumJ4D7go=; b=O8Ls+T1XzeCgds43cTiuPgtdPmCnJJ70CjCo9tGpddV+rIt/5DtEP9XK5/MWJyR0Yrexbm bhPK4du1wm6u8SCg== Date: Sun, 06 Dec 2020 22:46:17 +0100 From: Thomas Gleixner To: LKML Cc: Alexandre Belloni , Jason Gunthorpe , Miroslav Lichvar , John Stultz , Prarit Bhargava , Alessandro Zummo , linux-rtc@vger.kernel.org, Peter Zijlstra Subject: [patch 4/8] rtc: core: Make the sync offset default more realistic References: <20201206214613.444124194@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-transfer-encoding: 8-bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; rtc->irq_freq = 1; rtc->max_user_freq = 64;