Commit e0ae8fee authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI / scan: Change ordering of locks for device hotplug

Change the ordering of device hotplug locks in scan.c so that
acpi_scan_lock is always acquired after device_hotplug_lock.

This will make it possible to use device_hotplug_lock around some
code paths that acquire acpi_scan_lock safely (most importantly
system suspend and hibernation).  Apart from that, acpi_scan_lock
is platform-specific and device_hotplug_lock is general, so the
new ordering appears to be more appropriate from the overall
design viewpoint.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: default avatarToshi Kani <toshi.kani@hp.com>
parent f943db40
...@@ -207,8 +207,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) ...@@ -207,8 +207,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
return -EINVAL; return -EINVAL;
} }
lock_device_hotplug();
/* /*
* Carry out two passes here and ignore errors in the first pass, * Carry out two passes here and ignore errors in the first pass,
* because if the devices in question are memory blocks and * because if the devices in question are memory blocks and
...@@ -239,9 +237,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) ...@@ -239,9 +237,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
ACPI_UINT32_MAX, ACPI_UINT32_MAX,
acpi_bus_online_companions, NULL, acpi_bus_online_companions, NULL,
NULL, NULL); NULL, NULL);
unlock_device_hotplug();
put_device(&device->dev); put_device(&device->dev);
return -EBUSY; return -EBUSY;
} }
...@@ -252,8 +247,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) ...@@ -252,8 +247,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
acpi_bus_trim(device); acpi_bus_trim(device);
unlock_device_hotplug();
/* Device node has been unregistered. */ /* Device node has been unregistered. */
put_device(&device->dev); put_device(&device->dev);
device = NULL; device = NULL;
...@@ -309,6 +302,7 @@ static void acpi_bus_device_eject(void *context) ...@@ -309,6 +302,7 @@ static void acpi_bus_device_eject(void *context)
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
int error; int error;
lock_device_hotplug();
mutex_lock(&acpi_scan_lock); mutex_lock(&acpi_scan_lock);
acpi_bus_get_device(handle, &device); acpi_bus_get_device(handle, &device);
...@@ -332,6 +326,7 @@ static void acpi_bus_device_eject(void *context) ...@@ -332,6 +326,7 @@ static void acpi_bus_device_eject(void *context)
out: out:
mutex_unlock(&acpi_scan_lock); mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
return; return;
err_out: err_out:
...@@ -346,8 +341,8 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) ...@@ -346,8 +341,8 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
int error; int error;
mutex_lock(&acpi_scan_lock);
lock_device_hotplug(); lock_device_hotplug();
mutex_lock(&acpi_scan_lock);
if (ost_source != ACPI_NOTIFY_BUS_CHECK) { if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
acpi_bus_get_device(handle, &device); acpi_bus_get_device(handle, &device);
...@@ -373,9 +368,9 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) ...@@ -373,9 +368,9 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);
out: out:
unlock_device_hotplug();
acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
mutex_unlock(&acpi_scan_lock); mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
} }
static void acpi_scan_bus_check(void *context) static void acpi_scan_bus_check(void *context)
...@@ -466,6 +461,7 @@ void acpi_bus_hot_remove_device(void *context) ...@@ -466,6 +461,7 @@ void acpi_bus_hot_remove_device(void *context)
acpi_handle handle = device->handle; acpi_handle handle = device->handle;
int error; int error;
lock_device_hotplug();
mutex_lock(&acpi_scan_lock); mutex_lock(&acpi_scan_lock);
error = acpi_scan_hot_remove(device); error = acpi_scan_hot_remove(device);
...@@ -475,6 +471,7 @@ void acpi_bus_hot_remove_device(void *context) ...@@ -475,6 +471,7 @@ void acpi_bus_hot_remove_device(void *context)
NULL); NULL);
mutex_unlock(&acpi_scan_lock); mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
kfree(context); kfree(context);
} }
EXPORT_SYMBOL(acpi_bus_hot_remove_device); EXPORT_SYMBOL(acpi_bus_hot_remove_device);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment