From: David Gibson <david@gibson.dropbear.id.au>
To: Greg Kurz <groug@kaod.org>
Cc: qemu-ppc@nongnu.org, "Cédric Le Goater" <clg@kaod.org>,
qemu-devel@nongnu.org
Subject: Re: [PATCH 04/13] ppc/pnv: Introduce PnvMachineClass and PnvMachineClass::compat
Date: Tue, 17 Dec 2019 11:00:09 +1100 [thread overview]
Message-ID: <20191217000009.GG6242@umbus.fritz.box> (raw)
In-Reply-To: <20191216190743.776f1d71@bahia.lan>
[-- Attachment #1: Type: text/plain, Size: 6698 bytes --]
On Mon, Dec 16, 2019 at 07:07:43PM +0100, Greg Kurz wrote:
> On Fri, 13 Dec 2019 13:44:48 +0100
> Cédric Le Goater <clg@kaod.org> wrote:
>
> > On 13/12/2019 12:59, Greg Kurz wrote:
> > > The pnv_dt_create() function generates different contents for the
> > > "compatible" property of the root node in the DT, depending on the
> > > CPU type. This is open coded with multiple ifs using pnv_is_powerXX()
> > > helpers.
> > >
> > > It seems cleaner to achieve with QOM. Introduce a base class for the
> > > powernv machine and a compat attribute that each child class can use
> > > to provide the value for the "compatible" property.
> > >
> > > Signed-off-by: Greg Kurz <groug@kaod.org>
> >
> > Reviewed-by: Cédric Le Goater <clg@kaod.org>
> >
> >
> > > ---
> > > hw/ppc/pnv.c | 33 +++++++++++++++++++--------------
> > > include/hw/ppc/pnv.h | 13 +++++++++++++
> > > 2 files changed, 32 insertions(+), 14 deletions(-)
> > >
> > > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c
> > > index 0be0b6b411c3..5ac149b149d8 100644
> > > --- a/hw/ppc/pnv.c
> > > +++ b/hw/ppc/pnv.c
> > > @@ -484,9 +484,7 @@ static void pnv_dt_power_mgt(void *fdt)
> > >
> > > static void *pnv_dt_create(MachineState *machine)
> > > {
> > > - const char plat_compat8[] = "qemu,powernv8\0qemu,powernv\0ibm,powernv";
> > > - const char plat_compat9[] = "qemu,powernv9\0ibm,powernv";
> > > - const char plat_compat10[] = "qemu,powernv10\0ibm,powernv";
> > > + PnvMachineClass *pmc = PNV_MACHINE_GET_CLASS(machine);
> > > PnvMachineState *pnv = PNV_MACHINE(machine);
> > > void *fdt;
> > > char *buf;
> > > @@ -504,17 +502,8 @@ static void *pnv_dt_create(MachineState *machine)
> > > _FDT((fdt_setprop_cell(fdt, 0, "#size-cells", 0x2)));
> > > _FDT((fdt_setprop_string(fdt, 0, "model",
> > > "IBM PowerNV (emulated by qemu)")));
> > > - if (pnv_is_power10(pnv)) {
> > > - _FDT((fdt_setprop(fdt, 0, "compatible", plat_compat10,
> > > - sizeof(plat_compat10))));
> > > - } else if (pnv_is_power9(pnv)) {
> > > - _FDT((fdt_setprop(fdt, 0, "compatible", plat_compat9,
> > > - sizeof(plat_compat9))));
> > > - } else {
> > > - _FDT((fdt_setprop(fdt, 0, "compatible", plat_compat8,
> > > - sizeof(plat_compat8))));
> > > - }
> > > -
> > > + _FDT((fdt_setprop(fdt, 0, "compatible", pmc->compat,
> > > + sizeof(pmc->compat))));
>
> Of course the size should be pmc->compat_size ... David, can you fix this
> in your tree or should I post a v2 ?
Ah, yes. This message came just barely in time - I've folded in the
fix as I've been setting up to to a pull request including it.
>
> > >
> > > buf = qemu_uuid_unparse_strdup(&qemu_uuid);
> > > _FDT((fdt_setprop_string(fdt, 0, "vm,uuid", buf)));
> > > @@ -1692,6 +1681,8 @@ static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
> > > {
> > > MachineClass *mc = MACHINE_CLASS(oc);
> > > XICSFabricClass *xic = XICS_FABRIC_CLASS(oc);
> > > + PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);
> > > + static const char compat[] = "qemu,powernv8\0qemu,powernv\0ibm,powernv";
> > >
> > > mc->desc = "IBM PowerNV (Non-Virtualized) POWER8";
> > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power8_v2.0");
> > > @@ -1699,26 +1690,39 @@ static void pnv_machine_power8_class_init(ObjectClass *oc, void *data)
> > > xic->icp_get = pnv_icp_get;
> > > xic->ics_get = pnv_ics_get;
> > > xic->ics_resend = pnv_ics_resend;
> > > +
> > > + pmc->compat = compat;
> > > + pmc->compat_size = sizeof(compat);
> > > }
> > >
> > > static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)
> > > {
> > > MachineClass *mc = MACHINE_CLASS(oc);
> > > XiveFabricClass *xfc = XIVE_FABRIC_CLASS(oc);
> > > + PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);
> > > + static const char compat[] = "qemu,powernv9\0ibm,powernv";
> > >
> > > mc->desc = "IBM PowerNV (Non-Virtualized) POWER9";
> > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power9_v2.0");
> > > xfc->match_nvt = pnv_match_nvt;
> > >
> > > mc->alias = "powernv";
> > > +
> > > + pmc->compat = compat;
> > > + pmc->compat_size = sizeof(compat);
> > > }
> > >
> > > static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)
> > > {
> > > MachineClass *mc = MACHINE_CLASS(oc);
> > > + PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);
> > > + static const char compat[] = "qemu,powernv10\0ibm,powernv";
> > >
> > > mc->desc = "IBM PowerNV (Non-Virtualized) POWER10";
> > > mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("power10_v1.0");
> > > +
> > > + pmc->compat = compat;
> > > + pmc->compat_size = sizeof(compat);
> > > }
> > >
> > > static void pnv_machine_class_init(ObjectClass *oc, void *data)
> > > @@ -1796,6 +1800,7 @@ static const TypeInfo types[] = {
> > > .instance_size = sizeof(PnvMachineState),
> > > .instance_init = pnv_machine_instance_init,
> > > .class_init = pnv_machine_class_init,
> > > + .class_size = sizeof(PnvMachineClass),
> > > .interfaces = (InterfaceInfo[]) {
> > > { TYPE_INTERRUPT_STATS_PROVIDER },
> > > { },
> > > diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h
> > > index 92f80b1ccead..d534746bd493 100644
> > > --- a/include/hw/ppc/pnv.h
> > > +++ b/include/hw/ppc/pnv.h
> > > @@ -185,6 +185,19 @@ PowerPCCPU *pnv_chip_find_cpu(PnvChip *chip, uint32_t pir);
> > > #define TYPE_PNV_MACHINE MACHINE_TYPE_NAME("powernv")
> > > #define PNV_MACHINE(obj) \
> > > OBJECT_CHECK(PnvMachineState, (obj), TYPE_PNV_MACHINE)
> > > +#define PNV_MACHINE_GET_CLASS(obj) \
> > > + OBJECT_GET_CLASS(PnvMachineClass, obj, TYPE_PNV_MACHINE)
> > > +#define PNV_MACHINE_CLASS(klass) \
> > > + OBJECT_CLASS_CHECK(PnvMachineClass, klass, TYPE_PNV_MACHINE)
> > > +
> > > +typedef struct PnvMachineClass {
> > > + /*< private >*/
> > > + MachineClass parent_class;
> > > +
> > > + /*< public >*/
> > > + const char *compat;
> > > + int compat_size;
> > > +} PnvMachineClass;
> > >
> > > typedef struct PnvMachineState {
> > > /*< private >*/
> > >
> >
> >
>
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2019-12-17 0:31 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-13 11:59 [PATCH 00/13] ppc/pnv: Get rid of chip_type attributes Greg Kurz
2019-12-13 11:59 ` [PATCH 01/13] ppc: Drop useless extern annotation for functions Greg Kurz
2019-12-13 11:59 ` [PATCH 02/13] ppc/pnv: Introduce PnvPsiClass::compat Greg Kurz
2019-12-13 12:42 ` Cédric Le Goater
2019-12-13 11:59 ` [PATCH 03/13] ppc/pnv: Drop PnvPsiClass::chip_type Greg Kurz
2019-12-13 12:43 ` Cédric Le Goater
2019-12-13 11:59 ` [PATCH 04/13] ppc/pnv: Introduce PnvMachineClass and PnvMachineClass::compat Greg Kurz
2019-12-13 12:44 ` Cédric Le Goater
2019-12-16 18:07 ` Greg Kurz
2019-12-17 0:00 ` David Gibson [this message]
2019-12-13 11:59 ` [PATCH 05/13] ppc/pnv: Introduce PnvMachineClass::dt_power_mgt() Greg Kurz
2019-12-13 12:44 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 06/13] ppc/pnv: Drop pnv_is_power9() and pnv_is_power10() helpers Greg Kurz
2019-12-13 12:59 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 07/13] ppc/pnv: Introduce PnvChipClass::intc_print_info() method Greg Kurz
2019-12-13 13:00 ` Cédric Le Goater
2019-12-16 1:28 ` David Gibson
2019-12-16 7:54 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 08/13] ppc/pnv: Introduce PnvChipClass::xscom_core_base() method Greg Kurz
2019-12-13 13:01 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 09/13] ppc/pnv: Pass XSCOM base address and address size to pnv_dt_xscom() Greg Kurz
2019-12-13 13:03 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 10/13] ppc/pnv: Pass content of the "compatible" property " Greg Kurz
2019-12-13 13:03 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 11/13] ppc/pnv: Drop pnv_chip_is_power9() and pnv_chip_is_power10() helpers Greg Kurz
2019-12-13 13:05 ` Cédric Le Goater
2019-12-13 12:00 ` [PATCH 12/13] ppc/pnv: Introduce PnvChipClass::xscom_pcba() method Greg Kurz
2019-12-13 13:06 ` Cédric Le Goater
2019-12-16 1:32 ` David Gibson
2019-12-13 12:00 ` [PATCH 13/13] ppc/pnv: Drop PnvChipClass::type Greg Kurz
2019-12-13 13:06 ` Cédric Le Goater
2019-12-16 1:34 ` [PATCH 00/13] ppc/pnv: Get rid of chip_type attributes David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191217000009.GG6242@umbus.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=clg@kaod.org \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).