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>
This commit is contained in:
Cédric Le Goater 2021-12-17 17:57:19 +01:00
parent 12060cbd3f
commit 6f43d2551f
3 changed files with 11 additions and 0 deletions

View File

@ -382,6 +382,11 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
assert(pec->system_memory); 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 */ /* Create stacks */
for (i = 0; i < pec->num_stacks; i++) { for (i = 0; i < pec->num_stacks; i++) {
PnvPhb4PecStack *stack = &pec->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("index", PnvPhb4PecState, index, 0),
DEFINE_PROP_UINT32("num-stacks", PnvPhb4PecState, num_stacks, 0), DEFINE_PROP_UINT32("num-stacks", PnvPhb4PecState, num_stacks, 0),
DEFINE_PROP_UINT32("chip-id", PnvPhb4PecState, chip_id, 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, DEFINE_PROP_LINK("system-memory", PnvPhb4PecState, system_memory,
TYPE_MEMORY_REGION, MemoryRegion *), TYPE_MEMORY_REGION, MemoryRegion *),
DEFINE_PROP_END_OF_LIST(), DEFINE_PROP_END_OF_LIST(),

View File

@ -1402,6 +1402,8 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp)
&error_fatal); &error_fatal);
object_property_set_int(OBJECT(pec), "chip-id", chip->chip_id, object_property_set_int(OBJECT(pec), "chip-id", chip->chip_id,
&error_fatal); &error_fatal);
object_property_set_link(OBJECT(pec), "chip", OBJECT(chip),
&error_fatal);
object_property_set_link(OBJECT(pec), "system-memory", object_property_set_link(OBJECT(pec), "system-memory",
OBJECT(get_system_memory()), &error_abort); OBJECT(get_system_memory()), &error_abort);
if (!qdev_realize(DEVICE(pec), NULL, errp)) { if (!qdev_realize(DEVICE(pec), NULL, errp)) {

View File

@ -205,6 +205,8 @@ struct PnvPhb4PecState {
#define PHB4_PEC_MAX_STACKS 3 #define PHB4_PEC_MAX_STACKS 3
uint32_t num_stacks; uint32_t num_stacks;
PnvPhb4PecStack stacks[PHB4_PEC_MAX_STACKS]; PnvPhb4PecStack stacks[PHB4_PEC_MAX_STACKS];
PnvChip *chip;
}; };