Skip to content

Commit

Permalink
PCI/PM: Clean up PME state when removing a device
Browse files Browse the repository at this point in the history
Devices are added to pci_pme_list when drivers use pci_enable_wake()
or pci_wake_from_d3(), but they aren't removed from the list unless
the driver explicitly disables wakeup.  Many drivers never disable
wakeup, so their devices remain on the list even after they are
removed, e.g., via hotplug.  A subsequent PME poll will oops when
it tries to touch the device.

This patch disables PME# on a device before removing it, which removes
the device from pci_pme_list.  This is safe even if the device never
had PME# enabled.

This oops can be triggered by unplugging a Thunderbolt ethernet adapter
on a Macbook Pro, as reported by Daniel below.

[bhelgaas: changelog]
Reference: http://lkml.kernel.org/r/CAMVG2svG21yiM1wkH4_2pen2n+cr2-Zv7TbH3Gj+8MwevZjDbw@mail.gmail.com
Reported-and-tested-by: Daniel J Blueman <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
CC: [email protected]
  • Loading branch information
rjwysocki authored and bjorn-helgaas committed Feb 13, 2013
1 parent 444ee9b commit 249bfb8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/pci/remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ static void pci_free_resources(struct pci_dev *dev)

static void pci_stop_dev(struct pci_dev *dev)
{
pci_pme_active(dev, false);

if (dev->is_added) {
pci_proc_detach_device(dev);
pci_remove_sysfs_dev_files(dev);
Expand Down

0 comments on commit 249bfb8

Please sign in to comment.