Skip to contentSkip to conversation

rtc-cmos: strongly avoid "HPET emulation"

PATCH New David Brownell 1 participant 1 message Aug 16, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc-cmos: strongly avoid "HPET emulation"

From: David Brownell <[email protected]>

Add a new mechanism to the rtc-cmos platform glue: an irq_handler_t can now "filter" the interrupts.

Update rtc-cmos to use that mechanism where it's been set up, instead of "HPET emulation". http://bugzilla.kernel.org/show_bug.cgi?id=11153
shows the problem: that emulation makes update interrupts misbehave wildly, and thus makes NTP synch tools malfunction.

Make ACPI glue always set this using ACPI "events". That seems to work even if HPET isn't set up for "legacy replacement mode", which reroutes RTC irqs to SCI. In the future, ACPI might need to blacklist some boards where ACPI event handling doesn't work as well as "real" IRQs, yet booting "hpet=disable" isn't OK. For now we work around such problems by leaving ACPI RTC event code disabled most of the time.

---
CC'd ACPI team since this already works around at least two bugs in the ACPI event handling, or is it BIOS code?, and I don't have a good handle on what other surprises may lurk there. Should the RTC just request_irq(SCI, IRQF_SHARED, ...), in case of boards that don't expose this particular ACPI event? If so, how can it know the SCI irq? Maybe this should cook a while and not merge til 2.6.28 ...

 drivers/acpi/glue.c         |   27 ++++++++---
 drivers/rtc/rtc-cmos.c      |  102 ++++++++++++++++++++++++++++++++------------
 include/linux/mc146818rtc.h |    1 
 3 files changed, 97 insertions(+), 33 deletions(-)
drivers/acpi/glue.c +20 -7
@@ -11,6 +11,8 @@
 #include <linux/device.h>
 #include <linux/rwsem.h>
 #include <linux/acpi.h>
+#include <linux/interrupt.h>
+
 
 #define ACPI_GLUE_DEBUG	0
 #if ACPI_GLUE_DEBUG
@@ -261,14 +263,29 @@ arch_initcall(init_acpi_device_notify);
 
 #if defined(CONFIG_RTC_DRV_CMOS) || defined(CONFIG_RTC_DRV_CMOS_MODULE)
 
-#ifdef CONFIG_PM
+static irq_handler_t handler;
+static void *irq_context;
+
 static u32 rtc_handler(void *context)
 {
+	/* Handler will clear status at the IRQ chip; this matters most
+	 * when RTC irqs are routed through ACPI because of HPET.
+	 */
+	if (handler)
+		handler(0, irq_context);
+	else
+		acpi_disable_event(ACPI_EVENT_RTC, 0);
+
 	acpi_clear_event(ACPI_EVENT_RTC);
-	acpi_disable_event(ACPI_EVENT_RTC, 0);
 	return ACPI_INTERRUPT_HANDLED;
 }
 
+static void rtc_set_filter(irq_handler_t h, void *c)
+{
+	handler = h;
+	irq_context = c;
+}
+
 static inline void rtc_wake_setup(void)
 {
 	acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
@@ -290,11 +307,6 @@ static void rtc_wake_off(struct device *
 {
 	acpi_disable_event(ACPI_EVENT_RTC, 0);
 }
-#else
-#define rtc_wake_setup()	do{}while(0)
-#define rtc_wake_on		NULL
-#define rtc_wake_off		NULL
-#endif
 
 /* Every ACPI platform has a mc146818 compatible "cmos rtc".  Here we find
  * its device node and pass extra config data.  This helps its driver use
@@ -338,6 +350,7 @@ static int __init acpi_rtc_init(void)
 
 	if (dev) {
 		rtc_wake_setup();
+		rtc_info.set_filter = rtc_set_filter;
 		rtc_info.wake_on = rtc_wake_on;
 		rtc_info.wake_off = rtc_wake_off;
 
drivers/rtc/rtc-cmos.c +76 -26

244 lines not on this page · raw message

include/linux/mc146818rtc.h +1 -0
@@ -28,6 +28,7 @@ extern spinlock_t rtc_lock;		/* serializ
  * a separate wakeup alarm used by some almost-clone chips.
  */
 struct cmos_rtc_board_info {
+	void	(*set_filter)(irq_handler_t handler, void *context);
 	void	(*wake_on)(struct device *dev);
 	void	(*wake_off)(struct device *dev);