Message ID | 157623839642.360005.9243510140436689941.stgit@bahia.lan (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | ppc/pnv: Get rid of chip_type attributes | expand |
On 13/12/2019 12:59, Greg Kurz wrote: > We add an extra node to advertise power management on some machines, > namely powernv9 and powernv10. This is achieved by using the > pnv_is_power9() and pnv_is_power10() helpers. > > This can be achieved with QOM. Add a method to the base class for > powernv machines and have it implemented by machine types that > support power management instead. > > Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Cédric Le Goater <clg@kaod.org> > --- > hw/ppc/pnv.c | 10 ++++++---- > include/hw/ppc/pnv.h | 8 ++++++-- > 2 files changed, 12 insertions(+), 6 deletions(-) > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > index 5ac149b149d8..efc00f4cb67a 100644 > --- a/hw/ppc/pnv.c > +++ b/hw/ppc/pnv.c > @@ -472,7 +472,7 @@ static void pnv_dt_isa(PnvMachineState *pnv, void *fdt) > &args); > } > > -static void pnv_dt_power_mgt(void *fdt) > +static void pnv_dt_power_mgt(PnvMachineState *pnv, void *fdt) > { > int off; > > @@ -540,9 +540,9 @@ static void *pnv_dt_create(MachineState *machine) > pnv_dt_bmc_sensors(pnv->bmc, fdt); > } > > - /* Create an extra node for power management on Power9 and Power10 */ > - if (pnv_is_power9(pnv) || pnv_is_power10(pnv)) { > - pnv_dt_power_mgt(fdt); > + /* Create an extra node for power management on machines that support it */ > + if (pmc->dt_power_mgt) { > + pmc->dt_power_mgt(pnv, fdt); > } > > return fdt; > @@ -1710,6 +1710,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data) > > pmc->compat = compat; > pmc->compat_size = sizeof(compat); > + pmc->dt_power_mgt = pnv_dt_power_mgt; > } > > static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) > @@ -1723,6 +1724,7 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) > > pmc->compat = compat; > pmc->compat_size = sizeof(compat); > + pmc->dt_power_mgt = pnv_dt_power_mgt; > } > > static void pnv_machine_class_init(ObjectClass *oc, void *data) > diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h > index d534746bd493..8a42c199b65c 100644 > --- a/include/hw/ppc/pnv.h > +++ b/include/hw/ppc/pnv.h > @@ -190,6 +190,8 @@ PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir); > #define PNV_MACHINE_CLASS(klass) \ > OBJECT_CLASS_CHECK(PnvMachineClass, klass, TYPE_PNV_MACHINE) > > +typedef struct PnvMachineState PnvMachineState; > + > typedef struct PnvMachineClass { > /*< private >*/ > MachineClass parent_class; > @@ -197,9 +199,11 @@ typedef struct PnvMachineClass { > /*< public >*/ > const char *compat; > int compat_size; > + > + void (*dt_power_mgt)(PnvMachineState *pnv, void *fdt); > } PnvMachineClass; > > -typedef struct PnvMachineState { > +struct PnvMachineState { > /*< private >*/ > MachineState parent_obj; > > @@ -216,7 +220,7 @@ typedef struct PnvMachineState { > Notifier powerdown_notifier; > > PnvPnor *pnor; > -} PnvMachineState; > +}; > > static inline bool pnv_chip_is_power9(const PnvChip *chip) > { >
diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index 5ac149b149d8..efc00f4cb67a 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -472,7 +472,7 @@ static void pnv_dt_isa(PnvMachineState *pnv, void *fdt) &args); } -static void pnv_dt_power_mgt(void *fdt) +static void pnv_dt_power_mgt(PnvMachineState *pnv, void *fdt) { int off; @@ -540,9 +540,9 @@ static void *pnv_dt_create(MachineState *machine) pnv_dt_bmc_sensors(pnv->bmc, fdt); } - /* Create an extra node for power management on Power9 and Power10 */ - if (pnv_is_power9(pnv) || pnv_is_power10(pnv)) { - pnv_dt_power_mgt(fdt); + /* Create an extra node for power management on machines that support it */ + if (pmc->dt_power_mgt) { + pmc->dt_power_mgt(pnv, fdt); } return fdt; @@ -1710,6 +1710,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data) pmc->compat = compat; pmc->compat_size = sizeof(compat); + pmc->dt_power_mgt = pnv_dt_power_mgt; } static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) @@ -1723,6 +1724,7 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) pmc->compat = compat; pmc->compat_size = sizeof(compat); + pmc->dt_power_mgt = pnv_dt_power_mgt; } static void pnv_machine_class_init(ObjectClass *oc, void *data) diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h index d534746bd493..8a42c199b65c 100644 --- a/include/hw/ppc/pnv.h +++ b/include/hw/ppc/pnv.h @@ -190,6 +190,8 @@ PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir); #define PNV_MACHINE_CLASS(klass) \ OBJECT_CLASS_CHECK(PnvMachineClass, klass, TYPE_PNV_MACHINE) +typedef struct PnvMachineState PnvMachineState; + typedef struct PnvMachineClass { /*< private >*/ MachineClass parent_class; @@ -197,9 +199,11 @@ typedef struct PnvMachineClass { /*< public >*/ const char *compat; int compat_size; + + void (*dt_power_mgt)(PnvMachineState *pnv, void *fdt); } PnvMachineClass; -typedef struct PnvMachineState { +struct PnvMachineState { /*< private >*/ MachineState parent_obj; @@ -216,7 +220,7 @@ typedef struct PnvMachineState { Notifier powerdown_notifier; PnvPnor *pnor; -} PnvMachineState; +}; static inline bool pnv_chip_is_power9(const PnvChip *chip) {
We add an extra node to advertise power management on some machines, namely powernv9 and powernv10. This is achieved by using the pnv_is_power9() and pnv_is_power10() helpers. This can be achieved with QOM. Add a method to the base class for powernv machines and have it implemented by machine types that support power management instead. Signed-off-by: Greg Kurz <groug@kaod.org> --- hw/ppc/pnv.c | 10 ++++++---- include/hw/ppc/pnv.h | 8 ++++++-- 2 files changed, 12 insertions(+), 6 deletions(-)