]> xenbits.xensource.com Git - people/vhanquez/xen.git/commitdiff
x86, ioapic: Fix S3 suspend error.
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 2 Mar 2009 14:16:42 +0000 (14:16 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 2 Mar 2009 14:16:42 +0000 (14:16 +0000)
Invoke ioapic_pm_state_alloc() earlier,
thus avoiding check_lock() BUG_ON() in spin_lock().

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
xen-unstable changeset:   19239:9cad48ba52b0dd83dfeae014aaac7a16af0585dc
xen-unstable date:        Sun Mar 01 14:17:08 2009 +0000

xen/arch/x86/io_apic.c
xen/include/asm-x86/io_apic.h

index 04c44c1ef1e46120071060782ec128ecfa26c873..9fda4d0bfb82a2506755b88ac55712dbd56d73ac 100644 (file)
@@ -1845,6 +1845,20 @@ static inline void check_timer(void)
  */
 #define PIC_IRQS       (1 << PIC_CASCADE_IR)
 
+static struct IO_APIC_route_entry *ioapic_pm_state;
+
+void ioapic_pm_state_alloc(void)
+{
+    int i, nr_entry = 0;
+
+    for (i = 0; i < nr_ioapics; i++)
+        nr_entry += nr_ioapic_registers[i];
+
+    ioapic_pm_state = _xmalloc(sizeof(struct IO_APIC_route_entry)*nr_entry,
+                               sizeof(struct IO_APIC_route_entry));
+    BUG_ON(ioapic_pm_state == NULL);
+}
+
 void __init setup_IO_APIC(void)
 {
     enable_IO_APIC();
@@ -1867,40 +1881,16 @@ void __init setup_IO_APIC(void)
     init_IO_APIC_traps();
     check_timer();
     print_IO_APIC();
+    ioapic_pm_state_alloc();
 
     register_keyhandler('z', print_IO_APIC_keyhandler, "print ioapic info");
 }
 
-struct IO_APIC_route_entry *ioapic_pm_state=NULL;
-
-void ioapic_pm_state_alloc(void)
+void ioapic_suspend(void)
 {
-    int i, nr_entry = 0;
-
-    if (ioapic_pm_state != NULL)
-        return;
-
-    for (i = 0; i < nr_ioapics; i++)
-        nr_entry += nr_ioapic_registers[i];
-
-    ioapic_pm_state = _xmalloc(sizeof(struct IO_APIC_route_entry)*nr_entry,
-                               sizeof(struct IO_APIC_route_entry));
-}
-
-int ioapic_suspend(void)
-{
-    struct IO_APIC_route_entry *entry;
+    struct IO_APIC_route_entry *entry = ioapic_pm_state;
     unsigned long flags;
-    int apic,i;
-
-    ioapic_pm_state_alloc();
-
-    if (ioapic_pm_state == NULL) {
-        printk("Cannot suspend ioapic due to lack of memory\n");
-        return 1;
-    }
-
-    entry = ioapic_pm_state;
+    int apic, i;
 
     spin_lock_irqsave(&ioapic_lock, flags);
     for (apic = 0; apic < nr_ioapics; apic++) {
@@ -1910,23 +1900,14 @@ int ioapic_suspend(void)
         }
     }
     spin_unlock_irqrestore(&ioapic_lock, flags);
-
-    return 0;
 }
 
-int ioapic_resume(void)
+void ioapic_resume(void)
 {
-    struct IO_APIC_route_entry *entry;
+    struct IO_APIC_route_entry *entry = ioapic_pm_state;
     unsigned long flags;
     union IO_APIC_reg_00 reg_00;
-    int i,apic;
-    
-    if (ioapic_pm_state == NULL){
-        printk("Cannot resume ioapic due to lack of memory\n");
-        return 1;
-    }
-    
-    entry = ioapic_pm_state;
+    int i, apic;
 
     spin_lock_irqsave(&ioapic_lock, flags);
     for (apic = 0; apic < nr_ioapics; apic++){
@@ -1941,8 +1922,6 @@ int ioapic_resume(void)
         }
     }
     spin_unlock_irqrestore(&ioapic_lock, flags);
-
-    return 0;
 }
 
 /* --------------------------------------------------------------------------
index ff3cc6d991211de947db0e7079eb71f4a8cc8757..bc0c0276e33570f2cf9668ac2ffd60a90b6dab83 100644 (file)
@@ -182,13 +182,13 @@ extern int timer_uses_ioapic_pin_0;
 #endif /*CONFIG_ACPI_BOOT*/
 
 extern int (*ioapic_renumber_irq)(int ioapic, int irq);
-extern int ioapic_suspend(void);
-extern int ioapic_resume(void);
+extern void ioapic_suspend(void);
+extern void ioapic_resume(void);
 
 #else  /* !CONFIG_X86_IO_APIC */
 #define io_apic_assign_pci_irqs 0
-static inline int ioapic_suspend(void) {return 0};
-static inline int ioapic_resume(void) {return 0};
+static inline void ioapic_suspend(void) {}
+static inline void ioapic_resume(void) {}
 #endif
 
 extern int assign_irq_vector(int irq);