rtc: cmos: acknowledge ACPI driven wake alarms upon resume
authorZhang Rui <rui.zhang@intel.com>
Mon, 26 Mar 2018 13:58:02 +0000 (21:58 +0800)
committerAlexandre Belloni <alexandre.belloni@bootlin.com>
Thu, 19 Apr 2018 16:01:50 +0000 (18:01 +0200)
commitc6d3a278cc1201a93677737db565c25c58b2cfe0
treea89f55fcb86831c9c2011c47c473714ab230dba1
parent311ee9c151ad7f273eb698504c4a27ebddc6c6db
rtc: cmos: acknowledge ACPI driven wake alarms upon resume

Previously, the RTC alarm is acknowledged either by the cmos rtc irq
handler, or by the hpet rtc irq handler.

When using ACPI RTC Fixed event as the RTC alarm, the RTC alarm is
acknowledged by the ACPI RTC event handler, as addressed in the previous
patch.
But, when resume from suspend-to-ram (ACPI S3), the ACPI SCI is cleared
right after resume, thus the ACPI RTC event handler is not invoked at all,
results in the RTC Alarm unacknowledged.

Handle this by comparing the current time and the RTC Alarm time in the
rtc_cmos driver .resume() callback
1. Assume the wakeup event has already been fired if the RTC Alarm time
   is earlier than/equal to the current time, and ACK the RTC Alarm.
2. Assume the wakeup event has not been fired if the RTC Alarm time
   is later than current time, and re-arm it if needed.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
drivers/rtc/rtc-cmos.c