]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
PCI/ASPM: Fix link_state teardown on device removal
authorLukas Wunner <lukas@wunner.de>
Tue, 4 Sep 2018 17:34:18 +0000 (12:34 -0500)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:57:19 +0000 (19:57 -0600)
commit9ee7f2c62daf7919926fe8d039ccc23b0d41252f
tree1390d226c0fee39ca127802cebbac37fb0ad7153
parenta6f7488a271a19628babfc49ec2eba37611354ab
PCI/ASPM: Fix link_state teardown on device removal

BugLink: https://bugs.launchpad.net/bugs/1836802
commit aeae4f3e5c38d47bdaef50446dc0ec857307df68 upstream.

Upon removal of the last device on a bus, the link_state of the bridge
leading to that bus is sought to be torn down by having pci_stop_dev()
call pcie_aspm_exit_link_state().

When ASPM was originally introduced by commit 7d715a6c1ae5 ("PCI: add
PCI Express ASPM support"), it determined whether the device being
removed is the last one by calling list_empty() on the bridge's
subordinate devices list.  That didn't work because the device is only
removed from the list slightly later in pci_destroy_dev().

Commit 3419c75e15f8 ("PCI: properly clean up ASPM link state on device
remove") attempted to fix it by calling list_is_last(), but that's not
correct either because it checks whether the device is at the *end* of
the list, not whether it's the last one *left* in the list.  If the user
removes the device which happens to be at the end of the list via sysfs
but other devices are preceding the device in the list, the link_state
is torn down prematurely.

The real fix is to move the invocation of pcie_aspm_exit_link_state() to
pci_destroy_dev() and reinstate the call to list_empty().  Remove a
duplicate check for dev->bus->self because pcie_aspm_exit_link_state()
already contains an identical check.

Fixes: 7d715a6c1ae5 ("PCI: add PCI Express ASPM support")
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Shaohua Li <shaohua.li@intel.com>
Cc: stable@vger.kernel.org # v2.6.26
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/pci/pcie/aspm.c
drivers/pci/remove.c