* [PATCH 0/2] rtc: cmos: Fix ACPI RTC alarm handling
@ 2026-09-09 22:51 Gregory Price
2026-09-09 22:51 ` [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it Gregory Price
2026-09-09 22:51 ` [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value Gregory Price
0 siblings, 2 replies; 5+ messages in thread
From: Gregory Price @ 2026-09-09 22:51 UTC (permalink / raw)
To: linux-rtc; +Cc: linux-kernel, kernel-team, alexandre.belloni, rui.zhang
RTC update interrupt emulation can stop delivering events when rtc-cmos
uses the ACPI RTC fixed event. On an affected system, a test that waits
for five one-second update events completed only 40 of 50 runs. The ACPI
ff_rt_clk counter stopped at 218, exactly matching the number of events
delivered to userspace, with the event status set but delivery disabled.
The ACPI SCI handler disables the fixed event after dispatching the RTC
interrupt. Because dispatch queues work that rearms the next alarm, the
handler can disable an event that the worker has already enabled. Move
the clear and disable operations before dispatch so that rearming always
wins the race.
During diagnosis, an explicit rtc_cmos.use_acpi_alarm=0 argument was also
found to be ineffective. The automatic platform selection runs after
parameter parsing and overwrites the explicit false value. Record whether
the parameter was supplied and skip automatic selection in that case.
On the affected system, ACPI mode completed 150 of 150 runs after the
ordering fix and delivered all 750 requested events. With
rtc_cmos.use_acpi_alarm=0, sysfs reported N, HPET emulation was active,
and 100 of 100 runs passed without using the ACPI RTC event.
The in-tree RTC selftest also passed all 8 tests under VNG with
rtc_cmos.use_acpi_alarm=0. VNG does not deliver ACPI RTC fixed events, so
the ACPI ordering fix was tested on hardware.
Gregory Price (2):
rtc: cmos: Disable ACPI RTC event before handling it
rtc: cmos: Honor explicit use_acpi_alarm parameter value
drivers/rtc/rtc-cmos.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
--
2.53.0-Meta
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it
2026-09-09 22:51 [PATCH 0/2] rtc: cmos: Fix ACPI RTC alarm handling Gregory Price
@ 2026-09-09 22:51 ` Gregory Price
2026-09-09 23:03 ` sashiko-bot
2026-09-09 22:51 ` [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value Gregory Price
1 sibling, 1 reply; 5+ messages in thread
From: Gregory Price @ 2026-09-09 22:51 UTC (permalink / raw)
To: linux-rtc
Cc: linux-kernel, kernel-team, alexandre.belloni, rui.zhang, stable,
Gregory Price (Meta)
Users of RTC_UIE_ON can stop receiving update interrupts when rtc-cmos
handles alarms through ACPI. In one 50-run test, 40 runs passed and 10
timed out after receiving between one and four of five expected events.
The ACPI ff_rt_clk counter stopped at 218, exactly matching the number
of events delivered to userspace, and reported:
218 STS disabled unmasked
rtc_handler() runs in the threaded ACPI SCI handler and calls
cmos_interrupt(), which schedules rtc->irqwork. The work can run before
rtc_handler() returns:
ACPI SCI thread rtc->irqwork
cmos_interrupt()
schedule_work()
__rtc_set_alarm()
rtc_wake_on()
acpi_clear_event()
acpi_disable_event()
The SCI thread then disables the event that the worker enabled for the
next alarm. That alarm sets its status while delivery remains disabled,
so no update interrupt reaches userspace.
Clear and disable the current ACPI RTC event before cmos_interrupt()
schedules the work. The worker can then enable the next event without
the handler undoing it. With this ordering, 150 runs delivered all 750
events without a stall.
Fixes: 311ee9c151ad ("rtc: cmos: allow using ACPI for RTC alarm instead of HPET")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
---
drivers/rtc/rtc-cmos.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index f89ab58f5048a..462799667aa18 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -758,7 +758,9 @@ static u32 rtc_handler(void *context)
unsigned char rtc_intr;
unsigned long flags;
-
+ /* Quiesce this event before rtc->irqwork can arm the next one. */
+ acpi_clear_event(ACPI_EVENT_RTC);
+ acpi_disable_event(ACPI_EVENT_RTC, 0);
/*
* Always update rtc irq when ACPI is used as RTC Alarm.
* Or else, ACPI SCI is enabled during suspend/resume only,
@@ -781,8 +783,6 @@ static u32 rtc_handler(void *context)
}
pm_wakeup_hard_event(dev);
- acpi_clear_event(ACPI_EVENT_RTC);
- acpi_disable_event(ACPI_EVENT_RTC, 0);
return ACPI_INTERRUPT_HANDLED;
}
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it
2026-09-09 22:51 ` [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it Gregory Price
@ 2026-09-09 23:03 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-09 23:03 UTC (permalink / raw)
To: Gregory Price; +Cc: Alexandre Belloni, linux-rtc
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] RTC wakeup events are permanently lost if the ACPI SCI handler executes before the device resume callback and the BIOS has cleared the RTC control registers.
--
commit 8ca107b659080f6c7d65133bba3bda531b0c4968
Author: Gregory Price <gourry@gourry.net>
rtc: cmos: Disable ACPI RTC event before handling it
This commit resolves an issue where rtc-cmos alarm events are missed due to a
race condition with the ACPI SCI handler. It clears and disables the ACPI RTC
event before scheduling the irqwork so the worker can safely enable the next
event without interference.
> diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
> index fa04ece151b8b..fe514b1aa3433 100644
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -758,7 +758,9 @@ static u32 rtc_handler(void *context)
> unsigned char rtc_intr;
> unsigned long flags;
>
> -
> + /* Quiesce this event before rtc->irqwork can arm the next one. */
> + acpi_clear_event(ACPI_EVENT_RTC);
> + acpi_disable_event(ACPI_EVENT_RTC, 0);
[Severity: High]
This isn't a bug introduced by this patch, but this unconditional clearing of
the ACPI event status appears to permanently lose RTC wakeup events under
certain conditions.
If the system suspends with the RTC alarm enabled (cmos_rtc.suspend_ctrl has
RTC_AIE set) and use_acpi_alarm is false, the BIOS can clear the RTC_CONTROL
register during the suspend/resume cycle.
When the system wakes, the ACPI SCI handler rtc_handler() runs before
cmos_resume(). Because rtc_handler() clears the ACPI event status
unconditionally, it reads the cleared register and fails to call
rtc_update_irq():
rtc_handler() {
...
if (cmos_rtc.suspend_ctrl)
rtc_control = CMOS_READ(RTC_CONTROL);
if (rtc_control & RTC_AIE) {
...
rtc_update_irq(...);
}
}
Later, cmos_resume() runs and attempts to recover the lost event by calling
cmos_check_acpi_rtc_status(). However, since rtc_handler() already cleared the
ACPI event status, acpi_get_event_status() returns no event, and the IRQ is
permanently lost.
Will this indefinitely stall userspace processes waiting for the RTC alarm
via poll() on /dev/rtc?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909225132.1392883-1-gourry@gourry.net?part=1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value
2026-09-09 22:51 [PATCH 0/2] rtc: cmos: Fix ACPI RTC alarm handling Gregory Price
2026-09-09 22:51 ` [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it Gregory Price
@ 2026-09-09 22:51 ` Gregory Price
2026-09-09 22:55 ` sashiko-bot
1 sibling, 1 reply; 5+ messages in thread
From: Gregory Price @ 2026-09-09 22:51 UTC (permalink / raw)
To: linux-rtc
Cc: linux-kernel, kernel-team, alexandre.belloni, rui.zhang, stable,
Gregory Price (Meta)
An explicit rtc_cmos.use_acpi_alarm=0 command-line argument is ignored
on systems where use_acpi_alarm_quirks() enables ACPI RTC alarms. The
argument appears in /proc/cmdline, but the read-only parameter reports Y.
The boolean parameter defaults to false, so the driver cannot distinguish
an omitted argument from an explicit false value. Use a custom setter to
record whether parsing occurred and skip automatic selection when it did.
Preserve the bool parameter type metadata. Automatic selection remains
unchanged when the parameter is omitted.
On the affected system, the explicit false value reports N after this
change. The HPET-emulated path completed 100 test runs without a failure
while the ACPI RTC event counter remained at zero.
Fixes: 36d91a4d401c ("rtc: cmos: introduce quirks to enable use_acpi_alarm mode")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
---
drivers/rtc/rtc-cmos.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 462799667aa18..536bdcb79ea1c 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -57,7 +57,28 @@
*/
static bool use_acpi_alarm;
-module_param(use_acpi_alarm, bool, 0444);
+static bool use_acpi_alarm_explicit;
+
+static int set_use_acpi_alarm(const char *val, const struct kernel_param *kp)
+{
+ int ret;
+
+ ret = param_set_bool(val, kp);
+ if (!ret)
+ use_acpi_alarm_explicit = true;
+
+ return ret;
+}
+
+static const struct kernel_param_ops use_acpi_alarm_ops = {
+ .flags = KERNEL_PARAM_OPS_FL_NOARG,
+ .set = set_use_acpi_alarm,
+ .get = param_get_bool,
+};
+
+param_check_bool(use_acpi_alarm, &use_acpi_alarm);
+module_param_cb(use_acpi_alarm, &use_acpi_alarm_ops, &use_acpi_alarm, 0444);
+__MODULE_PARM_TYPE(use_acpi_alarm, "bool");
static inline int cmos_use_acpi_alarm(void)
{
@@ -822,6 +843,9 @@ static void rtc_wake_off(struct device *dev)
#ifdef CONFIG_X86
static void use_acpi_alarm_quirks(void)
{
+ if (use_acpi_alarm_explicit)
+ return;
+
if (acpi_gbl_FADT.flags & ACPI_FADT_FIXED_RTC)
return;
--
2.53.0-Meta
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value
2026-09-09 22:51 ` [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value Gregory Price
@ 2026-09-09 22:55 ` sashiko-bot
0 siblings, 0 replies; 5+ messages in thread
From: sashiko-bot @ 2026-09-09 22:55 UTC (permalink / raw)
To: Gregory Price; +Cc: linux-rtc, Alexandre Belloni
> An explicit rtc_cmos.use_acpi_alarm=0 command-line argument is ignored
> on systems where use_acpi_alarm_quirks() enables ACPI RTC alarms. The
> argument appears in /proc/cmdline, but the read-only parameter reports Y.
>
> The boolean parameter defaults to false, so the driver cannot distinguish
> an omitted argument from an explicit false value. Use a custom setter to
> record whether parsing occurred and skip automatic selection when it did.
> Preserve the bool parameter type metadata. Automatic selection remains
> unchanged when the parameter is omitted.
>
> On the affected system, the explicit false value reports N after this
> change. The HPET-emulated path completed 100 test runs without a failure
> while the ACPI RTC event counter remained at zero.
>
> Fixes: 36d91a4d401c ("rtc: cmos: introduce quirks to enable use_acpi_alarm mode")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Gregory Price (Meta) <gourry@gourry.net>
Sashiko has reviewed this patch and found no issues. It looks great!
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909225132.1392883-1-gourry@gourry.net?part=2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-09 23:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-09 22:51 [PATCH 0/2] rtc: cmos: Fix ACPI RTC alarm handling Gregory Price
2026-09-09 22:51 ` [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it Gregory Price
2026-09-09 23:03 ` sashiko-bot
2026-09-09 22:51 ` [PATCH 2/2] rtc: cmos: Honor explicit use_acpi_alarm parameter value Gregory Price
2026-09-09 22:55 ` sashiko-bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox