On Fri, 29 May 2026 15:03:46 +0200 (CEST)
Sebastian Ott <[email protected]> wrote:

> On Thu, 28 May 2026, Peter Maydell wrote:
> > On Thu, 28 May 2026 at 10:23, Sebastian Ott <[email protected]> wrote:  
> >>
> >> ACPI PCI hotplug of a PCI device using a bar > 2M fails on ARM
> >> with a resource allocation failure in the guest kernel (Linux):
> >>
> >> qemu-system-aarch64 [..] -device pcie-root-port,id=rp1,bus=pcie.0 \
> >>                     -global 
> >> acpi-ged.acpi-pci-hotplug-with-bridge-support=on \
> >>                     -pflash 
> >> /usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.qcow2
> >>
> >> (qemu) device_add pci-testdev,bus=rp1,membar=4M
> >>
> >> [   55.106283] pci 0000:01:00.0: [1b36:0005] type 00 class 0x00ff00 
> >> conventional PCI endpoint
> >> [   55.107627] pci 0000:01:00.0: BAR 0 [mem 0x00000000-0x00000fff]
> >> [   55.107864] pci 0000:01:00.0: BAR 1 [io  0x0000-0x00ff]
> >> [   55.108015] pci 0000:01:00.0: BAR 2 [mem 0x00000000-0x003fffff 64bit 
> >> pref]
> >> [   55.118609] pci 0000:01:00.0: BAR 2 [mem size 0x00400000 64bit pref]: 
> >> can't assign; no space
> >> [   55.118653] pci 0000:01:00.0: BAR 2 [mem size 0x00400000 64bit pref]: 
> >> failed to assign
> >> [   55.118671] pci 0000:01:00.0: BAR 0 [mem 0x10000000-0x10000fff]: 
> >> assigned
> >> [   55.122828] pci 0000:01:00.0: BAR 1 [io  0x1000-0x10ff]: assigned
> >> [   55.127090] pci 0000:01:00.0: BAR 0 [mem 0x10000000-0x10000fff]: 
> >> releasing
> >> [   55.127098] pci 0000:01:00.0: BAR 2 [mem size 0x00400000 64bit pref]: 
> >> can't assign; no space
> >> [   55.127102] pci 0000:01:00.0: BAR 2 [mem size 0x00400000 64bit pref]: 
> >> failed to assign
> >> [   55.127106] pci 0000:01:00.0: BAR 0 [mem 0x10000000-0x10000fff]: 
> >> assigned
> >>
> >> This behavior is exactly the same on x86 - except the busses are created
> >> with a default window size of 256M there. If the PCI devices being
> >> hotplugged use a bar > 256M you get the same failure like on ARM.
> >>
> >> The workaround on x86 is to specify "pref64-reserve=" for the PCIe
> >> root-port. On ARM this is currently ignored.  
> >
> > From the perspective of somebody who doesn't know much about
> > ACPI or PCI, this commit message doesn't really tell me why
> > QEMU needs to change. The above reads like "this is a kernel
> > problem" to me. Why is the kernel unable to allocate this BAR?  
> 
> Lack of resources on the parent bus/bridge device - the bridge windows are
> 2M per default on ARM. The native PCIe hotplug controller would add the
> additional resources to the parent bridge and retry allocation. The
> ACPI PCI hotplug controller does not do that. I'm curently playing with
> a hack that adds this to acpiphp.

some history:
ACPI PCIHP in kernel doesn't support bridge window resizing, and my attempt to
make it support bridge window resize like native PCIHP, didn't pan out as that
caused a regression. PCI resource assignment/enumeration in kernel is quite
a mess and when device enumerates in a few different ways, it's hard to
figure out edge cases. (I never had time to followup with  the case that got
patch reverted)

On Windows (past Vista) bridge window realloc worked fine for me
(Though I can't remember out if that applied to ACPI PCIHP or just native pcihp)

Now back to the issue at hand, the best would be (in case of ACPI PCIHP):
  * make ARM version of firmware do what x86 does (it had the same problems). 
  * make pref64-reserve= work for ARM as well, it's just a hint for firmware
    but mgmt to plan ahead and create a bridge with larger window
    assuming it knows what it's going to hotplug later.

but really if you don't need ACPI specific features (acpi-index, faster 
plug/unplug,
hotplug on older Windows versions that didn't have native PCIHP), then stick
with native pcihp.

> 
> Sebastian
> 
> 


Reply via email to