From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZUFc-0002p1-Op for qemu-devel@nongnu.org; Mon, 15 Aug 2016 22:37:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZUFY-00022c-0n for qemu-devel@nongnu.org; Mon, 15 Aug 2016 22:37:12 -0400 Date: Tue, 16 Aug 2016 12:21:30 +1000 From: David Gibson Message-ID: <20160816022130.GB14530@voom.fritz.box> References: <1470388537-2908-1-git-send-email-clg@kaod.org> <1470388537-2908-3-git-send-email-clg@kaod.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qcHopEYAB45HaUaB" Content-Disposition: inline In-Reply-To: <1470388537-2908-3-git-send-email-clg@kaod.org> Subject: Re: [Qemu-devel] [PATCH 2/3] ppc/pnv: add a PnvChip object List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?iso-8859-1?Q?C=E9dric?= Le Goater Cc: qemu-ppc@nongnu.org, Alexander Graf , Benjamin Herrenschmidt , qemu-devel@nongnu.org --qcHopEYAB45HaUaB Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 05, 2016 at 11:15:36AM +0200, C=E9dric Le Goater wrote: > This is is an abstraction of a P8 chip which is a set of cores plus > other 'units', like the pervasive unit, the interrupt controller, the > memory controller, the on-chip microcontroller, etc. The whole can be > seen as a socket. >=20 > We start with an empty PnvChip which we will grow in the subsequent > patches with controllers required to run the system. >=20 > Signed-off-by: C=E9dric Le Goater > --- > hw/ppc/pnv.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ > include/hw/ppc/pnv.h | 15 +++++++++++++++ > 2 files changed, 62 insertions(+) >=20 > diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c > index 3bb6a240c25b..a680780e9dea 100644 > --- a/hw/ppc/pnv.c > +++ b/hw/ppc/pnv.c > @@ -185,6 +185,7 @@ static void ppc_powernv_init(MachineState *machine) > sPowerNVMachineState *pnv =3D POWERNV_MACHINE(machine); > long fw_size; > char *filename; > + int i; > =20 > if (ram_size < (1 * G_BYTE)) { > error_report("Warning: skiboot may not work with < 1GB of RAM"); > @@ -236,6 +237,23 @@ static void ppc_powernv_init(MachineState *machine) > pnv->initrd_base =3D 0; > pnv->initrd_size =3D 0; > } > + > + /* Create PowerNV chips > + * > + * FIXME: We should decide how many chips to create based on > + * #cores and Venice vs. Murano vs. Naples chip type etc..., for > + * now, just create one chip, with all the cores. > + */ > + pnv->num_chips =3D 1; > + > + pnv->chips =3D g_new0(PnvChip, pnv->num_chips); > + for (i =3D 0; i < pnv->num_chips; i++) { > + PnvChip *chip =3D &pnv->chips[i]; > + > + object_initialize(chip, sizeof(*chip), TYPE_PNV_CHIP); I think you'd be better off having an array of pointers, each one you allocate with object_new() rather than doing an explicit g_new0() for the whole array then using object_initialize(). For one thing, if certain chip subtypes need to allocate more space for their instance, then this approach will break, whereas object_new() will get that right. > + object_property_set_int(OBJECT(chip), i, "chip-id", &error_abort= ); > + object_property_set_bool(OBJECT(chip), true, "realized", &error_= abort); > + } > } > =20 > static void powernv_machine_class_init(ObjectClass *oc, void *data) > @@ -274,10 +292,39 @@ static const TypeInfo powernv_machine_2_8_info =3D { > .class_init =3D powernv_machine_2_8_class_init, > }; > =20 > + > +static void pnv_chip_realize(DeviceState *dev, Error **errp) > +{ > + ; > +} > + > +static Property pnv_chip_properties[] =3D { > + DEFINE_PROP_UINT32("chip-id", PnvChip, chip_id, 0), > + DEFINE_PROP_END_OF_LIST(), > +}; > + > +static void pnv_chip_class_init(ObjectClass *klass, void *data) > +{ > + DeviceClass *dc =3D DEVICE_CLASS(klass); > + > + dc->realize =3D pnv_chip_realize; > + dc->props =3D pnv_chip_properties; > + dc->desc =3D "PowerNV Chip"; > + } > + > +static const TypeInfo pnv_chip_info =3D { > + .name =3D TYPE_PNV_CHIP, > + .parent =3D TYPE_SYS_BUS_DEVICE, > + .instance_size =3D sizeof(PnvChip), > + .class_init =3D pnv_chip_class_init, > +}; > + > + > static void powernv_machine_register_types(void) > { > type_register_static(&powernv_machine_info); > type_register_static(&powernv_machine_2_8_info); > + type_register_static(&pnv_chip_info); > } > =20 > type_init(powernv_machine_register_types) > diff --git a/include/hw/ppc/pnv.h b/include/hw/ppc/pnv.h > index 2990f691672d..6907dc9e5c3d 100644 > --- a/include/hw/ppc/pnv.h > +++ b/include/hw/ppc/pnv.h > @@ -20,6 +20,18 @@ > #define _PPC_PNV_H > =20 > #include "hw/boards.h" > +#include "hw/sysbus.h" > + > +#define TYPE_PNV_CHIP "powernv-chip" > +#define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP) > + > +typedef struct PnvChip { > + /*< private >*/ > + SysBusDevice parent_obj; > + > + /*< public >*/ > + uint32_t chip_id; > +} PnvChip; > =20 > #define TYPE_POWERNV_MACHINE "powernv-machine" > #define POWERNV_MACHINE(obj) \ > @@ -31,6 +43,9 @@ typedef struct sPowerNVMachineState { > =20 > uint32_t initrd_base; > long initrd_size; > + > + uint32_t num_chips; > + PnvChip *chips; > } sPowerNVMachineState; > =20 > #endif /* _PPC_PNV_H */ --=20 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 --qcHopEYAB45HaUaB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXsniqAAoJEGw4ysog2bOSBj4QAMgU2kJ5Z4wu0rZVBP67aKtC h8woHB8fEaKJL/nuK7CUgHnr+fGiUqN1mx9r2vPv4eUGRqsmspYeDo5QXiCpf7e6 cXZLeCr+n9jXSHjEY8PAKDYdOoyKAiBtD+r8/MH+qusTiY5VAbwJOPfEmh1Iluof mFRdsADfvcFKvSOYXEWJ26W5UmUGEbkPCqTbNGWLBv7RIKuBVgc/dh5ZQea1pRuL fD4gnycAcrk9JC/MPYjLEHOWybMeYcEtCJ4tv/sETSI6CiwKvfODTJs2q5qpz/1n sAm3HXhg406S+HUAxfM4B3rGleuawBmvojmrJDn8luorUBBSWN+lBWcfmbJ6YX1n ynJ4srqBN6ZvdZkNYcYJ64D7WuTm7WBDIp8WpmG+HboJJiZzMzAORO1b4uyDQyhy slFZ+T7uuJu5BAiPqUT5+b/oRM/OIpjT9TFFThKXr4a3Ap74O1M5fjOQSBTe+MiJ TxjXLE+Dony9kxuoS3iziL2IvocujI+eDWCGKnj8jmyDc4JbK2+n1XMevpvZgQr+ /poJS8TJFlerDpX7wcsIYgjN/DXchErsnB/IM/fIK2cm1DaMDyJC7/NiL6fQxnpk DClWx3o/f53GguxBPgOc1EECfWxU/+nGiS04uLpWcaMv8JlujSDndYt3yTbN91Wq +c/7B8xkm/l0cmRzqevi =wpGY -----END PGP SIGNATURE----- --qcHopEYAB45HaUaB--