aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2012-08-05 16:56:20 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2012-08-08 14:49:16 -0400
commit7523ceed42d84c1afaa1dc498bffed53c2aa444e (patch)
tree3da6d7ea253851657b49413001c8512871a86f96
parent0d7614f09c1ebdbaa1599a5aba7593f147bf96ee (diff)
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: NeilBrown <neilb@suse.de> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
-rw-r--r--drivers/rtc/interface.c2
-rw-r--r--drivers/rtc/rtc-cmos.c1
2 files changed, 2 insertions, 1 deletions
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
index eb415bd76494..9592b936b71b 100644
--- a/drivers/rtc/interface.c
+++ b/drivers/rtc/interface.c
@@ -582,6 +582,7 @@ enum hrtimer_restart rtc_pie_update_irq(struct hrtimer *timer)
582void rtc_update_irq(struct rtc_device *rtc, 582void rtc_update_irq(struct rtc_device *rtc,
583 unsigned long num, unsigned long events) 583 unsigned long num, unsigned long events)
584{ 584{
585 pm_stay_awake(rtc->dev.parent);
585 schedule_work(&rtc->irqwork); 586 schedule_work(&rtc->irqwork);
586} 587}
587EXPORT_SYMBOL_GPL(rtc_update_irq); 588EXPORT_SYMBOL_GPL(rtc_update_irq);
@@ -844,6 +845,7 @@ void rtc_timer_do_work(struct work_struct *work)
844 845
845 mutex_lock(&rtc->ops_lock); 846 mutex_lock(&rtc->ops_lock);
846again: 847again:
848 pm_relax(rtc->dev.parent);
847 __rtc_read_time(rtc, &tm); 849 __rtc_read_time(rtc, &tm);
848 now = rtc_tm_to_ktime(tm); 850 now = rtc_tm_to_ktime(tm);
849 while ((next = timerqueue_getnext(&rtc->timerqueue))) { 851 while ((next = timerqueue_getnext(&rtc->timerqueue))) {
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 132333d75408..4267789ca995 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -568,7 +568,6 @@ static irqreturn_t cmos_interrupt(int irq, void *p)
568 hpet_mask_rtc_irq_bit(RTC_AIE); 568 hpet_mask_rtc_irq_bit(RTC_AIE);
569 569
570 CMOS_READ(RTC_INTR_FLAGS); 570 CMOS_READ(RTC_INTR_FLAGS);
571 pm_wakeup_event(cmos_rtc.dev, 0);
572 } 571 }
573 spin_unlock(&rtc_lock); 572 spin_unlock(&rtc_lock);
574 573