Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Chengwen Feng <fengchengwen@huawei.com>
To: <alex@shazbot.org>, <jgg@ziepe.ca>
Cc: <wathsala.vithanage@arm.com>, <helgaas@kernel.org>,
	<wei.huang2@amd.com>, <wangzhou1@hisilicon.com>,
	<wangyushan12@huawei.com>, <liuyonglong@huawei.com>,
	<kvm@vger.kernel.org>, <linux-pci@vger.kernel.org>
Subject: [PATCH v8 3/7] PCI/TPH: Fix pcie_tph_get_st_table_size() for MSI-X table location
Date: Fri, 8 May 2026 14:40:49 +0800	[thread overview]
Message-ID: <20260508064053.37529-4-fengchengwen@huawei.com> (raw)
In-Reply-To: <20260508064053.37529-1-fengchengwen@huawei.com>

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 <fengchengwen@huawei.com>
---
 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, &reg);
-- 
2.17.1


  parent reply	other threads:[~2026-05-08  6:41 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  6:40 [PATCH v8 0/7] vfio/pci: Add PCIe TPH support Chengwen Feng
2026-05-08  6:40 ` [PATCH v8 1/7] PCI/TPH: Fix pcie_tph_get_st_table_loc() field extraction Chengwen Feng
2026-05-08  6:40 ` [PATCH v8 2/7] PCI/TPH: Export pcie_tph_get_st_modes() for external use Chengwen Feng
2026-05-08 19:02   ` sashiko-bot
2026-05-08  6:40 ` Chengwen Feng [this message]
2026-05-08 19:31   ` [PATCH v8 3/7] PCI/TPH: Fix pcie_tph_get_st_table_size() for MSI-X table location sashiko-bot
2026-05-08  6:40 ` [PATCH v8 4/7] vfio/pci: Add PCIe TPH interface with capability query Chengwen Feng
2026-05-08 20:03   ` sashiko-bot
2026-05-08 22:40   ` Alex Williamson
2026-05-09  3:28     ` fengchengwen
2026-05-11  4:36       ` Alex Williamson
2026-05-08  6:40 ` [PATCH v8 5/7] vfio/pci: Add PCIe TPH enable/disable support Chengwen Feng
2026-05-08 20:46   ` sashiko-bot
2026-05-08  6:40 ` [PATCH v8 6/7] vfio/pci: Add PCIe TPH GET_ST interface Chengwen Feng
2026-05-08  6:40 ` [PATCH v8 7/7] vfio/pci: Add PCIe TPH SET_ST interface Chengwen Feng
2026-05-08 21:49   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260508064053.37529-4-fengchengwen@huawei.com \
    --to=fengchengwen@huawei.com \
    --cc=alex@shazbot.org \
    --cc=helgaas@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuyonglong@huawei.com \
    --cc=wangyushan12@huawei.com \
    --cc=wangzhou1@hisilicon.com \
    --cc=wathsala.vithanage@arm.com \
    --cc=wei.huang2@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox