[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] ACPI S3: fix S3 resume fail on system w/ msi capable hpet



ACPI S3: fix S3 resume fail on system w/ msi capable hpet

Don't re-allocate memory for irq_channel which will cause a BUG_ON in 
hpet_msi_write, and make sure hpet_setup_msi_irq() executed during S3 resuming.

Signed-off-by: Wei Gang <gang.wei@xxxxxxxxx>

diff -r 927fd1587daf xen/arch/x86/hpet.c
--- a/xen/arch/x86/hpet.c       Fri Feb 26 16:00:41 2010 +0800
+++ b/xen/arch/x86/hpet.c       Fri Feb 26 17:18:11 2010 +0800
@@ -39,11 +39,12 @@ struct hpet_event_channel
 
     unsigned int idx;   /* physical channel idx */
     int cpu;            /* msi target */
-    unsigned int irq;/* msi irq */
+    int irq;            /* msi irq */
     unsigned int flags; /* HPET_EVT_x */
 } __cacheline_aligned;
 static struct hpet_event_channel legacy_hpet_event;
-static struct hpet_event_channel hpet_events[MAX_HPET_NUM];
+static struct hpet_event_channel hpet_events[MAX_HPET_NUM] = 
+    { [0 ... MAX_HPET_NUM-1].irq = -1 };
 static unsigned int num_hpets_used; /* msi hpet channels used for broadcast */
 
 DEFINE_PER_CPU(struct hpet_event_channel *, cpu_bc_channel);
@@ -353,24 +354,26 @@ static int hpet_setup_msi_irq(unsigned i
 
 static int hpet_assign_irq(struct hpet_event_channel *ch)
 {
-    int irq;
-
-    if ( ch->irq )
-        return 0;
-
-    if ( (irq = create_irq()) < 0 )
-        return irq;
-
-    irq_channel[irq] = ch - &hpet_events[0];
-
+    int irq = ch->irq;
+
+    if ( irq < 0 )
+    {
+        if ( (irq = create_irq()) < 0 )
+            return irq;
+
+        irq_channel[irq] = ch - &hpet_events[0];
+        ch->irq = irq;
+    }
+
+    /* hpet_setup_msi_irq should also be called for S3 resuming */
     if ( hpet_setup_msi_irq(irq) )
     {
         destroy_irq(irq);
         irq_channel[irq] = -1;
+        ch->irq = -1;
         return -EINVAL;
     }
 
-    ch->irq = irq;
     return 0;
 }
 
@@ -532,10 +535,14 @@ void hpet_broadcast_init(void)
     u32 hpet_id, cfg;
     int i;
 
-    irq_channel= xmalloc_array(int, nr_irqs);
-    BUG_ON(!irq_channel);
-    for (i = 0; i < nr_irqs ; i++)
-        irq_channel[i] = -1;
+    /* irq_channel should not be re-initialized during S3 resuming */
+    if ( !irq_channel )
+    {
+        irq_channel= xmalloc_array(int, nr_irqs);
+        BUG_ON(!irq_channel);
+        for ( i = 0; i < nr_irqs ; i++ )
+            irq_channel[i] = -1;
+    }
 
     hpet_rate = hpet_setup();
     if ( hpet_rate == 0 )

Attachment: fix_msi_hpet_s3_v2.patch
Description: fix_msi_hpet_s3_v2.patch

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.