From 446f9f036c994666be391b77c6a1554d4c50a350 Mon Sep 17 00:00:00 2001 From: Oliver O'Halloran Date: Tue, 5 Nov 2019 17:24:42 +1100 Subject: [PATCH] core/pci: Squash warning from devices with no ecaps 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 --- core/pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/pci.c b/core/pci.c index db0f42f56ffd..64f53307ce95 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;