Skip to content

Commit e2a6290

Browse files
marcel-apfmstsirkin
authored andcommitted
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. Acked-by: Igor Mammedov <[email protected]> Signed-off-by: Marcel Apfelbaum <[email protected]> Message-Id: <[email protected]> Reviewed-by: Michael S. Tsirkin <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent f2da205 commit e2a6290

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

hw/pci-bridge/gen_pcie_root_port.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(GenPCIERootPort, GEN_PCIE_ROOT_PORT)
2828
(GEN_PCIE_ROOT_PORT_AER_OFFSET + PCI_ERR_SIZEOF)
2929

3030
#define GEN_PCIE_ROOT_PORT_MSIX_NR_VECTOR 1
31+
#define GEN_PCIE_ROOT_DEFAULT_IO_RANGE 4096
3132

3233
struct GenPCIERootPort {
3334
/*< private >*/
@@ -75,6 +76,7 @@ static bool gen_rp_test_migrate_msix(void *opaque, int version_id)
7576
static void gen_rp_realize(DeviceState *dev, Error **errp)
7677
{
7778
PCIDevice *d = PCI_DEVICE(dev);
79+
PCIESlot *s = PCIE_SLOT(d);
7880
GenPCIERootPort *grp = GEN_PCIE_ROOT_PORT(d);
7981
PCIERootPortClass *rpc = PCIE_ROOT_PORT_GET_CLASS(d);
8082
Error *local_err = NULL;
@@ -85,6 +87,9 @@ static void gen_rp_realize(DeviceState *dev, Error **errp)
8587
return;
8688
}
8789

90+
if (grp->res_reserve.io == -1 && s->hotplug && !s->native_hotplug) {
91+
grp->res_reserve.io = GEN_PCIE_ROOT_DEFAULT_IO_RANGE;
92+
}
8893
int rc = pci_bridge_qemu_reserve_cap_init(d, 0,
8994
grp->res_reserve, errp);
9095

0 commit comments

Comments
 (0)