Skip to content

Commit 52525b7

Browse files
khfengtiwai
authored andcommitted
PCI: Add a helper to check Power Resource Requirements _PR3 existence
A driver may want to know the existence of _PR3, to choose different runtime suspend behavior. A user will be add in next patch. This is mostly the same as nouveau_pr3_present(). Signed-off-by: Kai-Heng Feng <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent acfedcb commit 52525b7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

drivers/pci/pci.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5856,6 +5856,24 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
58565856
return 0;
58575857
}
58585858

5859+
#ifdef CONFIG_ACPI
5860+
bool pci_pr3_present(struct pci_dev *pdev)
5861+
{
5862+
struct acpi_device *adev;
5863+
5864+
if (acpi_disabled)
5865+
return false;
5866+
5867+
adev = ACPI_COMPANION(&pdev->dev);
5868+
if (!adev)
5869+
return false;
5870+
5871+
return adev->power.flags.power_resources &&
5872+
acpi_has_method(adev->handle, "_PR3");
5873+
}
5874+
EXPORT_SYMBOL_GPL(pci_pr3_present);
5875+
#endif
5876+
58595877
/**
58605878
* pci_add_dma_alias - Add a DMA devfn alias for a device
58615879
* @dev: the PCI device for which alias is added

include/linux/pci.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,9 +2310,11 @@ struct irq_domain *pci_host_bridge_acpi_msi_domain(struct pci_bus *bus);
23102310

23112311
void
23122312
pci_msi_register_fwnode_provider(struct fwnode_handle *(*fn)(struct device *));
2313+
bool pci_pr3_present(struct pci_dev *pdev);
23132314
#else
23142315
static inline struct irq_domain *
23152316
pci_host_bridge_acpi_msi_domain(struct pci_bus *bus) { return NULL; }
2317+
static bool pci_pr3_present(struct pci_dev *pdev) { return false; }
23162318
#endif
23172319

23182320
#ifdef CONFIG_EEH

0 commit comments

Comments
 (0)