diff options
author | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-30 08:19:29 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-30 20:30:14 -0400 |
commit | e0ae8fee0e11c1a8e9b45ab14ab5fe58d87f031d (patch) | |
tree | 7ee9af50facb90a7c683cd0de10a32e7dd640479 /drivers/acpi/scan.c | |
parent | f943db40c29f3c82a56956e9ca36f21d6d855db9 (diff) |
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: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Toshi Kani <toshi.kani@hp.com>
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r-- | drivers/acpi/scan.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index e2f6d9dbdf0d..42982b522b36 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
@@ -207,8 +207,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
207 | return -EINVAL; | 207 | return -EINVAL; |
208 | } | 208 | } |
209 | 209 | ||
210 | lock_device_hotplug(); | ||
211 | |||
212 | /* | 210 | /* |
213 | * Carry out two passes here and ignore errors in the first pass, | 211 | * Carry out two passes here and ignore errors in the first pass, |
214 | * because if the devices in question are memory blocks and | 212 | * 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 | ACPI_UINT32_MAX, | 237 | ACPI_UINT32_MAX, |
240 | acpi_bus_online_companions, NULL, | 238 | acpi_bus_online_companions, NULL, |
241 | NULL, NULL); | 239 | NULL, NULL); |
242 | |||
243 | unlock_device_hotplug(); | ||
244 | |||
245 | put_device(&device->dev); | 240 | put_device(&device->dev); |
246 | return -EBUSY; | 241 | return -EBUSY; |
247 | } | 242 | } |
@@ -252,8 +247,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device) | |||
252 | 247 | ||
253 | acpi_bus_trim(device); | 248 | acpi_bus_trim(device); |
254 | 249 | ||
255 | unlock_device_hotplug(); | ||
256 | |||
257 | /* Device node has been unregistered. */ | 250 | /* Device node has been unregistered. */ |
258 | put_device(&device->dev); | 251 | put_device(&device->dev); |
259 | device = NULL; | 252 | device = NULL; |
@@ -309,6 +302,7 @@ static void acpi_bus_device_eject(void *context) | |||
309 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 302 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; |
310 | int error; | 303 | int error; |
311 | 304 | ||
305 | lock_device_hotplug(); | ||
312 | mutex_lock(&acpi_scan_lock); | 306 | mutex_lock(&acpi_scan_lock); |
313 | 307 | ||
314 | acpi_bus_get_device(handle, &device); | 308 | acpi_bus_get_device(handle, &device); |
@@ -332,6 +326,7 @@ static void acpi_bus_device_eject(void *context) | |||
332 | 326 | ||
333 | out: | 327 | out: |
334 | mutex_unlock(&acpi_scan_lock); | 328 | mutex_unlock(&acpi_scan_lock); |
329 | unlock_device_hotplug(); | ||
335 | return; | 330 | return; |
336 | 331 | ||
337 | err_out: | 332 | err_out: |
@@ -346,8 +341,8 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) | |||
346 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; | 341 | u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE; |
347 | int error; | 342 | int error; |
348 | 343 | ||
349 | mutex_lock(&acpi_scan_lock); | ||
350 | lock_device_hotplug(); | 344 | lock_device_hotplug(); |
345 | mutex_lock(&acpi_scan_lock); | ||
351 | 346 | ||
352 | if (ost_source != ACPI_NOTIFY_BUS_CHECK) { | 347 | if (ost_source != ACPI_NOTIFY_BUS_CHECK) { |
353 | acpi_bus_get_device(handle, &device); | 348 | acpi_bus_get_device(handle, &device); |
@@ -373,9 +368,9 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source) | |||
373 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); | 368 | kobject_uevent(&device->dev.kobj, KOBJ_ONLINE); |
374 | 369 | ||
375 | out: | 370 | out: |
376 | unlock_device_hotplug(); | ||
377 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); | 371 | acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL); |
378 | mutex_unlock(&acpi_scan_lock); | 372 | mutex_unlock(&acpi_scan_lock); |
373 | unlock_device_hotplug(); | ||
379 | } | 374 | } |
380 | 375 | ||
381 | static void acpi_scan_bus_check(void *context) | 376 | static void acpi_scan_bus_check(void *context) |
@@ -466,6 +461,7 @@ void acpi_bus_hot_remove_device(void *context) | |||
466 | acpi_handle handle = device->handle; | 461 | acpi_handle handle = device->handle; |
467 | int error; | 462 | int error; |
468 | 463 | ||
464 | lock_device_hotplug(); | ||
469 | mutex_lock(&acpi_scan_lock); | 465 | mutex_lock(&acpi_scan_lock); |
470 | 466 | ||
471 | error = acpi_scan_hot_remove(device); | 467 | error = acpi_scan_hot_remove(device); |
@@ -475,6 +471,7 @@ void acpi_bus_hot_remove_device(void *context) | |||
475 | NULL); | 471 | NULL); |
476 | 472 | ||
477 | mutex_unlock(&acpi_scan_lock); | 473 | mutex_unlock(&acpi_scan_lock); |
474 | unlock_device_hotplug(); | ||
478 | kfree(context); | 475 | kfree(context); |
479 | } | 476 | } |
480 | EXPORT_SYMBOL(acpi_bus_hot_remove_device); | 477 | EXPORT_SYMBOL(acpi_bus_hot_remove_device); |