RTC: Avoid races between RTC alarm wakeup and suspend.
authorNeilBrown <neilb@suse.de>
Sun, 5 Aug 2012 20:56:20 +0000 (22:56 +0200)
committerGrazvydas Ignotas <notasas@gmail.com>
Sat, 2 Mar 2013 20:11:52 +0000 (22:11 +0200)
commitd67faa52791d2959e640c0847a194e09b322c8f2
treeb3d82abca9181bc7bbf53568baa38c58b6d02ba2
parent1c2940354415189e113ac9eb2eb10cdebbeeb6f6
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>
drivers/rtc/interface.c