mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 10:13:56 -06:00
ppc/pnv: make PECs create and realize PHB4s
This patch changes the design of the PEC device to create and realize PHB4s instead of PecStacks. After all the recent changes, PHB4s now contain all the information needed for their proper functioning, not relying on PecStack in any capacity. All changes are being made in a single patch to avoid renaming parts of the PecState and leaving the code in a strange way. E.g. rename PecClass->num_stacks to num_phbs, which would then read a pnv_pec_num_stacks[] array. To avoid mixing the old and new design more than necessary it's clearer to do these changes in a single step. The name changes made are: - in PnvPhb4PecState: * rename 'num_stacks' to 'num_phbs' * remove the pec->stacks[] array. Current code relies on the pec->stacks[] obj acting as a simple container, without ever accessing pec->stacks[] for any other purpose. Instead of converting this into a pec->phbs[] array, remove it - in PnvPhb4PecClass, rename *num_stacks to *num_phbs; - pnv_pec_num_stacks[] is renamed to pnv_pec_num_phbs[]. The logical changes: - pnv_pec_default_phb_realize(): * init and set the properties of the PnvPHB4 qdev * do not use stack->phb anymore; - pnv_pec_realize(): * use the new default_phb_realize() to init/realize each PHB if running with defaults; - pnv_pec_instance_init(): removed since we're creating the PHBs during pec_realize(); - pnv_phb4_get_stack(): * renamed to pnv_phb4_get_pec() and returns a PnvPhb4PecState*; - pnv_phb4_realize(): use 'phb->pec' instead of 'stack'. This design change shouldn't caused any behavioral change in the runtime of the machine. Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Message-Id: <20220114180719.52117-7-danielhb413@gmail.com> Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
parent
5c9ecb2e44
commit
3f4c369ea6
3 changed files with 31 additions and 69 deletions
|
@ -884,7 +884,7 @@ static int pnv_phb4_get_phb_stack_no(PnvPHB4 *phb)
|
|||
int stack_no = phb->phb_id;
|
||||
|
||||
while (index--) {
|
||||
stack_no -= pecc->num_stacks[index];
|
||||
stack_no -= pecc->num_phbs[index];
|
||||
}
|
||||
|
||||
return stack_no;
|
||||
|
@ -1383,7 +1383,7 @@ int pnv_phb4_pec_get_phb_id(PnvPhb4PecState *pec, int stack_index)
|
|||
int offset = 0;
|
||||
|
||||
while (index--) {
|
||||
offset += pecc->num_stacks[index];
|
||||
offset += pecc->num_phbs[index];
|
||||
}
|
||||
|
||||
return offset + stack_index;
|
||||
|
@ -1534,8 +1534,8 @@ static void pnv_phb4_instance_init(Object *obj)
|
|||
object_initialize_child(obj, "source", &phb->xsrc, TYPE_XIVE_SOURCE);
|
||||
}
|
||||
|
||||
static PnvPhb4PecStack *pnv_phb4_get_stack(PnvChip *chip, PnvPHB4 *phb,
|
||||
Error **errp)
|
||||
static PnvPhb4PecState *pnv_phb4_get_pec(PnvChip *chip, PnvPHB4 *phb,
|
||||
Error **errp)
|
||||
{
|
||||
Pnv9Chip *chip9 = PNV9_CHIP(chip);
|
||||
int chip_id = phb->chip_id;
|
||||
|
@ -1544,14 +1544,14 @@ static PnvPhb4PecStack *pnv_phb4_get_stack(PnvChip *chip, PnvPHB4 *phb,
|
|||
|
||||
for (i = 0; i < chip->num_pecs; i++) {
|
||||
/*
|
||||
* For each PEC, check the amount of stacks it supports
|
||||
* and see if the given phb4 index matches a stack.
|
||||
* For each PEC, check the amount of phbs it supports
|
||||
* and see if the given phb4 index matches an index.
|
||||
*/
|
||||
PnvPhb4PecState *pec = &chip9->pecs[i];
|
||||
|
||||
for (j = 0; j < pec->num_stacks; j++) {
|
||||
for (j = 0; j < pec->num_phbs; j++) {
|
||||
if (index == pnv_phb4_pec_get_phb_id(pec, j)) {
|
||||
return &pec->stacks[j];
|
||||
return pec;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1576,7 +1576,6 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
|
|||
if (!phb->pec) {
|
||||
PnvMachineState *pnv = PNV_MACHINE(qdev_get_machine());
|
||||
PnvChip *chip = pnv_get_chip(pnv, phb->chip_id);
|
||||
PnvPhb4PecStack *stack;
|
||||
PnvPhb4PecClass *pecc;
|
||||
BusState *s;
|
||||
|
||||
|
@ -1585,18 +1584,13 @@ static void pnv_phb4_realize(DeviceState *dev, Error **errp)
|
|||
return;
|
||||
}
|
||||
|
||||
stack = pnv_phb4_get_stack(chip, phb, &local_err);
|
||||
phb->pec = pnv_phb4_get_pec(chip, phb, &local_err);
|
||||
if (local_err) {
|
||||
error_propagate(errp, local_err);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* All other phb properties but 'pec' ad 'version' are
|
||||
* already set.
|
||||
*/
|
||||
object_property_set_link(OBJECT(phb), "pec", OBJECT(stack->pec),
|
||||
&error_abort);
|
||||
/* All other phb properties are already set */
|
||||
pecc = PNV_PHB4_PEC_GET_CLASS(phb->pec);
|
||||
object_property_set_int(OBJECT(phb), "version", pecc->version,
|
||||
&error_fatal);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue