From d3be1471c71fdfb310846f91308f29f40eb8ce2f Mon Sep 17 00:00:00 2001 From: Sam Leffler Date: Wed, 5 Nov 2003 23:42:51 +0000 Subject: [PATCH] o make debug_mpsafenet globally visible o move it from subr_bus.c to netisr.c where it more properly belongs o add NET_PICKUP_GIANT and NET_DROP_GIANT macros that will be used to grab Giant as needed when MPSAFE operation is enabled Supported by: FreeBSD Foundation --- sys/kern/subr_bus.c | 10 ---------- sys/net/netisr.c | 10 ++++++++++ sys/sys/mutex.h | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 10 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 347489fe379..092f410d4d0 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 347fd9a0c94..cb24e12fb73 100644 --- a/sys/net/netisr.c +++ b/sys/net/netisr.c @@ -53,6 +53,16 @@ #include #include +/* + * 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 9601fd7f755..05575b5e61b 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); \