Skip to content

Commit

Permalink
ACPI / scan: Change ordering of locks for device hotplug
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Rafael J. Wysocki committed Aug 31, 2013
1 parent f943db4 commit e0ae8fe
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
return -EINVAL;
}

lock_device_hotplug();

/*
* Carry out two passes here and ignore errors in the first pass,
* because if the devices in question are memory blocks and
Expand Down Expand Up @@ -239,9 +237,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)
ACPI_UINT32_MAX,
acpi_bus_online_companions, NULL,
NULL, NULL);

unlock_device_hotplug();

put_device(&device->dev);
return -EBUSY;
}
Expand All @@ -252,8 +247,6 @@ static int acpi_scan_hot_remove(struct acpi_device *device)

acpi_bus_trim(device);

unlock_device_hotplug();

/* Device node has been unregistered. */
put_device(&device->dev);
device = NULL;
Expand Down Expand Up @@ -309,6 +302,7 @@ static void acpi_bus_device_eject(void *context)
u32 ost_code = ACPI_OST_SC_NON_SPECIFIC_FAILURE;
int error;

lock_device_hotplug();
mutex_lock(&acpi_scan_lock);

acpi_bus_get_device(handle, &device);
Expand All @@ -332,6 +326,7 @@ static void acpi_bus_device_eject(void *context)

out:
mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
return;

err_out:
Expand All @@ -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;
int error;

mutex_lock(&acpi_scan_lock);
lock_device_hotplug();
mutex_lock(&acpi_scan_lock);

if (ost_source != ACPI_NOTIFY_BUS_CHECK) {
acpi_bus_get_device(handle, &device);
Expand All @@ -373,9 +368,9 @@ static void acpi_scan_bus_device_check(acpi_handle handle, u32 ost_source)
kobject_uevent(&device->dev.kobj, KOBJ_ONLINE);

out:
unlock_device_hotplug();
acpi_evaluate_hotplug_ost(handle, ost_source, ost_code, NULL);
mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
}

static void acpi_scan_bus_check(void *context)
Expand Down Expand Up @@ -466,6 +461,7 @@ void acpi_bus_hot_remove_device(void *context)
acpi_handle handle = device->handle;
int error;

lock_device_hotplug();
mutex_lock(&acpi_scan_lock);

error = acpi_scan_hot_remove(device);
Expand All @@ -475,6 +471,7 @@ void acpi_bus_hot_remove_device(void *context)
NULL);

mutex_unlock(&acpi_scan_lock);
unlock_device_hotplug();
kfree(context);
}
EXPORT_SYMBOL(acpi_bus_hot_remove_device);
Expand Down

0 comments on commit e0ae8fe

Please sign in to comment.