aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2013-02-12 15:42:36 -0500
committerBjorn Helgaas <bhelgaas@google.com>2013-02-12 15:42:36 -0500
commit20f24208f631141bafe57ce5bcc8f2e7f3c41aae (patch)
tree6220d9be56bb9e8dd1154f34905671fbf06d35b1 /drivers/pci
parentf2dfcde4ccd101fa3ba8f6c27273a0e359ea9c9c (diff)
parent82fee4d67ab86d6fe5eb0f9a9e988ca9d654d765 (diff)
Merge branch 'pci/konstantin-runtime-pm' into next
* pci/konstantin-runtime-pm: PCI/PM: Clear state_saved during suspend PCI: Use atomic_inc_return() rather than atomic_add_return() PCI: Catch attempts to disable already-disabled devices PCI: Disable Bus Master unconditionally in pci_device_shutdown()
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-driver.c6
-rw-r--r--drivers/pci/pci.c7
2 files changed, 10 insertions, 3 deletions
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index acdcc3c6ecdd..1fa1e482a999 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -392,7 +392,7 @@ static void pci_device_shutdown(struct device *dev)
392 * Turn off Bus Master bit on the device to tell it to not 392 * Turn off Bus Master bit on the device to tell it to not
393 * continue to do DMA 393 * continue to do DMA
394 */ 394 */
395 pci_disable_device(pci_dev); 395 pci_clear_master(pci_dev);
396} 396}
397 397
398#ifdef CONFIG_PM 398#ifdef CONFIG_PM
@@ -628,6 +628,7 @@ static int pci_pm_suspend(struct device *dev)
628 goto Fixup; 628 goto Fixup;
629 } 629 }
630 630
631 pci_dev->state_saved = false;
631 if (pm->suspend) { 632 if (pm->suspend) {
632 pci_power_t prev = pci_dev->current_state; 633 pci_power_t prev = pci_dev->current_state;
633 int error; 634 int error;
@@ -774,6 +775,7 @@ static int pci_pm_freeze(struct device *dev)
774 return 0; 775 return 0;
775 } 776 }
776 777
778 pci_dev->state_saved = false;
777 if (pm->freeze) { 779 if (pm->freeze) {
778 int error; 780 int error;
779 781
@@ -862,6 +864,7 @@ static int pci_pm_poweroff(struct device *dev)
862 goto Fixup; 864 goto Fixup;
863 } 865 }
864 866
867 pci_dev->state_saved = false;
865 if (pm->poweroff) { 868 if (pm->poweroff) {
866 int error; 869 int error;
867 870
@@ -987,6 +990,7 @@ static int pci_pm_runtime_suspend(struct device *dev)
987 if (!pm || !pm->runtime_suspend) 990 if (!pm || !pm->runtime_suspend)
988 return -ENOSYS; 991 return -ENOSYS;
989 992
993 pci_dev->state_saved = false;
990 pci_dev->no_d3cold = false; 994 pci_dev->no_d3cold = false;
991 error = pm->runtime_suspend(dev); 995 error = pm->runtime_suspend(dev);
992 suspend_report_result(pm->runtime_suspend, error); 996 suspend_report_result(pm->runtime_suspend, error);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 393cf095a0c4..924e4665bd57 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1168,7 +1168,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
1168 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK); 1168 dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
1169 } 1169 }
1170 1170
1171 if (atomic_add_return(1, &dev->enable_cnt) > 1) 1171 if (atomic_inc_return(&dev->enable_cnt) > 1)
1172 return 0; /* already enabled */ 1172 return 0; /* already enabled */
1173 1173
1174 /* only skip sriov related */ 1174 /* only skip sriov related */
@@ -1395,7 +1395,10 @@ pci_disable_device(struct pci_dev *dev)
1395 if (dr) 1395 if (dr)
1396 dr->enabled = 0; 1396 dr->enabled = 0;
1397 1397
1398 if (atomic_sub_return(1, &dev->enable_cnt) != 0) 1398 dev_WARN_ONCE(&dev->dev, atomic_read(&dev->enable_cnt) <= 0,
1399 "disabling already-disabled device");
1400
1401 if (atomic_dec_return(&dev->enable_cnt) != 0)
1399 return; 1402 return;
1400 1403
1401 do_pci_disable_device(dev); 1404 do_pci_disable_device(dev);