summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/subr_bus.c10
-rw-r--r--sys/net/netisr.c10
-rw-r--r--sys/sys/mutex.h21
3 files changed, 31 insertions, 10 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c
index 347489f..092f410 100644
--- a/sys/kern/subr_bus.c
+++ b/sys/kern/subr_bus.c
@@ -2133,16 +2133,6 @@ bus_release_resource(device_t dev, int type, int rid, struct resource *r)
return (BUS_RELEASE_RESOURCE(dev->parent, dev, type, rid, r));
}
-/*
- * XXX this is a temporary measure to allow folks to
- * XXX disable INTR_MPSAFE in network drivers without
- * XXX recompiling--in case of problems.
- */
-int debug_mpsafenet = 0;
-TUNABLE_INT("debug.mpsafenet", &debug_mpsafenet);
-SYSCTL_INT(_debug, OID_AUTO, mpsafenet, CTLFLAG_RW, &debug_mpsafenet, 0,
- "Enable/disable MPSAFE network support");
-
int
bus_setup_intr(device_t dev, struct resource *r, int flags,
driver_intr_t handler, void *arg, void **cookiep)
diff --git a/sys/net/netisr.c b/sys/net/netisr.c
index 347fd9a..cb24e12 100644
--- a/sys/net/netisr.c
+++ b/sys/net/netisr.c
@@ -53,6 +53,16 @@
#include <net/if_var.h>
#include <net/netisr.h>
+/*
+ * XXX this is a temporary measure to allow folks to
+ * XXX disable Giant locking in the network code without
+ * XXX recompiling--in case of problems.
+ */
+int debug_mpsafenet = 0;
+TUNABLE_INT("debug.mpsafenet", &debug_mpsafenet);
+SYSCTL_INT(_debug, OID_AUTO, mpsafenet, CTLFLAG_RD, &debug_mpsafenet, 0,
+ "Enable/disable MPSAFE network support");
+
volatile unsigned int netisr; /* scheduling bits for network */
struct netisr {
diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h
index 9601fd7..05575b5 100644
--- a/sys/sys/mutex.h
+++ b/sys/sys/mutex.h
@@ -339,6 +339,27 @@ do { \
WITNESS_RESTORE(&Giant.mtx_object, Giant)
#endif
+/*
+ * Network MPSAFE temporary workarounds. When debug_mpsafenet
+ * is 1 the network is assumed to operate without Giant on the
+ * input path and protocols that require Giant must collect it
+ * on entry. When 0 Giant is grabbed in the network interface
+ * ISR's and in the netisr path and there is no need to grab
+ * the Giant lock.
+ *
+ * This mechanism is intended as temporary until everything of
+ * importance is properly locked.
+ */
+extern int debug_mpsafenet; /* defined in net/netisr.c */
+#define NET_PICKUP_GIANT() do { \
+ if (debug_mpsafenet) \
+ mtx_lock(&Giant); \
+} while (0)
+#define NET_DROP_GIANT() do { \
+ if (debug_mpsafenet) \
+ mtx_unlock(&Giant); \
+} while (0)
+
#define UGAR(rval) do { \
int _val = (rval); \
mtx_unlock(&Giant); \
OpenPOWER on IntegriCloud