Skip to content

Commit

Permalink
ACPI / hotplug / PCI: Move PCI rescan-remove locking to hotplug_event()
Browse files Browse the repository at this point in the history
Commit 9217a98 (ACPI / hotplug / PCI: Use global PCI rescan-remove
locking) modified ACPIPHP to protect its PCI device removal and addition
code paths from races against sysfs-driven rescan and remove operations
with the help of PCI rescan-remove locking.  However, it overlooked the
fact that hotplug_event_work() is not the only caller of hotplug_event()
which may also be called by dock_hotplug_event() and that code path
is missing the PCI rescan-remove locking.  This means that, although
the PCI rescan-remove lock is held as appropriate during the handling
of events originating from handle_hotplug_event(), the ACPIPHP's
operations resulting from dock events may still suffer the race
conditions that commit 9217a98 was supposed to eliminate.

To address that problem, move the PCI rescan-remove locking from
hotplug_event_work() to hotplug_event() so that it is used regardless
of the way that function is invoked.

Revamps: 9217a98 (ACPI / hotplug / PCI: Use global PCI rescan-remove locking)
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
  • Loading branch information
Rafael J. Wysocki committed Feb 3, 2014
1 parent 2d7c1b7 commit f41b326
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/pci/hotplug/acpiphp_glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)

mutex_unlock(&acpiphp_context_lock);

pci_lock_rescan_remove();
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);

switch (type) {
Expand Down Expand Up @@ -905,6 +906,7 @@ static void hotplug_event(acpi_handle handle, u32 type, void *data)
break;
}

pci_unlock_rescan_remove();
if (bridge)
put_bridge(bridge);
}
Expand All @@ -915,11 +917,9 @@ static void hotplug_event_work(void *data, u32 type)
acpi_handle handle = context->handle;

acpi_scan_lock_acquire();
pci_lock_rescan_remove();

hotplug_event(handle, type, context);

pci_unlock_rescan_remove();
acpi_scan_lock_release();
acpi_evaluate_hotplug_ost(handle, type, ACPI_OST_SC_SUCCESS, NULL);
put_bridge(context->func.parent);
Expand Down

0 comments on commit f41b326

Please sign in to comment.