hw/pcie-root-port: Fix hotplug for PCI devices requiring IO
PATCH v2 1/1 hw/pcie-root-port: Fix hotplug for PCI devices requiring IO
Q35 has now ACPI hotplug enabled by default for PCI(e) devices. As opposed to native PCIe hotplug, guests like Fedora 34 will not assign IO range to pcie-root-ports not supporting native hotplug, resulting into a regression.
Reproduce by:
qemu-bin -M q35 -device pcie-root-port,id=p1 -monitor stdio device_add e1000,bus=p1
In the Guest OS the respective pcie-root-port will have the IO range disabled.
Fix it by setting the "reserve-io" hint capability of the pcie-root-ports so the firmware will allocate the IO range instead.
---
v2:
- improve commit message (Igor)
hw/pci-bridge/gen_pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/pci-bridge/gen_pcie_root_port.c +5 -0
@@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT) (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1 +#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096struct GenPCIERootPort {/*< private >*/
@@ -75,6 +76,7 @@ static bool gen_rp_test_migrate_msix(void *opaque, int version_id)static void gen_rp_realize (DeviceState *dev,Error **errp) {PCIDevice *d =PCI_DEVICE (dev); +PCIESlot *s =PCIE_SLOT (d);GenPCIERootPort *grp =GEN_PCIE_ROOT_PORT (d);PCIERootPortClass *rpc =PCIE_ROOT_PORT_GET_CLASS (d);Error *local_err =NULL ;
@@ -85,6 +87,9 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)return ; } +if (grp->res_reserve.io ==-1 && s->hotplug && !s->native_hotplug) { + grp->res_reserve.io =GEN_PCIE_ROOT_DEFAULT_IO_RANGE ; + }int rc =pci_bridge_qemu_reserve_cap_init (d,0 , grp->res_reserve, errp);
Signature · 1 line
2.31.1
Quoted 4 lines · Marcel Apfelbaum
Q35 has now ACPI hotplug enabled by default for PCI(e) devices. As opposed to native PCIe hotplug, guests like Fedora 34 will not assign IO range to pcie-root-ports not supporting native hotplug, resulting into a regression.
Presumably this means this patch should have 'for 6.1' tagged in subject, as we don't want 6.1 to regress ?
Quoted 53 lines
Reproduce by:
qemu-bin -M q35 -device pcie-root-port,id=p1 -monitor stdiodevice_adde1000,bus=p1
In the Guest OS the respective pcie-root-port will have the IO range disabled.Fix it by setting the "reserve-io" hint capability of the pcie-root-ports so the firmware will allocate the IO range instead.
Acked-by Igor Mammedov <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>---
v2:
- improve commit message (Igor)hw/pci-bridge/gen_pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)hw/pci-bridge/gen_pcie_root_port.c +5
-0@@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT) (GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1 +#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096struct GenPCIERootPort {/*< private >*/ @@ -75,6 +76,7 @@ static bool gen_rp_test_migrate_msix(void *opaque, int version_id)static void gen_rp_realize (DeviceState *dev,Error **errp) {PCIDevice *d =PCI_DEVICE (dev); +PCIESlot *s =PCIE_SLOT (d);GenPCIERootPort *grp =GEN_PCIE_ROOT_PORT (d);PCIERootPortClass *rpc =PCIE_ROOT_PORT_GET_CLASS (d);Error *local_err =NULL ;@@ -85,6 +87,9 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)return ; } +if (grp->res_reserve.io ==-1 && s->hotplug && !s->native_hotplug) { + grp->res_reserve.io =GEN_PCIE_ROOT_DEFAULT_IO_RANGE ; + }int rc =pci_bridge_qemu_reserve_cap_init (d,0 , grp->res_reserve, errp);Signature · 1 line
2.31.1
Regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Hi Daniel,
Quoted 9 lines · Daniel P. Berrangé
Quoted 4 lines · Marcel Apfelbaum
Q35 has now ACPI hotplug enabled by default for PCI(e) devices. As opposed to native PCIe hotplug, guests like Fedora 34 will not assign IO range to pcie-root-ports not supporting native hotplug, resulting into a regression.
Presumably this means this patch should have 'for 6.1' tagged in subject, as we don't want 6.1 to regress ?
I agree I should have added the tag, however Michael is aware as he proposed this patch.
I can re-spin if necessary.
Thanks,
Marcel
Quoted 71 lines
Quoted 13 lines
Reproduce by:
qemu-bin -M q35 -device pcie-root-port,id=p1 -monitor stdiodevice_adde1000,bus=p1
In the Guest OS the respective pcie-root-port will have the IO range disabled.Fix it by setting the "reserve-io" hint capability of the pcie-root-ports so the firmware will allocate the IO range instead.
Acked-by Igor Mammedov <[email protected]>Signed-off-by Marcel Apfelbaum <[email protected]>Review
Quoted 8 lines
---
v2:
- improve commit message (Igor)hw/pci-bridge/gen_pcie_root_port.c | 5 +++++ 1 file changed, 5 insertions(+)(quoted diff) +0
-0
b/hw/pci-bridge/gen_pcie_root_port.chw/pci-bridge/gen_pcie_root_port.c OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort,
Quoted 4 lines
index
ec9907917e..20099a8ae3100644hw/pci-bridge/gen_pcie_root_port.c +0
-0@@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort,
GEN_PCIE_ROOT_PORT)hw/pci-bridge/gen_pcie_root_port.c static bool gen_rp_test_migrate_msix(void *opaque, int
Quoted 8 lines
hw/pci-bridge/gen_pcie_root_port.c +1
-0(GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1 +#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096struct GenPCIERootPort {/*< private >*/ @@ -75,6 +76,7 @@ static bool gen_rp_test_migrate_msix(void *opaque, int
version_id)hw/pci-bridge/gen_pcie_root_port.c static void gen_rp_realize(DeviceState *dev, Error
Quoted 8 lines
hw/pci-bridge/gen_pcie_root_port.c +1
-0static void gen_rp_realize (DeviceState *dev,Error **errp) {PCIDevice *d =PCI_DEVICE (dev); +PCIESlot *s =PCIE_SLOT (d);GenPCIERootPort *grp =GEN_PCIE_ROOT_PORT (d);PCIERootPortClass *rpc =PCIE_ROOT_PORT_GET_CLASS (d);Error *local_err =NULL ;@@ -85,6 +87,9 @@ static void gen_rp_realize(DeviceState *dev, Error**errp)
hw/pci-bridge/gen_pcie_root_port.c static void gen_rp_realize(DeviceState *dev, Error · line 90
Quoted 4 lines
hw/pci-bridge/gen_pcie_root_port.c +1
-0return ; } +if (grp->res_reserve.io ==-1 && s->hotplug && !s->native_hotplug){
Quoted 9 lines
hw/pci-bridge/gen_pcie_root_port.c +2
-1+ grp->res_reserve.io =GEN_PCIE_ROOT_DEFAULT_IO_RANGE ; + }int rc =pci_bridge_qemu_reserve_cap_init (d,0 , grp->res_reserve, errp); --2.31.1
Regards,
Daniel
--
|: https://berrange.com -o-
https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-
https://fstop138.berrange.com :|
|: https://entangle-photo.org -o-
https://www.instagram.com/dberrange :|