pci_auto: Downgrade prefetch if necessary
PATCH RESEND 1/3 pci_auto: Downgrade prefetch if necessary
Legacy PCI devices, like qemu's Bochs VGA device, are allowed to have prefetchable 32-bit BARs, while PCIe devices are not allowed to have 32-bit prefetchable BARs. Typically prefetchable BARs are 64-bit and typically the prefetch MMIO window is also 64-bit and placed above 4GiB, as it's the case on qemu sbsa-ref.
Currently the U-Boot code assumes that prefetchable BARs are 64-bit BARs and always tries to assign them into the prefetch MMIO window.
When a 32-bit BAR is marked as prefetch, but the prefetch area is not within the first 4GiB of the address space, then downgrade the BAR and place it in the non-prefetch MMIO window.
For prefetch BARs there's no downside on being placed in non prefetch MMIO areas, besides the possible slower performance when a driver tries to map it Write-Combine.
TEST: Fixes pci_auto on QEMU sbsa-ref fails to autoconfigure BAR0.
--- drivers/pci/pci_auto.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/pci/pci_auto.c +2 -1
@@ -107,7 +107,8 @@ static void dm_pciauto_setup_device(struct udevice *dev, }if (prefetch && - (bar_response &PCI_BASE_ADDRESS_MEM_PREFETCH )) + (bar_response &PCI_BASE_ADDRESS_MEM_PREFETCH ) && + (found_mem64 || prefetch->bus_lower <0x100000000ULL )) bar_res = prefetch;else bar_res = mem;
Signature · 1 line
2.48.1
PATCH RESEND 2/3 emulation: qemu-sbsa: Select SYS_PCI_64BIT
qemu's sbsa-ref is always using a 64bit CPU and the PCI prefetch MMIO window is located above 4GiB, thus always enable SYS_PCI_64BIT.
--- board/emulation/qemu-sbsa/Kconfig | 1 + 1 file changed, 1 insertion(+)
board/emulation/qemu-sbsa/Kconfig +1 -0
@@ -33,6 +33,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy select OF_SEPARATE select PCI select PCIE_ECAM_GENERIC + select SYS_PCI_64BIT select USB select GIC_V3 select GIC_V3_ITS
Signature · 1 line
2.48.1
PATCH RESEND 3/3 emulation: qemu-sbsa: Enable PCI enumeration
In reply to Patrick RudolphEnable PCI enumeration by default to get the Bochs display driver up and running before the boot medium is scanned.
This is just to enhance the user-experience while booting the machine.
TEST: U-Boot logo, version, log output and the U-Boot shell is visible
on the display device.
--- board/emulation/qemu-sbsa/Kconfig | 1 + 1 file changed, 1 insertion(+)
board/emulation/qemu-sbsa/Kconfig +1 -0
@@ -49,6 +49,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CFI_FLASH imply SYS_MTDPARTS_RUNTIME imply SET_DFU_ALT_INFO + imply PCI_INIT_R if DEBUG_UART
Signature · 1 line
2.48.1
Quoted 14 lines · Patrick Rudolph
Legacy PCI devices, like qemu's Bochs VGA device, are allowed to have prefetchable 32-bit BARs, while PCIe devices are not allowed to have 32-bit prefetchable BARs. Typically prefetchable BARs are 64-bit and typically the prefetch MMIO window is also 64-bit and placed above 4GiB, as it's the case on qemu sbsa-ref.
Currently the U-Boot code assumes that prefetchable BARs are 64-bit BARs and always tries to assign them into the prefetch MMIO window.
When a 32-bit BAR is marked as prefetch, but the prefetch area is not within the first 4GiB of the address space, then downgrade the BAR and place it in the non-prefetch MMIO window.
Quoted 7 lines
For prefetch BARs there's no downside on being placed in non prefetch MMIO areas, besides the possible slower performance when a driver tries to map it Write-Combine.
TEST: Fixes
pci_autoon QEMU sbsa-ref fails to autoconfigure BAR0.Signed-off-by Patrick Rudolph <[email protected]>
Do we need this series for v2025.04 or v2025.07? Thanks!
Signature · 1 line
Tom
Hi Tom,
Quoted 21 lines · Tom Rini
Quoted 18 lines · Patrick Rudolph
Legacy PCI devices, like qemu's Bochs VGA device, are allowed to have prefetchable 32-bit BARs, while PCIe devices are not allowed to have 32-bit prefetchable BARs. Typically prefetchable BARs are 64-bit and typically the prefetch MMIO window is also 64-bit and placed above 4GiB, as it's the case on qemu sbsa-ref.
Currently the U-Boot code assumes that prefetchable BARs are 64-bit BARs and always tries to assign them into the prefetch MMIO window.
When a 32-bit BAR is marked as prefetch, but the prefetch area is not within the first 4GiB of the address space, then downgrade the BAR and place it in the non-prefetch MMIO window.
For prefetch BARs there's no downside on being placed in non prefetch MMIO areas, besides the possible slower performance when a driver tries to map it Write-Combine.
Quoted 5 lines
Quoted 3 lines
TEST: Fixes
pci_autoon QEMU sbsa-ref fails to autoconfigure BAR0.Signed-off-by Patrick Rudolph <[email protected]>Do we need this series for v2025.04 or v2025.07? Thanks!
since this series only gets pre OS graphics working I'd say it's a cosmetic fix for v2025.07.
Regards,
Patrick
Quoted 3 lines
--
Tom
Quoted 23 lines · Patrick Rudolph
Hi Tom,
Quoted 21 lines · Tom Rini
Quoted 18 lines · Patrick Rudolph
Legacy PCI devices, like qemu's Bochs VGA device, are allowed to have prefetchable 32-bit BARs, while PCIe devices are not allowed to have 32-bit prefetchable BARs. Typically prefetchable BARs are 64-bit and typically the prefetch MMIO window is also 64-bit and placed above 4GiB, as it's the case on qemu sbsa-ref.
Currently the U-Boot code assumes that prefetchable BARs are 64-bit BARs and always tries to assign them into the prefetch MMIO window.
When a 32-bit BAR is marked as prefetch, but the prefetch area is not within the first 4GiB of the address space, then downgrade the BAR and place it in the non-prefetch MMIO window.
For prefetch BARs there's no downside on being placed in non prefetch MMIO areas, besides the possible slower performance when a driver tries to map it Write-Combine.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
TEST: Fixes
pci_autoon QEMU sbsa-ref fails to autoconfigure BAR0.Signed-off-by Patrick Rudolph <[email protected]>Do we need this series for v2025.04 or v2025.07? Thanks!
since this series only gets pre OS graphics working I'd say it's a cosmetic fix for v2025.07.
Thanks. The original series was on my TODO list for this week for -next, so I'll take this sometime this week.
Signature · 1 line
Tom