x86, hpet: Avoud double initialisation on boot or after S3.
authorKeir Fraser <keir.fraser@citrix.com>
Wed, 19 Nov 2008 12:48:31 +0000 (12:48 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Wed, 19 Nov 2008 12:48:31 +0000 (12:48 +0000)
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
xen/arch/x86/acpi/power.c
xen/arch/x86/hpet.c
xen/include/asm-x86/acpi.h

index 7e96bfc796926ecc04d710a24402f01dde476528..2eb68600700280f282b7289a6e08afede7ebe291 100644 (file)
@@ -30,6 +30,8 @@
 
 #include <acpi/cpufreq/cpufreq.h>
 
+uint32_t system_reset_counter = 1;
+
 static char opt_acpi_sleep[20];
 string_param("acpi_sleep", opt_acpi_sleep);
 
@@ -163,6 +165,7 @@ static int enter_state(u32 state)
     {
     case ACPI_STATE_S3:
         do_suspend_lowlevel();
+        system_reset_counter++;
         break;
     case ACPI_STATE_S5:
         acpi_enter_sleep_state(ACPI_STATE_S5);
index 5c2bc02885bdc18313b5e4ee87353aed6ea6f2eb..e72e8f94e46d9ac4b9307b6144281c3423cb0cbc 100644 (file)
@@ -264,12 +264,14 @@ int hpet_legacy_irq_tick(void)
 
 u64 hpet_setup(void)
 {
-    u64 hpet_rate;
+    static u64 hpet_rate;
+    static u32 system_reset_latch;
     u32 hpet_id, hpet_period, cfg;
     int i;
 
-    if ( hpet_address == 0 )
-        return 0;
+    if ( system_reset_latch == system_reset_counter )
+        return hpet_rate;
+    system_reset_latch = system_reset_counter;
 
     set_fixmap_nocache(FIX_HPET_BASE, hpet_address);
 
index 5ae806faa984c44a7e210608a5963ab9dd02ca5d..459978e49150398ef270416f0ca0ef55235c67a4 100644 (file)
@@ -166,4 +166,7 @@ extern u8 x86_acpiid_to_apicid[];
 
 extern int acpi_dmar_init(void);
 
+/* Incremented whenever we transition through S3. Value is 1 during boot. */
+extern uint32_t system_reset_counter;
+
 #endif /*__X86_ASM_ACPI_H*/