PERFORCE change 64958 for review

John Baldwin jhb at FreeBSD.org
Fri Nov 12 09:47:16 PST 2004


http://perforce.freebsd.org/chv.cgi?CH=64958

Change 64958 by jhb at jhb_slimer on 2004/11/12 17:46:44

	Do the TPR magic in lapic_ipi_wait() if needed as well.

Affected files ...

.. //depot/projects/smpng/sys/i386/i386/local_apic.c#17 edit

Differences ...

==== //depot/projects/smpng/sys/i386/i386/local_apic.c#17 (text+ko) ====

@@ -660,26 +660,37 @@
 int
 lapic_ipi_wait(int delay)
 {
-	int x, incr;
+	int x, incr, allow_ipis, done;
+
+	/*
+	 * If interrupts are disabled, then hack on the APIC to allow
+	 * safe IPIs to come in while we wait.
+	 */
+	allow_ipis = (read_eflags() & PSL_I) == 0;
+	if (allow_ipis)
+		APIC_IPI_SPINWAIT_ENTER();
 
 	/*
 	 * Wait delay loops for IPI to be sent.  This is highly bogus
 	 * since this is sensitive to CPU clock speed.  If delay is
 	 * -1, we wait forever.
-	 *
-	 * XXX: Should we be using the IPI spinwait macros here?
 	 */
 	if (delay == -1) {
 		incr = 0;
 		delay = 1;
 	} else
 		incr = 1;
+	done = 0;
 	for (x = 0; x < delay; x += incr) {
-		if ((lapic->icr_lo & APIC_DELSTAT_MASK) == APIC_DELSTAT_IDLE)
-			return (1);
+		if ((lapic->icr_lo & APIC_DELSTAT_MASK) == APIC_DELSTAT_IDLE) {
+			done = 1;
+			break;
+		}
 		ia32_pause();
 	}
-	return (0);
+	if (allow_ipis)
+		APIC_IPI_SPINWAIT_EXIT();
+	return (done);
 }
 
 void


More information about the p4-projects mailing list