Skip to contentSkip to conversation

pci: correct PCI device enumeration to include all functions on device 0

PATCH Superseded Maximilian Brune 3 participants 7 messages Apr 17 – Apr 27 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pci: correct PCI device enumeration to include all functions on device 0

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind on these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

Fix it by checking all functions on device 0 (Linux does the same).

TEST=build u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

---
 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
index 83b76d01f24..f58d542ef75 100644
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 		if (PCI_FUNC(bdf) && !found_multi)
 			continue;
 
-		if (only_one_child(bus) && (PCI_MASK_BUS(bdf) > 0))
+		if (only_one_child(bus) && (PCI_DEV(bdf) > 0))
 			continue;
 
 		/* Check only the first access, we don't expect problems */
Signature · 1 line
2.53.0
#1 lore raw

Hi Maximilian,

drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)

Quoted 20 lines · Maximilian Brune

pci: correct PCI device enumeration to include all functions on device 0

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind on these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

Fix it by checking all functions on device 0 (Linux does the same).

TEST=build u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

drivers/pci/pci-uclass.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +0 -0
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)

Right, PCI_MASK_BUS() returns both device and function bits, so it skipps any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child().

Fixes fbde868ba4aa ("pci: skip unnecessary PCIe scanning")

BTW, the TEST= format is non-standard for U-Boot - you could reword to prose or omit it.

I notice the mention of AMD - have you tried booting on a coreboot + OpenSIL platform?

Regards,
Simon

#2 lore raw
Quoted 4 lines

Right, PCI_MASK_BUS() returns both device and function bits, so it skipps any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child().

I will add this to the commit message. It is a helpful hint for the reader.

Quoted 1 line

BTW, the TEST= format is non-standard for U-Boot - you could reword to

prose or omit it.

I will reword it.

Quoted 1 line

I notice the mention of AMD - have you tried booting on a coreboot +

OpenSIL platform?

No AMD/crater is based on V2000A SOC which in turn only has a FSP implementation (as far as I know).
I myself have never tried booting an OpenSIL platform with coreboot+u-boot.

Am Mo., 20. Apr. 2026 um 04:30 Uhr schrieb Simon Glass <[email protected]>:

Quoted 41 lines

Hi Maximilian,

drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)

Quoted 20 lines · Maximilian Brune

pci: correct PCI device enumeration to include all functions on device 0

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind on these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

Fix it by checking all functions on device 0 (Linux does the same).

TEST=build u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

drivers/pci/pci-uclass.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +0 -0
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)

Right, PCI_MASK_BUS() returns both device and function bits, so it skipps any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child().

Fixes fbde868ba4aa ("pci: skip unnecessary PCIe scanning")

BTW, the TEST= format is non-standard for U-Boot - you could reword to prose or omit it.

I notice the mention of AMD - have you tried booting on a coreboot + OpenSIL platform?

Regards,
Simon

#3 lore raw

PATCH v2 1/1 pci: correct PCI device enumeration to include all functions on device 0

In reply to Maximilian Brune

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

PCI_MASK_BUS() returns both device and function bits, so it skipps any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child(). It therefore now checks all functions on device 0 (Linux does the same).

I build tested u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

Fixes fbde868ba4aa ("pci: skip unnecessary PCIe scanning")
CC Tom Rini <[email protected]>
CC Andrew Goodbody <[email protected]>
CC George McCollister <[email protected]>
CC Simon Glass <[email protected]>
---
 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
index 83b76d01f24..f58d542ef75 100644
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 		if (PCI_FUNC(bdf) && !found_multi)
 			continue;
 
-		if (only_one_child(bus) && (PCI_MASK_BUS(bdf) > 0))
+		if (only_one_child(bus) && (PCI_DEV(bdf) > 0))
 			continue;
 
 		/* Check only the first access, we don't expect problems */
Signature · 1 line
2.53.0
Reviewed-by on v2 1/1
#4 lore raw

Hi Maximilian,

drivers/pci/pci-uclass.c int pci_bind_bus_devices(struct udevice *bus)

Quoted 27 lines · Maximilian Brune

pci: correct PCI device enumeration to include all functions on device 0

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

PCI_MASK_BUS() returns both device and function bits, so it skipps any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child(). It therefore now checks all functions on device 0 (Linux does the same).

I build tested u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

Fixes fbde868ba4aa ("pci: skip unnecessary PCIe scanning")
[...]

drivers/pci/pci-uclass.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +0 -0
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)

Nit: "skipps" should be "skips" in the commit message.

#5 lore raw

PATCH v3 1/1 pci: correct PCI device enumeration to include all functions on device 0

In reply to Maximilian Brune

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

PCI_MASK_BUS() returns both device and function bits, so it skips any bdf where either device > 0 or function > 0. Using PCI_DEV() extracts only the device number, matching the intent in only_one_child(). It therefore now checks all functions on device 0 (Linux does the same).

I build tested u-boot as coreboot payload and run it on a recent x86 AMD platform. Devices like the XHCI controller are now found again.

Fixes fbde868ba4aa ("pci: skip unnecessary PCIe scanning")
CC Tom Rini <[email protected]>
CC Andrew Goodbody <[email protected]>
CC George McCollister <[email protected]>
CC Simon Glass <[email protected]>
---
 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
index 83b76d01f24..f58d542ef75 100644
@@ -927,7 +927,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 		if (PCI_FUNC(bdf) && !found_multi)
 			continue;
 
-		if (only_one_child(bus) && (PCI_MASK_BUS(bdf) > 0))
+		if (only_one_child(bus) && (PCI_DEV(bdf) > 0))
 			continue;
 
 		/* Check only the first access, we don't expect problems */
Signature · 1 line
2.53.0
#6 lore raw
Quoted 9 lines · Maximilian Brune

Currently the implementation does not just skip all devices beside device 0, it also skips all functions (besides 0) on device 0. This broke basically all AMD platforms, since they have a lot of internal SOC devices behind these functions.

This was detected, because the XHCI controller and therefore the USB devices were not found by u-boot on AMD/crater platform.

[...]

Applied to u-boot/master, thanks!

[1/1] pci: correct PCI device enumeration to include all functions on device 0

      commit: 6ab5b5d2804b00d3253d09c6d8f829d918d2ed1c
Signature · 1 line
Tom