Skip to content

Commit

Permalink
hw/pcie-root-port: Fix hotplug for PCI devices requiring IO
Browse files Browse the repository at this point in the history
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 <imammedo@redhat.com>
Signed-off-by: Marcel Apfelbaum <marcel@redhat.com>
Message-Id: <20210802090057.1709775-1-marcel@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
marcel-apf authored and mstsirkin committed Aug 3, 2021
1 parent f2da205 commit e2a6290
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hw/pci-bridge/gen_pcie_root_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 4096

struct GenPCIERootPort {
/*< private >*/
Expand Down Expand Up @@ -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;
Expand All @@ -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);

Expand Down

0 comments on commit e2a6290

Please sign in to comment.