Skip to contentSkip to conversation

PCI/TPH: Skip Root Port completer check for RC_END devices

PATCH Superseded George Abraham P 2 participants 3 messages Sep 18, 2025 – Sep 19, 2025 PCI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/TPH: Skip Root Port completer check for RC_END devices

Root Complex Integrated Endpoint devices (PCI_EXP_TYPE_RC_END) are directly integrated into the root complex and do not have an associated Root Port in the traditional PCIe hierarchy. The current TPH implementation incorrectly attempts to find and check a Root Port's TPH completer capability for these devices.

Add a check to skip Root Port completer type verification for RC_END devices, allowing them to use their full TPH requester capability without being limited by a non-existent Root Port's completer support.

For RC_END devices, the root complex itself acts as the TPH completer, and this relationship is handled differently than the standard endpoint-to-Root-Port model.

---
 drivers/pci/tph.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/tph.c +6 -3
index cc64f93709a4..c61456d24f61 100644
@@ -397,10 +397,13 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode)
 	else
 		pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY;
 
-	rp_req_type = get_rp_completer_type(pdev);
+	/* Check if the device is behind a Root Port */
+	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_END) {
+		rp_req_type = get_rp_completer_type(pdev);
 
-	/* Final req_type is the smallest value of two */
-	pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+		/* Final req_type is the smallest value of two */
+		pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+	}
 
 	if (pdev->tph_req_type == PCI_TPH_REQ_DISABLE)
 		return -EINVAL;

base-commit: c29008e61d8e75ac7da3efd5310e253c035e0458

Signature · 1 line
2.40.1
#1 lore raw

[+cc authors of TPH support]

Quoted 6 lines · George Abraham P

Root Complex Integrated Endpoint devices (PCI_EXP_TYPE_RC_END) are directly integrated into the root complex and do not have an associated Root Port in the traditional PCIe hierarchy. The current TPH implementation incorrectly attempts to find and check a Root Port's TPH completer capability for these devices.

Quoted 7 lines

Add a check to skip Root Port completer type verification for RC_END devices, allowing them to use their full TPH requester capability without being limited by a non-existent Root Port's completer support.

For RC_END devices, the root complex itself acts as the TPH completer, and this relationship is handled differently than the standard endpoint-to-Root-Port model.

I thought maybe the spec would mention TPH Completer Supported for a Root Complex in an RCRB, but I looked through PCIe r7.0 and didn't see anything in RCRB related to the Root Port TPH Completer Supported field in Device Capabilities 2.

It seems sort of surprising that Root Ports have to advertise what kinds of TPH Completers they support, but we can assume that Root Complexes support both TPH and Extended TPH Completers. Do you have any insight into that?

But I certainly agree that as-is, TPH is useless for RCiEPs since there's no Root Port, so we assume the completer has no TPH Completer support at all.

Do you think we should add a Fixes: tag for f69767a1ada3 ("PCI: Add TLP Processing Hints (TPH) support"), where the TPH support was added?

Quoted 31 lines
---
 drivers/pci/tph.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/tph.c +6 -3
index cc64f93709a4..c61456d24f61 100644
@@ -397,10 +397,13 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode)
 	else
 		pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY;
 
-	rp_req_type = get_rp_completer_type(pdev);
+	/* Check if the device is behind a Root Port */
+	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_END) {
+		rp_req_type = get_rp_completer_type(pdev);
 
-	/* Final req_type is the smallest value of two */
-	pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+		/* Final req_type is the smallest value of two */
+		pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+	}
 
 	if (pdev->tph_req_type == PCI_TPH_REQ_DISABLE)
 		return -EINVAL;

base-commit: c29008e61d8e75ac7da3efd5310e253c035e0458

Signature · 1 line
2.40.1
#2 lore raw

Hi Bjorn,

Quoted 22 lines · Bjorn Helgaas

[+cc authors of TPH support]

Quoted 6 lines · George Abraham P

Root Complex Integrated Endpoint devices (PCI_EXP_TYPE_RC_END) are directly integrated into the root complex and do not have an associated Root Port in the traditional PCIe hierarchy. The current TPH implementation incorrectly attempts to find and check a Root Port's TPH completer capability for these devices.

Quoted 7 lines

Add a check to skip Root Port completer type verification for RC_END devices, allowing them to use their full TPH requester capability without being limited by a non-existent Root Port's completer support.

For RC_END devices, the root complex itself acts as the TPH completer, and this relationship is handled differently than the standard endpoint-to-Root-Port model.

I thought maybe the spec would mention TPH Completer Supported for a Root Complex in an RCRB, but I looked through PCIe r7.0 and didn't see anything in RCRB related to the Root Port TPH Completer Supported field in Device Capabilities 2.

Quoted 5 lines

It seems sort of surprising that Root Ports have to advertise what kinds of TPH Completers they support, but we can assume that Root Complexes support both TPH and Extended TPH Completers. Do you have any insight into that?

I too was was scouring the PCI spec for this same information. Unfortunately couldn't find the solution to the same.
The only statement in the spec that supports this patch would be that the TPH Completer Supported field is only applicable to Root Ports and Endpoints. Hence, for RCiEP, this check should be bypassed.
If there is a better way to handle this, please suggest.

Quoted 7 lines

But I certainly agree that as-is, TPH is useless for RCiEPs since there's no Root Port, so we assume the completer has no TPH Completer support at all.

Do you think we should add a Fixes: tag for f69767a1ada3 ("PCI: Add TLP Processing Hints (TPH) support"), where the TPH support was added?

Sure, will modify as suggested. Thanks.

Quoted 24 lines
Quoted 24 lines
---
 drivers/pci/tph.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/pci/tph.c +6 -3
index cc64f93709a4..c61456d24f61 100644
@@ -397,10 +397,13 @@ int pcie_enable_tph(struct pci_dev *pdev, int mode)
 	else
 		pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY;
 
-	rp_req_type = get_rp_completer_type(pdev);
+	/* Check if the device is behind a Root Port */
+	if (pci_pcie_type(pdev) != PCI_EXP_TYPE_RC_END) {
+		rp_req_type = get_rp_completer_type(pdev);
 
-	/* Final req_type is the smallest value of two */
-	pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+		/* Final req_type is the smallest value of two */
+		pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type);
+	}
 
Quoted 7 lines
Quoted 7 lines
drivers/pci/tph.c +0 -0
 	if (pdev->tph_req_type == PCI_TPH_REQ_DISABLE)
 		return -EINVAL;

base-commit: c29008e61d8e75ac7da3efd5310e253c035e0458

Signature · 1 line
2.40.1

Regards,
George