diff options
author | attilio <attilio@FreeBSD.org> | 2009-08-02 14:28:40 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2009-08-02 14:28:40 +0000 |
commit | 7f42e47a67ad2835fbc404253f835223020256d4 (patch) | |
tree | c00d808d1df8000c2086c86613be9ec8536a5e28 /sys/dev/usb/controller/usb_controller.c | |
parent | ea03af42ccd07d2533707afe4d1ba08f34bdb2e9 (diff) | |
download | FreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.zip FreeBSD-src-7f42e47a67ad2835fbc404253f835223020256d4.tar.gz |
Make the newbus subsystem Giant free by adding the new newbus sxlock.
The newbus lock is responsible for protecting newbus internIal structures,
device states and devclass flags. It is necessary to hold it when all
such datas are accessed. For the other operations, softc locking should
ensure enough protection to avoid races.
Newbus lock is automatically held when virtual operations on the device
and bus are invoked when loading the driver or when the suspend/resume
take place. For other 'spourious' operations trying to access/modify
the newbus topology, newbus lock needs to be automatically acquired and
dropped.
For the moment Giant is also acquired in some key point (modules subsystem)
in order to avoid problems before the 8.0 release as module handlers could
make assumptions about it. This Giant locking should go just after
the release happens.
Please keep in mind that the public interface can be expanded in order
to provide more support, if there are really necessities at some point
and also some bugs could arise as long as the patch needs a bit of
further testing.
Bump __FreeBSD_version in order to reflect the newbus lock introduction.
Reviewed by: ed, hps, jhb, imp, mav, scottl
No answer by: ariff, thompsa, yongari
Tested by: pho,
G. Trematerra <giovanni dot trematerra at gmail dot com>,
Brandon Gooch <jamesbrandongooch at gmail dot com>
Sponsored by: Yahoo! Incorporated
Approved by: re (ksmith)
Diffstat (limited to 'sys/dev/usb/controller/usb_controller.c')
-rw-r--r-- | sys/dev/usb/controller/usb_controller.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/sys/dev/usb/controller/usb_controller.c b/sys/dev/usb/controller/usb_controller.c index 7a019dc..f6776f01 100644 --- a/sys/dev/usb/controller/usb_controller.c +++ b/sys/dev/usb/controller/usb_controller.c @@ -143,9 +143,7 @@ usb_attach(device_t dev) } if (usb_post_init_called) { - mtx_lock(&Giant); usb_attach_sub(dev, bus); - mtx_unlock(&Giant); usb_needs_explore(bus, 1); } return (0); /* return success */ @@ -228,20 +226,13 @@ usb_bus_explore(struct usb_proc_msg *pm) } USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); - /* * First update the USB power state! */ usb_bus_powerd(bus); - /* - * Explore the Root USB HUB. This call can sleep, - * exiting Giant, which is actually Giant. - */ - (udev->hub->explore) (udev); - - mtx_unlock(&Giant); + /* Explore the Root USB HUB. */ + (udev->hub->explore) (udev); USB_BUS_LOCK(bus); } if (bus->bus_roothold != NULL) { @@ -269,7 +260,7 @@ usb_bus_detach(struct usb_proc_msg *pm) device_set_softc(dev, NULL); USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); + newbus_xlock(); /* detach children first */ bus_generic_detach(dev); @@ -281,7 +272,7 @@ usb_bus_detach(struct usb_proc_msg *pm) usb_free_device(udev, USB_UNCFG_FLAG_FREE_EP0); - mtx_unlock(&Giant); + newbus_xunlock(); USB_BUS_LOCK(bus); /* clear bdev variable last */ bus->bdev = NULL; @@ -350,7 +341,7 @@ usb_bus_attach(struct usb_proc_msg *pm) } USB_BUS_UNLOCK(bus); - mtx_lock(&Giant); /* XXX not required by USB */ + newbus_xlock(); /* default power_mask value */ bus->hw_power_state = @@ -383,7 +374,7 @@ usb_bus_attach(struct usb_proc_msg *pm) err = USB_ERR_NOMEM; } - mtx_unlock(&Giant); + newbus_xunlock(); USB_BUS_LOCK(bus); if (err) { @@ -472,7 +463,7 @@ usb_post_init(void *arg) int max; int n; - mtx_lock(&Giant); + newbus_xlock(); usb_devclass_ptr = devclass_find("usbus"); @@ -483,11 +474,8 @@ usb_post_init(void *arg) dev = devclass_get_device(dc, n); if (dev && device_is_attached(dev)) { bus = device_get_ivars(dev); - if (bus) { - mtx_lock(&Giant); + if (bus) usb_attach_sub(dev, bus); - mtx_unlock(&Giant); - } } } } else { @@ -499,7 +487,7 @@ usb_post_init(void *arg) usb_needs_explore_all(); - mtx_unlock(&Giant); + newbus_xunlock(); } SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL); |