Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: renesas-rtca3: Disable interrupts only if the RTC is enabled

If the RTC is not enabled and the code attempts to disable the interrupt,
the readb_poll_timeout_atomic() function in the
rtca3_alarm_irq_set_helper() may timeout, leading to probe failures.
This issue is reproducible on some devices because the initial values of
the PIE and AIE bits in the RCR1 register are undefined.

To prevent probe failures in this scenario, disable RTC interrupts only
when the RTC is actually enabled.

Fixes: d4488377609e ("rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC")
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Link: https://lore.kernel.org/r/20250205095519.2031742-1-claudiu.beznea.uj@bp.renesas.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

authored by

Claudiu Beznea and committed by
Alexandre Belloni
27b2fcbd 8a9b1751

+6 -9
+6 -9
drivers/rtc/rtc-renesas-rtca3.c
··· 586 586 */ 587 587 usleep_range(sleep_us, sleep_us + 10); 588 588 589 - /* Disable all interrupts. */ 590 - mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE; 591 - ret = rtca3_alarm_irq_set_helper(priv, mask, 0); 592 - if (ret) 593 - return ret; 594 - 595 589 mask = RTCA3_RCR2_START | RTCA3_RCR2_HR24; 596 590 val = readb(priv->base + RTCA3_RCR2); 597 - /* Nothing to do if already started in 24 hours and calendar count mode. */ 598 - if ((val & mask) == mask) 599 - return 0; 591 + /* Only disable the interrupts if already started in 24 hours and calendar count mode. */ 592 + if ((val & mask) == mask) { 593 + /* Disable all interrupts. */ 594 + mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE; 595 + return rtca3_alarm_irq_set_helper(priv, mask, 0); 596 + } 600 597 601 598 /* Reconfigure the RTC in 24 hours and calendar count mode. */ 602 599 mask = RTCA3_RCR2_START | RTCA3_RCR2_CNTMD;