linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rtc: Fix hwclock write fail problem in x86 arch
@ 2021-05-19  9:23 Jingxian He
  2021-05-20  8:59 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Jingxian He @ 2021-05-19  9:23 UTC (permalink / raw)
  To: tglx, mingo, bp, x86, linux-kernel, hpa
  Cc: hejie3, hewenliang4, wuxu.wu, hejingxian

When RTC_ALWAYS_BCD is set as 1, the function mc146818_set_time
ignores the reading value of RTC_CONTROL register,
and assumes that RTC always operates in binary mode.

However, the mc146818 development manual says that:
if !(CMOS_READ(RTC_CONTROL) & 0x04), then
the rtc time is in binary mode;
if (CMOS_READ(RTC_CONTROL) & 0x04), then
the rtc time is in bcd mode.

We use 'hwclock -w' to set the RTC from the system time
at our x86 machines, and we find that when 
(CMOS_READ(RTC_CONTROL) & 0x04) is equal to 1,
'hwclock -w' will fail to set the RTC.

We change the RTC_ALWAYS_BCD to 0 to parse the rtc
time according to the read value of RTC_CONTROL register.

Signed-off-by: Jingxian He <hejingxian@huawei.com>
Signed-off-by: Jie He <hejie3@huawei.com>
---
 arch/x86/include/asm/mc146818rtc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index 9719800..63cf0d5 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -10,7 +10,7 @@
 
 #ifndef RTC_PORT
 #define RTC_PORT(x)	(0x70 + (x))
-#define RTC_ALWAYS_BCD	1	/* RTC operates in binary mode */
+#define RTC_ALWAYS_BCD	0
 #endif
 
 #if defined(CONFIG_X86_32)
-- 
2.9.5


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

* Re: [PATCH] rtc: Fix hwclock write fail problem in x86 arch
  2021-05-19  9:23 [PATCH] rtc: Fix hwclock write fail problem in x86 arch Jingxian He
@ 2021-05-20  8:59 ` Thomas Gleixner
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2021-05-20  8:59 UTC (permalink / raw)
  To: Jingxian He
  Cc: mingo, bp, x86, linux-kernel, hpa, hejie3, hewenliang4, wuxu.wu,
	hejingxian, Sang Yan

On Wed, May 19 2021 at 17:23, Jingxian He wrote:

So at 17:19 this very same patch was posted by Sang Yan <sangyan@huawei.com>

   https://lore.kernel.org/r/20210519091908.513593-1-sangyan@huawei.com

Can you please coordinate patch posting internaly?

It has the same broken SOB chain as this one:

> Signed-off-by: Jingxian He <hejingxian@huawei.com>
> Signed-off-by: Jie He <hejie3@huawei.com>

See Documentation/process/submitting-patches.rst

Thanks,

        tglx

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

* [PATCH] rtc: Fix hwclock write fail problem in x86 arch
@ 2021-05-19  9:19 Sang Yan
  0 siblings, 0 replies; 3+ messages in thread
From: Sang Yan @ 2021-05-19  9:19 UTC (permalink / raw)
  To: tglx, mingo, bp, x86, linux-kernel, hpa
  Cc: hejie3, hewenliang4, wuxu.wu, hejingxian

From: Jingxian He <hejingxian@huawei.com>

When RTC_ALWAYS_BCD is set as 1, the function mc146818_set_time
ignores the reading value of RTC_CONTROL register,
and assumes that RTC always operates in binary mode.

However, the mc146818 development manual says that:
if !(CMOS_READ(RTC_CONTROL) & 0x04), then
the rtc time is in binary mode;
if (CMOS_READ(RTC_CONTROL) & 0x04), then
the rtc time is in bcd mode.

We use 'hwclock -w' to set the RTC from the system time
at our x86 machines, and we find that when 
(CMOS_READ(RTC_CONTROL) & 0x04) is equal to 1,
'hwclock -w' will fail to set the RTC.

We change the RTC_ALWAYS_BCD to 0 to parse the rtc
time according to the read value of RTC_CONTROL register.

Signed-off-by: Jingxian He <hejingxian@huawei.com>
Signed-off-by: Jie He <hejie3@huawei.com>
---
 arch/x86/include/asm/mc146818rtc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/mc146818rtc.h b/arch/x86/include/asm/mc146818rtc.h
index 9719800..63cf0d5 100644
--- a/arch/x86/include/asm/mc146818rtc.h
+++ b/arch/x86/include/asm/mc146818rtc.h
@@ -10,7 +10,7 @@
 
 #ifndef RTC_PORT
 #define RTC_PORT(x)	(0x70 + (x))
-#define RTC_ALWAYS_BCD	1	/* RTC operates in binary mode */
+#define RTC_ALWAYS_BCD	0
 #endif
 
 #if defined(CONFIG_X86_32)
-- 
2.9.5


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

end of thread, other threads:[~2021-05-20  8:59 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  9:23 [PATCH] rtc: Fix hwclock write fail problem in x86 arch Jingxian He
2021-05-20  8:59 ` Thomas Gleixner
  -- strict thread matches above, loose matches on Subject: below --
2021-05-19  9:19 Sang Yan

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).