Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp128619pxb; Mon, 16 Aug 2021 01:26:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9VHE8BJWvw4gCFJFxa8GO1dV4JyMxO/gA3625r4sCiyrRI4Cbm6Pkcw9Fo9XbuzUiRemz X-Received: by 2002:a05:6402:1648:: with SMTP id s8mr18404330edx.214.1629102397718; Mon, 16 Aug 2021 01:26:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629102397; cv=none; d=google.com; s=arc-20160816; b=c0PAVAT7GzbHVPRn4QcL3PrbRlXtYfmOqsOVxJkfJBMbPjDjC50No9ZjX8G+TO7QLj ekBwWa3eJBIBU+pkS0O0qxNWmQksmeeCsjnYz1cuz7JACUBxNueqlqUim1Q5n/TYzlS7 +CMPut22CGz7TElfzx8DaIiS/md1VO2SdyYXhDDBBIMYJ+IZEOHTBImtSsygzMMfQjGJ U3NGiR8X/d39HWEkK3HS8ZxVfaw8C5AjYm9UAR8kEfxLIi6+vSjra54y1M9XLZ/iFFPe TLz+C7sgGoa7IRKS5m6GHvlTnSfqYvH1t1kpWv4A+84tVmUTsSy/I0FkPv8KHnsN97gS 3j1Q== 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=kDEm9KNxdTpBYhwR6LsgOu0AC9lxroAuRamk7Ger/AA=; b=wl5hZBVfQmyPA5sJS0EqtI6EXlNktpbyaI6WFIhMs2c2OLtdX/ZVAwT3JgnljzfaMZ bCN3mpZTEaeXRpS6DM3KXJWcWY/5qv6X/sph+N6BX71J/qDLGyWiQWonSbUyFhog9X/U g0DH5TFezrHksOSg4s3YtpjS9J9UwV2KC/B35zncaDXQQiL3kk03aojMo3wD9uperZcB od1FxRwFhqdLajLwSrhfLnOihtmeWpGE9K6+euksKmxm8HuG8fYsAdP1JgYAfVLXvQTf CiMhlf2NwD+ovmXnxAOR7AKxzK7+zjmUntx0FbQ36vED7lKH37TQJ9iIu0pOBbCNF7zC x/7Q== 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 j14si9278946edw.120.2021.08.16.01.26.14; Mon, 16 Aug 2021 01:26:37 -0700 (PDT) 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 S234662AbhHPIYf (ORCPT + 99 others); Mon, 16 Aug 2021 04:24:35 -0400 Received: from relay4-d.mail.gandi.net ([217.70.183.196]:55833 "EHLO relay4-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231716AbhHPIYe (ORCPT ); Mon, 16 Aug 2021 04:24:34 -0400 Received: (Authenticated sender: alexandre.belloni@bootlin.com) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 2ABE7E0007; Mon, 16 Aug 2021 08:24:01 +0000 (UTC) Date: Mon, 16 Aug 2021 10:24:01 +0200 From: Alexandre Belloni To: Tony W Wang-oc Cc: a.zummo@towertech.it, linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org, TimGuo-oc@zhaoxin.com, CooperYan@zhaoxin.com, QiyuanWang@zhaoxin.com, HerryYang@zhaoxin.com, CobeChen@zhaoxin.com, YanchenSun@zhaoxin.com Subject: Re: [PATCH] rtc: Fix set RTC time delay 500ms on some Zhaoxin SOCs Message-ID: References: <1629121638-3246-1-git-send-email-TonyWWang-oc@zhaoxin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1629121638-3246-1-git-send-email-TonyWWang-oc@zhaoxin.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On 16/08/2021 21:47:18+0800, Tony W Wang-oc wrote: > When the RTC divider is changed from reset to an operating time base, > the first update cycle should be 500ms later. But on some Zhaoxin SOCs, > this first update cycle is one second later. > > So set RTC time on these Zhaoxin SOCs will causing 500ms delay. > Can you explain what is the relationship between writing the divider and the 500ms delay? Isn't the issue that you are using systohc and set_offset_nsec is set to NSEC_PER_SEC / 2 ? > Skip setup RTC divider on these SOCs in mc146818_set_time to fix it. > > Signed-off-by: Tony W Wang-oc > --- > drivers/rtc/rtc-mc146818-lib.c | 18 ++++++++++++++++++ > 1 file changed, 18 insertions(+) > > diff --git a/drivers/rtc/rtc-mc146818-lib.c b/drivers/rtc/rtc-mc146818-lib.c > index dcfaf09..322f94b 100644 > --- a/drivers/rtc/rtc-mc146818-lib.c > +++ b/drivers/rtc/rtc-mc146818-lib.c > @@ -190,8 +190,18 @@ int mc146818_set_time(struct rtc_time *time) > spin_lock_irqsave(&rtc_lock, flags); > save_control = CMOS_READ(RTC_CONTROL); > CMOS_WRITE((save_control|RTC_SET), RTC_CONTROL); > + > +#ifdef CONFIG_X86 > + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || > + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) && > + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59))) { > + save_freq_select = CMOS_READ(RTC_FREQ_SELECT); > + CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); > + } > +#else > save_freq_select = CMOS_READ(RTC_FREQ_SELECT); > CMOS_WRITE((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); > +#endif > > #ifdef CONFIG_MACH_DECSTATION > CMOS_WRITE(real_yrs, RTC_DEC_YEAR); > @@ -209,7 +219,15 @@ int mc146818_set_time(struct rtc_time *time) > #endif > > CMOS_WRITE(save_control, RTC_CONTROL); > + > +#ifdef CONFIG_X86 > + if (!((boot_cpu_data.x86_vendor == X86_VENDOR_CENTAUR || > + boot_cpu_data.x86_vendor == X86_VENDOR_ZHAOXIN) && > + (boot_cpu_data.x86 <= 7 && boot_cpu_data.x86_model <= 59))) > + CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); > +#else > CMOS_WRITE(save_freq_select, RTC_FREQ_SELECT); > +#endif > > spin_unlock_irqrestore(&rtc_lock, flags); > > -- > 2.7.4 > -- Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com