Skip to contentSkip to conversation

INIT-SIPI-SIPI timing and CPU bringup on new Intel CPUs

PATCH Tim Deegan 1 participant 2 messages Jun 23, 2011 – Jul 19, 2011

lore
Share & tools
lore

Tim Deegan

author
#0 lore raw

Hi,

I've come across the problem reported in this thread:
http://lists.xensource.com/archives/html/xen-devel/2011-02/msg00702.html
where on a very new Intel system some of the APs don't respond when the BSP tries to wake them.

I've found that removing the delays between the IPIs makes this problem go away. I'm hoping someone from Intel can help me understand why, and whether that's a sensible answer. Since this is an x2apic system I guess we don't have to wait for the IPI to be acked by the sending APIC, but the SDMs still recommend delaying between INIT, SIPI and SIPI, and I can imagine I might be breaking some other systems by doing this.

So the questions I have are:
- is it safe always to issue INIT-SIPI-SIPI back-to-back on x2apic systems?
- is there any reason why the delay should make a difference (except maybe that this is an early version of a chip?)

My patch is attached; it removes the delays only in the x2apic case, so shouldn't break any older systems.

Cheers,

Tim.

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

x86: Remove timeouts from INIT-SIPI-SIPI sequence when using x2apic.

Some of the timeouts are pointless since they're waiting for the ICR to ack the IPI delivery and that doesn't happen on x2apic. The others should be benign (and are suggested in the SDM) but removing them makes AP bringup much more reliable on some test boxes.

xen/arch/x86/smpboot.c +33 -30
diff -r e2235fe267eb -r 132dae3ced15 xen/arch/x86/smpboot.c
@@ -435,29 +435,30 @@ static int wakeup_secondary_cpu(int phys
     apic_icr_write(APIC_INT_LEVELTRIG | APIC_INT_ASSERT | APIC_DM_INIT,
                    phys_apicid);
 
-    Dprintk("Waiting for send to finish...\n");
-    timeout = 0;
-    do {
-        Dprintk("+");
-        udelay(100);
-        if ( !x2apic_enabled )
+    if ( !x2apic_enabled )
+    {
+        Dprintk("Waiting for send to finish...\n");
+        timeout = 0;
+        do {
+            Dprintk("+");
+            udelay(100);
             send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
-    } while ( send_status && (timeout++ < 1000) );
+        } while ( send_status && (timeout++ < 1000) );
 
-    mdelay(10);
+        mdelay(10);
 
-    Dprintk("Deasserting INIT.\n");
+        Dprintk("Deasserting INIT.\n");
 
-    apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
+        apic_icr_write(APIC_INT_LEVELTRIG | APIC_DM_INIT, phys_apicid);
 
-    Dprintk("Waiting for send to finish...\n");
-    timeout = 0;
-    do {
-        Dprintk("+");
-        udelay(100);
-        if ( !x2apic_enabled )
+        Dprintk("Waiting for send to finish...\n");
+        timeout = 0;
+        do {
+            Dprintk("+");
+            udelay(100);
             send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
-    } while ( send_status && (timeout++ < 1000) );
+        } while ( send_status && (timeout++ < 1000) );
+    }
 
     /*
      * Should we send STARTUP IPIs ?
@@ -486,22 +487,24 @@ static int wakeup_secondary_cpu(int phys
          */
         apic_icr_write(APIC_DM_STARTUP | (start_eip >> 12), phys_apicid);
 
-        /* Give the other CPU some time to accept the IPI. */
-        udelay(300);
+        if ( !x2apic_enabled )
+        {
+            /* Give the other CPU some time to accept the IPI. */
+            udelay(300);
 
-        Dprintk("Startup point 1.\n");
+            Dprintk("Startup point 1.\n");
 
-        Dprintk("Waiting for send to finish...\n");
-        timeout = 0;
-        do {
-            Dprintk("+");
-            udelay(100);
-            if ( !x2apic_enabled )
-            send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
-        } while ( send_status && (timeout++ < 1000) );
+            Dprintk("Waiting for send to finish...\n");
+            timeout = 0;
+            do {
+                Dprintk("+");
+                udelay(100);
+                send_status = apic_read(APIC_ICR) & APIC_ICR_BUSY;
+            } while ( send_status && (timeout++ < 1000) );
 
-        /* Give the other CPU some time to accept the IPI. */
-        udelay(200);
+            /* Give the other CPU some time to accept the IPI. */
+            udelay(200);
+        }
 
         /* Due to the Pentium erratum 3AP. */
         if ( maxlvt > 3 )

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel

author
#1 lore raw
Quoted 7 lines · Tim Deegan

I've found that removing the delays between the IPIs makes this problem go away. I'm hoping someone from Intel can help me understand why, and whether that's a sensible answer. Since this is an x2apic system I guess we don't have to wait for the IPI to be acked by the sending APIC, but the SDMs still recommend delaying between INIT, SIPI and SIPI, and I can imagine I might be breaking some other systems by doing this.

Quoted 7 lines

So the questions I have are:
- is it safe always to issue INIT-SIPI-SIPI back-to-back on x2apic systems?
- is there any reason why the delay should make a difference (except maybe that this is an early version of a chip?)

My patch is attached; it removes the delays only in the x2apic case, so shouldn't break any older systems.

We've tested this on the XenServer automated test pools for a couple of weeks and not seen any ill effects. In the absence of any negative feedback, I propose that we apply this patch to xen-unstable.

Cheers,

Tim.

Signature · 3 lines
Tim Deegan <[email protected]>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)