Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F139376340
D31831.id94648.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
27 KB
Referenced Files
None
Subscribers
None
D31831.id94648.diff
View Options
Index: sys/compat/linuxkpi/common/include/linux/device.h
===================================================================
--- sys/compat/linuxkpi/common/include/linux/device.h
+++ sys/compat/linuxkpi/common/include/linux/device.h
@@ -465,9 +465,9 @@
dev->bsddev = NULL;
if (bsddev != NULL && dev->bsddev_attached_here) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(device_get_parent(bsddev), bsddev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
put_device(dev);
}
@@ -481,9 +481,9 @@
dev->bsddev = NULL;
if (bsddev != NULL && dev->bsddev_attached_here) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(device_get_parent(bsddev), bsddev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
}
Index: sys/compat/linuxkpi/common/src/linux_pci.c
===================================================================
--- sys/compat/linuxkpi/common/src/linux_pci.c
+++ sys/compat/linuxkpi/common/src/linux_pci.c
@@ -605,10 +605,10 @@
pdrv->bsddriver.methods = pci_methods;
pdrv->bsddriver.size = sizeof(struct pci_dev);
- mtx_lock(&Giant);
+ bus_topo_lock();
error = devclass_add_driver(dc, &pdrv->bsddriver,
BUS_PASS_DEFAULT, &pdrv->bsdclass);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (-error);
}
@@ -676,10 +676,10 @@
spin_lock(&pci_lock);
list_del(&pdrv->links);
spin_unlock(&pci_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
if (bus != NULL)
devclass_delete_driver(bus, &pdrv->bsddriver);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
void
@@ -692,10 +692,10 @@
spin_lock(&pci_lock);
list_del(&pdrv->links);
spin_unlock(&pci_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
if (bus != NULL)
devclass_delete_driver(bus, &pdrv->bsddriver);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
CTASSERT(sizeof(dma_addr_t) <= sizeof(uint64_t));
Index: sys/compat/linuxkpi/common/src/linux_usb.c
===================================================================
--- sys/compat/linuxkpi/common/src/linux_usb.c
+++ sys/compat/linuxkpi/common/src/linux_usb.c
@@ -1166,7 +1166,9 @@
LIST_FOREACH(sc, &usb_linux_attached_list, sc_attached_list) {
if (sc->sc_udrv == drv) {
mtx_unlock(&Giant);
+ bus_topo_lock();
device_detach(sc->sc_fbsd_dev);
+ bus_topo_unlock();
goto repeat;
}
}
Index: sys/dev/aac/aac.c
===================================================================
--- sys/dev/aac/aac.c
+++ sys/dev/aac/aac.c
@@ -3305,10 +3305,10 @@
while (co != NULL) {
if (co->co_found == 0) {
mtx_unlock(&sc->aac_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(sc->aac_dev,
co->co_disk);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->aac_io_lock);
co_next = TAILQ_NEXT(co, co_link);
mtx_lock(&sc->aac_container_lock);
@@ -3326,9 +3326,9 @@
/* Attach the newly created containers */
if (added) {
mtx_unlock(&sc->aac_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
bus_generic_attach(sc->aac_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->aac_io_lock);
}
Index: sys/dev/acpica/acpi.c
===================================================================
--- sys/dev/acpica/acpi.c
+++ sys/dev/acpica/acpi.c
@@ -3096,10 +3096,9 @@
#endif
/*
- * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE
- * drivers need this.
+ * Be sure to hold Giant across DEVICE_SUSPEND/RESUME
*/
- mtx_lock(&Giant);
+ bus_topo_lock();
slp_state = ACPI_SS_NONE;
@@ -3225,7 +3224,7 @@
}
sc->acpi_next_sstate = 0;
- mtx_unlock(&Giant);
+ bus_topo_unlock();
#ifdef EARLY_AP_STARTUP
thread_lock(curthread);
Index: sys/dev/acpica/acpi_dock.c
===================================================================
--- sys/dev/acpica/acpi_dock.c
+++ sys/dev/acpica/acpi_dock.c
@@ -193,9 +193,9 @@
if (!device_is_enabled(dev))
device_enable(dev);
- mtx_lock(&Giant);
+ bus_topo_lock();
device_probe_and_attach(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
static ACPI_STATUS
@@ -306,9 +306,9 @@
dev = acpi_get_device(handle);
if (dev != NULL && device_is_attached(dev)) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_detach(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
acpi_SetInteger(handle, "_EJ0", 0);
Index: sys/dev/acpica/acpi_pci.c
===================================================================
--- sys/dev/acpica/acpi_pci.c
+++ sys/dev/acpica/acpi_pci.c
@@ -340,9 +340,9 @@
switch (notify) {
case ACPI_NOTIFY_BUS_CHECK:
- mtx_lock(&Giant);
+ bus_topo_lock();
BUS_RESCAN(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
break;
default:
device_printf(dev, "unknown notify %#x\n", notify);
@@ -361,9 +361,9 @@
switch (notify) {
case ACPI_NOTIFY_DEVICE_CHECK:
- mtx_lock(&Giant);
+ bus_topo_lock();
BUS_RESCAN(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
break;
case ACPI_NOTIFY_EJECT_REQUEST:
child = acpi_get_device(h);
@@ -372,23 +372,23 @@
acpi_name(h));
return;
}
- mtx_lock(&Giant);
+ bus_topo_lock();
error = device_detach(child);
if (error) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
device_printf(dev, "failed to detach %s: %d\n",
device_get_nameunit(child), error);
return;
}
status = acpi_SetInteger(h, "_EJ0", 1);
if (ACPI_FAILURE(status)) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
device_printf(dev, "failed to eject %s: %s\n",
acpi_name(h), AcpiFormatException(status));
return;
}
BUS_RESCAN(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
break;
default:
device_printf(dev, "unknown notify %#x for %s\n", notify,
Index: sys/dev/bhnd/cores/chipc/chipc.c
===================================================================
--- sys/dev/bhnd/cores/chipc/chipc.c
+++ sys/dev/bhnd/cores/chipc/chipc.c
@@ -1145,13 +1145,13 @@
if (!CHIPC_QUIRK(sc, MUX_SPROM))
return (true);
- mtx_lock(&Giant); /* for newbus */
+ bus_topo_lock();
parent = device_get_parent(sc->dev);
hostb = bhnd_bus_find_hostb_device(parent);
if ((error = device_get_children(parent, &devs, &devcount))) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (false);
}
@@ -1174,7 +1174,7 @@
}
free(devs, M_TEMP);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (result);
}
Index: sys/dev/cardbus/cardbus.c
===================================================================
--- sys/dev/cardbus/cardbus.c
+++ sys/dev/cardbus/cardbus.c
@@ -199,7 +199,7 @@
domain = pcib_get_domain(cbdev);
bus = pcib_get_bus(cbdev);
slot = 0;
- mtx_lock(&Giant);
+ bus_topo_lock();
/* For each function, set it up and try to attach a driver to it */
for (func = 0; func <= cardbusfunchigh; func++) {
struct cardbus_devinfo *dinfo;
@@ -233,7 +233,7 @@
else
pci_cfg_save(dinfo->pci.cfg.dev, &dinfo->pci, 1);
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (cardattached > 0)
return (0);
/* POWER_DISABLE_SOCKET(brdev, cbdev); */
Index: sys/dev/drm2/drm_dp_iic_helper.c
===================================================================
--- sys/dev/drm2/drm_dp_iic_helper.c
+++ sys/dev/drm2/drm_dp_iic_helper.c
@@ -228,12 +228,12 @@
int idx, error;
static int dp_bus_counter;
- mtx_lock(&Giant);
+ bus_topo_lock();
idx = atomic_fetchadd_int(&dp_bus_counter, 1);
ibus = device_add_child(dev, "drm_iic_dp_aux", idx);
if (ibus == NULL) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
DRM_ERROR("drm_iic_dp_aux bus %d creation error\n", idx);
return (-ENXIO);
}
@@ -241,7 +241,7 @@
error = device_probe_and_attach(ibus);
if (error != 0) {
device_delete_child(dev, ibus);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
DRM_ERROR("drm_iic_dp_aux bus %d attach failed, %d\n",
idx, error);
return (-error);
@@ -256,7 +256,7 @@
*bus = ibus;
*adapter = data->port;
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (-error);
}
Index: sys/dev/hyperv/pcib/vmbus_pcib.c
===================================================================
--- sys/dev/hyperv/pcib/vmbus_pcib.c
+++ sys/dev/hyperv/pcib/vmbus_pcib.c
@@ -560,14 +560,14 @@
devfn = wslot_to_devfn(hpdev->desc.wslot.val);
- mtx_lock(&Giant);
+ bus_topo_lock();
pci_dev = pci_find_dbsf(hbus->pci_domain,
0, PCI_SLOT(devfn), PCI_FUNC(devfn));
if (pci_dev)
device_delete_child(hbus->pci_bus, pci_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&hbus->device_list_lock);
TAILQ_REMOVE(&hbus->children, hpdev, link);
Index: sys/dev/ida/ida.c
===================================================================
--- sys/dev/ida/ida.c
+++ sys/dev/ida/ida.c
@@ -334,9 +334,9 @@
config_intrhook_disestablish(&ida->ich);
- mtx_lock(&Giant);
+ bus_topo_lock();
bus_generic_attach(ida->dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
int
Index: sys/dev/mfi/mfi.c
===================================================================
--- sys/dev/mfi/mfi.c
+++ sys/dev/mfi/mfi.c
@@ -1425,9 +1425,9 @@
if (found == 0) {
printf("DELETE\n");
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(sc->mfi_dev, syspd->pd_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
}
}
@@ -1585,9 +1585,9 @@
KASSERT(ld != NULL, ("volume dissappeared"));
*/
if (ld != NULL) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(sc->mfi_dev, ld->ld_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
}
break;
@@ -1602,11 +1602,11 @@
pd_link) {
if (syspd->pd_id ==
detail->args.pd.device_id) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(
sc->mfi_dev,
syspd->pd_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
break;
}
}
@@ -1923,11 +1923,11 @@
mfi_release_command(cm);
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
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);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
return;
}
@@ -1935,7 +1935,7 @@
device_set_ivars(child, ld_info);
device_set_desc(child, "MFI Logical Disk");
bus_generic_attach(sc->mfi_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
}
@@ -2011,11 +2011,11 @@
mfi_release_command(cm);
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
if ((child = device_add_child(sc->mfi_dev, "mfisyspd", -1)) == NULL) {
device_printf(sc->mfi_dev, "Failed to add system pd\n");
free(pd_info, M_MFIBUF);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
return;
}
@@ -2023,7 +2023,7 @@
device_set_ivars(child, pd_info);
device_set_desc(child, "MFI System PD");
bus_generic_attach(sc->mfi_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
}
@@ -2832,9 +2832,9 @@
KASSERT(ld != NULL, ("volume dissappeared"));
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(sc->mfi_dev, ld->ld_dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
} else
mfi_disk_enable(ld);
@@ -2842,11 +2842,11 @@
case MFI_DCMD_CFG_CLEAR:
if (cm->cm_frame->header.cmd_status == MFI_STAT_OK) {
mtx_unlock(&sc->mfi_io_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
TAILQ_FOREACH_SAFE(ld, &sc->mfi_ld_tqh, ld_link, ldn) {
device_delete_child(sc->mfi_dev, ld->ld_dev);
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
mtx_lock(&sc->mfi_io_lock);
} else {
TAILQ_FOREACH(ld, &sc->mfi_ld_tqh, ld_link)
Index: sys/dev/mfi/mfi_cam.c
===================================================================
--- sys/dev/mfi/mfi_cam.c
+++ sys/dev/mfi/mfi_cam.c
@@ -298,9 +298,9 @@
struct cam_sim *sim;
device_t mfip_dev;
- mtx_lock(&Giant);
+ bus_topo_lock();
mfip_dev = device_find_child(sc->mfi_dev, "mfip", -1);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (mfip_dev == NULL) {
device_printf(sc->mfi_dev, "Couldn't find mfip child device!\n");
return;
Index: sys/dev/mii/mii.c
===================================================================
--- sys/dev/mii/mii.c
+++ sys/dev/mii/mii.c
@@ -414,7 +414,9 @@
ivars->ifmedia_upd = ifmedia_upd;
ivars->ifmedia_sts = ifmedia_sts;
ivars->mii_flags = flags;
+ bus_topo_lock();
*miibus = device_add_child(dev, "miibus", -1);
+ bus_topo_unlock();
if (*miibus == NULL) {
rv = ENXIO;
goto fail;
@@ -442,6 +444,7 @@
device_get_unit(*miibus), "phymask", &phymask) != 0)
phymask = 0xffffffff;
+ bus_topo_lock();
if (device_get_children(*miibus, &children, &nchildren) != 0) {
children = NULL;
nchildren = 0;
@@ -512,6 +515,7 @@
skip:
ivars->mii_offset++;
}
+ bus_topo_unlock();
free(children, M_TEMP);
if (first != 0) {
@@ -527,22 +531,29 @@
rv = ENXIO;
goto fail;
}
+ bus_topo_lock();
rv = bus_generic_attach(dev);
+ bus_topo_unlock();
if (rv != 0)
goto fail;
/* Attaching of the PHY drivers is done in miibus_attach(). */
return (0);
}
+ bus_topo_lock();
rv = bus_generic_attach(*miibus);
+ bus_topo_unlock();
if (rv != 0)
goto fail;
return (0);
fail:
- if (*miibus != NULL)
+ if (*miibus != NULL) {
+ bus_topo_lock();
device_delete_child(dev, *miibus);
+ bus_topo_unlock();
+ }
free(ivars, M_DEVBUF);
if (first != 0)
*miibus = NULL;
Index: sys/dev/mlx/mlx.c
===================================================================
--- sys/dev/mlx/mlx.c
+++ sys/dev/mlx/mlx.c
@@ -830,9 +830,9 @@
* Scan the controller to see whether new drives have appeared.
*/
case MLX_RESCAN_DRIVES:
- mtx_lock(&Giant);
+ bus_topo_lock();
mlx_startup(sc);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return(0);
/*
@@ -979,9 +979,9 @@
case MLX_GET_SYSDRIVE:
error = ENOENT;
MLX_CONFIG_LOCK(sc);
- mtx_lock(&Giant);
+ bus_topo_lock();
mlxd = (struct mlxd_softc *)devclass_get_softc(mlxd_devclass, *arg);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if ((mlxd != NULL) && (mlxd->mlxd_drive >= sc->mlx_sysdrive) &&
(mlxd->mlxd_drive < (sc->mlx_sysdrive + MLX_MAXDRIVES))) {
error = 0;
Index: sys/dev/mlx5/mlx5_core/mlx5_fwdump.c
===================================================================
--- sys/dev/mlx5/mlx5_core/mlx5_fwdump.c
+++ sys/dev/mlx5/mlx5_core/mlx5_fwdump.c
@@ -340,11 +340,11 @@
error = -mlx5_set_mfrl_reg(mdev, MLX5_FRL_LEVEL3);
if (error == 0) {
dev = mdev->pdev->dev.bsddev;
- mtx_lock(&Giant);
+ bus_topo_lock();
bus = device_get_parent(dev);
error = BUS_RESET_CHILD(device_get_parent(bus), bus,
DEVF_RESET_DETACH);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
return (error);
}
Index: sys/dev/mlx5/mlx5_core/mlx5_health.c
===================================================================
--- sys/dev/mlx5/mlx5_core/mlx5_health.c
+++ sys/dev/mlx5/mlx5_core/mlx5_health.c
@@ -374,7 +374,8 @@
priv = container_of(health, struct mlx5_priv, health);
dev = container_of(priv, struct mlx5_core_dev, priv);
- mtx_lock(&Giant); /* XXX newbus needs this */
+ /* This might likely be wrong, cut and paste from elsewhere? */
+ bus_topo_lock();
if (sensor_pci_no_comm(dev)) {
mlx5_core_err(dev,
@@ -401,7 +402,7 @@
mlx5_recover_device(dev);
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
/* How much time to wait until health resetting the driver (in msecs) */
Index: sys/dev/pccard/pccard.c
===================================================================
--- sys/dev/pccard/pccard.c
+++ sys/dev/pccard/pccard.c
@@ -238,7 +238,7 @@
DEVPRINTF((dev, "Card has %d functions. pccard_mfc is %d\n", i + 1,
pccard_mfc(sc)));
- mtx_lock(&Giant);
+ bus_topo_lock();
STAILQ_FOREACH(pf, &sc->card.pf_head, pf_list) {
if (STAILQ_EMPTY(&pf->cfe_head))
continue;
@@ -251,7 +251,7 @@
pf->dev = child;
pccard_probe_and_attach_child(dev, child, pf);
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (0);
}
Index: sys/dev/pci/pci_pci.c
===================================================================
--- sys/dev/pci/pci_pci.c
+++ sys/dev/pci/pci_pci.c
@@ -1397,7 +1397,7 @@
pcib_pcie_cc_timeout, sc);
TIMEOUT_TASK_INIT(taskqueue_pci_hp, &sc->pcie_dll_task, 0,
pcib_pcie_dll_timeout, sc);
- sc->pcie_hp_lock = &Giant;
+ sc->pcie_hp_lock = bus_topo_mtx();
/* Allocate IRQ. */
if (pcib_alloc_pcie_irq(sc) != 0)
Index: sys/dev/pci/pci_user.c
===================================================================
--- sys/dev/pci/pci_user.c
+++ sys/dev/pci/pci_user.c
@@ -1059,8 +1059,8 @@
}
}
- /* Giant because newbus is Giant locked revisit with newbus locking */
- mtx_lock(&Giant);
+ /* Not entirely sure this is correct */
+ bus_topo_lock();
switch (cmd) {
case PCIOCGETCONF:
@@ -1412,7 +1412,7 @@
break;
}
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return (error);
}
Index: sys/dev/sdio/sdiob.c
===================================================================
--- sys/dev/sdio/sdiob.c
+++ sys/dev/sdio/sdiob.c
@@ -945,10 +945,10 @@
return (ENXIO);
}
- mtx_lock(&Giant);
+ bus_topo_lock();
error = devclass_add_driver(bus_devclass, &sdiob_driver,
BUS_PASS_DEFAULT, &sdiob_devclass);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (error != 0) {
printf("%s: Failed to add driver to devclass: %d.\n",
__func__, error);
Index: sys/dev/twe/twe_freebsd.c
===================================================================
--- sys/dev/twe/twe_freebsd.c
+++ sys/dev/twe/twe_freebsd.c
@@ -583,10 +583,10 @@
char buf[80];
int error;
- mtx_lock(&Giant);
+ bus_topo_lock();
dr->td_disk = device_add_child(sc->twe_dev, NULL, -1);
if (dr->td_disk == NULL) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
twe_printf(sc, "Cannot add unit\n");
return (EIO);
}
@@ -603,7 +603,7 @@
device_set_desc_copy(dr->td_disk, buf);
error = device_probe_and_attach(dr->td_disk);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (error != 0) {
twe_printf(sc, "Cannot attach unit to controller. error = %d\n", error);
return (EIO);
@@ -622,9 +622,9 @@
int error = 0;
TWE_CONFIG_ASSERT_LOCKED(sc);
- mtx_lock(&Giant);
+ bus_topo_lock();
error = device_delete_child(sc->twe_dev, sc->twe_drive[unit].td_disk);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (error != 0) {
twe_printf(sc, "failed to delete unit %d\n", unit);
return(error);
Index: sys/dev/usb/controller/usb_controller.c
===================================================================
--- sys/dev/usb/controller/usb_controller.c
+++ sys/dev/usb/controller/usb_controller.c
@@ -438,9 +438,9 @@
USB_BUS_UNLOCK(bus);
/* detach children first */
- mtx_lock(&Giant);
+ bus_topo_lock();
bus_generic_detach(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
/*
* Free USB device and all subdevices, if any.
@@ -803,10 +803,10 @@
static void
usb_attach_sub(device_t dev, struct usb_bus *bus)
{
- mtx_lock(&Giant);
+ bus_topo_lock();
if (usb_devclass_ptr == NULL)
usb_devclass_ptr = devclass_find("usbus");
- mtx_unlock(&Giant);
+ bus_topo_unlock();
#if USB_HAVE_PF
usbpf_attach(bus);
Index: sys/dev/usb/net/if_axe.c
===================================================================
--- sys/dev/usb/net/if_axe.c
+++ sys/dev/usb/net/if_axe.c
@@ -904,11 +904,9 @@
adv_pause = MIIF_DOPAUSE;
else
adv_pause = 0;
- mtx_lock(&Giant);
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts,
BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, adv_pause);
- mtx_unlock(&Giant);
return (error);
}
Index: sys/dev/usb/net/if_axge.c
===================================================================
--- sys/dev/usb/net/if_axge.c
+++ sys/dev/usb/net/if_axge.c
@@ -470,11 +470,9 @@
ifp->if_hwassist = AXGE_CSUM_FEATURES;
ifp->if_capenable = ifp->if_capabilities;
- mtx_lock(&Giant);
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts,
BMSR_DEFCAPMASK, AXGE_PHY_ADDR, MII_OFFSET_ANY, MIIF_DOPAUSE);
- mtx_unlock(&Giant);
return (error);
}
Index: sys/dev/usb/net/if_muge.c
===================================================================
--- sys/dev/usb/net/if_muge.c
+++ sys/dev/usb/net/if_muge.c
@@ -1638,11 +1638,9 @@
ifp->if_capenable = ifp->if_capabilities;
- mtx_lock(&Giant);
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp, uether_ifmedia_upd,
ue->ue_methods->ue_mii_sts, BMSR_DEFCAPMASK, sc->sc_phyno,
MII_OFFSET_ANY, 0);
- mtx_unlock(&Giant);
return (0);
}
Index: sys/dev/usb/net/if_smsc.c
===================================================================
--- sys/dev/usb/net/if_smsc.c
+++ sys/dev/usb/net/if_smsc.c
@@ -1641,11 +1641,9 @@
ifp->if_capenable = ifp->if_capabilities;
- mtx_lock(&Giant);
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts,
BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0);
- mtx_unlock(&Giant);
return (error);
}
Index: sys/dev/usb/net/if_ure.c
===================================================================
--- sys/dev/usb/net/if_ure.c
+++ sys/dev/usb/net/if_ure.c
@@ -1014,7 +1014,6 @@
#endif
if_setcapenable(ifp, if_getcapabilities(ifp));
- mtx_lock(&Giant);
if (sc->sc_flags & (URE_FLAG_8156 | URE_FLAG_8156B)) {
ifmedia_init(&sc->sc_ifmedia, IFM_IMASK, ure_ifmedia_upd,
ure_ifmedia_sts);
@@ -1028,7 +1027,6 @@
uether_ifmedia_upd, ue->ue_methods->ue_mii_sts,
BMSR_DEFCAPMASK, sc->sc_phyno, MII_OFFSET_ANY, 0);
}
- mtx_unlock(&Giant);
sctx = device_get_sysctl_ctx(sc->sc_ue.ue_dev);
soid = device_get_sysctl_tree(sc->sc_ue.ue_dev);
Index: sys/dev/usb/net/usb_ethernet.c
===================================================================
--- sys/dev/usb/net/usb_ethernet.c
+++ sys/dev/usb/net/usb_ethernet.c
@@ -249,12 +249,9 @@
if (ue->ue_methods->ue_mii_upd != NULL &&
ue->ue_methods->ue_mii_sts != NULL) {
- /* device_xxx() depends on this */
- mtx_lock(&Giant);
error = mii_attach(ue->ue_dev, &ue->ue_miibus, ifp,
ue_ifmedia_upd, ue->ue_methods->ue_mii_sts,
BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0);
- mtx_unlock(&Giant);
}
}
@@ -327,9 +324,9 @@
/* detach miibus */
if (ue->ue_miibus != NULL) {
- mtx_lock(&Giant); /* device_xxx() depends on this */
+ bus_topo_lock();
device_delete_child(ue->ue_dev, ue->ue_miibus);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
/* free interface instance */
Index: sys/dev/usb/usb_device.c
===================================================================
--- sys/dev/usb/usb_device.c
+++ sys/dev/usb/usb_device.c
@@ -2902,7 +2902,7 @@
* are locked before locking Giant. Else the lock can be
* locked multiple times.
*/
- mtx_lock(&Giant);
+ bus_topo_lock();
return (1);
}
@@ -2922,7 +2922,7 @@
sx_xunlock(&udev->enum_sx);
return (255);
}
- mtx_lock(&Giant);
+ bus_topo_lock();
return (1);
}
#endif
@@ -2932,7 +2932,7 @@
void
usbd_enum_unlock(struct usb_device *udev)
{
- mtx_unlock(&Giant);
+ bus_topo_unlock();
sx_xunlock(&udev->enum_sx);
sx_xunlock(&udev->sr_sx);
}
@@ -2948,7 +2948,7 @@
* are locked before locking Giant. Else the lock can be
* locked multiple times.
*/
- mtx_lock(&Giant);
+ bus_topo_lock();
}
/* The following function unlocks suspend and resume. */
@@ -2956,7 +2956,7 @@
void
usbd_sr_unlock(struct usb_device *udev)
{
- mtx_unlock(&Giant);
+ bus_topo_unlock();
sx_xunlock(&udev->sr_sx);
}
Index: sys/dev/xen/control/control.c
===================================================================
--- sys/dev/xen/control/control.c
+++ sys/dev/xen/control/control.c
@@ -232,12 +232,11 @@
KASSERT((PCPU_GET(cpuid) == 0), ("Not running on CPU#0"));
/*
- * Be sure to hold Giant across DEVICE_SUSPEND/RESUME since non-MPSAFE
- * drivers need this.
+ * Be sure to hold Giant across DEVICE_SUSPEND/RESUME.
*/
- mtx_lock(&Giant);
+ bus_topo_lock();
if (DEVICE_SUSPEND(root_bus) != 0) {
- mtx_unlock(&Giant);
+ bus_topo_unlock();
printf("%s: device_suspend failed\n", __func__);
return;
}
@@ -310,7 +309,7 @@
* similar.
*/
DEVICE_RESUME(root_bus);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
/*
* Warm up timecounter again and reset system clock.
Index: sys/dev/xen/pcifront/pcifront.c
===================================================================
--- sys/dev/xen/pcifront/pcifront.c
+++ sys/dev/xen/pcifront/pcifront.c
@@ -273,9 +273,9 @@
printf("pcifront: connected to %s\n", pdev->xdev->nodename);
- mtx_lock(&Giant);
+ bus_topo_lock();
device_probe_and_attach(pdev->ndev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
return 0;
}
Index: sys/kern/subr_bus.c
===================================================================
--- sys/kern/subr_bus.c
+++ sys/kern/subr_bus.c
@@ -864,6 +864,27 @@
DEFINE_CLASS(null, null_methods, 0);
+struct mtx *
+bus_topo_mtx(void)
+{
+
+ return (&Giant);
+}
+
+void
+bus_topo_lock(void)
+{
+
+ mtx_lock(bus_topo_mtx());
+}
+
+void
+bus_topo_unlock(void)
+{
+
+ mtx_unlock(bus_topo_mtx());
+}
+
/*
* Bus pass implementation
*/
Index: sys/net/iflib_clone.c
===================================================================
--- sys/net/iflib_clone.c
+++ sys/net/iflib_clone.c
@@ -182,9 +182,9 @@
if (__predict_false(iflib_pseudodev == NULL)) {
/* SYSINIT initialization would panic !?! */
- mtx_lock(&Giant);
+ bus_topo_lock();
iflib_pseudodev = device_add_child(root_bus, "ifpseudo", 0);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
MPASS(iflib_pseudodev != NULL);
}
ip = iflib_ip_lookup(name);
@@ -208,9 +208,9 @@
MPASS(devclass_get_device(ip->ip_dc, unit) == dev);
rc = iflib_pseudo_register(dev, ip->ip_sctx, &ctx, &clctx);
if (rc) {
- mtx_lock(&Giant);
+ bus_topo_lock();
device_delete_child(iflib_pseudodev, dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
} else
device_set_softc(dev, ctx);
@@ -236,9 +236,9 @@
iflib_stop(ctx);
sx_xunlock(ctx_lock);
- mtx_lock(&Giant);
+ bus_topo_lock();
rc = device_delete_child(iflib_pseudodev, dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
if (rc == 0)
iflib_pseudo_deregister(ctx);
}
Index: sys/sys/bus.h
===================================================================
--- sys/sys/bus.h
+++ sys/sys/bus.h
@@ -735,6 +735,14 @@
void bus_set_pass(int pass);
+/**
+ * Routines to lock / unlock the newbus lock.
+ * Must be taken out to interact with newbus.
+ */
+void bus_topo_lock(void);
+void bus_topo_unlock(void);
+struct mtx * bus_topo_mtx(void);
+
/**
* Shorthands for constructing method tables.
*/
@@ -765,7 +773,7 @@
#define EARLY_DRIVER_MODULE_ORDERED(name, busname, driver, devclass, \
evh, arg, order, pass) \
- \
+ \
static struct driver_module_data name##_##busname##_driver_mod = { \
evh, arg, \
#busname, \
Index: sys/xen/xenbus/xenbusb.c
===================================================================
--- sys/xen/xenbus/xenbusb.c
+++ sys/xen/xenbus/xenbusb.c
@@ -533,12 +533,9 @@
{
device_t dev = (device_t)arg;
- /*
- * Hold Giant until the Giant free newbus changes are committed.
- */
- mtx_lock(&Giant);
+ bus_topo_lock();
xenbusb_probe_children(dev);
- mtx_unlock(&Giant);
+ bus_topo_unlock();
}
/**
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 12, 10:42 AM (3 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
26894436
Default Alt Text
D31831.id94648.diff (27 KB)
Attached To
Mode
D31831: Create wrapper for Giant taken for newbus
Attached
Detach File
Event Timeline
Log In to Comment