ia64/xen-unstable

changeset 19240:9cad48ba52b0

x86, ioapic: Fix S3 suspend error.

Invoke ioapic_pm_state_alloc() earlier,
thus avoiding check_lock() BUG_ON() in spin_lock().

Signed-off-by: Guanqun Lu <guanqun.lu@intel.com>
author Keir Fraser <keir.fraser@citrix.com>
date Sun Mar 01 14:17:08 2009 +0000 (2009-03-01)
parents f8187a343ad2
children 9af46734ce70
files xen/arch/x86/io_apic.c xen/include/asm-x86/io_apic.h
line diff
     1.1 --- a/xen/arch/x86/io_apic.c	Fri Feb 20 17:02:36 2009 +0000
     1.2 +++ b/xen/arch/x86/io_apic.c	Sun Mar 01 14:17:08 2009 +0000
     1.3 @@ -1779,6 +1779,20 @@ static inline void check_timer(void)
     1.4   */
     1.5  #define PIC_IRQS	(1 << PIC_CASCADE_IR)
     1.6  
     1.7 +static struct IO_APIC_route_entry *ioapic_pm_state;
     1.8 +
     1.9 +void ioapic_pm_state_alloc(void)
    1.10 +{
    1.11 +    int i, nr_entry = 0;
    1.12 +
    1.13 +    for (i = 0; i < nr_ioapics; i++)
    1.14 +        nr_entry += nr_ioapic_registers[i];
    1.15 +
    1.16 +    ioapic_pm_state = _xmalloc(sizeof(struct IO_APIC_route_entry)*nr_entry,
    1.17 +                               sizeof(struct IO_APIC_route_entry));
    1.18 +    BUG_ON(ioapic_pm_state == NULL);
    1.19 +}
    1.20 +
    1.21  void __init setup_IO_APIC(void)
    1.22  {
    1.23      enable_IO_APIC();
    1.24 @@ -1801,40 +1815,16 @@ void __init setup_IO_APIC(void)
    1.25      init_IO_APIC_traps();
    1.26      check_timer();
    1.27      print_IO_APIC();
    1.28 +    ioapic_pm_state_alloc();
    1.29  
    1.30      register_keyhandler('z', print_IO_APIC_keyhandler, "print ioapic info");
    1.31  }
    1.32  
    1.33 -struct IO_APIC_route_entry *ioapic_pm_state=NULL;
    1.34 -
    1.35 -void ioapic_pm_state_alloc(void)
    1.36 +void ioapic_suspend(void)
    1.37  {
    1.38 -    int i, nr_entry = 0;
    1.39 -
    1.40 -    if (ioapic_pm_state != NULL)
    1.41 -        return;
    1.42 -
    1.43 -    for (i = 0; i < nr_ioapics; i++)
    1.44 -        nr_entry += nr_ioapic_registers[i];
    1.45 -
    1.46 -    ioapic_pm_state = _xmalloc(sizeof(struct IO_APIC_route_entry)*nr_entry,
    1.47 -                               sizeof(struct IO_APIC_route_entry));
    1.48 -}
    1.49 -
    1.50 -int ioapic_suspend(void)
    1.51 -{
    1.52 -    struct IO_APIC_route_entry *entry;
    1.53 +    struct IO_APIC_route_entry *entry = ioapic_pm_state;
    1.54      unsigned long flags;
    1.55 -    int apic,i;
    1.56 -
    1.57 -    ioapic_pm_state_alloc();
    1.58 -
    1.59 -    if (ioapic_pm_state == NULL) {
    1.60 -        printk("Cannot suspend ioapic due to lack of memory\n");
    1.61 -        return 1;
    1.62 -    }
    1.63 -
    1.64 -    entry = ioapic_pm_state;
    1.65 +    int apic, i;
    1.66  
    1.67      spin_lock_irqsave(&ioapic_lock, flags);
    1.68      for (apic = 0; apic < nr_ioapics; apic++) {
    1.69 @@ -1844,23 +1834,14 @@ int ioapic_suspend(void)
    1.70          }
    1.71      }
    1.72      spin_unlock_irqrestore(&ioapic_lock, flags);
    1.73 -
    1.74 -    return 0;
    1.75  }
    1.76  
    1.77 -int ioapic_resume(void)
    1.78 +void ioapic_resume(void)
    1.79  {
    1.80 -    struct IO_APIC_route_entry *entry;
    1.81 +    struct IO_APIC_route_entry *entry = ioapic_pm_state;
    1.82      unsigned long flags;
    1.83      union IO_APIC_reg_00 reg_00;
    1.84 -    int i,apic;
    1.85 -    
    1.86 -    if (ioapic_pm_state == NULL){
    1.87 -        printk("Cannot resume ioapic due to lack of memory\n");
    1.88 -        return 1;
    1.89 -    }
    1.90 -    
    1.91 -    entry = ioapic_pm_state;
    1.92 +    int i, apic;
    1.93  
    1.94      spin_lock_irqsave(&ioapic_lock, flags);
    1.95      for (apic = 0; apic < nr_ioapics; apic++){
    1.96 @@ -1875,8 +1856,6 @@ int ioapic_resume(void)
    1.97          }
    1.98      }
    1.99      spin_unlock_irqrestore(&ioapic_lock, flags);
   1.100 -
   1.101 -    return 0;
   1.102  }
   1.103  
   1.104  /* --------------------------------------------------------------------------
     2.1 --- a/xen/include/asm-x86/io_apic.h	Fri Feb 20 17:02:36 2009 +0000
     2.2 +++ b/xen/include/asm-x86/io_apic.h	Sun Mar 01 14:17:08 2009 +0000
     2.3 @@ -182,13 +182,13 @@ extern int timer_uses_ioapic_pin_0;
     2.4  #endif /*CONFIG_ACPI_BOOT*/
     2.5  
     2.6  extern int (*ioapic_renumber_irq)(int ioapic, int irq);
     2.7 -extern int ioapic_suspend(void);
     2.8 -extern int ioapic_resume(void);
     2.9 +extern void ioapic_suspend(void);
    2.10 +extern void ioapic_resume(void);
    2.11  
    2.12  #else  /* !CONFIG_X86_IO_APIC */
    2.13  #define io_apic_assign_pci_irqs 0
    2.14 -static inline int ioapic_suspend(void) {return 0};
    2.15 -static inline int ioapic_resume(void) {return 0};
    2.16 +static inline void ioapic_suspend(void) {}
    2.17 +static inline void ioapic_resume(void) {}
    2.18  #endif
    2.19  
    2.20  extern int assign_irq_vector(int irq);