Commit f377d9cb authored by Bjorn Helgaas's avatar Bjorn Helgaas
Browse files

Merge branch 'pci/pm'

- Add pm_runtime_put() cleanup helper for use with __free() to
  automatically drop the device usage count when a pointer goes out of
  scope (Alex Williamson)

- Increment PM usage counter when probing reset methods so we don't try to
  read config space of a powered-off device (Alex Williamson)

- Set all devices to D0 during enumeration to ensure ACPI opregion is
  connected via _REG (Mario Limonciello)

* pci/pm:
  PCI: Explicitly put devices into D0 when initializing
  PCI: Increment PM usage counter when probing reset methods
  PM: runtime: Define pm_runtime_put cleanup helper
parents 80fe18d1 4d4c10f7
Loading
Loading
Loading
Loading
+0 −6
Original line number Diff line number Diff line
@@ -555,12 +555,6 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev)
	pci_enable_wake(pci_dev, PCI_D0, false);
}

static void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
{
	pci_power_up(pci_dev);
	pci_update_current_state(pci_dev, PCI_D0);
}

static void pci_pm_default_resume_early(struct pci_dev *pci_dev)
{
	pci_pm_power_up_and_verify_state(pci_dev);
+3 −0
Original line number Diff line number Diff line
@@ -1475,6 +1475,9 @@ static ssize_t reset_method_store(struct device *dev,
		return count;
	}

	pm_runtime_get_sync(dev);
	struct device *pmdev __free(pm_runtime_put) = dev;

	if (sysfs_streq(buf, "default")) {
		pci_init_reset_methods(pdev);
		return count;
+10 −3
Original line number Diff line number Diff line
@@ -3192,6 +3192,12 @@ void pci_d3cold_disable(struct pci_dev *dev)
}
EXPORT_SYMBOL_GPL(pci_d3cold_disable);

void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev)
{
	pci_power_up(pci_dev);
	pci_update_current_state(pci_dev, PCI_D0);
}

/**
 * pci_pm_init - Initialize PM functions of given PCI device
 * @dev: PCI device to handle.
@@ -3202,9 +3208,6 @@ void pci_pm_init(struct pci_dev *dev)
	u16 status;
	u16 pmc;

	pm_runtime_forbid(&dev->dev);
	pm_runtime_set_active(&dev->dev);
	pm_runtime_enable(&dev->dev);
	device_enable_async_suspend(&dev->dev);
	dev->wakeup_prepared = false;

@@ -3266,6 +3269,10 @@ void pci_pm_init(struct pci_dev *dev)
	pci_read_config_word(dev, PCI_STATUS, &status);
	if (status & PCI_STATUS_IMM_READY)
		dev->imm_ready = 1;
	pci_pm_power_up_and_verify_state(dev);
	pm_runtime_forbid(&dev->dev);
	pm_runtime_set_active(&dev->dev);
	pm_runtime_enable(&dev->dev);
}

static unsigned long pci_ea_flags(struct pci_dev *dev, u8 prop)
+1 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ void pci_dev_adjust_pme(struct pci_dev *dev);
void pci_dev_complete_resume(struct pci_dev *pci_dev);
void pci_config_pm_runtime_get(struct pci_dev *dev);
void pci_config_pm_runtime_put(struct pci_dev *dev);
void pci_pm_power_up_and_verify_state(struct pci_dev *pci_dev);
void pci_pm_init(struct pci_dev *dev);
void pci_ea_init(struct pci_dev *dev);
void pci_msi_init(struct pci_dev *dev);
+2 −0
Original line number Diff line number Diff line
@@ -466,6 +466,8 @@ static inline int pm_runtime_put(struct device *dev)
	return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
}

DEFINE_FREE(pm_runtime_put, struct device *, if (_T) pm_runtime_put(_T))

/**
 * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
 * @dev: Target device.