RTC: Don't clear pending interrupt in resume path

The linux kernel relies on the RTC reporting pending interrupts if
the RTC alarm was used to wake the system.  If we clear these flags
here then the rtc-cmos driver in the kernel will think that no
interrupts are pending and will not re-start the timerqueue to
handle the alarm timerqueue node.

This flag doesn't exist in SMM but the rtc code is compiled there.
Since rtc_init() is not called by SMM it is guarded with an ifdef.

I performed several thousand suspend/resume cycles without seeing
an issue where hwclock was unable to read from /dev/rtc.  There
still is a potential kernel issue where the timerqueue can stall
but this makes that much less likely to happen on resume.

Change-Id: I5a343da4ce5c4c8ec4783b4e503869ccfa5077f0
Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Reviewed-on: http://review.coreboot.org/1741
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Duncan Laurie 2012-09-05 10:52:44 -07:00 committed by Stefan Reinauer
parent 2558c736a0
commit 4b1610d766
1 changed files with 15 additions and 0 deletions

View File

@ -8,6 +8,9 @@
#include "option_table.h" #include "option_table.h"
#include <cbfs.h> #include <cbfs.h>
#endif #endif
#if CONFIG_HAVE_ACPI_RESUME
#include <arch/acpi.h>
#endif
/* control registers - Moto names /* control registers - Moto names
*/ */
@ -127,6 +130,7 @@ static void rtc_set_checksum(int range_start, int range_end, int cks_loc)
#endif #endif
#endif #endif
#ifndef __SMM__
void rtc_init(int invalid) void rtc_init(int invalid)
{ {
int cmos_invalid = 0; int cmos_invalid = 0;
@ -192,9 +196,20 @@ void rtc_init(int invalid)
PC_CKS_RANGE_END,PC_CKS_LOC); PC_CKS_RANGE_END,PC_CKS_LOC);
#endif #endif
#if CONFIG_HAVE_ACPI_RESUME
/*
* Avoid clearing pending interrupts in the resume path because
* the Linux kernel relies on this to know if it should restart
* the RTC timerqueue if the wake was due to the RTC alarm.
*/
if (acpi_slp_type == 3)
return;
#endif
/* Clear any pending interrupts */ /* Clear any pending interrupts */
(void) cmos_read(RTC_INTR_FLAGS); (void) cmos_read(RTC_INTR_FLAGS);
} }
#endif
#if CONFIG_USE_OPTION_TABLE #if CONFIG_USE_OPTION_TABLE