rtc: mc146818: Dont test for bit 0-5 in Register D
authorThomas Gleixner <tglx@linutronix.de>
Mon, 1 Feb 2021 19:24:17 +0000 (20:24 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 2 Feb 2021 19:35:02 +0000 (20:35 +0100)
The recent change to validate the RTC turned out to be overly tight.

While it cures the problem on the reporters machine it breaks machines
with Intel chipsets which use bit 0-5 of the D register. So check only
for bit 6 being 0 which is the case on these Intel machines as well.

Fixes: 211e5db19d15 ("rtc: mc146818: Detect and handle broken RTCs")
Reported-by: Serge Belyshev <belyshev@depni.sinp.msu.ru>
Reported-by: Dirk Gouders <dirk@gouders.net>
Reported-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Dirk Gouders <dirk@gouders.net>
Tested-by: Len Brown <len.brown@intel.com>
Tested-by: Borislav Petkov <bp@suse.de>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Link: https://lore.kernel.org/r/87zh0nbnha.fsf@nanos.tec.linutronix.de
drivers/rtc/rtc-cmos.c
drivers/rtc/rtc-mc146818-lib.c

index 68a9ac6f2fe1776a1f3d2206f5a2145f815f51b0..a701dae653c4a617b46865c9556ad5c969149ab7 100644 (file)
@@ -805,8 +805,8 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
 
        spin_lock_irq(&rtc_lock);
 
-       /* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
-       if ((CMOS_READ(RTC_VALID) & 0x7f) != 0) {
+       /* Ensure that the RTC is accessible. Bit 6 must be 0! */
+       if ((CMOS_READ(RTC_VALID) & 0x40) != 0) {
                spin_unlock_irq(&rtc_lock);
                dev_warn(dev, "not accessible\n");
                retval = -ENXIO;
index f83c13818af3b6d207ae73226ef07a2b351118ea..dcfaf09946ee36de628ded0d776f3ddecc5b84ae 100644 (file)
@@ -21,8 +21,8 @@ unsigned int mc146818_get_time(struct rtc_time *time)
 
 again:
        spin_lock_irqsave(&rtc_lock, flags);
-       /* Ensure that the RTC is accessible. Bit 0-6 must be 0! */
-       if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x7f) != 0)) {
+       /* Ensure that the RTC is accessible. Bit 6 must be 0! */
+       if (WARN_ON_ONCE((CMOS_READ(RTC_VALID) & 0x40) != 0)) {
                spin_unlock_irqrestore(&rtc_lock, flags);
                memset(time, 0xff, sizeof(*time));
                return 0;