Skip to content

Commit

Permalink
pnv_phb4.c: make pnv-phb4-root-port user creatable
Browse files Browse the repository at this point in the history
We want to create only the absolutely minimal amount of devices when
running with -nodefaults. The root port is something that the machine
can boot up without. But, to do that, we need to provide a way for the
user to add them by hand.

This patch makes pnv-phb4-root-port user creatable and then uses the
pnv_phb_attach_root_port() helper to add a pnv_phb4_root_port only when
running with default settings.

Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <20220105212338.49899-5-danielhb413@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
  • Loading branch information
danielhb authored and legoater committed Jan 12, 2022
1 parent a71cd51 commit 1360fd8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 7 additions & 11 deletions hw/pci-host/pnv_phb4.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "qom/object.h"
#include "sysemu/sysemu.h"
#include "trace.h"

#define phb_error(phb, fmt, ...) \
Expand Down Expand Up @@ -1159,12 +1160,6 @@ static void pnv_phb4_instance_init(Object *obj)

/* XIVE interrupt source object */
object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE);

/* Root Port */
object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB4_ROOT_PORT);

qdev_prop_set_int32(DEVICE(&phb->root), "addr", PCI_DEVFN(0, 0));
qdev_prop_set_bit(DEVICE(&phb->root), "multifunction", false);
}

static void pnv_phb4_realize(DeviceState *dev, Error **errp)
Expand Down Expand Up @@ -1208,10 +1203,11 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
pci_setup_iommu(pci->bus, pnv_phb4_dma_iommu, phb);
pci->bus->flags |= PCI_BUS_EXTENDED_CONFIG_SPACE;

/* Add a single Root port */
qdev_prop_set_uint8(DEVICE(&phb->root), "chassis", phb->chip_id);
qdev_prop_set_uint16(DEVICE(&phb->root), "slot", phb->phb_id);
qdev_realize(DEVICE(&phb->root), BUS(pci->bus), &error_fatal);
/* Add a single Root port if running with defaults */
if (defaults_enabled()) {
pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb),
TYPE_PNV_PHB4_ROOT_PORT);
}

/* Setup XIVE Source */
if (phb->big_phb) {
Expand Down Expand Up @@ -1369,7 +1365,7 @@ static void pnv_phb4_root_port_class_init(ObjectClass *klass, void *data)
PCIERootPortClass *rpc = PCIE_ROOT_PORT_CLASS(klass);

dc->desc = "IBM PHB4 PCIE Root Port";
dc->user_creatable = false;
dc->user_creatable = true;

device_class_set_parent_realize(dc, pnv_phb4_root_port_realize,
&rpc->parent_realize);
Expand Down
2 changes: 0 additions & 2 deletions include/hw/pci-host/pnv_phb4.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(PnvPHB4, PNV_PHB4)
struct PnvPHB4 {
PCIExpressHost parent_obj;

PnvPHB4RootPort root;

uint32_t chip_id;
uint32_t phb_id;

Expand Down

0 comments on commit 1360fd8

Please sign in to comment.