Commit accd2dd7 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

PCI/ASPM: Add pcie_aspm_enabled()

Add a function checking whether or not PCIe ASPM has been enabled for
a given device.

It will be used by the NVMe driver to decide how to handle the
device during system suspend.
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarKeith Busch <keith.busch@intel.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
parent d45331b0
......@@ -1170,6 +1170,26 @@ static int pcie_aspm_get_policy(char *buffer, const struct kernel_param *kp)
module_param_call(policy, pcie_aspm_set_policy, pcie_aspm_get_policy,
NULL, 0644);
/**
* pcie_aspm_enabled - Check if PCIe ASPM has been enabled for a device.
* @pdev: Target device.
*/
bool pcie_aspm_enabled(struct pci_dev *pdev)
{
struct pci_dev *bridge = pci_upstream_bridge(pdev);
bool ret;
if (!bridge)
return false;
mutex_lock(&aspm_lock);
ret = bridge->link_state ? !!bridge->link_state->aspm_enabled : false;
mutex_unlock(&aspm_lock);
return ret;
}
EXPORT_SYMBOL_GPL(pcie_aspm_enabled);
#ifdef CONFIG_PCIEASPM_DEBUG
static ssize_t link_state_show(struct device *dev,
struct device_attribute *attr,
......
......@@ -1567,8 +1567,10 @@ extern bool pcie_ports_native;
#ifdef CONFIG_PCIEASPM
bool pcie_aspm_support_enabled(void);
bool pcie_aspm_enabled(struct pci_dev *pdev);
#else
static inline bool pcie_aspm_support_enabled(void) { return false; }
static inline bool pcie_aspm_enabled(struct pci_dev *pdev) { return false; }
#endif
#ifdef CONFIG_PCIEAER
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment