Skip to contentSkip to conversation

PCI: Skip devices with RRS Vendor ID(0x0001) on root bus

PATCH In review Zhu Lingshan 2 participants 3 messages Mar 27 – Apr 2 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: Skip devices with RRS Vendor ID(0x0001) on root bus

PCIe Request Retry Status (RRS) is a link-layer mechanism where a downstream device responds with RRS to indicate it is not ready.

With RRS Software Visibility enabled, the Root Port translates RRS into Vendor ID 0x0001 (reserved by PCI SIG) for the driver.

Devices on the root bus, for example the root port itself, have no upstream PCIe link and can never legitimately return RRS.

This patch skips any devices with RRS Vendor ID 0x0001 on the root bus instead of entering the RRS retry loop.

---
 drivers/pci/probe.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/pci/probe.c +20 -1
index bccc7a4bdd79..2fad89ca594c 100644
@@ -2578,8 +2578,27 @@ bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
 	    *l == 0x0000ffff || *l == 0xffff0000)
 		return false;
 
-	if (pci_bus_rrs_vendor_id(*l))
+	if (pci_bus_rrs_vendor_id(*l)) {
+		/*
+		 * RRS (Request Retry Status) is a PCIe link-layer mechanism
+		 * where a downstream device sends a RRS completion status, and the
+		 * Root Port (with RRS Software Visibility enabled) translates
+		 * it to Vendor ID 0x0001 for the driver, indicating the
+		 * device is not ready.
+		 *
+		 * Therefore, RRS is a root port feature, and devices on the root bus,
+		 * for example the root port itself have no upstream PCIe link,
+		 * so they can never legitimately return RRS.
+		 */
+		if (pci_is_root_bus(bus)) {
+			pr_err("pci %04x:%02x:%02x.%d: invalid Vendor ID %04x (RRS, reserved by PCI SIG) on root bus, buggy device\n",
+				pci_domain_nr(bus), bus->number,
+				PCI_SLOT(devfn), PCI_FUNC(devfn),
+				*l & 0xffff);
+			return false;
+		}
 		return pci_bus_wait_rrs(bus, devfn, l, timeout);
+	}
 
 	return true;
 }
Signature · 1 line
2.53.0
#1 lore raw

Gentle Ping

Thanks
Zhu Lingshan

Quoted 51 lines · Zhu Lingshan

PCIe Request Retry Status (RRS) is a link-layer mechanism where a downstream device responds with RRS to indicate it is not ready.

With RRS Software Visibility enabled, the Root Port translates RRS into Vendor ID 0x0001 (reserved by PCI SIG) for the driver.

Devices on the root bus, for example the root port itself, have no upstream PCIe link and can never legitimately return RRS.

This patch skips any devices with RRS Vendor ID 0x0001 on the root bus instead of entering the RRS retry loop.

---
 drivers/pci/probe.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
drivers/pci/probe.c +20 -1
index bccc7a4bdd79..2fad89ca594c 100644
@@ -2578,8 +2578,27 @@ bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
 	    *l == 0x0000ffff || *l == 0xffff0000)
 		return false;
 
-	if (pci_bus_rrs_vendor_id(*l))
+	if (pci_bus_rrs_vendor_id(*l)) {
+		/*
+		 * RRS (Request Retry Status) is a PCIe link-layer mechanism
+		 * where a downstream device sends a RRS completion status, and the
+		 * Root Port (with RRS Software Visibility enabled) translates
+		 * it to Vendor ID 0x0001 for the driver, indicating the
+		 * device is not ready.
+		 *
+		 * Therefore, RRS is a root port feature, and devices on the root bus,
+		 * for example the root port itself have no upstream PCIe link,
+		 * so they can never legitimately return RRS.
+		 */
+		if (pci_is_root_bus(bus)) {
+			pr_err("pci %04x:%02x:%02x.%d: invalid Vendor ID %04x (RRS, reserved by PCI SIG) on root bus, buggy device\n",
+				pci_domain_nr(bus), bus->number,
+				PCI_SLOT(devfn), PCI_FUNC(devfn),
+				*l & 0xffff);
+			return false;
+		}
 		return pci_bus_wait_rrs(bus, devfn, l, timeout);
+	}
 
 	return true;
 }
#2 lore raw
In reply to Zhu Lingshan
Quoted 11 lines · Zhu Lingshan

PCIe Request Retry Status (RRS) is a link-layer mechanism where a downstream device responds with RRS to indicate it is not ready.

With RRS Software Visibility enabled, the Root Port translates RRS into Vendor ID 0x0001 (reserved by PCI SIG) for the driver.

Devices on the root bus, for example the root port itself, have no upstream PCIe link and can never legitimately return RRS.

This patch skips any devices with RRS Vendor ID 0x0001 on the root bus instead of entering the RRS retry loop.

What problem does this solve? Did you see a device that claimed a 0x0001 Vendor ID?

How does this work for devices on s390 and virtualized guest topologies where a device may be on the root bus seen by the guest kernel, but still have an upstream link to a Root Port not visible to that kernel?

The device may respond with RRS completions, but I don't know how that would be handled.

Quoted 6 lines
drivers/pci/probe.c +1 -1
@@ -2578,8 +2578,27 @@ bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
 	    *l == 0x0000ffff || *l == 0xffff0000)
 		return false;
 
-	if (pci_bus_rrs_vendor_id(*l))
+	if (pci_bus_rrs_vendor_id(*l)) {

drivers/pci/probe.c bool pci_bus_generic_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l, · line 2591

Quoted 10 lines
drivers/pci/probe.c +10 -0
+		/*
+		 * RRS (Request Retry Status) is a PCIe link-layer mechanism
+		 * where a downstream device sends a RRS completion status, and the
+		 * Root Port (with RRS Software Visibility enabled) translates
+		 * it to Vendor ID 0x0001 for the driver, indicating the
+		 * device is not ready.
+		 *
+		 * Therefore, RRS is a root port feature, and devices on the root bus,
+		 * for example the root port itself have no upstream PCIe link,
+		 * so they can never legitimately return RRS.

Please wrap comments to fit in 80 columns like the rest of the file.

Quoted 16 lines
drivers/pci/probe.c +9 -0
+		 */
+		if (pci_is_root_bus(bus)) {
+			pr_err("pci %04x:%02x:%02x.%d: invalid Vendor ID %04x (RRS, reserved by PCI SIG) on root bus, buggy device\n",
+				pci_domain_nr(bus), bus->number,
+				PCI_SLOT(devfn), PCI_FUNC(devfn),
+				*l & 0xffff);
+			return false;
+		}
 		return pci_bus_wait_rrs(bus, devfn, l, timeout);
+	}
 
 	return true;
 }
Signature · 1 line
2.53.0