[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 18/19] ppc/pnv: Introduce support for user created PHB4 device
From: |
Cédric Le Goater |
Subject: |
[PATCH v2 18/19] ppc/pnv: Introduce support for user created PHB4 devices |
Date: |
Mon, 13 Dec 2021 14:28:29 +0100 |
PHB4 devices and PCI devices can now be added to the powernv9 machine
using:
-device pnv-phb4-pec,chip-id=0,index=0
-device nec-usb-xhci,bus=pci.0,addr=0x0
In case of user created devices, a lookup on 'chip-id' is required to
assign the owning chip.
To be noted, that the PEC PHB4 devices can add more than one PHB4
devices:
* PEC0 provides 1 PHB (PHB0)
* PEC1 provides 2 PHBs (PHB1 and PHB2)
* PEC2 provides 3 PHBs (PHB3, PHB4 and PHB5)
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Reviewed-by: Frederic Barrat <fbarrat@linux.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
hw/pci-host/pnv_phb4_pec.c | 19 ++++++++++++++++++-
hw/ppc/pnv.c | 5 +++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 24a3adcae326..4fbb8061455d 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -394,6 +394,17 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
char name[64];
int i;
+ /* User created devices */
+ if (!pec->chip) {
+ PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
+
+ pec->chip = pnv_get_chip(pnv, pec->chip_id);
+ if (!pec->chip) {
+ error_setg(errp, "invalid chip id: %d", pec->chip_id);
+ return;
+ }
+ }
+
if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) {
error_setg(errp, "invalid PEC index: %d", pec->index);
return;
@@ -401,6 +412,12 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
pec->num_stacks = pecc->num_stacks[pec->index];
+ /*
+ * Reparent user created devices to the chip to build correctly
+ * the device tree.
+ */
+ pnv_chip_parent_fixup(pec->chip, OBJECT(pec), pec->index);
+
/* Create stacks */
for (i = 0; i < pec->num_stacks; i++) {
PnvPhb4PecStack *stack = &pec->stacks[i];
@@ -516,7 +533,7 @@ static void pnv_pec_class_init(ObjectClass *klass, void
*data)
dc->realize = pnv_pec_realize;
device_class_set_props(dc, pnv_pec_properties);
- dc->user_creatable = false;
+ dc->user_creatable = true;
pecc->xscom_nest_base = pnv_pec_xscom_nest_base;
pecc->xscom_pci_base = pnv_pec_xscom_pci_base;
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 9c45aae1befe..2b027e299d27 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1350,8 +1350,9 @@ static void pnv_chip_power9_instance_init(Object *obj)
object_initialize_child(obj, "homer", &chip9->homer, TYPE_PNV9_HOMER);
- /* Number of PECs is the chip default */
- chip->num_pecs = pcc->num_pecs;
+ if (defaults_enabled()) {
+ chip->num_pecs = pcc->num_pecs;
+ }
for (i = 0; i < chip->num_pecs; i++) {
object_initialize_child(obj, "pec[*]", &chip9->pecs[i],
--
2.31.1
- [PATCH v2 05/19] ppc/pnv: Move mapping of the PHB3 CQ regions under pnv_pbcq_realize(), (continued)
- [PATCH v2 05/19] ppc/pnv: Move mapping of the PHB3 CQ regions under pnv_pbcq_realize(), Cédric Le Goater, 2021/12/13
- [PATCH v2 03/19] ppc/pnv: Use the chip class to check the index of PHB3 devices, Cédric Le Goater, 2021/12/13
- [PATCH v2 14/19] ppc/pnv: Use QOM hierarchy to scan PEC PHB4 devices, Cédric Le Goater, 2021/12/13
- [PATCH v2 01/19] ppc/pnv: Change the maximum of PHB3 devices for Power8NVL, Cédric Le Goater, 2021/12/13
- [PATCH v2 15/19] ppc/pnv: Introduce support for user created PHB3 devices, Cédric Le Goater, 2021/12/13
- [PATCH v2 16/19] ppc/pnv: Reparent user created PHB3 devices to the PnvChip, Cédric Le Goater, 2021/12/13
- [PATCH v2 13/19] ppc/pnv: Move realize of PEC stacks under the PEC model, Cédric Le Goater, 2021/12/13
- [PATCH v2 18/19] ppc/pnv: Introduce support for user created PHB4 devices,
Cédric Le Goater <=
- [PATCH v2 04/19] ppc/pnv: Drop the "num-phbs" property, Cédric Le Goater, 2021/12/13
- [PATCH v2 17/19] ppc/pnv: Complete user created PHB3 devices, Cédric Le Goater, 2021/12/13
- [PATCH v2 19/19] ppc/pnv: Move num_phbs under Pnv8Chip, Cédric Le Goater, 2021/12/13
- [PATCH v2 07/19] ppc/pnv: Introduce a num_pecs class attribute for PHB4 PEC devices, Cédric Le Goater, 2021/12/13
- [PATCH v2 09/19] ppc/pnv: Introduce a "chip" property under the PHB4 model, Cédric Le Goater, 2021/12/13
- Re: [PATCH v2 00/19] ppc/pnv: Add support for user created PHB3/PHB4 devices, Cédric Le Goater, 2021/12/15