[PATCH v3 6/6] PCI/FLIT: Manage Flit Logging on Endpoint Upstream Ports

From: Yazen Ghannam

Date: Fri Dec 04 2026 - 13:16:41 EST


An Endpoint implements the Flit Logging Extended Capability in Function 0
of its Upstream Port.[1] The port bus driver does not bind to Endpoints,
so with _OSC control granted, nothing manages those instances.

ERR_COR signaling needs no driver binding. pci_flit_init() starts the
counter, its state is saved and restored with the device, and AER
services its events. Manage the capability on Endpoints where ERR_COR
is usable, and leave other Endpoints as found.

Function Level Reset does not affect the capability, so an Endpoint
driver resetting its device does not disturb it.[2]

[1] PCIe r7.1, sec 7.7.9
[2] PCIe r7.1, sec 6.6.2

Signed-off-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
---
drivers/pci/pcie/flit.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/pcie/flit.c b/drivers/pci/pcie/flit.c
index 83a6b50221ef..050360295f2f 100644
--- a/drivers/pci/pcie/flit.c
+++ b/drivers/pci/pcie/flit.c
@@ -113,6 +113,21 @@ static bool flit_is_port(struct pci_dev *pdev)
}
}

+/* No port service binds to an Endpoint, so it can only use ERR_COR */
+static bool flit_is_endpoint(struct pci_dev *pdev)
+{
+ if (!pci_is_pcie(pdev))
+ return false;
+
+ switch (pci_pcie_type(pdev)) {
+ case PCI_EXP_TYPE_ENDPOINT:
+ case PCI_EXP_TYPE_LEG_END:
+ return true;
+ default:
+ return false;
+ }
+}
+
/* Flit Logging control is only meaningful alongside AER control */
static bool flit_is_native(struct pci_dev *pdev)
{
@@ -229,7 +244,8 @@ void pci_flit_init(struct pci_dev *pdev)
u16 trigger;
u32 ctrl;

- if (!flit_is_port(pdev) || !flit_is_native(pdev))
+ if (!(flit_is_port(pdev) || flit_is_endpoint(pdev)) ||
+ !flit_is_native(pdev))
return;

pdev->flit_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_FLIT);
@@ -247,6 +263,12 @@ void pci_flit_init(struct pci_dev *pdev)
info->cntr_cap = flit_read_cntr_cap(pdev);
info->err_cor = flit_err_cor_usable(pdev);

+ /* Leave an Endpoint without ERR_COR as found */
+ if (!info->err_cor && flit_is_endpoint(pdev)) {
+ pci_flit_exit(pdev);
+ return;
+ }
+
spin_lock_init(&info->lock);
mutex_init(&info->service_lock);

--
2.55.0