aboutsummaryrefslogtreecommitdiff
path: root/hw/pci-host/pnv_phb4_pec.c
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2021-12-17 17:57:19 +0100
committerCédric Le Goater <clg@kaod.org>2021-12-17 17:57:19 +0100
commit6f43d2551fba2569e67c8c1ac4e8768a566738eb (patch)
treecbf83b89ee71f5d0a514b274aa6e05b9305746db /hw/pci-host/pnv_phb4_pec.c
parent12060cbd3fd42e2a263c473829f5872c89dc71d7 (diff)
ppc/pnv: Introduce a "chip" property under the PHB4 model
And check the PEC index using the chip class. 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> Message-Id: <20211213132830.108372-10-clg@kaod.org> Signed-off-by: Cédric Le Goater <clg@kaod.org>
Diffstat (limited to 'hw/pci-host/pnv_phb4_pec.c')
-rw-r--r--hw/pci-host/pnv_phb4_pec.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/hw/pci-host/pnv_phb4_pec.c b/hw/pci-host/pnv_phb4_pec.c
index 9f722729ac..4b32b5ae6e 100644
--- a/hw/pci-host/pnv_phb4_pec.c
+++ b/hw/pci-host/pnv_phb4_pec.c
@@ -382,6 +382,11 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
assert(pec->system_memory);
+ if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) {
+ error_setg(errp, "invalid PEC index: %d", pec->index);
+ return;
+ }
+
/* Create stacks */
for (i = 0; i < pec->num_stacks; i++) {
PnvPhb4PecStack *stack = &pec->stacks[i];
@@ -462,6 +467,8 @@ static Property pnv_pec_properties[] = {
DEFINE_PROP_UINT32("index", PnvPhb4PecState, index, 0),
DEFINE_PROP_UINT32("num-stacks", PnvPhb4PecState, num_stacks, 0),
DEFINE_PROP_UINT32("chip-id", PnvPhb4PecState, chip_id, 0),
+ DEFINE_PROP_LINK("chip", PnvPhb4PecState, chip, TYPE_PNV_CHIP,
+ PnvChip *),
DEFINE_PROP_LINK("system-memory", PnvPhb4PecState, system_memory,
TYPE_MEMORY_REGION, MemoryRegion *),
DEFINE_PROP_END_OF_LIST(),