Commit fcf92cde authored by Thomas Gleixner's avatar Thomas Gleixner Committed by sanglipeng
Browse files

rtc: mc146818: Detect and handle broken RTCs

stable inclusion
from stable-v5.10.159
commit 3736972360fad22805e7e9d322387fd1ec0f48fc
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I7NTXH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3736972360fad22805e7e9d322387fd1ec0f48fc



--------------------------------

[ Upstream commit 211e5db1 ]

The recent fix for handling the UIP bit unearthed another issue in the RTC
code. If the RTC is advertised but the readout is straight 0xFF because
it's not available, the old code just proceeded with crappy values, but the
new code hangs because it waits for the UIP bit to become low.

Add a sanity check in the RTC CMOS probe function which reads the RTC_VALID
register (Register D) which should have bit 0-6 cleared. If that's not the
case then fail to register the CMOS.

Add the same check to mc146818_get_time(), warn once when the condition
is true and invalidate the rtc_time data.

Reported-by: default avatarMickaël Salaün <mic@digikod.net>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarMickaël Salaün <mic@linux.microsoft.com>
Acked-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/87tur3fx7w.fsf@nanos.tec.linutronix.de


Stable-dep-of: cd17420e ("rtc: cmos: avoid UIP when writing alarm time")
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarsanglipeng <sanglipeng1@jd.com>
parent 6b97cdaf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment