svn commit: r205432 - head/sys/ia64/pci

Marcel Moolenaar marcel at FreeBSD.org
Mon Mar 22 03:06:12 UTC 2010


Author: marcel
Date: Mon Mar 22 03:06:11 2010
New Revision: 205432
URL: http://svn.freebsd.org/changeset/base/205432

Log:
  Disable interrupts when calling into SAL for PCI configuration
  cycles. This serves 2 purposes:
  1.  It prevents preemption and CPU migration while running SAL code.
  2.  It reduces the chance of stack overflows: we're supposed to enter
      SAL with at least 16KB of either memory- or register stack space,
      which we can't do without switching to a different stack.

Modified:
  head/sys/ia64/pci/pci_cfgreg.c

Modified: head/sys/ia64/pci/pci_cfgreg.c
==============================================================================
--- head/sys/ia64/pci/pci_cfgreg.c	Mon Mar 22 02:01:33 2010	(r205431)
+++ head/sys/ia64/pci/pci_cfgreg.c	Mon Mar 22 03:06:11 2010	(r205432)
@@ -28,6 +28,7 @@
  */
 
 #include <sys/param.h>
+#include <machine/cpufunc.h>
 #include <machine/pci_cfgreg.h>
 #include <machine/sal.h>
 
@@ -66,6 +67,7 @@ uint32_t
 pci_cfgregread(int bus, int slot, int func, int reg, int len)
 {
 	struct ia64_sal_result res;
+	register_t is;
 	u_long addr;
 
 	addr = pci_sal_address(0, bus, slot, func, reg);
@@ -75,17 +77,18 @@ pci_cfgregread(int bus, int slot, int fu
 	if (!pci_valid_access(reg, len))
 		return (~0);
 
+	is = intr_disable();
 	res = ia64_sal_entry(SAL_PCI_CONFIG_READ, addr, len, 0, 0, 0, 0, 0);
-	if (res.sal_status < 0)
-		return (~0);
+	intr_restore(is);
 
-	return (res.sal_result[0]);
+	return ((res.sal_status < 0) ? ~0 : res.sal_result[0]);
 }
 
 void
 pci_cfgregwrite(int bus, int slot, int func, int reg, uint32_t data, int len)
 {
 	struct ia64_sal_result res;
+	register_t is;
 	u_long addr;
 
 	addr = pci_sal_address(0, bus, slot, func, reg);
@@ -95,5 +98,7 @@ pci_cfgregwrite(int bus, int slot, int f
 	if (!pci_valid_access(reg, len))
 		return;
 
+	is = intr_disable();
 	res = ia64_sal_entry(SAL_PCI_CONFIG_WRITE, addr, len, data, 0, 0, 0, 0);
+	intr_restore(is);
 }


More information about the svn-src-all mailing list