Skip to content

Commit

Permalink
hw/pci: add PCI resource reserve capability to legacy PCI bridge
Browse files Browse the repository at this point in the history
Add hint to firmware (e.g. SeaBIOS) to reserve addtional
BUS/IO/MEM/PREF resource for legacy pci-pci bridge. Add the
resource reserve capability deleting in pci_bridge_dev_exitfn.

Signed-off-by: Jing Liu <jing2.liu@linux.intel.com>
Reviewed-by: Marcel Apfelbaum<marcel.apfelbaum@gmail.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Jing Liu authored and mstsirkin committed Sep 7, 2018
1 parent 9e89939 commit 6755e61
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions hw/pci-bridge/pci_bridge_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ struct PCIBridgeDev {
uint32_t flags;

OnOffAuto msi;

/* additional resources to reserve */
PCIResReserve res_reserve;
};
typedef struct PCIBridgeDev PCIBridgeDev;

Expand Down Expand Up @@ -95,6 +98,12 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp)
error_free(local_err);
}

err = pci_bridge_qemu_reserve_cap_init(dev, 0,
bridge_dev->res_reserve, errp);
if (err) {
goto cap_error;
}

if (shpc_present(dev)) {
/* TODO: spec recommends using 64 bit prefetcheable BAR.
* Check whether that works well. */
Expand All @@ -103,6 +112,8 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp)
}
return;

cap_error:
msi_uninit(dev);
msi_error:
slotid_cap_cleanup(dev);
slotid_error:
Expand All @@ -116,6 +127,8 @@ static void pci_bridge_dev_realize(PCIDevice *dev, Error **errp)
static void pci_bridge_dev_exitfn(PCIDevice *dev)
{
PCIBridgeDev *bridge_dev = PCI_BRIDGE_DEV(dev);

pci_del_capability(dev, PCI_CAP_ID_VNDR, sizeof(PCIBridgeQemuCap));
if (msi_present(dev)) {
msi_uninit(dev);
}
Expand Down Expand Up @@ -162,6 +175,17 @@ static Property pci_bridge_dev_properties[] = {
ON_OFF_AUTO_AUTO),
DEFINE_PROP_BIT(PCI_BRIDGE_DEV_PROP_SHPC, PCIBridgeDev, flags,
PCI_BRIDGE_DEV_F_SHPC_REQ, true),
DEFINE_PROP_UINT32("bus-reserve", PCIBridgeDev,
res_reserve.bus, -1),
DEFINE_PROP_SIZE("io-reserve", PCIBridgeDev,
res_reserve.io, -1),
DEFINE_PROP_SIZE("mem-reserve", PCIBridgeDev,
res_reserve.mem_non_pref, -1),
DEFINE_PROP_SIZE("pref32-reserve", PCIBridgeDev,
res_reserve.mem_pref_32, -1),
DEFINE_PROP_SIZE("pref64-reserve", PCIBridgeDev,
res_reserve.mem_pref_64, -1),

DEFINE_PROP_END_OF_LIST(),
};

Expand Down

0 comments on commit 6755e61

Please sign in to comment.