Export the helper to retrieve supported PCIe TPH steering tag modes so that drivers like VFIO can query and expose device capabilities to userspace. And also add pcie_tph_get_st_table_size() and pcie_tph_get_st_table_loc() stub implementation in the !CONFIG_PCI_TPH case. Signed-off-by: Chengwen Feng --- drivers/pci/tph.c | 13 +++++++++++-- include/linux/pci-tph.h | 7 +++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c index 91145e8d9d95..f8767bf6fee9 100644 --- a/drivers/pci/tph.c +++ b/drivers/pci/tph.c @@ -145,7 +145,15 @@ static void set_ctrl_reg_req_en(struct pci_dev *pdev, u8 req_type) pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); } -static u8 get_st_modes(struct pci_dev *pdev) +/** + * pcie_tph_get_st_modes - Get supported Steering Tag modes + * @pdev: PCI device to query + * + * Return: + * Bitmask of supported ST modes (PCI_TPH_CAP_ST_NS, PCI_TPH_CAP_ST_IV, + * PCI_TPH_CAP_ST_DS) + */ +u8 pcie_tph_get_st_modes(struct pci_dev *pdev) { u32 reg; @@ -154,6 +162,7 @@ static u8 get_st_modes(struct pci_dev *pdev) return reg; } +EXPORT_SYMBOL(pcie_tph_get_st_modes); /** * pcie_tph_get_st_table_loc - Return the device's ST table location @@ -400,7 +409,7 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode) /* Sanitize and check ST mode compatibility */ mode &= PCI_TPH_CTRL_MODE_SEL_MASK; - dev_modes = get_st_modes(pdev); + dev_modes = pcie_tph_get_st_modes(pdev); if (!((1 << mode) & dev_modes)) return -EINVAL; diff --git a/include/linux/pci-tph.h b/include/linux/pci-tph.h index be68cd17f2f8..586c75b19e01 100644 --- a/include/linux/pci-tph.h +++ b/include/linux/pci-tph.h @@ -30,6 +30,7 @@ void pcie_disable_tph(struct pci_dev *pdev); int pcie_enable_tph(struct pci_dev *pdev, int mode); 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_get_st_modes(struct pci_dev *pdev); #else static inline int pcie_tph_set_st_entry(struct pci_dev *pdev, unsigned int index, u16 tag) @@ -41,6 +42,12 @@ static inline int pcie_tph_get_cpu_st(struct pci_dev *dev, static inline void pcie_disable_tph(struct pci_dev *pdev) { } static inline int pcie_enable_tph(struct pci_dev *pdev, int mode) { return -EINVAL; } +static inline u16 pcie_tph_get_st_table_size(struct pci_dev *pdev) +{ return 0; } +static inline u32 pcie_tph_get_st_table_loc(struct pci_dev *pdev) +{ return 0x7FF; /* Values that do not appear in normal case */ } +static inline u8 pcie_tph_get_st_modes(struct pci_dev *pdev) +{ return 0; } #endif #endif /* LINUX_PCI_TPH_H */ -- 2.17.1