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
This commit is contained in:
parent
497e910cd3
commit
a56fe095f0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196403
@ -3270,10 +3270,10 @@ aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib)
|
|||||||
while (co != NULL) {
|
while (co != NULL) {
|
||||||
if (co->co_found == 0) {
|
if (co->co_found == 0) {
|
||||||
mtx_unlock(&sc->aac_io_lock);
|
mtx_unlock(&sc->aac_io_lock);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
device_delete_child(sc->aac_dev,
|
device_delete_child(sc->aac_dev,
|
||||||
co->co_disk);
|
co->co_disk);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->aac_io_lock);
|
mtx_lock(&sc->aac_io_lock);
|
||||||
co_next = TAILQ_NEXT(co, co_link);
|
co_next = TAILQ_NEXT(co, co_link);
|
||||||
mtx_lock(&sc->aac_container_lock);
|
mtx_lock(&sc->aac_container_lock);
|
||||||
@ -3291,9 +3291,9 @@ aac_handle_aif(struct aac_softc *sc, struct aac_fib *fib)
|
|||||||
/* Attach the newly created containers */
|
/* Attach the newly created containers */
|
||||||
if (added) {
|
if (added) {
|
||||||
mtx_unlock(&sc->aac_io_lock);
|
mtx_unlock(&sc->aac_io_lock);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
bus_generic_attach(sc->aac_dev);
|
bus_generic_attach(sc->aac_dev);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->aac_io_lock);
|
mtx_lock(&sc->aac_io_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -675,6 +675,8 @@ acpi_suspend(device_t dev)
|
|||||||
device_t child, *devlist;
|
device_t child, *devlist;
|
||||||
int error, i, numdevs, pstate;
|
int error, i, numdevs, pstate;
|
||||||
|
|
||||||
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
/* First give child devices a chance to suspend. */
|
/* First give child devices a chance to suspend. */
|
||||||
error = bus_generic_suspend(dev);
|
error = bus_generic_suspend(dev);
|
||||||
if (error)
|
if (error)
|
||||||
@ -717,6 +719,8 @@ acpi_resume(device_t dev)
|
|||||||
int i, numdevs, error;
|
int i, numdevs, error;
|
||||||
device_t child, *devlist;
|
device_t child, *devlist;
|
||||||
|
|
||||||
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put all devices in D0 before resuming them. Call _S0D on each one
|
* Put all devices in D0 before resuming them. Call _S0D on each one
|
||||||
* since some systems expect this.
|
* since some systems expect this.
|
||||||
@ -741,6 +745,8 @@ static int
|
|||||||
acpi_shutdown(device_t dev)
|
acpi_shutdown(device_t dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
/* Allow children to shutdown first. */
|
/* Allow children to shutdown first. */
|
||||||
bus_generic_shutdown(dev);
|
bus_generic_shutdown(dev);
|
||||||
|
|
||||||
@ -2528,7 +2534,11 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
|||||||
thread_unlock(curthread);
|
thread_unlock(curthread);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
newbus_xlock();
|
/*
|
||||||
|
* Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE
|
||||||
|
* drivers need this.
|
||||||
|
*/
|
||||||
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
slp_state = ACPI_SS_NONE;
|
slp_state = ACPI_SS_NONE;
|
||||||
|
|
||||||
@ -2601,7 +2611,7 @@ acpi_EnterSleepState(struct acpi_softc *sc, int state)
|
|||||||
if (slp_state >= ACPI_SS_SLEPT)
|
if (slp_state >= ACPI_SS_SLEPT)
|
||||||
acpi_enable_fixed_events(sc);
|
acpi_enable_fixed_events(sc);
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
#ifdef SMP
|
#ifdef SMP
|
||||||
thread_lock(curthread);
|
thread_lock(curthread);
|
||||||
|
@ -329,7 +329,6 @@ acpi_battery_find_dev(u_int logical_unit)
|
|||||||
|
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
found_unit = 0;
|
found_unit = 0;
|
||||||
newbus_slock();
|
|
||||||
batt_dc = devclass_find("battery");
|
batt_dc = devclass_find("battery");
|
||||||
maxunit = devclass_get_maxunit(batt_dc);
|
maxunit = devclass_get_maxunit(batt_dc);
|
||||||
for (i = 0; i < maxunit; i++) {
|
for (i = 0; i < maxunit; i++) {
|
||||||
@ -341,7 +340,6 @@ acpi_battery_find_dev(u_int logical_unit)
|
|||||||
found_unit++;
|
found_unit++;
|
||||||
dev = NULL;
|
dev = NULL;
|
||||||
}
|
}
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
return (dev);
|
return (dev);
|
||||||
}
|
}
|
||||||
@ -371,17 +369,13 @@ acpi_battery_ioctl(u_long cmd, caddr_t addr, void *arg)
|
|||||||
*/
|
*/
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case ACPIIO_BATT_GET_UNITS:
|
case ACPIIO_BATT_GET_UNITS:
|
||||||
newbus_slock();
|
|
||||||
*(int *)addr = acpi_battery_get_units();
|
*(int *)addr = acpi_battery_get_units();
|
||||||
newbus_sunlock();
|
|
||||||
error = 0;
|
error = 0;
|
||||||
break;
|
break;
|
||||||
case ACPIIO_BATT_GET_BATTINFO:
|
case ACPIIO_BATT_GET_BATTINFO:
|
||||||
if (dev != NULL || unit == ACPI_BATTERY_ALL_UNITS) {
|
if (dev != NULL || unit == ACPI_BATTERY_ALL_UNITS) {
|
||||||
bzero(&ioctl_arg->battinfo, sizeof(ioctl_arg->battinfo));
|
bzero(&ioctl_arg->battinfo, sizeof(ioctl_arg->battinfo));
|
||||||
newbus_slock();
|
|
||||||
error = acpi_battery_get_battinfo(dev, &ioctl_arg->battinfo);
|
error = acpi_battery_get_battinfo(dev, &ioctl_arg->battinfo);
|
||||||
newbus_sunlock();
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ACPIIO_BATT_GET_BIF:
|
case ACPIIO_BATT_GET_BIF:
|
||||||
@ -422,11 +416,6 @@ acpi_battery_sysctl(SYSCTL_HANDLER_ARGS)
|
|||||||
{
|
{
|
||||||
int val, error;
|
int val, error;
|
||||||
|
|
||||||
/*
|
|
||||||
* Tolerate a race here because newbus lock can't be acquired before
|
|
||||||
* acpi_battery_get_battinfo() as it can create a LOR with the sysctl
|
|
||||||
* lock.
|
|
||||||
*/
|
|
||||||
acpi_battery_get_battinfo(NULL, &acpi_battery_battinfo);
|
acpi_battery_get_battinfo(NULL, &acpi_battery_battinfo);
|
||||||
val = *(u_int *)oidp->oid_arg1;
|
val = *(u_int *)oidp->oid_arg1;
|
||||||
error = sysctl_handle_int(oidp, &val, 0, req);
|
error = sysctl_handle_int(oidp, &val, 0, req);
|
||||||
@ -438,10 +427,6 @@ acpi_battery_units_sysctl(SYSCTL_HANDLER_ARGS)
|
|||||||
{
|
{
|
||||||
int count, error;
|
int count, error;
|
||||||
|
|
||||||
/*
|
|
||||||
* Tolerate a race here in order to avoid a LOR between sysctl lock
|
|
||||||
* and newbus lock.
|
|
||||||
*/
|
|
||||||
count = acpi_battery_get_units();
|
count = acpi_battery_get_units();
|
||||||
error = sysctl_handle_int(oidp, &count, 0, req);
|
error = sysctl_handle_int(oidp, &count, 0, req);
|
||||||
return (error);
|
return (error);
|
||||||
|
@ -732,9 +732,7 @@ acpi_cpu_startup(void *arg)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Get set of CPU devices */
|
/* Get set of CPU devices */
|
||||||
newbus_slock();
|
|
||||||
devclass_get_devices(acpi_cpu_devclass, &cpu_devices, &cpu_ndevices);
|
devclass_get_devices(acpi_cpu_devclass, &cpu_devices, &cpu_ndevices);
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup any quirks that might necessary now that we have probed
|
* Setup any quirks that might necessary now that we have probed
|
||||||
|
@ -188,12 +188,12 @@ acpi_dock_attach_later(void *context)
|
|||||||
|
|
||||||
dev = (device_t)context;
|
dev = (device_t)context;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
if (!device_is_enabled(dev))
|
if (!device_is_enabled(dev))
|
||||||
device_enable(dev);
|
device_enable(dev);
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
device_probe_and_attach(dev);
|
device_probe_and_attach(dev);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ACPI_STATUS
|
static ACPI_STATUS
|
||||||
@ -299,11 +299,11 @@ acpi_dock_eject_child(ACPI_HANDLE handle, UINT32 level, void *context,
|
|||||||
"ejecting device for %s\n", acpi_name(handle));
|
"ejecting device for %s\n", acpi_name(handle));
|
||||||
|
|
||||||
dev = acpi_get_device(handle);
|
dev = acpi_get_device(handle);
|
||||||
newbus_xlock();
|
|
||||||
if (dev != NULL && device_is_attached(dev)) {
|
if (dev != NULL && device_is_attached(dev)) {
|
||||||
|
mtx_lock(&Giant);
|
||||||
device_detach(dev);
|
device_detach(dev);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
acpi_SetInteger(handle, "_EJ0", 0);
|
acpi_SetInteger(handle, "_EJ0", 0);
|
||||||
out:
|
out:
|
||||||
|
@ -936,8 +936,6 @@ acpi_tz_thread(void *arg)
|
|||||||
sc = NULL;
|
sc = NULL;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
newbus_slock();
|
|
||||||
|
|
||||||
/* If the number of devices has changed, re-evaluate. */
|
/* If the number of devices has changed, re-evaluate. */
|
||||||
if (devclass_get_count(acpi_tz_devclass) != devcount) {
|
if (devclass_get_count(acpi_tz_devclass) != devcount) {
|
||||||
if (devs != NULL) {
|
if (devs != NULL) {
|
||||||
@ -950,7 +948,6 @@ acpi_tz_thread(void *arg)
|
|||||||
for (i = 0; i < devcount; i++)
|
for (i = 0; i < devcount; i++)
|
||||||
sc[i] = device_get_softc(devs[i]);
|
sc[i] = device_get_softc(devs[i]);
|
||||||
}
|
}
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
/* Check for temperature events and act on them. */
|
/* Check for temperature events and act on them. */
|
||||||
for (i = 0; i < devcount; i++) {
|
for (i = 0; i < devcount; i++) {
|
||||||
|
@ -113,7 +113,6 @@ adb_bus_enumerate(void *xdev)
|
|||||||
uint8_t i, next_free;
|
uint8_t i, next_free;
|
||||||
uint16_t r3;
|
uint16_t r3;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
sc->sc_dev = dev;
|
sc->sc_dev = dev;
|
||||||
sc->parent = device_get_parent(dev);
|
sc->parent = device_get_parent(dev);
|
||||||
|
|
||||||
@ -188,7 +187,6 @@ adb_bus_enumerate(void *xdev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bus_generic_attach(dev);
|
bus_generic_attach(dev);
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
config_intrhook_disestablish(&sc->enum_hook);
|
config_intrhook_disestablish(&sc->enum_hook);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +269,6 @@ amdtemp_intrhook(void *arg)
|
|||||||
/*
|
/*
|
||||||
* dev.cpu.N.temperature.
|
* dev.cpu.N.temperature.
|
||||||
*/
|
*/
|
||||||
newbus_xlock();
|
|
||||||
nexus = device_find_child(root_bus, "nexus", 0);
|
nexus = device_find_child(root_bus, "nexus", 0);
|
||||||
acpi = device_find_child(nexus, "acpi", 0);
|
acpi = device_find_child(nexus, "acpi", 0);
|
||||||
|
|
||||||
@ -286,7 +285,6 @@ amdtemp_intrhook(void *arg)
|
|||||||
"Max of sensor 0 / 1");
|
"Max of sensor 0 / 1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
config_intrhook_disestablish(&sc->sc_ich);
|
config_intrhook_disestablish(&sc->sc_ich);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,10 +90,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
SYSCTL_NODE(_hw, OID_AUTO, amr, CTLFLAG_RD, 0, "AMR driver parameters");
|
SYSCTL_NODE(_hw, OID_AUTO, amr, CTLFLAG_RD, 0, "AMR driver parameters");
|
||||||
|
|
||||||
/*
|
|
||||||
* In order to get rid of Giant, amr_state should be protected by
|
|
||||||
* a proper softc lock for the cdev operations.
|
|
||||||
*/
|
|
||||||
static d_open_t amr_open;
|
static d_open_t amr_open;
|
||||||
static d_close_t amr_close;
|
static d_close_t amr_close;
|
||||||
static d_ioctl_t amr_ioctl;
|
static d_ioctl_t amr_ioctl;
|
||||||
@ -316,11 +312,9 @@ amr_startup(void *arg)
|
|||||||
config_intrhook_disestablish(&sc->amr_ich);
|
config_intrhook_disestablish(&sc->amr_ich);
|
||||||
sc->amr_ich.ich_func = NULL;
|
sc->amr_ich.ich_func = NULL;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
/* get up-to-date drive information */
|
/* get up-to-date drive information */
|
||||||
if (amr_query_controller(sc)) {
|
if (amr_query_controller(sc)) {
|
||||||
device_printf(sc->amr_dev, "can't scan controller for drives\n");
|
device_printf(sc->amr_dev, "can't scan controller for drives\n");
|
||||||
newbus_xunlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -353,7 +347,6 @@ amr_startup(void *arg)
|
|||||||
|
|
||||||
/* interrupts will be enabled before we do anything more */
|
/* interrupts will be enabled before we do anything more */
|
||||||
sc->amr_state |= AMR_STATE_INTEN;
|
sc->amr_state |= AMR_STATE_INTEN;
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the timeout routine.
|
* Start the timeout routine.
|
||||||
@ -441,11 +434,7 @@ static int
|
|||||||
amr_open(struct cdev *dev, int flags, int fmt, struct thread *td)
|
amr_open(struct cdev *dev, int flags, int fmt, struct thread *td)
|
||||||
{
|
{
|
||||||
int unit = dev2unit(dev);
|
int unit = dev2unit(dev);
|
||||||
struct amr_softc *sc;
|
struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit);
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
sc = devclass_get_softc(devclass_find("amr"), unit);
|
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
debug_called(1);
|
debug_called(1);
|
||||||
|
|
||||||
@ -501,11 +490,7 @@ static int
|
|||||||
amr_close(struct cdev *dev, int flags, int fmt, struct thread *td)
|
amr_close(struct cdev *dev, int flags, int fmt, struct thread *td)
|
||||||
{
|
{
|
||||||
int unit = dev2unit(dev);
|
int unit = dev2unit(dev);
|
||||||
struct amr_softc *sc;
|
struct amr_softc *sc = devclass_get_softc(devclass_find("amr"), unit);
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
sc = devclass_get_softc(devclass_find("amr"), unit);
|
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
debug_called(1);
|
debug_called(1);
|
||||||
|
|
||||||
@ -522,7 +507,6 @@ amr_rescan_drives(struct cdev *dev)
|
|||||||
struct amr_softc *sc = (struct amr_softc *)dev->si_drv1;
|
struct amr_softc *sc = (struct amr_softc *)dev->si_drv1;
|
||||||
int i, error = 0;
|
int i, error = 0;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
sc->amr_state |= AMR_STATE_REMAP_LD;
|
sc->amr_state |= AMR_STATE_REMAP_LD;
|
||||||
while (sc->amr_busyslots) {
|
while (sc->amr_busyslots) {
|
||||||
device_printf(sc->amr_dev, "idle controller\n");
|
device_printf(sc->amr_dev, "idle controller\n");
|
||||||
@ -546,7 +530,6 @@ amr_rescan_drives(struct cdev *dev)
|
|||||||
sc->amr_drive[i].al_disk = 0;
|
sc->amr_drive[i].al_disk = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
shutdown_out:
|
shutdown_out:
|
||||||
amr_startup(sc);
|
amr_startup(sc);
|
||||||
@ -822,9 +805,7 @@ amr_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, struct threa
|
|||||||
struct amr_linux_ioctl ali;
|
struct amr_linux_ioctl ali;
|
||||||
int adapter, error;
|
int adapter, error;
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
devclass = devclass_find("amr");
|
devclass = devclass_find("amr");
|
||||||
newbus_sunlock();
|
|
||||||
if (devclass == NULL)
|
if (devclass == NULL)
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
|
|
||||||
|
@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
static d_ioctl_t ata_ioctl;
|
static d_ioctl_t ata_ioctl;
|
||||||
static struct cdevsw ata_cdevsw = {
|
static struct cdevsw ata_cdevsw = {
|
||||||
.d_version = D_VERSION,
|
.d_version = D_VERSION,
|
||||||
|
.d_flags = D_NEEDGIANT, /* we need this as newbus isn't mpsafe */
|
||||||
.d_ioctl = ata_ioctl,
|
.d_ioctl = ata_ioctl,
|
||||||
.d_name = "ata",
|
.d_name = "ata",
|
||||||
};
|
};
|
||||||
@ -203,9 +204,7 @@ ata_conn_event(void *context, int dummy)
|
|||||||
{
|
{
|
||||||
device_t dev = (device_t)context;
|
device_t dev = (device_t)context;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
ata_reinit(dev);
|
ata_reinit(dev);
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@ -247,6 +246,7 @@ ata_reinit(device_t dev)
|
|||||||
|
|
||||||
/* reinit the children and delete any that fails */
|
/* reinit the children and delete any that fails */
|
||||||
if (!device_get_children(dev, &children, &nchildren)) {
|
if (!device_get_children(dev, &children, &nchildren)) {
|
||||||
|
mtx_lock(&Giant); /* newbus suckage it needs Giant */
|
||||||
for (i = 0; i < nchildren; i++) {
|
for (i = 0; i < nchildren; i++) {
|
||||||
/* did any children go missing ? */
|
/* did any children go missing ? */
|
||||||
if (children[i] && device_is_attached(children[i]) &&
|
if (children[i] && device_is_attached(children[i]) &&
|
||||||
@ -269,6 +269,7 @@ ata_reinit(device_t dev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(children, M_TEMP);
|
free(children, M_TEMP);
|
||||||
|
mtx_unlock(&Giant); /* newbus suckage dealt with, release Giant */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we still have a good request put it on the queue again */
|
/* if we still have a good request put it on the queue again */
|
||||||
@ -394,7 +395,6 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
int *value = (int *)data;
|
int *value = (int *)data;
|
||||||
int i, nchildren, error = ENOTTY;
|
int i, nchildren, error = ENOTTY;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case IOCATAGMAXCHANNEL:
|
case IOCATAGMAXCHANNEL:
|
||||||
/* In case we have channel 0..n this will return n+1. */
|
/* In case we have channel 0..n this will return n+1. */
|
||||||
@ -405,40 +405,32 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
case IOCATAREINIT:
|
case IOCATAREINIT:
|
||||||
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
||||||
!(device = devclass_get_device(ata_devclass, *value)) ||
|
!(device = devclass_get_device(ata_devclass, *value)) ||
|
||||||
!device_is_attached(device)) {
|
!device_is_attached(device))
|
||||||
newbus_xunlock();
|
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
|
||||||
error = ata_reinit(device);
|
error = ata_reinit(device);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCATAATTACH:
|
case IOCATAATTACH:
|
||||||
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
||||||
!(device = devclass_get_device(ata_devclass, *value)) ||
|
!(device = devclass_get_device(ata_devclass, *value)) ||
|
||||||
!device_is_attached(device)) {
|
!device_is_attached(device))
|
||||||
newbus_xunlock();
|
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
|
||||||
error = DEVICE_ATTACH(device);
|
error = DEVICE_ATTACH(device);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCATADETACH:
|
case IOCATADETACH:
|
||||||
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
if (*value >= devclass_get_maxunit(ata_devclass) ||
|
||||||
!(device = devclass_get_device(ata_devclass, *value)) ||
|
!(device = devclass_get_device(ata_devclass, *value)) ||
|
||||||
!device_is_attached(device)) {
|
!device_is_attached(device))
|
||||||
newbus_xunlock();
|
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
|
||||||
error = DEVICE_DETACH(device);
|
error = DEVICE_DETACH(device);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IOCATADEVICES:
|
case IOCATADEVICES:
|
||||||
if (devices->channel >= devclass_get_maxunit(ata_devclass) ||
|
if (devices->channel >= devclass_get_maxunit(ata_devclass) ||
|
||||||
!(device = devclass_get_device(ata_devclass, devices->channel)) ||
|
!(device = devclass_get_device(ata_devclass, devices->channel)) ||
|
||||||
!device_is_attached(device)) {
|
!device_is_attached(device))
|
||||||
newbus_xunlock();
|
|
||||||
return ENXIO;
|
return ENXIO;
|
||||||
}
|
|
||||||
bzero(devices->name[0], 32);
|
bzero(devices->name[0], 32);
|
||||||
bzero(&devices->params[0], sizeof(struct ata_params));
|
bzero(&devices->params[0], sizeof(struct ata_params));
|
||||||
bzero(devices->name[1], 32);
|
bzero(devices->name[1], 32);
|
||||||
@ -473,7 +465,6 @@ ata_ioctl(struct cdev *dev, u_long cmd, caddr_t data,
|
|||||||
if (ata_raid_ioctl_func)
|
if (ata_raid_ioctl_func)
|
||||||
error = ata_raid_ioctl_func(cmd, data);
|
error = ata_raid_ioctl_func(cmd, data);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -581,7 +572,7 @@ ata_boot_attach(void)
|
|||||||
struct ata_channel *ch;
|
struct ata_channel *ch;
|
||||||
int ctlr;
|
int ctlr;
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant); /* newbus suckage it needs Giant */
|
||||||
|
|
||||||
/* kick of probe and attach on all channels */
|
/* kick of probe and attach on all channels */
|
||||||
for (ctlr = 0; ctlr < devclass_get_maxunit(ata_devclass); ctlr++) {
|
for (ctlr = 0; ctlr < devclass_get_maxunit(ata_devclass); ctlr++) {
|
||||||
@ -596,7 +587,8 @@ ata_boot_attach(void)
|
|||||||
free(ata_delayed_attach, M_TEMP);
|
free(ata_delayed_attach, M_TEMP);
|
||||||
ata_delayed_attach = NULL;
|
ata_delayed_attach = NULL;
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
|
mtx_unlock(&Giant); /* newbus suckage dealt with, release Giant */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -725,6 +717,7 @@ ata_identify(device_t dev)
|
|||||||
if (bootverbose)
|
if (bootverbose)
|
||||||
device_printf(dev, "Identifying devices: %08x\n", ch->devices);
|
device_printf(dev, "Identifying devices: %08x\n", ch->devices);
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
/* Skip existing devices. */
|
/* Skip existing devices. */
|
||||||
if (!device_get_children(dev, &children, &nchildren)) {
|
if (!device_get_children(dev, &children, &nchildren)) {
|
||||||
for (i = 0; i < nchildren; i++) {
|
for (i = 0; i < nchildren; i++) {
|
||||||
@ -736,8 +729,10 @@ ata_identify(device_t dev)
|
|||||||
/* Create new devices. */
|
/* Create new devices. */
|
||||||
if (bootverbose)
|
if (bootverbose)
|
||||||
device_printf(dev, "New devices: %08x\n", n);
|
device_printf(dev, "New devices: %08x\n", n);
|
||||||
if (n == 0)
|
if (n == 0) {
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return (0);
|
return (0);
|
||||||
|
}
|
||||||
for (i = 0; i < ATA_PM; ++i) {
|
for (i = 0; i < ATA_PM; ++i) {
|
||||||
if (n & (((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << i))) {
|
if (n & (((ATA_ATA_MASTER | ATA_ATAPI_MASTER) << i))) {
|
||||||
int unit = -1;
|
int unit = -1;
|
||||||
@ -780,6 +775,7 @@ ata_identify(device_t dev)
|
|||||||
}
|
}
|
||||||
bus_generic_probe(dev);
|
bus_generic_probe(dev);
|
||||||
bus_generic_attach(dev);
|
bus_generic_attach(dev);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1488,9 +1488,7 @@ psmopen(struct cdev *dev, int flag, int fmt, struct thread *td)
|
|||||||
if (sc->state & PSM_OPEN)
|
if (sc->state & PSM_OPEN)
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
device_busy(devclass_get_device(psm_devclass, unit));
|
device_busy(devclass_get_device(psm_devclass, unit));
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
/* Initialize state */
|
/* Initialize state */
|
||||||
sc->mode.level = sc->dflt_mode.level;
|
sc->mode.level = sc->dflt_mode.level;
|
||||||
@ -1645,9 +1643,7 @@ psmclose(struct cdev *dev, int flag, int fmt, struct thread *td)
|
|||||||
/* close is almost always successful */
|
/* close is almost always successful */
|
||||||
sc->state &= ~PSM_OPEN;
|
sc->state &= ~PSM_OPEN;
|
||||||
kbdc_lock(sc->kbdc, FALSE);
|
kbdc_lock(sc->kbdc, FALSE);
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(devclass_get_device(psm_devclass, unit));
|
device_unbusy(devclass_get_device(psm_devclass, unit));
|
||||||
newbus_xunlock();
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,9 +597,7 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td )
|
|||||||
return( ENXIO );
|
return( ENXIO );
|
||||||
|
|
||||||
/* Record that the device is now busy */
|
/* Record that the device is now busy */
|
||||||
newbus_xlock();
|
|
||||||
device_busy(devclass_get_device(bktr_devclass, unit));
|
device_busy(devclass_get_device(bktr_devclass, unit));
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
|
|
||||||
if (bt848_card != -1) {
|
if (bt848_card != -1) {
|
||||||
@ -670,11 +668,8 @@ bktr_open( struct cdev *dev, int flags, int fmt, struct thread *td )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* If there was an error opening the device, undo the busy status */
|
/* If there was an error opening the device, undo the busy status */
|
||||||
if (result != 0) {
|
if (result != 0)
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(devclass_get_device(bktr_devclass, unit));
|
device_unbusy(devclass_get_device(bktr_devclass, unit));
|
||||||
newbus_xunlock();
|
|
||||||
}
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,7 +689,6 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td )
|
|||||||
/* Get the device data */
|
/* Get the device data */
|
||||||
bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit);
|
bktr = (struct bktr_softc*)devclass_get_softc(bktr_devclass, unit);
|
||||||
if (bktr == NULL) {
|
if (bktr == NULL) {
|
||||||
|
|
||||||
/* the device is no longer valid/functioning */
|
/* the device is no longer valid/functioning */
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
@ -711,11 +705,10 @@ bktr_close( struct cdev *dev, int flags, int fmt, struct thread *td )
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(devclass_get_device(bktr_devclass, unit));
|
device_unbusy(devclass_get_device(bktr_devclass, unit));
|
||||||
newbus_xunlock();
|
|
||||||
return( result );
|
return( result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,13 +614,11 @@ int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
|
|||||||
|
|
||||||
if (!retcode) {
|
if (!retcode) {
|
||||||
atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
|
atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
|
||||||
newbus_xlock();
|
|
||||||
DRM_LOCK();
|
DRM_LOCK();
|
||||||
device_busy(dev->device);
|
device_busy(dev->device);
|
||||||
if (!dev->open_count++)
|
if (!dev->open_count++)
|
||||||
retcode = drm_firstopen(dev);
|
retcode = drm_firstopen(dev);
|
||||||
DRM_UNLOCK();
|
DRM_UNLOCK();
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return retcode;
|
return retcode;
|
||||||
@ -634,11 +632,6 @@ void drm_close(void *data)
|
|||||||
|
|
||||||
DRM_DEBUG("open_count = %d\n", dev->open_count);
|
DRM_DEBUG("open_count = %d\n", dev->open_count);
|
||||||
|
|
||||||
/*
|
|
||||||
* We require to lock newbus here for handling device_unbusy() and
|
|
||||||
* avoid a LOR with DRM_LOCK.
|
|
||||||
*/
|
|
||||||
newbus_xlock();
|
|
||||||
DRM_LOCK();
|
DRM_LOCK();
|
||||||
|
|
||||||
if (dev->driver->preclose != NULL)
|
if (dev->driver->preclose != NULL)
|
||||||
@ -715,7 +708,6 @@ void drm_close(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DRM_UNLOCK();
|
DRM_UNLOCK();
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm.
|
/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm.
|
||||||
|
@ -173,12 +173,10 @@ ips_intrhook(void *arg)
|
|||||||
struct ips_softc *sc = (struct ips_softc *)arg;
|
struct ips_softc *sc = (struct ips_softc *)arg;
|
||||||
|
|
||||||
config_intrhook_disestablish(&sc->ips_ich);
|
config_intrhook_disestablish(&sc->ips_ich);
|
||||||
newbus_xlock();
|
|
||||||
if (ips_adapter_init(sc))
|
if (ips_adapter_init(sc))
|
||||||
ips_pci_free(sc);
|
ips_pci_free(sc);
|
||||||
else
|
else
|
||||||
sc->configured = 1;
|
sc->configured = 1;
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ips_pci_free(ips_softc_t *sc)
|
static int ips_pci_free(ips_softc_t *sc)
|
||||||
|
@ -1327,11 +1327,11 @@ mfi_add_ld_complete(struct mfi_command *cm)
|
|||||||
mfi_release_command(cm);
|
mfi_release_command(cm);
|
||||||
|
|
||||||
mtx_unlock(&sc->mfi_io_lock);
|
mtx_unlock(&sc->mfi_io_lock);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
if ((child = device_add_child(sc->mfi_dev, "mfid", -1)) == NULL) {
|
if ((child = device_add_child(sc->mfi_dev, "mfid", -1)) == NULL) {
|
||||||
device_printf(sc->mfi_dev, "Failed to add logical disk\n");
|
device_printf(sc->mfi_dev, "Failed to add logical disk\n");
|
||||||
free(ld_info, M_MFIBUF);
|
free(ld_info, M_MFIBUF);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->mfi_io_lock);
|
mtx_lock(&sc->mfi_io_lock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1339,7 +1339,7 @@ mfi_add_ld_complete(struct mfi_command *cm)
|
|||||||
device_set_ivars(child, ld_info);
|
device_set_ivars(child, ld_info);
|
||||||
device_set_desc(child, "MFI Logical Disk");
|
device_set_desc(child, "MFI Logical Disk");
|
||||||
bus_generic_attach(sc->mfi_dev);
|
bus_generic_attach(sc->mfi_dev);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->mfi_io_lock);
|
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"));
|
KASSERT(ld != NULL, ("volume dissappeared"));
|
||||||
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
|
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
|
||||||
mtx_unlock(&sc->mfi_io_lock);
|
mtx_unlock(&sc->mfi_io_lock);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
device_delete_child(sc->mfi_dev, ld->ld_dev);
|
device_delete_child(sc->mfi_dev, ld->ld_dev);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->mfi_io_lock);
|
mtx_lock(&sc->mfi_io_lock);
|
||||||
} else
|
} else
|
||||||
mfi_disk_enable(ld);
|
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:
|
case MFI_DCMD_CFG_CLEAR:
|
||||||
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
|
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
|
||||||
mtx_unlock(&sc->mfi_io_lock);
|
mtx_unlock(&sc->mfi_io_lock);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
TAILQ_FOREACH_SAFE(ld, &sc->mfi_ld_tqh, ld_link, ldn) {
|
TAILQ_FOREACH_SAFE(ld, &sc->mfi_ld_tqh, ld_link, ldn) {
|
||||||
device_delete_child(sc->mfi_dev, ld->ld_dev);
|
device_delete_child(sc->mfi_dev, ld->ld_dev);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
mtx_lock(&sc->mfi_io_lock);
|
mtx_lock(&sc->mfi_io_lock);
|
||||||
} else {
|
} else {
|
||||||
TAILQ_FOREACH(ld, &sc->mfi_ld_tqh, ld_link)
|
TAILQ_FOREACH(ld, &sc->mfi_ld_tqh, ld_link)
|
||||||
@ -1985,9 +1985,7 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td
|
|||||||
|
|
||||||
adapter = ioc->mfi_adapter_no;
|
adapter = ioc->mfi_adapter_no;
|
||||||
if (device_get_unit(sc->mfi_dev) == 0 && adapter != 0) {
|
if (device_get_unit(sc->mfi_dev) == 0 && adapter != 0) {
|
||||||
newbus_slock();
|
|
||||||
devclass = devclass_find("mfi");
|
devclass = devclass_find("mfi");
|
||||||
newbus_sunlock();
|
|
||||||
sc = devclass_get_softc(devclass, adapter);
|
sc = devclass_get_softc(devclass, adapter);
|
||||||
}
|
}
|
||||||
mtx_lock(&sc->mfi_io_lock);
|
mtx_lock(&sc->mfi_io_lock);
|
||||||
@ -2175,9 +2173,7 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td
|
|||||||
struct mfi_linux_ioc_packet l_ioc;
|
struct mfi_linux_ioc_packet l_ioc;
|
||||||
int adapter;
|
int adapter;
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
devclass = devclass_find("mfi");
|
devclass = devclass_find("mfi");
|
||||||
newbus_sunlock();
|
|
||||||
if (devclass == NULL)
|
if (devclass == NULL)
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
|
|
||||||
@ -2198,9 +2194,7 @@ mfi_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td
|
|||||||
struct mfi_linux_ioc_aen l_aen;
|
struct mfi_linux_ioc_aen l_aen;
|
||||||
int adapter;
|
int adapter;
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
devclass = devclass_find("mfi");
|
devclass = devclass_find("mfi");
|
||||||
newbus_sunlock();
|
|
||||||
if (devclass == NULL)
|
if (devclass == NULL)
|
||||||
return (ENOENT);
|
return (ENOENT);
|
||||||
|
|
||||||
|
@ -772,9 +772,7 @@ mlx_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int32_t flag, struct threa
|
|||||||
* Scan the controller to see whether new drives have appeared.
|
* Scan the controller to see whether new drives have appeared.
|
||||||
*/
|
*/
|
||||||
case MLX_RESCAN_DRIVES:
|
case MLX_RESCAN_DRIVES:
|
||||||
newbus_xlock();
|
|
||||||
mlx_startup(sc);
|
mlx_startup(sc);
|
||||||
newbus_xunlock();
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1496,9 +1496,7 @@ mmc_delayed_attach(void *xsc)
|
|||||||
{
|
{
|
||||||
struct mmc_softc *sc = xsc;
|
struct mmc_softc *sc = xsc;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
mmc_scan(sc);
|
mmc_scan(sc);
|
||||||
newbus_xunlock();
|
|
||||||
config_intrhook_disestablish(&sc->config_intrhook);
|
config_intrhook_disestablish(&sc->config_intrhook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,14 @@ cbb_event_thread(void *arg)
|
|||||||
sc->flags |= CBB_KTHREAD_RUNNING;
|
sc->flags |= CBB_KTHREAD_RUNNING;
|
||||||
while ((sc->flags & CBB_KTHREAD_DONE) == 0) {
|
while ((sc->flags & CBB_KTHREAD_DONE) == 0) {
|
||||||
mtx_unlock(&sc->mtx);
|
mtx_unlock(&sc->mtx);
|
||||||
newbus_xlock();
|
/*
|
||||||
|
* We take out Giant here because we need it deep,
|
||||||
|
* down in the bowels of the vm system for mapping the
|
||||||
|
* memory we need to read the CIS. In addition, since
|
||||||
|
* we are adding/deleting devices from the dev tree,
|
||||||
|
* and that code isn't MP safe, we have to hold Giant.
|
||||||
|
*/
|
||||||
|
mtx_lock(&Giant);
|
||||||
status = cbb_get(sc, CBB_SOCKET_STATE);
|
status = cbb_get(sc, CBB_SOCKET_STATE);
|
||||||
DPRINTF(("Status is 0x%x\n", status));
|
DPRINTF(("Status is 0x%x\n", status));
|
||||||
if (!CBB_CARD_PRESENT(status)) {
|
if (!CBB_CARD_PRESENT(status)) {
|
||||||
@ -490,7 +497,7 @@ cbb_event_thread(void *arg)
|
|||||||
not_a_card = 0; /* We know card type */
|
not_a_card = 0; /* We know card type */
|
||||||
cbb_insert(sc);
|
cbb_insert(sc);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First time through we need to tell mountroot that we're
|
* First time through we need to tell mountroot that we're
|
||||||
|
@ -152,9 +152,7 @@ iop_attach(void *arg)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
case I2O_CLASS_RANDOM_BLOCK_STORAGE:
|
||||||
newbus_xlock();
|
|
||||||
pst_add_raid(sc, &sc->lct[i]);
|
pst_add_raid(sc, &sc->lct[i]);
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -903,9 +903,7 @@ rpopen(struct tty *tp)
|
|||||||
rp_callout_handle = timeout(rp_do_poll,
|
rp_callout_handle = timeout(rp_do_poll,
|
||||||
(void *)NULL, POLL_INTERVAL);
|
(void *)NULL, POLL_INTERVAL);
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
device_busy(rp->rp_ctlp->dev);
|
device_busy(rp->rp_ctlp->dev);
|
||||||
newbus_xunlock();
|
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,9 +914,7 @@ rpclose(struct tty *tp)
|
|||||||
|
|
||||||
rp = tty_softc(tp);
|
rp = tty_softc(tp);
|
||||||
rphardclose(tp);
|
rphardclose(tp);
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(rp->rp_ctlp->dev);
|
device_unbusy(rp->rp_ctlp->dev);
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -7435,7 +7435,6 @@ hdac_attach2(void *arg)
|
|||||||
quirks_on, quirks_off);
|
quirks_on, quirks_off);
|
||||||
);
|
);
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
hdac_lock(sc);
|
hdac_lock(sc);
|
||||||
|
|
||||||
/* Remove ourselves from the config hooks */
|
/* Remove ourselves from the config hooks */
|
||||||
@ -7675,7 +7674,6 @@ hdac_attach2(void *arg)
|
|||||||
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO,
|
SYSCTL_CHILDREN(device_get_sysctl_tree(sc->dev)), OID_AUTO,
|
||||||
"pindump", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev),
|
"pindump", CTLTYPE_INT | CTLFLAG_RW, sc->dev, sizeof(sc->dev),
|
||||||
sysctl_hdac_pindump, "I", "Dump pin states/data");
|
sysctl_hdac_pindump, "I", "Dump pin states/data");
|
||||||
newbus_xunlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -294,10 +294,8 @@ twe_init(struct twe_softc *sc)
|
|||||||
/*
|
/*
|
||||||
* Scan for drives
|
* Scan for drives
|
||||||
*/
|
*/
|
||||||
newbus_xlock();
|
|
||||||
for (i = 0; i < TWE_MAX_UNITS; i++)
|
for (i = 0; i < TWE_MAX_UNITS; i++)
|
||||||
twe_add_unit(sc, i);
|
twe_add_unit(sc, i);
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialise connection with controller.
|
* Initialise connection with controller.
|
||||||
@ -623,15 +621,11 @@ twe_ioctl(struct twe_softc *sc, int ioctlcmd, void *addr)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TWEIO_ADD_UNIT:
|
case TWEIO_ADD_UNIT:
|
||||||
newbus_xlock();
|
|
||||||
error = twe_add_unit(sc, td->td_unit);
|
error = twe_add_unit(sc, td->td_unit);
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TWEIO_DEL_UNIT:
|
case TWEIO_DEL_UNIT:
|
||||||
newbus_xlock();
|
|
||||||
error = twe_del_unit(sc, td->td_unit);
|
error = twe_del_unit(sc, td->td_unit);
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* XXX implement ATA PASSTHROUGH */
|
/* XXX implement ATA PASSTHROUGH */
|
||||||
|
@ -143,7 +143,9 @@ usb_attach(device_t dev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (usb_post_init_called) {
|
if (usb_post_init_called) {
|
||||||
|
mtx_lock(&Giant);
|
||||||
usb_attach_sub(dev, bus);
|
usb_attach_sub(dev, bus);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
usb_needs_explore(bus, 1);
|
usb_needs_explore(bus, 1);
|
||||||
}
|
}
|
||||||
return (0); /* return success */
|
return (0); /* return success */
|
||||||
@ -226,13 +228,20 @@ usb_bus_explore(struct usb_proc_msg *pm)
|
|||||||
}
|
}
|
||||||
USB_BUS_UNLOCK(bus);
|
USB_BUS_UNLOCK(bus);
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* First update the USB power state!
|
* First update the USB power state!
|
||||||
*/
|
*/
|
||||||
usb_bus_powerd(bus);
|
usb_bus_powerd(bus);
|
||||||
|
/*
|
||||||
/* Explore the Root USB HUB. */
|
* Explore the Root USB HUB. This call can sleep,
|
||||||
|
* exiting Giant, which is actually Giant.
|
||||||
|
*/
|
||||||
(udev->hub->explore) (udev);
|
(udev->hub->explore) (udev);
|
||||||
|
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
USB_BUS_LOCK(bus);
|
USB_BUS_LOCK(bus);
|
||||||
}
|
}
|
||||||
if (bus->bus_roothold != NULL) {
|
if (bus->bus_roothold != NULL) {
|
||||||
@ -260,7 +269,7 @@ usb_bus_detach(struct usb_proc_msg *pm)
|
|||||||
device_set_softc(dev, NULL);
|
device_set_softc(dev, NULL);
|
||||||
USB_BUS_UNLOCK(bus);
|
USB_BUS_UNLOCK(bus);
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
/* detach children first */
|
/* detach children first */
|
||||||
bus_generic_detach(dev);
|
bus_generic_detach(dev);
|
||||||
@ -272,7 +281,7 @@ usb_bus_detach(struct usb_proc_msg *pm)
|
|||||||
usb_free_device(udev,
|
usb_free_device(udev,
|
||||||
USB_UNCFG_FLAG_FREE_EP0);
|
USB_UNCFG_FLAG_FREE_EP0);
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
USB_BUS_LOCK(bus);
|
USB_BUS_LOCK(bus);
|
||||||
/* clear bdev variable last */
|
/* clear bdev variable last */
|
||||||
bus->bdev = NULL;
|
bus->bdev = NULL;
|
||||||
@ -341,7 +350,7 @@ usb_bus_attach(struct usb_proc_msg *pm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
USB_BUS_UNLOCK(bus);
|
USB_BUS_UNLOCK(bus);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant); /* XXX not required by USB */
|
||||||
|
|
||||||
/* default power_mask value */
|
/* default power_mask value */
|
||||||
bus->hw_power_state =
|
bus->hw_power_state =
|
||||||
@ -374,7 +383,7 @@ usb_bus_attach(struct usb_proc_msg *pm)
|
|||||||
err = USB_ERR_NOMEM;
|
err = USB_ERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
USB_BUS_LOCK(bus);
|
USB_BUS_LOCK(bus);
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -463,7 +472,7 @@ usb_post_init(void *arg)
|
|||||||
int max;
|
int max;
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
usb_devclass_ptr = devclass_find("usbus");
|
usb_devclass_ptr = devclass_find("usbus");
|
||||||
|
|
||||||
@ -474,8 +483,11 @@ usb_post_init(void *arg)
|
|||||||
dev = devclass_get_device(dc, n);
|
dev = devclass_get_device(dc, n);
|
||||||
if (dev && device_is_attached(dev)) {
|
if (dev && device_is_attached(dev)) {
|
||||||
bus = device_get_ivars(dev);
|
bus = device_get_ivars(dev);
|
||||||
if (bus)
|
if (bus) {
|
||||||
|
mtx_lock(&Giant);
|
||||||
usb_attach_sub(dev, bus);
|
usb_attach_sub(dev, bus);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -487,7 +499,7 @@ usb_post_init(void *arg)
|
|||||||
|
|
||||||
usb_needs_explore_all();
|
usb_needs_explore_all();
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
|
|
||||||
SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL);
|
SYSINIT(usb_post_init, SI_SUB_KICK_SCHEDULER, SI_ORDER_ANY, usb_post_init, NULL);
|
||||||
|
@ -745,7 +745,7 @@ ukbd_attach(device_t dev)
|
|||||||
uint16_t n;
|
uint16_t n;
|
||||||
uint16_t hid_len;
|
uint16_t hid_len;
|
||||||
|
|
||||||
mtx_lock(&Giant);
|
mtx_assert(&Giant, MA_OWNED);
|
||||||
|
|
||||||
kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0);
|
kbd_init_struct(kbd, UKBD_DRIVER_NAME, KB_OTHER, unit, 0, 0, 0);
|
||||||
|
|
||||||
@ -854,6 +854,9 @@ ukbd_attach(device_t dev)
|
|||||||
if (bootverbose) {
|
if (bootverbose) {
|
||||||
genkbd_diag(kbd, bootverbose);
|
genkbd_diag(kbd, bootverbose);
|
||||||
}
|
}
|
||||||
|
/* lock keyboard mutex */
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
/* start the keyboard */
|
/* start the keyboard */
|
||||||
|
|
||||||
@ -876,7 +879,7 @@ ukbd_detach(device_t dev)
|
|||||||
struct ukbd_softc *sc = device_get_softc(dev);
|
struct ukbd_softc *sc = device_get_softc(dev);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
mtx_lock(&Giant);
|
mtx_assert(&Giant, MA_OWNED);
|
||||||
|
|
||||||
DPRINTF("\n");
|
DPRINTF("\n");
|
||||||
|
|
||||||
@ -913,8 +916,6 @@ ukbd_detach(device_t dev)
|
|||||||
|
|
||||||
usb_callout_drain(&sc->sc_callout);
|
usb_callout_drain(&sc->sc_callout);
|
||||||
|
|
||||||
mtx_unlock(&Giant);
|
|
||||||
|
|
||||||
DPRINTF("%s: disconnected\n",
|
DPRINTF("%s: disconnected\n",
|
||||||
device_get_nameunit(dev));
|
device_get_nameunit(dev));
|
||||||
|
|
||||||
@ -926,9 +927,9 @@ ukbd_resume(device_t dev)
|
|||||||
{
|
{
|
||||||
struct ukbd_softc *sc = device_get_softc(dev);
|
struct ukbd_softc *sc = device_get_softc(dev);
|
||||||
|
|
||||||
mtx_lock(&Giant);
|
mtx_assert(&Giant, MA_OWNED);
|
||||||
|
|
||||||
ukbd_clear_state(&sc->sc_kbd);
|
ukbd_clear_state(&sc->sc_kbd);
|
||||||
mtx_unlock(&Giant);
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -221,10 +221,10 @@ ue_attach_post_task(struct usb_proc_msg *_task)
|
|||||||
|
|
||||||
if (ue->ue_methods->ue_mii_upd != NULL &&
|
if (ue->ue_methods->ue_mii_upd != NULL &&
|
||||||
ue->ue_methods->ue_mii_sts != NULL) {
|
ue->ue_methods->ue_mii_sts != NULL) {
|
||||||
newbus_xlock();
|
mtx_lock(&Giant); /* device_xxx() depends on this */
|
||||||
error = mii_phy_probe(ue->ue_dev, &ue->ue_miibus,
|
error = mii_phy_probe(ue->ue_dev, &ue->ue_miibus,
|
||||||
ue_ifmedia_upd, ue->ue_methods->ue_mii_sts);
|
ue_ifmedia_upd, ue->ue_methods->ue_mii_sts);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
if (error) {
|
if (error) {
|
||||||
device_printf(ue->ue_dev, "MII without any PHY\n");
|
device_printf(ue->ue_dev, "MII without any PHY\n");
|
||||||
goto error;
|
goto error;
|
||||||
@ -279,12 +279,9 @@ uether_ifdetach(struct usb_ether *ue)
|
|||||||
|
|
||||||
/* detach miibus */
|
/* detach miibus */
|
||||||
if (ue->ue_miibus != NULL) {
|
if (ue->ue_miibus != NULL) {
|
||||||
|
mtx_lock(&Giant); /* device_xxx() depends on this */
|
||||||
/*
|
|
||||||
* It is up to the callers to provide the correct
|
|
||||||
* newbus locking.
|
|
||||||
*/
|
|
||||||
device_delete_child(ue->ue_dev, ue->ue_miibus);
|
device_delete_child(ue->ue_dev, ue->ue_miibus);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* detach ethernet */
|
/* detach ethernet */
|
||||||
|
@ -215,12 +215,14 @@ usb_linux_probe(device_t dev)
|
|||||||
if (uaa->usb_mode != USB_MODE_HOST) {
|
if (uaa->usb_mode != USB_MODE_HOST) {
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
|
mtx_lock(&Giant);
|
||||||
LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
|
LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
|
||||||
if (usb_linux_lookup_id(udrv->id_table, uaa)) {
|
if (usb_linux_lookup_id(udrv->id_table, uaa)) {
|
||||||
err = 0;
|
err = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
@ -237,7 +239,9 @@ usb_linux_get_usb_driver(struct usb_linux_softc *sc)
|
|||||||
{
|
{
|
||||||
struct usb_driver *udrv;
|
struct usb_driver *udrv;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
udrv = sc->sc_udrv;
|
udrv = sc->sc_udrv;
|
||||||
|
mtx_unlock(&Giant);
|
||||||
return (udrv);
|
return (udrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,11 +260,13 @@ usb_linux_attach(device_t dev)
|
|||||||
struct usb_driver *udrv;
|
struct usb_driver *udrv;
|
||||||
const struct usb_device_id *id = NULL;
|
const struct usb_device_id *id = NULL;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
|
LIST_FOREACH(udrv, &usb_linux_driver_list, linux_driver_list) {
|
||||||
id = usb_linux_lookup_id(udrv->id_table, uaa);
|
id = usb_linux_lookup_id(udrv->id_table, uaa);
|
||||||
if (id)
|
if (id)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
@ -281,7 +287,9 @@ usb_linux_attach(device_t dev)
|
|||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
mtx_lock(&Giant);
|
||||||
LIST_INSERT_HEAD(&usb_linux_attached_list, sc, sc_attached_list);
|
LIST_INSERT_HEAD(&usb_linux_attached_list, sc, sc_attached_list);
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
/* success */
|
/* success */
|
||||||
return (0);
|
return (0);
|
||||||
@ -299,12 +307,14 @@ usb_linux_detach(device_t dev)
|
|||||||
struct usb_linux_softc *sc = device_get_softc(dev);
|
struct usb_linux_softc *sc = device_get_softc(dev);
|
||||||
struct usb_driver *udrv = NULL;
|
struct usb_driver *udrv = NULL;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
if (sc->sc_attached_list.le_prev) {
|
if (sc->sc_attached_list.le_prev) {
|
||||||
LIST_REMOVE(sc, sc_attached_list);
|
LIST_REMOVE(sc, sc_attached_list);
|
||||||
sc->sc_attached_list.le_prev = NULL;
|
sc->sc_attached_list.le_prev = NULL;
|
||||||
udrv = sc->sc_udrv;
|
udrv = sc->sc_udrv;
|
||||||
sc->sc_udrv = NULL;
|
sc->sc_udrv = NULL;
|
||||||
}
|
}
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
if (udrv && udrv->disconnect) {
|
if (udrv && udrv->disconnect) {
|
||||||
(udrv->disconnect) (sc->sc_ui);
|
(udrv->disconnect) (sc->sc_ui);
|
||||||
@ -464,10 +474,13 @@ usb_unlink_bsd(struct usb_xfer *xfer,
|
|||||||
if (!usbd_transfer_pending(xfer))
|
if (!usbd_transfer_pending(xfer))
|
||||||
return;
|
return;
|
||||||
if (xfer->priv_fifo == (void *)urb) {
|
if (xfer->priv_fifo == (void *)urb) {
|
||||||
if (drain)
|
if (drain) {
|
||||||
|
mtx_unlock(&Giant);
|
||||||
usbd_transfer_drain(xfer);
|
usbd_transfer_drain(xfer);
|
||||||
else
|
mtx_lock(&Giant);
|
||||||
|
} else {
|
||||||
usbd_transfer_stop(xfer);
|
usbd_transfer_stop(xfer);
|
||||||
|
}
|
||||||
usbd_transfer_start(xfer);
|
usbd_transfer_start(xfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1135,9 +1148,9 @@ usb_linux_register(void *arg)
|
|||||||
{
|
{
|
||||||
struct usb_driver *drv = arg;
|
struct usb_driver *drv = arg;
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
LIST_INSERT_HEAD(&usb_linux_driver_list, drv, linux_driver_list);
|
LIST_INSERT_HEAD(&usb_linux_driver_list, drv, linux_driver_list);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
usb_needs_explore_all();
|
usb_needs_explore_all();
|
||||||
}
|
}
|
||||||
@ -1159,16 +1172,16 @@ usb_linux_deregister(void *arg)
|
|||||||
struct usb_linux_softc *sc;
|
struct usb_linux_softc *sc;
|
||||||
|
|
||||||
repeat:
|
repeat:
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
LIST_FOREACH(sc, &usb_linux_attached_list, sc_attached_list) {
|
LIST_FOREACH(sc, &usb_linux_attached_list, sc_attached_list) {
|
||||||
if (sc->sc_udrv == drv) {
|
if (sc->sc_udrv == drv) {
|
||||||
|
mtx_unlock(&Giant);
|
||||||
device_detach(sc->sc_fbsd_dev);
|
device_detach(sc->sc_fbsd_dev);
|
||||||
newbus_xunlock();
|
|
||||||
goto repeat;
|
goto repeat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LIST_REMOVE(drv, linux_driver_list);
|
LIST_REMOVE(drv, linux_driver_list);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
/*------------------------------------------------------------------------*
|
||||||
|
@ -1040,14 +1040,9 @@ usb_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int fflag, struct thread*
|
|||||||
* Performance optimisation: We try to check for IOCTL's that
|
* Performance optimisation: We try to check for IOCTL's that
|
||||||
* don't need the USB reference first. Then we grab the USB
|
* don't need the USB reference first. Then we grab the USB
|
||||||
* reference if we need it!
|
* reference if we need it!
|
||||||
* Note that some ioctl_post handlers would need to run with the
|
|
||||||
* newbus lock held. It cannot be acquired later because it can
|
|
||||||
* introduce a LOR, so acquire it here.
|
|
||||||
*/
|
*/
|
||||||
newbus_xlock();
|
|
||||||
err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
|
err = usb_ref_device(cpd, &refs, 0 /* no uref */ );
|
||||||
if (err) {
|
if (err) {
|
||||||
newbus_xunlock();
|
|
||||||
return (ENXIO);
|
return (ENXIO);
|
||||||
}
|
}
|
||||||
fflags = cpd->fflags;
|
fflags = cpd->fflags;
|
||||||
@ -1081,7 +1076,6 @@ usb_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int fflag, struct thread*
|
|||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
usb_unref_device(cpd, &refs);
|
usb_unref_device(cpd, &refs);
|
||||||
newbus_xunlock();
|
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ usb_handle_set_config(struct usb_xfer *xfer, uint8_t conf_no)
|
|||||||
* attach:
|
* attach:
|
||||||
*/
|
*/
|
||||||
USB_XFER_UNLOCK(xfer);
|
USB_XFER_UNLOCK(xfer);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant); /* XXX */
|
||||||
sx_xlock(udev->default_sx + 1);
|
sx_xlock(udev->default_sx + 1);
|
||||||
|
|
||||||
if (conf_no == USB_UNCONFIG_NO) {
|
if (conf_no == USB_UNCONFIG_NO) {
|
||||||
@ -176,8 +176,8 @@ usb_handle_set_config(struct usb_xfer *xfer, uint8_t conf_no)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
mtx_unlock(&Giant); /* XXX */
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
USB_XFER_LOCK(xfer);
|
USB_XFER_LOCK(xfer);
|
||||||
return (err);
|
return (err);
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ usb_handle_iface_request(struct usb_xfer *xfer,
|
|||||||
* attach:
|
* attach:
|
||||||
*/
|
*/
|
||||||
USB_XFER_UNLOCK(xfer);
|
USB_XFER_UNLOCK(xfer);
|
||||||
newbus_xlock();
|
mtx_lock(&Giant); /* XXX */
|
||||||
sx_xlock(udev->default_sx + 1);
|
sx_xlock(udev->default_sx + 1);
|
||||||
|
|
||||||
error = ENXIO;
|
error = ENXIO;
|
||||||
@ -353,20 +353,20 @@ usb_handle_iface_request(struct usb_xfer *xfer,
|
|||||||
goto tr_stalled;
|
goto tr_stalled;
|
||||||
}
|
}
|
||||||
tr_valid:
|
tr_valid:
|
||||||
|
mtx_unlock(&Giant);
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
USB_XFER_LOCK(xfer);
|
USB_XFER_LOCK(xfer);
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
tr_short:
|
tr_short:
|
||||||
|
mtx_unlock(&Giant);
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
USB_XFER_LOCK(xfer);
|
USB_XFER_LOCK(xfer);
|
||||||
return (USB_ERR_SHORT_XFER);
|
return (USB_ERR_SHORT_XFER);
|
||||||
|
|
||||||
tr_stalled:
|
tr_stalled:
|
||||||
|
mtx_unlock(&Giant);
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
USB_XFER_LOCK(xfer);
|
USB_XFER_LOCK(xfer);
|
||||||
return (USB_ERR_STALLED);
|
return (USB_ERR_STALLED);
|
||||||
}
|
}
|
||||||
|
@ -234,10 +234,8 @@ uhub_explore_sub(struct uhub_softc *sc, struct usb_port *up)
|
|||||||
|
|
||||||
if (child->driver_added_refcount != refcount) {
|
if (child->driver_added_refcount != refcount) {
|
||||||
child->driver_added_refcount = refcount;
|
child->driver_added_refcount = refcount;
|
||||||
newbus_xlock();
|
|
||||||
err = usb_probe_and_attach(child,
|
err = usb_probe_and_attach(child,
|
||||||
USB_IFACE_INDEX_ANY);
|
USB_IFACE_INDEX_ANY);
|
||||||
newbus_xunlock();
|
|
||||||
if (err) {
|
if (err) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
@ -320,11 +318,9 @@ uhub_reattach_port(struct uhub_softc *sc, uint8_t portno)
|
|||||||
/* detach any existing devices */
|
/* detach any existing devices */
|
||||||
|
|
||||||
if (child) {
|
if (child) {
|
||||||
newbus_xlock();
|
|
||||||
usb_free_device(child,
|
usb_free_device(child,
|
||||||
USB_UNCFG_FLAG_FREE_SUBDEV |
|
USB_UNCFG_FLAG_FREE_SUBDEV |
|
||||||
USB_UNCFG_FLAG_FREE_EP0);
|
USB_UNCFG_FLAG_FREE_EP0);
|
||||||
newbus_xunlock();
|
|
||||||
child = NULL;
|
child = NULL;
|
||||||
}
|
}
|
||||||
/* get fresh status */
|
/* get fresh status */
|
||||||
@ -432,10 +428,9 @@ uhub_reattach_port(struct uhub_softc *sc, uint8_t portno)
|
|||||||
mode = USB_MODE_HOST;
|
mode = USB_MODE_HOST;
|
||||||
|
|
||||||
/* need to create a new child */
|
/* need to create a new child */
|
||||||
newbus_xlock();
|
|
||||||
child = usb_alloc_device(sc->sc_dev, udev->bus, udev,
|
child = usb_alloc_device(sc->sc_dev, udev->bus, udev,
|
||||||
udev->depth + 1, portno - 1, portno, speed, mode);
|
udev->depth + 1, portno - 1, portno, speed, mode);
|
||||||
newbus_xunlock();
|
|
||||||
if (child == NULL) {
|
if (child == NULL) {
|
||||||
DPRINTFN(0, "could not allocate new device!\n");
|
DPRINTFN(0, "could not allocate new device!\n");
|
||||||
goto error;
|
goto error;
|
||||||
@ -444,11 +439,9 @@ uhub_reattach_port(struct uhub_softc *sc, uint8_t portno)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
if (child) {
|
if (child) {
|
||||||
newbus_xlock();
|
|
||||||
usb_free_device(child,
|
usb_free_device(child,
|
||||||
USB_UNCFG_FLAG_FREE_SUBDEV |
|
USB_UNCFG_FLAG_FREE_SUBDEV |
|
||||||
USB_UNCFG_FLAG_FREE_EP0);
|
USB_UNCFG_FLAG_FREE_EP0);
|
||||||
newbus_xunlock();
|
|
||||||
child = NULL;
|
child = NULL;
|
||||||
}
|
}
|
||||||
if (err == 0) {
|
if (err == 0) {
|
||||||
@ -987,6 +980,7 @@ uhub_child_location_string(device_t parent, device_t child,
|
|||||||
struct usb_hub *hub = sc->sc_udev->hub;
|
struct usb_hub *hub = sc->sc_udev->hub;
|
||||||
struct hub_result res;
|
struct hub_result res;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
uhub_find_iface_index(hub, child, &res);
|
uhub_find_iface_index(hub, child, &res);
|
||||||
if (!res.udev) {
|
if (!res.udev) {
|
||||||
DPRINTF("device not on hub\n");
|
DPRINTF("device not on hub\n");
|
||||||
@ -998,6 +992,7 @@ uhub_child_location_string(device_t parent, device_t child,
|
|||||||
snprintf(buf, buflen, "port=%u interface=%u",
|
snprintf(buf, buflen, "port=%u interface=%u",
|
||||||
res.portno, res.iface_index);
|
res.portno, res.iface_index);
|
||||||
done:
|
done:
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -1011,6 +1006,7 @@ uhub_child_pnpinfo_string(device_t parent, device_t child,
|
|||||||
struct usb_interface *iface;
|
struct usb_interface *iface;
|
||||||
struct hub_result res;
|
struct hub_result res;
|
||||||
|
|
||||||
|
mtx_lock(&Giant);
|
||||||
uhub_find_iface_index(hub, child, &res);
|
uhub_find_iface_index(hub, child, &res);
|
||||||
if (!res.udev) {
|
if (!res.udev) {
|
||||||
DPRINTF("device not on hub\n");
|
DPRINTF("device not on hub\n");
|
||||||
@ -1041,6 +1037,7 @@ uhub_child_pnpinfo_string(device_t parent, device_t child,
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
done:
|
done:
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -1778,13 +1775,10 @@ usb_dev_resume_peer(struct usb_device *udev)
|
|||||||
/* always update hardware power! */
|
/* always update hardware power! */
|
||||||
(bus->methods->set_hw_power) (bus);
|
(bus->methods->set_hw_power) (bus);
|
||||||
}
|
}
|
||||||
newbus_xlock();
|
|
||||||
sx_xlock(udev->default_sx + 1);
|
sx_xlock(udev->default_sx + 1);
|
||||||
|
|
||||||
/* notify all sub-devices about resume */
|
/* notify all sub-devices about resume */
|
||||||
err = usb_suspend_resume(udev, 0);
|
err = usb_suspend_resume(udev, 0);
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
/* check if peer has wakeup capability */
|
/* check if peer has wakeup capability */
|
||||||
if (usb_peer_can_wakeup(udev)) {
|
if (usb_peer_can_wakeup(udev)) {
|
||||||
@ -1850,13 +1844,10 @@ usb_dev_suspend_peer(struct usb_device *udev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
sx_xlock(udev->default_sx + 1);
|
sx_xlock(udev->default_sx + 1);
|
||||||
|
|
||||||
/* notify all sub-devices about suspend */
|
/* notify all sub-devices about suspend */
|
||||||
err = usb_suspend_resume(udev, 1);
|
err = usb_suspend_resume(udev, 1);
|
||||||
sx_unlock(udev->default_sx + 1);
|
sx_unlock(udev->default_sx + 1);
|
||||||
newbus_xunlock();
|
|
||||||
|
|
||||||
if (usb_peer_can_wakeup(udev)) {
|
if (usb_peer_can_wakeup(udev)) {
|
||||||
/* allow device to do remote wakeup */
|
/* allow device to do remote wakeup */
|
||||||
|
@ -465,7 +465,7 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case SIOCSIFFLAGS:
|
case SIOCSIFFLAGS:
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
if (ifp->if_flags & IFF_UP) {
|
if (ifp->if_flags & IFF_UP) {
|
||||||
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
|
||||||
if ((ifp->if_flags ^ sc->sc_if_flags) &
|
if ((ifp->if_flags ^ sc->sc_if_flags) &
|
||||||
@ -482,7 +482,7 @@ upgt_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
|
|||||||
sc->sc_if_flags = ifp->if_flags;
|
sc->sc_if_flags = ifp->if_flags;
|
||||||
if (startall)
|
if (startall)
|
||||||
ieee80211_start_all(ic);
|
ieee80211_start_all(ic);
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
break;
|
break;
|
||||||
case SIOCGIFMEDIA:
|
case SIOCGIFMEDIA:
|
||||||
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
|
error = ifmedia_ioctl(ifp, ifr, &ic->ic_media, cmd);
|
||||||
|
@ -1156,7 +1156,7 @@ vbd_add_dev(struct xenbus_device *xdev)
|
|||||||
devclass_t dc;
|
devclass_t dc;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
/* We will add a vbd device as a child of nexus0 (for now) */
|
/* We will add a vbd device as a child of nexus0 (for now) */
|
||||||
if (!(dc = devclass_find("nexus")) ||
|
if (!(dc = devclass_find("nexus")) ||
|
||||||
@ -1183,7 +1183,7 @@ vbd_add_dev(struct xenbus_device *xdev)
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -1388,7 +1388,7 @@ vif_add_dev(struct xenbus_device *xdev)
|
|||||||
devclass_t dc;
|
devclass_t dc;
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
newbus_xlock();
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
/* We will add a vif device as a child of nexus0 (for now) */
|
/* We will add a vif device as a child of nexus0 (for now) */
|
||||||
if (!(dc = devclass_find("nexus")) ||
|
if (!(dc = devclass_find("nexus")) ||
|
||||||
@ -1415,7 +1415,7 @@ vif_add_dev(struct xenbus_device *xdev)
|
|||||||
|
|
||||||
done:
|
done:
|
||||||
|
|
||||||
newbus_xunlock();
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,6 @@ acpi_capm_get_info(apm_info_t aip)
|
|||||||
else
|
else
|
||||||
aip->ai_acline = acline; /* on/off */
|
aip->ai_acline = acline; /* on/off */
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
if (acpi_battery_get_battinfo(NULL, &batt) != 0) {
|
if (acpi_battery_get_battinfo(NULL, &batt) != 0) {
|
||||||
aip->ai_batt_stat = APM_UNKNOWN;
|
aip->ai_batt_stat = APM_UNKNOWN;
|
||||||
aip->ai_batt_life = APM_UNKNOWN;
|
aip->ai_batt_life = APM_UNKNOWN;
|
||||||
@ -176,7 +175,6 @@ acpi_capm_get_info(apm_info_t aip)
|
|||||||
aip->ai_batt_time = (batt.min == -1) ? -1 : batt.min * 60;
|
aip->ai_batt_time = (batt.min == -1) ? -1 : batt.min * 60;
|
||||||
aip->ai_batteries = acpi_battery_get_units();
|
aip->ai_batteries = acpi_battery_get_units();
|
||||||
}
|
}
|
||||||
newbus_sunlock();
|
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -192,7 +190,6 @@ acpi_capm_get_pwstatus(apm_pwstatus_t app)
|
|||||||
(app->ap_device < PMDV_BATT0 || app->ap_device > PMDV_BATT_ALL))
|
(app->ap_device < PMDV_BATT0 || app->ap_device > PMDV_BATT_ALL))
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
if (app->ap_device == PMDV_ALLDEV)
|
if (app->ap_device == PMDV_ALLDEV)
|
||||||
error = acpi_battery_get_battinfo(NULL, &batt);
|
error = acpi_battery_get_battinfo(NULL, &batt);
|
||||||
else {
|
else {
|
||||||
@ -203,7 +200,6 @@ acpi_capm_get_pwstatus(apm_pwstatus_t app)
|
|||||||
else
|
else
|
||||||
error = ENXIO;
|
error = ENXIO;
|
||||||
}
|
}
|
||||||
newbus_sunlock();
|
|
||||||
if (error)
|
if (error)
|
||||||
return (1);
|
return (1);
|
||||||
|
|
||||||
@ -287,9 +283,7 @@ apmopen(struct cdev *dev, int flag, int fmt, struct thread *td)
|
|||||||
struct acpi_softc *acpi_sc;
|
struct acpi_softc *acpi_sc;
|
||||||
struct apm_clone_data *clone;
|
struct apm_clone_data *clone;
|
||||||
|
|
||||||
newbus_slock();
|
|
||||||
acpi_sc = devclass_get_softc(devclass_find("acpi"), 0);
|
acpi_sc = devclass_get_softc(devclass_find("acpi"), 0);
|
||||||
newbus_sunlock();
|
|
||||||
clone = apm_create_clone(dev, acpi_sc);
|
clone = apm_create_clone(dev, acpi_sc);
|
||||||
dev->si_drv1 = clone;
|
dev->si_drv1 = clone;
|
||||||
|
|
||||||
|
@ -288,12 +288,10 @@ smapi_modevent (module_t mod, int what, void *arg)
|
|||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
break;
|
break;
|
||||||
case MOD_UNLOAD:
|
case MOD_UNLOAD:
|
||||||
newbus_xlock();
|
|
||||||
devclass_get_devices(smapi_devclass, &devs, &count);
|
devclass_get_devices(smapi_devclass, &devs, &count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -230,12 +230,10 @@ smbios_modevent (mod, what, arg)
|
|||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
break;
|
break;
|
||||||
case MOD_UNLOAD:
|
case MOD_UNLOAD:
|
||||||
newbus_xlock();
|
|
||||||
devclass_get_devices(smbios_devclass, &devs, &count);
|
devclass_get_devices(smbios_devclass, &devs, &count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -248,12 +248,10 @@ vpd_modevent (mod, what, arg)
|
|||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
break;
|
break;
|
||||||
case MOD_UNLOAD:
|
case MOD_UNLOAD:
|
||||||
newbus_xlock();
|
|
||||||
devclass_get_devices(vpd_devclass, &devs, &count);
|
devclass_get_devices(vpd_devclass, &devs, &count);
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
device_delete_child(device_get_parent(devs[i]), devs[i]);
|
||||||
}
|
}
|
||||||
newbus_xunlock();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/rman.h>
|
#include <sys/rman.h>
|
||||||
#include <sys/selinfo.h>
|
#include <sys/selinfo.h>
|
||||||
#include <sys/signalvar.h>
|
#include <sys/signalvar.h>
|
||||||
#include <sys/sx.h>
|
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
@ -192,54 +191,6 @@ void print_devclass_list(void);
|
|||||||
#define print_devclass_list() /* nop */
|
#define print_devclass_list() /* nop */
|
||||||
#endif
|
#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
|
* dev sysctl tree
|
||||||
*/
|
*/
|
||||||
@ -413,6 +364,7 @@ static d_poll_t devpoll;
|
|||||||
|
|
||||||
static struct cdevsw dev_cdevsw = {
|
static struct cdevsw dev_cdevsw = {
|
||||||
.d_version = D_VERSION,
|
.d_version = D_VERSION,
|
||||||
|
.d_flags = D_NEEDGIANT,
|
||||||
.d_open = devopen,
|
.d_open = devopen,
|
||||||
.d_close = devclose,
|
.d_close = devclose,
|
||||||
.d_read = devread,
|
.d_read = devread,
|
||||||
@ -1109,7 +1061,6 @@ devclass_delete_driver(devclass_t busclass, driver_t *driver)
|
|||||||
int i;
|
int i;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass)));
|
PDEBUG(("%s from devclass %s", driver->name, DEVCLANAME(busclass)));
|
||||||
|
|
||||||
if (!dc)
|
if (!dc)
|
||||||
@ -1808,7 +1759,6 @@ device_delete_child(device_t dev, device_t child)
|
|||||||
int error;
|
int error;
|
||||||
device_t grandchild;
|
device_t grandchild;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
|
PDEBUG(("%s from %s", DEVICENAME(child), DEVICENAME(dev)));
|
||||||
|
|
||||||
/* remove children first */
|
/* remove children first */
|
||||||
@ -1907,7 +1857,7 @@ device_probe_child(device_t dev, device_t child)
|
|||||||
int result, pri = 0;
|
int result, pri = 0;
|
||||||
int hasclass = (child->devclass != NULL);
|
int hasclass = (child->devclass != NULL);
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
dc = dev->devclass;
|
dc = dev->devclass;
|
||||||
if (!dc)
|
if (!dc)
|
||||||
@ -2558,7 +2508,7 @@ device_probe(device_t dev)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0)
|
if (dev->state >= DS_ALIVE && (dev->flags & DF_REBID) == 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
@ -2592,7 +2542,7 @@ device_probe_and_attach(device_t dev)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
error = device_probe(dev);
|
error = device_probe(dev);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
@ -2626,8 +2576,6 @@ device_attach(device_t dev)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
|
|
||||||
device_sysctl_init(dev);
|
device_sysctl_init(dev);
|
||||||
if (!device_is_quiet(dev))
|
if (!device_is_quiet(dev))
|
||||||
device_print_child(dev->parent, dev);
|
device_print_child(dev->parent, dev);
|
||||||
@ -2669,7 +2617,7 @@ device_detach(device_t dev)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
GIANT_REQUIRED;
|
||||||
|
|
||||||
PDEBUG(("%s", DEVICENAME(dev)));
|
PDEBUG(("%s", DEVICENAME(dev)));
|
||||||
if (dev->state == DS_BUSY)
|
if (dev->state == DS_BUSY)
|
||||||
@ -2713,8 +2661,6 @@ int
|
|||||||
device_quiesce(device_t dev)
|
device_quiesce(device_t dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
|
|
||||||
PDEBUG(("%s", DEVICENAME(dev)));
|
PDEBUG(("%s", DEVICENAME(dev)));
|
||||||
if (dev->state == DS_BUSY)
|
if (dev->state == DS_BUSY)
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
@ -2735,7 +2681,6 @@ device_quiesce(device_t dev)
|
|||||||
int
|
int
|
||||||
device_shutdown(device_t dev)
|
device_shutdown(device_t dev)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (dev->state < DS_ATTACHED)
|
if (dev->state < DS_ATTACHED)
|
||||||
return (0);
|
return (0);
|
||||||
return (DEVICE_SHUTDOWN(dev));
|
return (DEVICE_SHUTDOWN(dev));
|
||||||
@ -3151,8 +3096,6 @@ bus_generic_attach(device_t dev)
|
|||||||
{
|
{
|
||||||
device_t child;
|
device_t child;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
|
|
||||||
TAILQ_FOREACH(child, &dev->children, link) {
|
TAILQ_FOREACH(child, &dev->children, link) {
|
||||||
device_probe_and_attach(child);
|
device_probe_and_attach(child);
|
||||||
}
|
}
|
||||||
@ -3173,8 +3116,6 @@ bus_generic_detach(device_t dev)
|
|||||||
device_t child;
|
device_t child;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
NBL_ASSERT(SA_XLOCKED);
|
|
||||||
|
|
||||||
if (dev->state != DS_ATTACHED)
|
if (dev->state != DS_ATTACHED)
|
||||||
return (EBUSY);
|
return (EBUSY);
|
||||||
|
|
||||||
@ -4055,7 +3996,6 @@ root_bus_module_handler(module_t mod, int what, void* arg)
|
|||||||
switch (what) {
|
switch (what) {
|
||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
TAILQ_INIT(&bus_data_devices);
|
TAILQ_INIT(&bus_data_devices);
|
||||||
NBL_LOCK_INIT();
|
|
||||||
kobj_class_compile((kobj_class_t) &root_driver);
|
kobj_class_compile((kobj_class_t) &root_driver);
|
||||||
root_bus = make_device(NULL, "root", 0);
|
root_bus = make_device(NULL, "root", 0);
|
||||||
root_bus->desc = "System root bus";
|
root_bus->desc = "System root bus";
|
||||||
@ -4115,28 +4055,14 @@ driver_module_handler(module_t mod, int what, void *arg)
|
|||||||
kobj_class_t driver;
|
kobj_class_t driver;
|
||||||
int error, pass;
|
int error, pass;
|
||||||
|
|
||||||
error = 0;
|
|
||||||
dmd = (struct driver_module_data *)arg;
|
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);
|
bus_devclass = devclass_find_internal(dmd->dmd_busname, NULL, TRUE);
|
||||||
if (bus_devclass == NULL) {
|
error = 0;
|
||||||
NBL_XUNLOCK();
|
|
||||||
return (ENOMEM);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (what) {
|
switch (what) {
|
||||||
case MOD_LOAD:
|
case MOD_LOAD:
|
||||||
if (dmd->dmd_chainevh)
|
if (dmd->dmd_chainevh)
|
||||||
error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
|
error = dmd->dmd_chainevh(mod,what,dmd->dmd_chainarg);
|
||||||
if (error != 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
pass = dmd->dmd_pass;
|
pass = dmd->dmd_pass;
|
||||||
driver = dmd->dmd_driver;
|
driver = dmd->dmd_driver;
|
||||||
@ -4189,7 +4115,6 @@ driver_module_handler(module_t mod, int what, void *arg)
|
|||||||
error = EOPNOTSUPP;
|
error = EOPNOTSUPP;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
NBL_XUNLOCK();
|
|
||||||
|
|
||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
@ -1499,9 +1499,7 @@ fdstrategy(struct bio *bp)
|
|||||||
bioq_disksort(&fdc->head, bp);
|
bioq_disksort(&fdc->head, bp);
|
||||||
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
|
untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
|
||||||
devstat_start_transaction_bio(fd->device_stats, bp);
|
devstat_start_transaction_bio(fd->device_stats, bp);
|
||||||
newbus_xlock();
|
|
||||||
device_busy(fd->dev);
|
device_busy(fd->dev);
|
||||||
newbus_xunlock();
|
|
||||||
fdstart(fdc);
|
fdstart(fdc);
|
||||||
splx(s);
|
splx(s);
|
||||||
return;
|
return;
|
||||||
@ -2180,9 +2178,7 @@ fdstate(fdc_p fdc)
|
|||||||
fd->skip = 0;
|
fd->skip = 0;
|
||||||
bp->bio_resid = 0;
|
bp->bio_resid = 0;
|
||||||
fdc->bp = NULL;
|
fdc->bp = NULL;
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(fd->dev);
|
device_unbusy(fd->dev);
|
||||||
newbus_xunlock();
|
|
||||||
biofinish(bp, fd->device_stats, 0);
|
biofinish(bp, fd->device_stats, 0);
|
||||||
fdc->fd = (fd_p) 0;
|
fdc->fd = (fd_p) 0;
|
||||||
fdc->fdu = -1;
|
fdc->fdu = -1;
|
||||||
@ -2343,9 +2339,7 @@ retrier(struct fdc_data *fdc)
|
|||||||
bp->bio_resid = 0;
|
bp->bio_resid = 0;
|
||||||
fdc->bp = NULL;
|
fdc->bp = NULL;
|
||||||
fdc->fd->skip = 0;
|
fdc->fd->skip = 0;
|
||||||
newbus_xlock();
|
|
||||||
device_unbusy(fd->dev);
|
device_unbusy(fd->dev);
|
||||||
newbus_xunlock();
|
|
||||||
biofinish(bp, fdc->fd->device_stats, 0);
|
biofinish(bp, fdc->fd->device_stats, 0);
|
||||||
fdc->state = FINDWORK;
|
fdc->state = FINDWORK;
|
||||||
fdc->flags |= FDC_NEEDS_RESET;
|
fdc->flags |= FDC_NEEDS_RESET;
|
||||||
|
@ -478,14 +478,6 @@ int resource_set_string(const char *name, int unit, const char *resname,
|
|||||||
int bus_data_generation_check(int generation);
|
int bus_data_generation_check(int generation);
|
||||||
void bus_data_generation_update(void);
|
void bus_data_generation_update(void);
|
||||||
|
|
||||||
/*
|
|
||||||
* Exported locking facilities.
|
|
||||||
*/
|
|
||||||
void newbus_xlock(void);
|
|
||||||
void newbus_slock(void);
|
|
||||||
void newbus_xunlock(void);
|
|
||||||
void newbus_sunlock(void);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some convenience defines for probe routines to return. These are just
|
* Some convenience defines for probe routines to return. These are just
|
||||||
* suggested values, and there's nothing magical about them.
|
* suggested values, and there's nothing magical about them.
|
||||||
|
@ -348,9 +348,7 @@ xenbus_devices_changed(struct xenbus_watch *watch,
|
|||||||
if (p)
|
if (p)
|
||||||
*p = 0;
|
*p = 0;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
xenbus_add_device(dev, bus, type, id);
|
xenbus_add_device(dev, bus, type, id);
|
||||||
newbus_xunlock();
|
|
||||||
taskqueue_enqueue(taskqueue_thread, &sc->xs_probechildren);
|
taskqueue_enqueue(taskqueue_thread, &sc->xs_probechildren);
|
||||||
out:
|
out:
|
||||||
free(node, M_DEVBUF);
|
free(node, M_DEVBUF);
|
||||||
@ -363,9 +361,7 @@ xenbus_attach_deferred(void *arg)
|
|||||||
struct xenbus_softc *sc = device_get_softc(dev);
|
struct xenbus_softc *sc = device_get_softc(dev);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
newbus_xlock();
|
|
||||||
error = xenbus_enumerate_bus(dev, "device");
|
error = xenbus_enumerate_bus(dev, "device");
|
||||||
newbus_xunlock();
|
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
xenbus_probe_children(dev);
|
xenbus_probe_children(dev);
|
||||||
|
Loading…
Reference in New Issue
Block a user