diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2009-01-07 07:03:42 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-01-07 14:14:40 -0500 |
commit | fa58d305d9925b01830e535896a7227a868a9e15 (patch) | |
tree | 6b0509663958c9fc6c3b201e6a3b061af784ffa9 /drivers/pci/pci.c | |
parent | c9b9972b3c88272be02d971346285d1c67fbb95f (diff) |
PCI PM: Add suspend counterpart of pci_reenable_device
PCI devices without drivers are not disabled during suspend and
hibernation, but they are enabled during resume, with the help of
pci_reenable_device(), so there is an unbalanced execution of
pcibios_enable_device() in the resume code path.
To correct this introduce function pci_disable_enabled_device()
that will disable the argument device, if it is enabled when the
function is being run, without updating the device's pci_dev
structure and use it in the suspend code path to balance the
pci_reenable_device() executed during resume.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@suse.cz>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r-- | drivers/pci/pci.c | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index f3fd55df67d..6e309c8b47d 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -970,6 +970,32 @@ void pcim_pin_device(struct pci_dev *pdev) | |||
970 | */ | 970 | */ |
971 | void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {} | 971 | void __attribute__ ((weak)) pcibios_disable_device (struct pci_dev *dev) {} |
972 | 972 | ||
973 | static void do_pci_disable_device(struct pci_dev *dev) | ||
974 | { | ||
975 | u16 pci_command; | ||
976 | |||
977 | pci_read_config_word(dev, PCI_COMMAND, &pci_command); | ||
978 | if (pci_command & PCI_COMMAND_MASTER) { | ||
979 | pci_command &= ~PCI_COMMAND_MASTER; | ||
980 | pci_write_config_word(dev, PCI_COMMAND, pci_command); | ||
981 | } | ||
982 | |||
983 | pcibios_disable_device(dev); | ||
984 | } | ||
985 | |||
986 | /** | ||
987 | * pci_disable_enabled_device - Disable device without updating enable_cnt | ||
988 | * @dev: PCI device to disable | ||
989 | * | ||
990 | * NOTE: This function is a backend of PCI power management routines and is | ||
991 | * not supposed to be called drivers. | ||
992 | */ | ||
993 | void pci_disable_enabled_device(struct pci_dev *dev) | ||
994 | { | ||
995 | if (atomic_read(&dev->enable_cnt)) | ||
996 | do_pci_disable_device(dev); | ||
997 | } | ||
998 | |||
973 | /** | 999 | /** |
974 | * pci_disable_device - Disable PCI device after use | 1000 | * pci_disable_device - Disable PCI device after use |
975 | * @dev: PCI device to be disabled | 1001 | * @dev: PCI device to be disabled |
@@ -984,7 +1010,6 @@ void | |||
984 | pci_disable_device(struct pci_dev *dev) | 1010 | pci_disable_device(struct pci_dev *dev) |
985 | { | 1011 | { |
986 | struct pci_devres *dr; | 1012 | struct pci_devres *dr; |
987 | u16 pci_command; | ||
988 | 1013 | ||
989 | dr = find_pci_dr(dev); | 1014 | dr = find_pci_dr(dev); |
990 | if (dr) | 1015 | if (dr) |
@@ -993,14 +1018,9 @@ pci_disable_device(struct pci_dev *dev) | |||
993 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) | 1018 | if (atomic_sub_return(1, &dev->enable_cnt) != 0) |
994 | return; | 1019 | return; |
995 | 1020 | ||
996 | pci_read_config_word(dev, PCI_COMMAND, &pci_command); | 1021 | do_pci_disable_device(dev); |
997 | if (pci_command & PCI_COMMAND_MASTER) { | ||
998 | pci_command &= ~PCI_COMMAND_MASTER; | ||
999 | pci_write_config_word(dev, PCI_COMMAND, pci_command); | ||
1000 | } | ||
1001 | dev->is_busmaster = 0; | ||
1002 | 1022 | ||
1003 | pcibios_disable_device(dev); | 1023 | dev->is_busmaster = 0; |
1004 | } | 1024 | } |
1005 | 1025 | ||
1006 | /** | 1026 | /** |