diff options
author | jhb <jhb@FreeBSD.org> | 2009-08-20 19:17:53 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2009-08-20 19:17:53 +0000 |
commit | 9b0755de9f1e9517732f96a37f0ef30b8db23811 (patch) | |
tree | ee9b2a74c07c732ee357d4810494c3b6aecd6e71 /sys/kern | |
parent | ab0b6203abac22f7fa981c24cf452d3dab032727 (diff) | |
download | FreeBSD-src-9b0755de9f1e9517732f96a37f0ef30b8db23811.zip FreeBSD-src-9b0755de9f1e9517732f96a37f0ef30b8db23811.tar.gz |
Temporarily revert the new-bus locking for 8.0 release. It will be
reintroduced after HEAD is reopened for commits by re@.
Approved by: re (kib), attilio
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_bus.c | 87 |
1 files changed, 6 insertions, 81 deletions
diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 52cd766..2964b8c 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); #include <sys/rman.h> #include <sys/selinfo.h> #include <sys/signalvar.h> -#include <sys/sx.h> #include <sys/sysctl.h> #include <sys/systm.h> #include <sys/uio.h> @@ -193,54 +192,6 @@ void print_devclass_list(void); #endif /* - * Newbus locking facilities. - */ -static struct sx newbus_lock; - -#define NBL_LOCK_INIT() sx_init(&newbus_lock, "newbus") -#define NBL_LOCK_DESTROY() sx_destroy(&newbus_lock) -#define NBL_XLOCK() sx_xlock(&newbus_lock) -#define NBL_SLOCK() sx_slock(&newbus_lock) -#define NBL_XUNLOCK() sx_xunlock(&newbus_lock) -#define NBL_SUNLOCK() sx_sunlock(&newbus_lock) -#ifdef INVARIANTS -#define NBL_ASSERT(what) do { \ - if (cold == 0) \ - sx_assert(&newbus_lock, (what)); \ -} while (0) -#else -#define NBL_ASSERT(what) -#endif - -void -newbus_xlock() -{ - - NBL_XLOCK(); -} - -void -newbus_slock() -{ - - NBL_SLOCK(); -} - -void -newbus_xunlock() -{ - - NBL_XUNLOCK(); -} - -void -newbus_sunlock() -{ - - NBL_SUNLOCK(); -} - -/* * dev sysctl tree */ @@ -413,6 +364,7 @@ static d_poll_t devpoll; static struct cdevsw dev_cdevsw = { .d_version = D_VERSION, + .d_flags = D_NEEDGIANT, .d_open = devopen, .d_close = devclose, .d_read = devread, @@ -1109,7 +1061,6 @@ devclass_delete_driver(devclass_t busclass, driver_t *driver) int i; int error; - NBL_ASSERT(SA_XLOCKED); PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass))); if (!dc) @@ -1808,7 +1759,6 @@ device_delete_child(device_t dev, device_t child) int error; device_t grandchild; - NBL_ASSERT(SA_XLOCKED); PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev))); /* remove children first */ @@ -1907,7 +1857,7 @@ device_probe_child(device_t dev, device_t child) int result, pri = 0; int hasclass = (child->devclass != NULL); - NBL_ASSERT(SA_XLOCKED); + GIANT_REQUIRED; dc = dev->devclass; if (!dc) @@ -2558,7 +2508,7 @@ device_probe(device_t dev) { int error; - NBL_ASSERT(SA_XLOCKED); + GIANT_REQUIRED; if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0) return (-1); @@ -2592,7 +2542,7 @@ device_probe_and_attach(device_t dev) { int error; - NBL_ASSERT(SA_XLOCKED); + GIANT_REQUIRED; error = device_probe(dev); if (error == -1) @@ -2626,8 +2576,6 @@ device_attach(device_t dev) { int error; - NBL_ASSERT(SA_XLOCKED); - device_sysctl_init(dev); if (!device_is_quiet(dev)) device_print_child(dev->parent, dev); @@ -2669,7 +2617,7 @@ device_detach(device_t dev) { int error; - NBL_ASSERT(SA_XLOCKED); + GIANT_REQUIRED; PDEBUG(("%s", DEVICENAME(dev))); if (dev->state == DS_BUSY) @@ -2713,8 +2661,6 @@ int device_quiesce(device_t dev) { - NBL_ASSERT(SA_XLOCKED); - PDEBUG(("%s", DEVICENAME(dev))); if (dev->state == DS_BUSY) return (EBUSY); @@ -2735,7 +2681,6 @@ device_quiesce(device_t dev) int device_shutdown(device_t dev) { - if (dev->state < DS_ATTACHED) return (0); return (DEVICE_SHUTDOWN(dev)); @@ -3151,8 +3096,6 @@ bus_generic_attach(device_t dev) { device_t child; - NBL_ASSERT(SA_XLOCKED); - TAILQ_FOREACH(child, &dev->children, link) { device_probe_and_attach(child); } @@ -3173,8 +3116,6 @@ bus_generic_detach(device_t dev) device_t child; int error; - NBL_ASSERT(SA_XLOCKED); - if (dev->state != DS_ATTACHED) return (EBUSY); @@ -4055,7 +3996,6 @@ root_bus_module_handler(module_t mod, int what, void* arg) switch (what) { case MOD_LOAD: TAILQ_INIT(&bus_data_devices); - NBL_LOCK_INIT(); kobj_class_compile((kobj_class_t) &root_driver); root_bus = make_device(NULL, "root", 0); root_bus->desc = "System root bus"; @@ -4115,28 +4055,14 @@ driver_module_handler(module_t mod, int what, void *arg) kobj_class_t driver; int error, pass; - error = 0; dmd = (struct driver_module_data *)arg; - - /* - * If MOD_SHUTDOWN is passed, return immediately in order to - * avoid unnecessary locking and a LOR with the modules sx lock. - */ - if (what == MOD_SHUTDOWN) - return (EOPNOTSUPP); - NBL_XLOCK(); bus_devclass = devclass_find_internal(dmd->dmd_busname, NULL, TRUE); - if (bus_devclass == NULL) { - NBL_XUNLOCK(); - return (ENOMEM); - } + error = 0; switch (what) { case MOD_LOAD: if (dmd->dmd_chainevh) error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg); - if (error != 0) - break; pass = dmd->dmd_pass; driver = dmd->dmd_driver; @@ -4189,7 +4115,6 @@ driver_module_handler(module_t mod, int what, void *arg) error = EOPNOTSUPP; break; } - NBL_XUNLOCK(); return (error); } |