freebsd_network: Move up Giant ownership during attach.
device_attach can be recursed for MIIbus drivers, so avoid the complexity and lock Giant from init_drivers() instead.
This commit is contained in:
@@ -481,9 +481,6 @@ device_attach(device_t device)
|
|||||||
|| device->methods.attach == NULL)
|
|| device->methods.attach == NULL)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
// Always hold the giant lock during attach.
|
|
||||||
mtx_lock(&Giant);
|
|
||||||
|
|
||||||
result = device->methods.attach(device);
|
result = device->methods.attach(device);
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
@@ -492,7 +489,6 @@ device_attach(device_t device)
|
|||||||
if (result == 0 && HAIKU_DRIVER_REQUIRES(FBSD_WLAN_FEATURE))
|
if (result == 0 && HAIKU_DRIVER_REQUIRES(FBSD_WLAN_FEATURE))
|
||||||
result = start_wlan(device);
|
result = start_wlan(device);
|
||||||
|
|
||||||
mtx_unlock(&Giant);
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -310,6 +310,9 @@ _fbsd_init_drivers()
|
|||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
goto err6;
|
goto err6;
|
||||||
|
|
||||||
|
// Always hold the giant lock during attach.
|
||||||
|
mtx_lock(&Giant);
|
||||||
|
|
||||||
for (int p = 0; sProbedDevices[p].bus != BUS_INVALID; p++) {
|
for (int p = 0; sProbedDevices[p].bus != BUS_INVALID; p++) {
|
||||||
device_t root, device = NULL;
|
device_t root, device = NULL;
|
||||||
status = init_root_device(&root, sProbedDevices[p].bus);
|
status = init_root_device(&root, sProbedDevices[p].bus);
|
||||||
@@ -341,6 +344,8 @@ _fbsd_init_drivers()
|
|||||||
device_delete_child(NULL, root);
|
device_delete_child(NULL, root);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mtx_unlock(&Giant);
|
||||||
|
|
||||||
if (gDeviceCount > 0)
|
if (gDeviceCount > 0)
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user