[Skiboot] [PATCH] core/pci: Squash warning from devices with no ecaps

Oliver O'Halloran oohall at gmail.com
Tue Nov 5 17:24:42 AEDT 2019


The PCIe Base spec says that normal endpoints that implement no extended
capabilities should return 0x0 when reading from 0x100. In other words the
extended capability ID and next pointer should be zero. The rules are
slightly different for root complex integrated endpoints and root ports.
Those are supposed to return 0xFFFF for the extended capbility ID if they
implement no extended capabilities in their Root Complex Register Block.

For a bit of added fun QEMU just returns 0xFFs for any reads above 0x100
when the device doesn't implement any extended capabilities, so check for
that too.

Fixing this isn't really needed since we already detect loops in the
capability linked-list, but it squashes some spurious errors when booting
under Qemu.

e.g.

[    6.128432797,5] PCI: Probing slots...
[    6.141580545,3] PHB#0000:01:00.0 pci_find_ecap hit a loop !
[    6.147535578,3] PHB#0001:01:00.0 pci_find_ecap hit a loop !
[    6.151533200,3] PHB#0002:01:00.0 pci_find_ecap hit a loop !
[    6.158426029,3] PHB#0002:02:00.0 pci_find_ecap hit a loop !
[    6.159566265,3] PHB#0002:02:01.0 pci_find_ecap hit a loop !
[    6.160878962,3] PHB#0002:02:02.0 pci_find_ecap hit a loop !
[    6.171709230,3] PHB#0002:09:00.0 pci_find_ecap hit a loop !

Signed-off-by: Oliver O'Halloran <oohall at gmail.com>
---
 core/pci.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/core/pci.c b/core/pci.c
index 9ee70f4fddc5..8a1ef642aad8 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -91,6 +91,11 @@ int64_t pci_find_ecap(struct phb *phb, uint16_t bdfn, uint16_t want,
 		rc = pci_cfg_read32(phb, bdfn, off, &cap);
 		if (rc)
 			return rc;
+
+		/* no ecaps supported */
+		if (cap == 0 || (cap & 0xffff) == 0xffff)
+			return OPAL_UNSUPPORTED;
+
 		if ((cap & 0xffff) == want) {
 			if (version)
 				*version = (cap >> 16) & 0xf;
-- 
2.21.0



More information about the Skiboot mailing list