summaryrefslogtreecommitdiffstats
path: root/sys/dev/mfi
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-08-02 14:28:40 +0000
committerattilio <attilio@FreeBSD.org>2009-08-02 14:28:40 +0000
commit7f42e47a67ad2835fbc404253f835223020256d4 (patch)
treec00d808d1df8000c2086c86613be9ec8536a5e28 /sys/dev/mfi
parentea03af42ccd07d2533707afe4d1ba08f34bdb2e9 (diff)
downloadFreeBSD-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/mfi')
-rw-r--r--sys/dev/mfi/mfi.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/dev/mfi/mfi.c b/sys/dev/mfi/mfi.c
index eb18ffe..0ae585e 100644
--- a/sys/dev/mfi/mfi.c
+++ b/sys/dev/mfi/mfi.c
@@ -1327,11 +1327,11 @@ mfi_add_ld_complete(struct mfi_command *cm)
mfi_release_command(cm);
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ newbus_xlock();
if ((child = device_add_child(sc->mfi_dev, "mfid", -1)) == NULL) {
device_printf(sc->mfi_dev, "Failed to add logical disk\n");
free(ld_info, M_MFIBUF);
- mtx_unlock(&Giant);
+ newbus_xunlock();
mtx_lock(&sc->mfi_io_lock);
return;
}
@@ -1339,7 +1339,7 @@ mfi_add_ld_complete(struct mfi_command *cm)
device_set_ivars(child, ld_info);
device_set_desc(child, "MFI Logical Disk");
bus_generic_attach(sc->mfi_dev);
- mtx_unlock(&Giant);
+ newbus_xunlock();
mtx_lock(&sc->mfi_io_lock);
}
@@ -1805,9 +1805,9 @@ mfi_check_command_post(struct mfi_softc *sc, struct mfi_command *cm)
KASSERT(ld != NULL, ("volume dissappeared"));
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ newbus_xlock();
device_delete_child(sc->mfi_dev, ld->ld_dev);
- mtx_unlock(&Giant);
+ newbus_xunlock();
mtx_lock(&sc->mfi_io_lock);
} else
mfi_disk_enable(ld);
@@ -1815,11 +1815,11 @@ mfi_check_command_post(struct mfi_softc *sc, struct mfi_command *cm)
case MFI_DCMD_CFG_CLEAR:
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ newbus_xlock();
TAILQ_FOREACH_SAFE(ld, &sc->mfi_ld_tqh, ld_link, ldn) {
device_delete_child(sc->mfi_dev, ld->ld_dev);
}
- mtx_unlock(&Giant);
+ newbus_xunlock();
mtx_lock(&sc->mfi_io_lock);
} else {
TAILQ_FOREACH(ld, &sc->mfi_ld_tqh, ld_link)
@@ -1985,7 +1985,9 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td
adapter = ioc->mfi_adapter_no;
if (device_get_unit(sc->mfi_dev) == 0 && adapter != 0) {
+ newbus_slock();
devclass = devclass_find("mfi");
+ newbus_sunlock();
sc = devclass_get_softc(devclass, adapter);
}
mtx_lock(&sc->mfi_io_lock);
@@ -2173,7 +2175,9 @@ out:
struct mfi_linux_ioc_packet l_ioc;
int adapter;
+ newbus_slock();
devclass = devclass_find("mfi");
+ newbus_sunlock();
if (devclass == NULL)
return (ENOENT);
@@ -2194,7 +2198,9 @@ out:
struct mfi_linux_ioc_aen l_aen;
int adapter;
+ newbus_slock();
devclass = devclass_find("mfi");
+ newbus_sunlock();
if (devclass == NULL)
return (ENOENT);
OpenPOWER on IntegriCloud