linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set
@ 2020-04-09 20:46 Leonid Bloch
  0 siblings, 0 replies; 4+ messages in thread
From: Leonid Bloch @ 2020-04-09 20:46 UTC (permalink / raw)
  To: linux-kernel; +Cc: John Stultz, Thomas Gleixner, Stephen Boyd, Leonid Bloch

According to documentation in 'drivers/rtc/Kconfig', if
'CONFIG_RTC_SYSTOHC' is set, then:

'''
The system time (wall clock) will be stored in the RTC specified by
RTC_HCTOSYS_DEVICE approximately every 11 minutes if userspace reports
synchronized NTP status.
'''

However in reality, even if 'CONFIG_RTC_SYSTOHC' is not set, the RTC
is still sometimes synced with the system time: at least when the RTC
driver is 'rtc_cmos', in certain situations. This commit prevents that.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
---
 kernel/time/ntp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 069ca78fb0bf..58260ca75c64 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -535,9 +535,6 @@ static void sync_rtc_clock(void)
 	struct timespec64 adjust, now;
 	int rc;
 
-	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
-		return;
-
 	ktime_get_real_ts64(&now);
 
 	adjust = now;
@@ -613,6 +610,9 @@ static bool sync_cmos_clock(void)
  */
 static void sync_hw_clock(struct work_struct *work)
 {
+	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
+		return;
+
 	if (!ntp_synced())
 		return;
 
-- 
2.26.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set
  2020-04-27  9:30 ` Thomas Gleixner
@ 2020-04-27 14:36   ` Leonid Bloch
  0 siblings, 0 replies; 4+ messages in thread
From: Leonid Bloch @ 2020-04-27 14:36 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, John Stultz, Stephen Boyd

On Mon, Apr 27, 2020 at 12:30 PM Thomas Gleixner <tglx@linutronix.de> wrote:
>
> Leonid Bloch <lb.workbox@gmail.com> writes:
> > According to documentation in 'drivers/rtc/Kconfig', if
> > 'CONFIG_RTC_SYSTOHC' is set, then:
> >
> > '''
> > The system time (wall clock) will be stored in the RTC specified by
> > RTC_HCTOSYS_DEVICE approximately every 11 minutes if userspace reports
> > synchronized NTP status.
> > '''
> >
> > However in reality, even if 'CONFIG_RTC_SYSTOHC' is not set, the RTC
> > is still sometimes synced with the system time: at least when the RTC
> > driver is 'rtc_cmos', in certain situations. This commit prevents
> > that.
>
> But in reality sync_cmos_clock() depends on CONFIG_GENERIC_CMOS_UPDATE
> and has nothing to do with CONFIG_RTC_SYSTOHC.
>
> That's a historical leftover from the days where RTCs were strictly a
> platform/architecture specific issue.
>
> Your change would break all architectures which still depend on that.

Thanks for your clarification, Thomas!

Then maybe it's worth to reword the help string in
drivers/rtc/Kconfig? Because one can unset 'CONFIG_RTC_SYSTOHC' and
expect that the RTC clock will not be updated by NTP syncs, while in
reality it will be, unless 'CONFIG_GENERIC_CMOS_UPDATE' is unset, and
it is selected automatically by X86.

Regards,
Leonid.
___

>
>
> Thanks,
>
>         tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set
  2020-04-26  1:35 Leonid Bloch
@ 2020-04-27  9:30 ` Thomas Gleixner
  2020-04-27 14:36   ` Leonid Bloch
  0 siblings, 1 reply; 4+ messages in thread
From: Thomas Gleixner @ 2020-04-27  9:30 UTC (permalink / raw)
  To: Leonid Bloch, linux-kernel; +Cc: John Stultz, Stephen Boyd, Leonid Bloch

Leonid Bloch <lb.workbox@gmail.com> writes:
> According to documentation in 'drivers/rtc/Kconfig', if
> 'CONFIG_RTC_SYSTOHC' is set, then:
>
> '''
> The system time (wall clock) will be stored in the RTC specified by
> RTC_HCTOSYS_DEVICE approximately every 11 minutes if userspace reports
> synchronized NTP status.
> '''
>
> However in reality, even if 'CONFIG_RTC_SYSTOHC' is not set, the RTC
> is still sometimes synced with the system time: at least when the RTC
> driver is 'rtc_cmos', in certain situations. This commit prevents
> that.

But in reality sync_cmos_clock() depends on CONFIG_GENERIC_CMOS_UPDATE
and has nothing to do with CONFIG_RTC_SYSTOHC.

That's a historical leftover from the days where RTCs were strictly a
platform/architecture specific issue.

Your change would break all architectures which still depend on that.

Thanks,

        tglx

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set
@ 2020-04-26  1:35 Leonid Bloch
  2020-04-27  9:30 ` Thomas Gleixner
  0 siblings, 1 reply; 4+ messages in thread
From: Leonid Bloch @ 2020-04-26  1:35 UTC (permalink / raw)
  To: linux-kernel; +Cc: John Stultz, Thomas Gleixner, Stephen Boyd, Leonid Bloch

According to documentation in 'drivers/rtc/Kconfig', if
'CONFIG_RTC_SYSTOHC' is set, then:

'''
The system time (wall clock) will be stored in the RTC specified by
RTC_HCTOSYS_DEVICE approximately every 11 minutes if userspace reports
synchronized NTP status.
'''

However in reality, even if 'CONFIG_RTC_SYSTOHC' is not set, the RTC
is still sometimes synced with the system time: at least when the RTC
driver is 'rtc_cmos', in certain situations. This commit prevents that.

Signed-off-by: Leonid Bloch <lb.workbox@gmail.com>
---
 kernel/time/ntp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index 069ca78fb0bf..58260ca75c64 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -535,9 +535,6 @@ static void sync_rtc_clock(void)
 	struct timespec64 adjust, now;
 	int rc;
 
-	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
-		return;
-
 	ktime_get_real_ts64(&now);
 
 	adjust = now;
@@ -613,6 +610,9 @@ static bool sync_cmos_clock(void)
  */
 static void sync_hw_clock(struct work_struct *work)
 {
+	if (!IS_ENABLED(CONFIG_RTC_SYSTOHC))
+		return;
+
 	if (!ntp_synced())
 		return;
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-04-27 14:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 20:46 [PATCH] rtc: Do not sync CMOS clock when CONFIG_RTC_SYSTOHC is not set Leonid Bloch
2020-04-26  1:35 Leonid Bloch
2020-04-27  9:30 ` Thomas Gleixner
2020-04-27 14:36   ` Leonid Bloch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).