Commit 7523ceed authored by NeilBrown's avatar NeilBrown Committed by Rafael J. Wysocki

RTC: Avoid races between RTC alarm wakeup and suspend.

If an RTC alarm fires just as suspend is happening, it is possible for
suspend to complete and the alarm to be missed.

To avoid the race, we must register the event with the PM core.

As the event is made visible to userspace through a thread which is
only scheduled by the interrupt, we need a pm_stay_awake/pm_relax
pair preventing suspend from the interrupt until the thread completes
its work.

This makes the pm_wakeup_event() call in cmos_interrupt unnecessary as
it provides suspend protection for all RTCs that use rtc_update_irq.
Signed-off-by: default avatarNeilBrown <>
Signed-off-by: default avatarRafael J. Wysocki <>
parent 0d7614f0
......@@ -582,6 +582,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
void rtc_update_irq(struct rtc_device *rtc,
unsigned long num, unsigned long events)
......@@ -844,6 +845,7 @@ void rtc_timer_do_work(struct work_struct *work)
__rtc_read_time(rtc, &tm);
now = rtc_tm_to_ktime(tm);
while ((next = timerqueue_getnext(&rtc->timerqueue))) {
......@@ -568,7 +568,6 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
pm_wakeup_event(, 0);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment