From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
If the ACPI RTC fixed event is used, a dedicated IRQ is not required
for the CMOS RTC alarm to work, so allow the driver to use the alarm
without a valid IRQ in that case.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
drivers/rtc/rtc-cmos.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -216,6 +216,11 @@ static inline void cmos_write_bank2(unsi
/*----------------------------------------------------------------*/
+static bool cmos_no_alarm(struct cmos_rtc *cmos)
+{
+ return !is_valid_irq(cmos->irq) && !cmos_use_acpi_alarm();
+}
+
static int cmos_read_time(struct device *dev, struct rtc_time *t)
{
int ret;
@@ -287,7 +292,7 @@ static int cmos_read_alarm(struct device
};
/* This not only a rtc_op, but also called directly */
- if (!is_valid_irq(cmos->irq))
+ if (cmos_no_alarm(cmos))
return -ETIMEDOUT;
/* Basic alarms only support hour, minute, and seconds fields.
@@ -520,7 +525,7 @@ static int cmos_set_alarm(struct device
int ret;
/* This not only a rtc_op, but also called directly */
- if (!is_valid_irq(cmos->irq))
+ if (cmos_no_alarm(cmos))
return -EIO;
ret = cmos_validate_alarm(dev, t);
@@ -1096,7 +1101,7 @@ cmos_do_probe(struct device *dev, struct
dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
goto cleanup1;
}
- } else {
+ } else if (!cmos_use_acpi_alarm()) {
clear_bit(RTC_FEATURE_ALARM, cmos_rtc.rtc->features);
}
@@ -1121,7 +1126,7 @@ cmos_do_probe(struct device *dev, struct
acpi_rtc_event_setup(dev);
dev_info(dev, "%s%s, %d bytes nvram%s\n",
- !is_valid_irq(rtc_irq) ? "no alarms" :
+ cmos_no_alarm(&cmos_rtc) ? "no alarms" :
cmos_rtc.mon_alrm ? "alarms up to one year" :
cmos_rtc.day_alrm ? "alarms up to one month" :
"alarms up to one day",
@@ -1147,7 +1152,7 @@ cleanup0:
static void cmos_do_shutdown(int rtc_irq)
{
spin_lock_irq(&rtc_lock);
- if (is_valid_irq(rtc_irq))
+ if (!cmos_no_alarm(&cmos_rtc))
cmos_irq_disable(&cmos_rtc, RTC_IRQMASK);
spin_unlock_irq(&rtc_lock);
}
On 14/03/2026 13:12:44+0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> If the ACPI RTC fixed event is used, a dedicated IRQ is not required
> for the CMOS RTC alarm to work, so allow the driver to use the alarm
> without a valid IRQ in that case.
>
> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> ---
> drivers/rtc/rtc-cmos.c | 15 ++++++++++-----
> 1 file changed, 10 insertions(+), 5 deletions(-)
>
> --- a/drivers/rtc/rtc-cmos.c
> +++ b/drivers/rtc/rtc-cmos.c
> @@ -216,6 +216,11 @@ static inline void cmos_write_bank2(unsi
>
> /*----------------------------------------------------------------*/
>
> +static bool cmos_no_alarm(struct cmos_rtc *cmos)
> +{
> + return !is_valid_irq(cmos->irq) && !cmos_use_acpi_alarm();
> +}
> +
> static int cmos_read_time(struct device *dev, struct rtc_time *t)
> {
> int ret;
> @@ -287,7 +292,7 @@ static int cmos_read_alarm(struct device
> };
>
> /* This not only a rtc_op, but also called directly */
> - if (!is_valid_irq(cmos->irq))
> + if (cmos_no_alarm(cmos))
> return -ETIMEDOUT;
>
> /* Basic alarms only support hour, minute, and seconds fields.
> @@ -520,7 +525,7 @@ static int cmos_set_alarm(struct device
> int ret;
>
> /* This not only a rtc_op, but also called directly */
> - if (!is_valid_irq(cmos->irq))
> + if (cmos_no_alarm(cmos))
> return -EIO;
>
> ret = cmos_validate_alarm(dev, t);
> @@ -1096,7 +1101,7 @@ cmos_do_probe(struct device *dev, struct
> dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
> goto cleanup1;
> }
> - } else {
> + } else if (!cmos_use_acpi_alarm()) {
> clear_bit(RTC_FEATURE_ALARM, cmos_rtc.rtc->features);
> }
>
> @@ -1121,7 +1126,7 @@ cmos_do_probe(struct device *dev, struct
> acpi_rtc_event_setup(dev);
>
> dev_info(dev, "%s%s, %d bytes nvram%s\n",
> - !is_valid_irq(rtc_irq) ? "no alarms" :
> + cmos_no_alarm(&cmos_rtc) ? "no alarms" :
> cmos_rtc.mon_alrm ? "alarms up to one year" :
> cmos_rtc.day_alrm ? "alarms up to one month" :
> "alarms up to one day",
> @@ -1147,7 +1152,7 @@ cleanup0:
> static void cmos_do_shutdown(int rtc_irq)
> {
> spin_lock_irq(&rtc_lock);
> - if (is_valid_irq(rtc_irq))
> + if (!cmos_no_alarm(&cmos_rtc))
> cmos_irq_disable(&cmos_rtc, RTC_IRQMASK);
> spin_unlock_irq(&rtc_lock);
> }
>
>
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
On 3/20/2026 1:00 PM, Alexandre Belloni wrote:
> On 14/03/2026 13:12:44+0100, Rafael J. Wysocki wrote:
>> From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>>
>> If the ACPI RTC fixed event is used, a dedicated IRQ is not required
>> for the CMOS RTC alarm to work, so allow the driver to use the alarm
>> without a valid IRQ in that case.
>>
>> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
>
> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Reviewed-by: Mario Limonciello (AMD) <superm1@kernel.org>
>
>> ---
>> drivers/rtc/rtc-cmos.c | 15 ++++++++++-----
>> 1 file changed, 10 insertions(+), 5 deletions(-)
>>
>> --- a/drivers/rtc/rtc-cmos.c
>> +++ b/drivers/rtc/rtc-cmos.c
>> @@ -216,6 +216,11 @@ static inline void cmos_write_bank2(unsi
>>
>> /*----------------------------------------------------------------*/
>>
>> +static bool cmos_no_alarm(struct cmos_rtc *cmos)
>> +{
>> + return !is_valid_irq(cmos->irq) && !cmos_use_acpi_alarm();
>> +}
>> +
>> static int cmos_read_time(struct device *dev, struct rtc_time *t)
>> {
>> int ret;
>> @@ -287,7 +292,7 @@ static int cmos_read_alarm(struct device
>> };
>>
>> /* This not only a rtc_op, but also called directly */
>> - if (!is_valid_irq(cmos->irq))
>> + if (cmos_no_alarm(cmos))
>> return -ETIMEDOUT;
>>
>> /* Basic alarms only support hour, minute, and seconds fields.
>> @@ -520,7 +525,7 @@ static int cmos_set_alarm(struct device
>> int ret;
>>
>> /* This not only a rtc_op, but also called directly */
>> - if (!is_valid_irq(cmos->irq))
>> + if (cmos_no_alarm(cmos))
>> return -EIO;
>>
>> ret = cmos_validate_alarm(dev, t);
>> @@ -1096,7 +1101,7 @@ cmos_do_probe(struct device *dev, struct
>> dev_dbg(dev, "IRQ %d is already in use\n", rtc_irq);
>> goto cleanup1;
>> }
>> - } else {
>> + } else if (!cmos_use_acpi_alarm()) {
>> clear_bit(RTC_FEATURE_ALARM, cmos_rtc.rtc->features);
>> }
>>
>> @@ -1121,7 +1126,7 @@ cmos_do_probe(struct device *dev, struct
>> acpi_rtc_event_setup(dev);
>>
>> dev_info(dev, "%s%s, %d bytes nvram%s\n",
>> - !is_valid_irq(rtc_irq) ? "no alarms" :
>> + cmos_no_alarm(&cmos_rtc) ? "no alarms" :
>> cmos_rtc.mon_alrm ? "alarms up to one year" :
>> cmos_rtc.day_alrm ? "alarms up to one month" :
>> "alarms up to one day",
>> @@ -1147,7 +1152,7 @@ cleanup0:
>> static void cmos_do_shutdown(int rtc_irq)
>> {
>> spin_lock_irq(&rtc_lock);
>> - if (is_valid_irq(rtc_irq))
>> + if (!cmos_no_alarm(&cmos_rtc))
>> cmos_irq_disable(&cmos_rtc, RTC_IRQMASK);
>> spin_unlock_irq(&rtc_lock);
>> }
>>
>>
>>
>
© 2016 - 2026 Red Hat, Inc.