From: Sang Yan <sangyan@huawei.com>
To: <tglx@linutronix.de>, <mingo@redhat.com>, <bp@alien8.de>,
<x86@kernel.org>, <linux-kernel@vger.kernel.org>, <hpa@zytor.com>
Cc: <hejie3@huawei.com>, <hewenliang4@huawei.com>,
<wuxu.wu@huawei.com>, <hejingxian@huawei.com>
Subject: [PATCH] rtc: Fix hwclock write fail problem in x86 arch
Date: Wed, 19 May 2021 17:19:08 +0800 [thread overview]
Message-ID: <20210519091908.513593-1-sangyan@huawei.com> (raw)
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
next reply other threads:[~2021-05-19 9:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-19 9:19 Sang Yan [this message]
-- strict thread matches above, loose matches on Subject: below --
2021-05-19 9:23 [PATCH] rtc: Fix hwclock write fail problem in x86 arch Jingxian He
2021-05-20 8:59 ` Thomas Gleixner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210519091908.513593-1-sangyan@huawei.com \
--to=sangyan@huawei.com \
--cc=bp@alien8.de \
--cc=hejie3@huawei.com \
--cc=hejingxian@huawei.com \
--cc=hewenliang4@huawei.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=wuxu.wu@huawei.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox