[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 15/19] ppc/pnv: Introduce support for user created PHB3 device
From: |
Cédric Le Goater |
Subject: |
[PATCH v2 15/19] ppc/pnv: Introduce support for user created PHB3 devices |
Date: |
Mon, 13 Dec 2021 14:28:26 +0100 |
PHB3 devices and PCI devices can now be added to the powernv8 machine
using :
-device pnv-phb3,chip-id=0,index=1 \
-device nec-usb-xhci,bus=pci.1,addr=0x0
The 'index' property identifies the PHB3 in the chip. In case of user
created devices, a lookup on 'chip-id' is required to assign the
owning chip.
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
include/hw/ppc/pnv.h | 2 ++
hw/pci-host/pnv_phb3.c | 11 ++++++++++-
hw/ppc/pnv.c | 23 ++++++++++++++++++-----
3 files changed, 30 insertions(+), 6 deletions(-)
diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
index c781525277db..9b06a9e9948d 100644
--- a/include/hw/ppc/pnv.h
+++ b/include/hw/ppc/pnv.h
@@ -217,6 +217,8 @@ struct PnvMachineState {
hwaddr fw_load_addr;
};
+PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id);
+
#define PNV_FDT_ADDR 0x01000000
#define PNV_TIMEBASE_FREQ 512000000ULL
diff --git a/hw/pci-host/pnv_phb3.c b/hw/pci-host/pnv_phb3.c
index 9c4451ca0d1c..4a022de7c1dc 100644
--- a/hw/pci-host/pnv_phb3.c
+++ b/hw/pci-host/pnv_phb3.c
@@ -993,6 +993,15 @@ static void pnv_phb3_realize(DeviceState *dev, Error
**errp)
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
int i;
+ /* User created devices */
+ if (!phb->chip) {
+ phb->chip = pnv_get_chip(pnv, phb->chip_id);
+ if (!phb->chip) {
+ error_setg(errp, "invalid chip id: %d", phb->chip_id);
+ return;
+ }
+ }
+
if (phb->phb_id >= PNV_CHIP_GET_CLASS(phb->chip)->num_phbs) {
error_setg(errp, "invalid PHB index: %d", phb->phb_id);
return;
@@ -1105,7 +1114,7 @@ static void pnv_phb3_class_init(ObjectClass *klass, void
*data)
dc->realize = pnv_phb3_realize;
device_class_set_props(dc, pnv_phb3_properties);
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
- dc->user_creatable = false;
+ dc->user_creatable = true;
}
static const TypeInfo pnv_phb3_type_info = {
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
index 9de8b8353014..d134eca0ee9d 100644
--- a/hw/ppc/pnv.c
+++ b/hw/ppc/pnv.c
@@ -1117,14 +1117,14 @@ static void pnv_chip_power8_instance_init(Object *obj)
object_initialize_child(obj, "homer", &chip8->homer, TYPE_PNV8_HOMER);
- for (i = 0; i < pcc->num_phbs; i++) {
+ if (defaults_enabled()) {
+ chip->num_phbs = pcc->num_phbs;
+ }
+
+ for (i = 0; i < chip->num_phbs; i++) {
object_initialize_child(obj, "phb[*]", &chip8->phbs[i], TYPE_PNV_PHB3);
}
- /*
- * Number of PHBs is the chip default
- */
- chip->num_phbs = pcc->num_phbs;
}
static void pnv_chip_icp_realize(Pnv8Chip *chip8, Error **errp)
@@ -1806,6 +1806,19 @@ static ICSState *pnv_ics_get(XICSFabric *xi, int irq)
return NULL;
}
+PnvChip *pnv_get_chip(PnvMachineState *pnv, uint32_t chip_id)
+{
+ int i;
+
+ for (i = 0; i < pnv->num_chips; i++) {
+ PnvChip *chip = pnv->chips[i];
+ if (chip->chip_id == chip_id) {
+ return chip;
+ }
+ }
+ return NULL;
+}
+
static int pnv_ics_resend_child(Object *child, void *opaque)
{
PnvPHB3 *phb3 = (PnvPHB3 *) object_dynamic_cast(child, TYPE_PNV_PHB3);
--
2.31.1
- [PATCH v2 12/19] ppc/pnv: Remove "system-memory" property from PHB4 PEC, (continued)
- [PATCH v2 12/19] ppc/pnv: Remove "system-memory" property from PHB4 PEC, Cédric Le Goater, 2021/12/13
- [PATCH v2 10/19] ppc/pnv: Introduce a num_stack class attribute, Cédric Le Goater, 2021/12/13
- [PATCH v2 11/19] ppc/pnv: Compute the PHB index from the PHB4 PEC model, Cédric Le Goater, 2021/12/13
- [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 <=
- [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, 2021/12/13
- [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