pcie_tph_get_st_table_size() previously only returned valid size when ST Table is in TPH Capability space. According to PCIe spec [1], ST table size is also valid when ST Table is located in MSI-X table. Fix it to return valid table size for both PCI_TPH_LOC_CAP and PCI_TPH_LOC_MSIX locations. [1] PCI Express Base 6.1 Table 7-258 TPH Requester Capability Register ST Table Size: - Value indicates the maximum number of ST Table entries the Function may use. Software reads this field to determine the ST Table Size N, which is encoded as N-1. For example, a returned value of 000 0000 0011b indicates a table size of four entries. - There is an upper limit of 64 entries when the ST Table is located in the TPH Requester Extended Capability structure. - When the ST Table is located in the MSI-X Table, this value is limited by the size of the MSI-X Table. - This field is only applicable for Functions that implement an ST Table as indicated by the ST Table Location field. Otherwise, the value in this field is undefined. Signed-off-by: Chengwen Feng --- drivers/pci/tph.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c index ba31b010f67a..de5bd7039cdc 100644 --- a/drivers/pci/tph.c +++ b/drivers/pci/tph.c @@ -191,7 +191,8 @@ EXPORT_SYMBOL(pcie_tph_get_st_table_loc); /* * Return the size of ST table. If ST table is not in TPH Requester Extended - * Capability space, return 0. Otherwise return the ST Table Size + 1. + * Capability space or MSI-X table, return 0. Otherwise return the + * ST Table Size + 1. */ u16 pcie_tph_get_st_table_size(struct pci_dev *pdev) { @@ -200,7 +201,7 @@ u16 pcie_tph_get_st_table_size(struct pci_dev *pdev) /* Check ST table location first */ loc = pcie_tph_get_st_table_loc(pdev); - if (loc != PCI_TPH_LOC_CAP) + if (loc != PCI_TPH_LOC_CAP && loc != PCI_TPH_LOC_MSIX) return 0; pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); -- 2.17.1