Message ID | 20211222063817.1541058-5-clg@kaod.org |
---|---|
State | Superseded |
Headers | show |
Series | ppc/pnv: Preliminary cleanups before user created PHBs | expand |
On 12/22/21 03:38, Cédric Le Goater wrote: > This cleanups the PHB3 model a bit more since the root port is an > independent device and it will ease our task when adding user created > PHB3s. > > Signed-off-by: Cédric Le Goater <clg@kaod.org> > --- Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> > include/hw/pci-host/pnv_phb3.h | 2 -- > hw/pci-host/pnv_phb3.c | 8 -------- > hw/ppc/pnv.c | 14 ++++++++++++++ > 3 files changed, 14 insertions(+), 10 deletions(-) > > diff --git a/include/hw/pci-host/pnv_phb3.h b/include/hw/pci-host/pnv_phb3.h > index e9c13e6bd821..2e423c3890bc 100644 > --- a/include/hw/pci-host/pnv_phb3.h > +++ b/include/hw/pci-host/pnv_phb3.h > @@ -155,8 +155,6 @@ struct PnvPHB3 { > > PnvPBCQState pbcq; > > - PnvPHB3RootPort root; > - > QLIST_HEAD(, PnvPhb3DMASpace) dma_spaces; > > PnvChip *chip; > diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c > index 9c4451ca0d1c..39f03bd256d0 100644 > --- a/hw/pci-host/pnv_phb3.c > +++ b/hw/pci-host/pnv_phb3.c > @@ -980,10 +980,6 @@ static void pnv_phb3_instance_init(Object *obj) > /* Power Bus Common Queue */ > object_initialize_child(obj, "pbcq", &phb->pbcq, TYPE_PNV_PBCQ); > > - /* Root Port */ > - object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB3_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_phb3_realize(DeviceState *dev, Error **errp) > @@ -1051,10 +1047,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) > > pci_setup_iommu(pci->bus, pnv_phb3_dma_iommu, phb); > > - /* 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); > } > > void pnv_phb3_update_regions(PnvPHB3 *phb) > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > index 9de8b8353014..6edfd6876fd0 100644 > --- a/hw/ppc/pnv.c > +++ b/hw/ppc/pnv.c > @@ -1156,6 +1156,17 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp) > } > } > > +/* Attach a root port device */ > +static void pnv_phb_attach_root_port(PCIHostState *pci, int id, > + const char *name) > +{ > + PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name); > + > + qdev_prop_set_uint8(&root->qdev, "chassis", id); > + qdev_prop_set_uint16(&root->qdev, "slot", id); > + pci_realize_and_unref(root, pci->bus, &error_fatal); > +} > + > static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) > { > PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev); > @@ -1250,6 +1261,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) > if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) { > return; > } > + > + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id, > + TYPE_PNV_PHB3_ROOT_PORT); > } > } > >
diff --git a/include/hw/pci-host/pnv_phb3.h b/include/hw/pci-host/pnv_phb3.h index e9c13e6bd821..2e423c3890bc 100644 --- a/include/hw/pci-host/pnv_phb3.h +++ b/include/hw/pci-host/pnv_phb3.h @@ -155,8 +155,6 @@ struct PnvPHB3 { PnvPBCQState pbcq; - PnvPHB3RootPort root; - QLIST_HEAD(, PnvPhb3DMASpace) dma_spaces; PnvChip *chip; diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c index 9c4451ca0d1c..39f03bd256d0 100644 --- a/hw/pci-host/pnv_phb3.c +++ b/hw/pci-host/pnv_phb3.c @@ -980,10 +980,6 @@ static void pnv_phb3_instance_init(Object *obj) /* Power Bus Common Queue */ object_initialize_child(obj, "pbcq", &phb->pbcq, TYPE_PNV_PBCQ); - /* Root Port */ - object_initialize_child(obj, "root", &phb->root, TYPE_PNV_PHB3_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_phb3_realize(DeviceState *dev, Error **errp) @@ -1051,10 +1047,6 @@ static void pnv_phb3_realize(DeviceState *dev, Error **errp) pci_setup_iommu(pci->bus, pnv_phb3_dma_iommu, phb); - /* 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); } void pnv_phb3_update_regions(PnvPHB3 *phb) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 9de8b8353014..6edfd6876fd0 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -1156,6 +1156,17 @@ static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp) } } +/* Attach a root port device */ +static void pnv_phb_attach_root_port(PCIHostState *pci, int id, + const char *name) +{ + PCIDevice *root = pci_new(PCI_DEVFN(0, 0), name); + + qdev_prop_set_uint8(&root->qdev, "chassis", id); + qdev_prop_set_uint16(&root->qdev, "slot", id); + pci_realize_and_unref(root, pci->bus, &error_fatal); +} + static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) { PnvChipClass *pcc = PNV_CHIP_GET_CLASS(dev); @@ -1250,6 +1261,9 @@ static void pnv_chip_power8_realize(DeviceState *dev, Error **errp) if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) { return; } + + pnv_phb_attach_root_port(PCI_HOST_BRIDGE(phb), phb->phb_id, + TYPE_PNV_PHB3_ROOT_PORT); } }
This cleanups the PHB3 model a bit more since the root port is an independent device and it will ease our task when adding user created PHB3s. Signed-off-by: Cédric Le Goater <clg@kaod.org> --- include/hw/pci-host/pnv_phb3.h | 2 -- hw/pci-host/pnv_phb3.c | 8 -------- hw/ppc/pnv.c | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 10 deletions(-)