From: David Gibson <david@gibson.dropbear.id.au>
To: "Cédric Le Goater" <clg@kaod.org>
Cc: qemu-ppc@nongnu.org, Alexander Graf <agraf@suse.de>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 2/3] ppc/pnv: add a PnvChip object
Date: Tue, 16 Aug 2016 12:21:30 +1000 [thread overview]
Message-ID: <20160816022130.GB14530@voom.fritz.box> (raw)
In-Reply-To: <1470388537-2908-3-git-send-email-clg@kaod.org>
[-- Attachment #1: Type: text/plain, Size: 4638 bytes --]
On Fri, Aug 05, 2016 at 11:15:36AM +0200, Cédric 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.
>
> We start with an empty PnvChip which we will grow in the subsequent
> patches with controllers required to run the system.
>
> Signed-off-by: Cédric Le Goater <clg@kaod.org>
> ---
> hw/ppc/pnv.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
> include/hw/ppc/pnv.h | 15 +++++++++++++++
> 2 files changed, 62 insertions(+)
>
> 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 = POWERNV_MACHINE(machine);
> long fw_size;
> char *filename;
> + int i;
>
> 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 = 0;
> pnv->initrd_size = 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 = 1;
> +
> + pnv->chips = g_new0(PnvChip, pnv->num_chips);
> + for (i = 0; i < pnv->num_chips; i++) {
> + PnvChip *chip = &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);
> + }
> }
>
> static void powernv_machine_class_init(ObjectClass *oc, void *data)
> @@ -274,10 +292,39 @@ static const TypeInfo powernv_machine_2_8_info = {
> .class_init = powernv_machine_2_8_class_init,
> };
>
> +
> +static void pnv_chip_realize(DeviceState *dev, Error **errp)
> +{
> + ;
> +}
> +
> +static Property pnv_chip_properties[] = {
> + 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 = DEVICE_CLASS(klass);
> +
> + dc->realize = pnv_chip_realize;
> + dc->props = pnv_chip_properties;
> + dc->desc = "PowerNV Chip";
> + }
> +
> +static const TypeInfo pnv_chip_info = {
> + .name = TYPE_PNV_CHIP,
> + .parent = TYPE_SYS_BUS_DEVICE,
> + .instance_size = sizeof(PnvChip),
> + .class_init = 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);
> }
>
> 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
>
> #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;
>
> #define TYPE_POWERNV_MACHINE "powernv-machine"
> #define POWERNV_MACHINE(obj) \
> @@ -31,6 +43,9 @@ typedef struct sPowerNVMachineState {
>
> uint32_t initrd_base;
> long initrd_size;
> +
> + uint32_t num_chips;
> + PnvChip *chips;
> } sPowerNVMachineState;
>
> #endif /* _PPC_PNV_H */
--
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: 819 bytes --]
next prev parent reply other threads:[~2016-08-16 2:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-05 9:15 [Qemu-devel] [PATCH 0/3] ppc/pnc: add a minimal platform Cédric Le Goater
2016-08-05 9:15 ` [Qemu-devel] [PATCH 1/3] ppc/pnv: add skeleton PowerNV platform Cédric Le Goater
2016-08-16 2:12 ` David Gibson
2016-08-26 14:47 ` Cédric Le Goater
2016-08-26 22:48 ` Benjamin Herrenschmidt
2016-08-29 14:17 ` David Gibson
2016-08-29 14:16 ` David Gibson
2016-08-05 9:15 ` [Qemu-devel] [PATCH 2/3] ppc/pnv: add a PnvChip object Cédric Le Goater
2016-08-05 9:44 ` Benjamin Herrenschmidt
2016-08-05 16:48 ` Cédric Le Goater
2016-08-05 22:43 ` Benjamin Herrenschmidt
2016-08-16 2:18 ` David Gibson
2016-08-16 2:21 ` David Gibson [this message]
2016-08-26 16:31 ` Cédric Le Goater
2016-08-05 9:15 ` [Qemu-devel] [PATCH 3/3] ppc/pnv: add a PowerNVCPUCore object Cédric Le Goater
2016-08-16 2:39 ` David Gibson
2016-08-16 5:02 ` Benjamin Herrenschmidt
2016-08-26 17:55 ` Cédric Le Goater
2016-08-26 17:49 ` Cédric Le Goater
2016-08-29 14:30 ` David Gibson
2016-08-30 6:15 ` Benjamin Herrenschmidt
2016-08-30 6:28 ` David Gibson
2016-08-31 1:06 ` Benjamin Herrenschmidt
2016-08-30 7:23 ` Cédric Le Goater
2016-09-05 1:45 ` David Gibson
2016-09-06 7:45 ` Cédric Le Goater
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=20160816022130.GB14530@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=agraf@suse.de \
--cc=benh@kernel.crashing.org \
--cc=clg@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.