Linux RTC
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: "Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	linux-rtc@vger.kernel.org
Subject: Re: [PATCH 1/2] rtc: cmos: Disable ACPI RTC event before handling it
Date: Wed, 09 Sep 2026 23:03:38 +0000	[thread overview]
Message-ID: <20260909230339.2EA191F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260909225132.1392883-2-gourry@gourry.net>

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

  reply	other threads:[~2026-09-09 23:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=20260909230339.2EA191F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=alexandre.belloni@bootlin.com \
    --cc=gourry@gourry.net \
    --cc=linux-rtc@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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