Add new helper pci_tph_dsm_supported() to check whether the root port of a given PCI device exposes the TPH ST ACPI _DSM method. Wrap all ACPI logic under CONFIG_ACPI guard, return false directly when ACPI is disabled. This helper is prepared for follow-up VFIO TPH virtualization patches to uniformly judge platform CPU TPH resolving support. Signed-off-by: Chengwen Feng --- drivers/pci/tph.c | 28 ++++++++++++++++++++++++++++ include/linux/pci-tph.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c index 8194f8b45e3c..e6a850ab2b03 100644 --- a/drivers/pci/tph.c +++ b/drivers/pci/tph.c @@ -627,3 +627,31 @@ void pci_tph_init(struct pci_dev *pdev) save_size = sizeof(u32) + num_entries * sizeof(u16); pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size); } + +/** + * pcie_tph_dsm_supported - Check if root port exposes TPH ST _DSM + * @pdev: target PCI device + * + * Return true if root port of @pdev provides TPH ST DSM function, + * false otherwise (ACPI disabled or DSM missing). + */ +bool pcie_tph_dsm_supported(struct pci_dev *pdev) +{ +#ifdef CONFIG_ACPI + struct pci_dev *rp = pcie_find_root_port(pdev); + acpi_handle handle; + + if (!rp || !rp->bus || !rp->bus->bridge) + return false; + + handle = ACPI_HANDLE(rp->bus->bridge); + if (!handle) + return false; + + return acpi_check_dsm(handle, &pci_acpi_dsm_guid, 7, + BIT(TPH_ST_DSM_FUNC_INDEX)); +#else + return false; +#endif +} +EXPORT_SYMBOL_GPL(pcie_tph_dsm_supported); diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index c26bf8bba478..aeaf701e7965 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -50,6 +50,7 @@ u16 pcie_tph_get_st_table_size(struct pci_dev *pdev); u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev); u8 pcie_tph_enabled_req_type(struct pci_dev *pdev); u8 pcie_tph_completer_type(struct pci_dev *pdev); +bool pcie_tph_dsm_supported(struct pci_dev *pdev); #else #define pcie_std_tph_supported(pdev) false #define pcie_ext_tph_supported(pdev) false @@ -83,6 +84,8 @@ static inline u8 pcie_tph_enabled_req_type(struct pci_dev *pdev) { return PCI_TPH_REQ_DISABLE; } static inline u8 pcie_tph_completer_type(struct pci_dev *pdev) { return PCI_EXP_DEVCAP2_TPH_COMP_NONE; } +static inline bool pcie_tph_dsm_supported(struct pci_dev *pdev) +{ return false; } #endif #endif /* LINUX_PCI_TPH_H */ -- 2.17.1