From: Zhiping Zhang <zhipingz@meta.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Wei Huang <wei.huang2@amd.com>, <linux-pci@vger.kernel.org>
Cc: Christian Konig <christian.koenig@amd.com>,
Alex Williamson <alex@shazbot.org>, <linux-rdma@vger.kernel.org>,
Zhiping Zhang <zhipingz@meta.com>
Subject: [PATCH v3] PCI/TPH: treat reserved 0b10 completer encoding as unsupported
Date: Mon, 20 Jul 2026 10:22:24 -0700 [thread overview]
Message-ID: <20260720172304.117134-1-zhipingz@meta.com> (raw)
get_rp_completer_type() returns the Root Port's "TPH Completer
Supported" field (bits 13:12 of Device Capabilities 2) verbatim. The
0b10 encoding is reserved, but pcie_enable_tph() feeds the raw value
into the requester type:
pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
and later writes tph_req_type to the TPH Requester Enable field, which
only defines 0b00 (disable), 0b01 (TPH only) and 0b11 (extended TPH).
No known hardware presents the reserved 0b10 in this field, so this is
defensive hardening rather than a fix for observed silicon: fold the
reserved encoding into "not supported" so only the three architected
values can ever reach the Requester Enable field.
Fixes: f69767a1ada3 ("PCI: Add TLP Processing Hints (TPH) support")
Signed-off-by: Zhiping Zhang <zhipingz@meta.com>
---
drivers/pci/tph.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/pci/tph.c b/drivers/pci/tph.c
index 655ffd60e62f..5cbb381e2a02 100644
--- a/drivers/pci/tph.c
+++ b/drivers/pci/tph.c
@@ -200,6 +200,7 @@ EXPORT_SYMBOL(pcie_tph_get_st_table_size);
static u8 get_rp_completer_type(struct pci_dev *pdev)
{
struct pci_dev *rp;
+ u8 tph_comp;
u32 reg;
int ret;
@@ -211,7 +212,15 @@ static u8 get_rp_completer_type(struct pci_dev *pdev)
if (ret)
return 0;
- return FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg);
+ /*
+ * 0b10 is reserved; treat it as "not supported" so only the
+ * architected encodings reach the Requester Enable field.
+ */
+ tph_comp = FIELD_GET(PCI_EXP_DEVCAP2_TPH_COMP_MASK, reg);
+ if (tph_comp == PCI_EXP_DEVCAP2_TPH_COMP_TPH_ONLY ||
+ tph_comp == PCI_EXP_DEVCAP2_TPH_COMP_EXT_TPH)
+ return tph_comp;
+ return PCI_EXP_DEVCAP2_TPH_COMP_NONE;
}
/* Write tag to ST table - Return 0 if OK, otherwise -errno */
--
2.53.0-Meta
reply other threads:[~2026-07-20 17:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260720172304.117134-1-zhipingz@meta.com \
--to=zhipingz@meta.com \
--cc=alex@shazbot.org \
--cc=bhelgaas@google.com \
--cc=christian.koenig@amd.com \
--cc=linux-pci@vger.kernel.org \
--cc=linux-rdma@vger.kernel.org \
--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