Skip to content

Commit

Permalink
Merge branch 'pci/konstantin-runtime-pm' into next
Browse files Browse the repository at this point in the history
* 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()
  • Loading branch information
Bjorn Helgaas committed Feb 12, 2013
2 parents f2dfcde + 82fee4d commit 20f2420
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion drivers/pci/pci-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ static void pci_device_shutdown(struct device *dev)
* Turn off Bus Master bit on the device to tell it to not
* continue to do DMA
*/
pci_disable_device(pci_dev);
pci_clear_master(pci_dev);
}

#ifdef CONFIG_PM
Expand Down Expand Up @@ -628,6 +628,7 @@ static int pci_pm_suspend(struct device *dev)
goto Fixup;
}

pci_dev->state_saved = false;
if (pm->suspend) {
pci_power_t prev = pci_dev->current_state;
int error;
Expand Down Expand Up @@ -774,6 +775,7 @@ static int pci_pm_freeze(struct device *dev)
return 0;
}

pci_dev->state_saved = false;
if (pm->freeze) {
int error;

Expand Down Expand Up @@ -862,6 +864,7 @@ static int pci_pm_poweroff(struct device *dev)
goto Fixup;
}

pci_dev->state_saved = false;
if (pm->poweroff) {
int error;

Expand Down Expand Up @@ -987,6 +990,7 @@ static int pci_pm_runtime_suspend(struct device *dev)
if (!pm || !pm->runtime_suspend)
return -ENOSYS;

pci_dev->state_saved = false;
pci_dev->no_d3cold = false;
error = pm->runtime_suspend(dev);
suspend_report_result(pm->runtime_suspend, error);
Expand Down
7 changes: 5 additions & 2 deletions drivers/pci/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ static int pci_enable_device_flags(struct pci_dev *dev, unsigned long flags)
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
}

if (atomic_add_return(1, &dev->enable_cnt) > 1)
if (atomic_inc_return(&dev->enable_cnt) > 1)
return 0; /* already enabled */

/* only skip sriov related */
Expand Down Expand Up @@ -1395,7 +1395,10 @@ pci_disable_device(struct pci_dev *dev)
if (dr)
dr->enabled = 0;

if (atomic_sub_return(1, &dev->enable_cnt) != 0)
dev_WARN_ONCE(&dev->dev, atomic_read(&dev->enable_cnt) <= 0,
"disabling already-disabled device");

if (atomic_dec_return(&dev->enable_cnt) != 0)
return;

do_pci_disable_device(dev);
Expand Down

0 comments on commit 20f2420

Please sign in to comment.