ppc/pnv: Introduce a num_stack class attribute

Each PEC device of the POWER9 chip has a predefined number of stacks,
equivalent of a root port complex:

  PEC0 -> 1 stack
  PEC1 -> 2 stacks
  PEC2 -> 3 stacks

Introduce a class attribute to hold these values and remove the
"num-stacks" property.

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-11-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 6f43d2551f
commit cf0ee6955c
3 changed files with 12 additions and 8 deletions

View File

@ -377,6 +377,7 @@ static void pnv_pec_instance_init(Object *obj)
static void pnv_pec_realize(DeviceState *dev, Error **errp) static void pnv_pec_realize(DeviceState *dev, Error **errp)
{ {
PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); PnvPhb4PecState *pec = PNV_PHB4_PEC(dev);
PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec);
char name[64]; char name[64];
int i; int i;
@ -387,6 +388,8 @@ static void pnv_pec_realize(DeviceState *dev, Error **errp)
return; return;
} }
pec->num_stacks = pecc->num_stacks[pec->index];
/* 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];
@ -465,7 +468,6 @@ static int pnv_pec_dt_xscom(PnvXScomInterface *dev, void *fdt,
static Property pnv_pec_properties[] = { 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("chip-id", PnvPhb4PecState, chip_id, 0), DEFINE_PROP_UINT32("chip-id", PnvPhb4PecState, chip_id, 0),
DEFINE_PROP_LINK("chip", PnvPhb4PecState, chip, TYPE_PNV_CHIP, DEFINE_PROP_LINK("chip", PnvPhb4PecState, chip, TYPE_PNV_CHIP,
PnvChip *), PnvChip *),
@ -484,6 +486,13 @@ static uint32_t pnv_pec_xscom_nest_base(PnvPhb4PecState *pec)
return PNV9_XSCOM_PEC_NEST_BASE + 0x400 * pec->index; return PNV9_XSCOM_PEC_NEST_BASE + 0x400 * pec->index;
} }
/*
* PEC0 -> 1 stack
* PEC1 -> 2 stacks
* PEC2 -> 3 stacks
*/
static const uint32_t pnv_pec_num_stacks[] = { 1, 2, 3 };
static void pnv_pec_class_init(ObjectClass *klass, void *data) static void pnv_pec_class_init(ObjectClass *klass, void *data)
{ {
DeviceClass *dc = DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass);
@ -508,6 +517,7 @@ static void pnv_pec_class_init(ObjectClass *klass, void *data)
pecc->stk_compat_size = sizeof(stk_compat); pecc->stk_compat_size = sizeof(stk_compat);
pecc->version = PNV_PHB4_VERSION; pecc->version = PNV_PHB4_VERSION;
pecc->device_id = PNV_PHB4_DEVICE_ID; pecc->device_id = PNV_PHB4_DEVICE_ID;
pecc->num_stacks = pnv_pec_num_stacks;
} }
static const TypeInfo pnv_pec_type_info = { static const TypeInfo pnv_pec_type_info = {

View File

@ -1393,13 +1393,6 @@ static void pnv_chip_power9_phb_realize(PnvChip *chip, Error **errp)
uint32_t pec_pci_base; uint32_t pec_pci_base;
object_property_set_int(OBJECT(pec), "index", i, &error_fatal); object_property_set_int(OBJECT(pec), "index", i, &error_fatal);
/*
* PEC0 -> 1 stack
* PEC1 -> 2 stacks
* PEC2 -> 3 stacks
*/
object_property_set_int(OBJECT(pec), "num-stacks", i + 1,
&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), object_property_set_link(OBJECT(pec), "chip", OBJECT(chip),

View File

@ -223,6 +223,7 @@ struct PnvPhb4PecClass {
int stk_compat_size; int stk_compat_size;
uint64_t version; uint64_t version;
uint64_t device_id; uint64_t device_id;
const uint32_t *num_stacks;
}; };
#endif /* PCI_HOST_PNV_PHB4_H */ #endif /* PCI_HOST_PNV_PHB4_H */