PCI: properly clean up ASPM link state on device remove
authorAlex Chiang <achiang@hp.com>
Wed, 28 Jan 2009 21:59:18 +0000 (14:59 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 12 Feb 2009 17:31:10 +0000 (09:31 -0800)
commitca9e7b96abf17668950e16329b6e6c9233d72653
treea32b2a7fb26a7db972dd25b29ee7d11659d5171b
parent3c77819ac0e056ea17fab8bfe7ee0ed34e3ad584
PCI: properly clean up ASPM link state on device remove

commit 3419c75e15f82c3ab09bd944fddbde72c9e4b3ea upstream.

We only want to disable ASPM when the last function is removed from
the parent's device list. We determine this by checking to see if
the parent's device list is completely empty.

Unfortunately, we never hit that code because the parent is considered
an upstream port, and never had an ASPM link_state associated with it.

The early check for !link_state causes us to return early, we never
discover that our device list is empty, and thus we never remove the
downstream ports' link_state nodes.

Instead of checking to see if the parent's device list is empty, we can
check to see if we are the last device on the list, and if so, then we
know that we can clean up properly.

Cc: Shaohua Li <shaohua.li@intel.com>
Signed-off-by: Alex Chiang <achiang@hp.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/pcie/aspm.c