From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: mdroth@linux.vnet.ibm.com, agraf@suse.de, ehabkost@redhat.com,
qemu-devel@nongnu.org, pbonzini@redhat.com, qemu-ppc@nongnu.org,
tyreld@linux.vnet.ibm.com, nfont@linux.vnet.ibm.com,
imammedo@redhat.com, afaerber@suse.de,
david@gibson.dropbear.id.au
Subject: Re: [Qemu-devel] [PATCH v6 08/11] target-ppc: Introduce PowerPC specific CPU core device
Date: Wed, 13 Jan 2016 10:00:28 +0530 [thread overview]
Message-ID: <20160113043028.GF11785@in.ibm.com> (raw)
In-Reply-To: <56958FC7.3090609@ozlabs.ru>
On Wed, Jan 13, 2016 at 10:44:07AM +1100, Alexey Kardashevskiy wrote:
> On 01/08/2016 05:55 PM, Bharata B Rao wrote:
> >CPU core device is a container of CPU thread devices. CPU hotplug is
> >performed at the granularity of CPU core device. When hotplugged, CPU core
> >creates CPU thread devices.
> >
> >Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
> >---
> > hw/ppc/Makefile.objs | 1 +
> > hw/ppc/cpu-core.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++
> > include/hw/ppc/cpu-core.h | 22 +++++++++++++++
> > 3 files changed, 92 insertions(+)
> > create mode 100644 hw/ppc/cpu-core.c
> > create mode 100644 include/hw/ppc/cpu-core.h
> >
> >diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
> >index c1ffc77..a6b7cfb 100644
> >--- a/hw/ppc/Makefile.objs
> >+++ b/hw/ppc/Makefile.objs
> >@@ -21,3 +21,4 @@ obj-$(CONFIG_E500) += e500.o mpc8544ds.o e500plat.o
> > obj-$(CONFIG_E500) += mpc8544_guts.o ppce500_spin.o
> > # PowerPC 440 Xilinx ML507 reference board.
> > obj-$(CONFIG_XILINX) += virtex_ml507.o
> >+obj-y += cpu-core.o
> >diff --git a/hw/ppc/cpu-core.c b/hw/ppc/cpu-core.c
> >new file mode 100644
> >index 0000000..c5c6188
> >--- /dev/null
> >+++ b/hw/ppc/cpu-core.c
> >@@ -0,0 +1,69 @@
> >+/*
> >+ * CPU core device, acts as container of CPU thread devices.
> >+ *
> >+ * Copyright (C) 2015 Bharata B Rao <bharata@linux.vnet.ibm.com>
> >+ *
> >+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
> >+ * See the COPYING file in the top-level directory.
> >+ */
> >+#include "hw/ppc/cpu-core.h"
> >+#include "hw/boards.h"
> >+#include <sysemu/cpus.h>
> >+#include "qemu/error-report.h"
> >+
> >+static int ppc_cpu_core_realize_child(Object *child, void *opaque)
> >+{
> >+ Error **errp = opaque;
> >+
> >+ object_property_set_bool(child, true, "realized", errp);
> >+ if (*errp) {
> >+ return 1;
> >+ }
> >+
> >+ return 0;
> >+}
> >+
> >+static void ppc_cpu_core_realize(DeviceState *dev, Error **errp)
> >+{
> >+ object_child_foreach(OBJECT(dev), ppc_cpu_core_realize_child, errp);
> >+}
> >+
> >+static void ppc_cpu_core_class_init(ObjectClass *oc, void *data)
> >+{
> >+ DeviceClass *dc = DEVICE_CLASS(oc);
> >+
> >+ dc->realize = ppc_cpu_core_realize;
> >+}
> >+
> >+static void ppc_cpu_core_instance_init(Object *obj)
> >+{
> >+ int i;
> >+ CPUState *cpu;
> >+ MachineState *machine = MACHINE(qdev_get_machine());
> >+
> >+ /* Create as many CPU threads as specified in the topology */
> >+ for (i = 0; i < smp_threads; i++) {
> >+ cpu = cpu_generic_init(TYPE_POWERPC_CPU, machine->cpu_model);
> >+ if (!cpu) {
> >+ error_report("Unable to find CPU definition: %s\n",
> >+ machine->cpu_model);
> >+ exit(EXIT_FAILURE);
> >+ }
> >+ object_property_add_child(obj, "thread[*]", OBJECT(cpu), &error_abort);
> >+ object_unref(OBJECT(cpu));
> >+ }
> >+}
> >+
> >+static const TypeInfo ppc_cpu_core_type_info = {
> >+ .name = TYPE_POWERPC_CPU_CORE,
> >+ .parent = TYPE_DEVICE,
> >+ .class_init = ppc_cpu_core_class_init,
> >+ .instance_init = ppc_cpu_core_instance_init,
>
>
> Out of curiosity - why not .realize (and return Error instead of exit())?
> I'd think this is the recommended approach now for QOM.
This is an error during object creation and hence we don't have any
other option but to exit. I guess I should use error_setg(&error_fatal, )
instead of exit().
Note that realize time errors are being handled in
.realize (ppc_cpu_core_realize) already.
Regards,
Bharata.
next prev parent reply other threads:[~2016-01-13 4:30 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-08 6:55 [Qemu-devel] [PATCH v6 00/11] sPAPR CPU hotplug Bharata B Rao
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 01/11] machine: Don't allow CPU toplogies with partially filled cores Bharata B Rao
2016-01-12 4:03 ` David Gibson
2016-01-12 23:24 ` Alexey Kardashevskiy
2016-01-23 13:47 ` Eduardo Habkost
2016-01-25 8:57 ` Bharata B Rao
2016-01-26 17:47 ` Eduardo Habkost
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 02/11] exec: Remove cpu from cpus list during cpu_exec_exit() Bharata B Rao
2016-01-12 4:06 ` David Gibson
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 03/11] exec: Do vmstate unregistration from cpu_exec_exit() Bharata B Rao
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 04/11] cpu: Don't realize CPU from cpu_generic_init() Bharata B Rao
2016-01-12 4:09 ` David Gibson
2016-01-23 13:31 ` Eduardo Habkost
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 05/11] cpu: Reclaim vCPU objects Bharata B Rao
2016-01-12 4:13 ` David Gibson
2016-01-27 16:31 ` Matthew Rosato
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 06/11] cpu: Add a sync version of cpu_remove() Bharata B Rao
2016-01-12 4:16 ` David Gibson
2016-01-12 6:53 ` Bharata B Rao
2016-01-13 3:45 ` David Gibson
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 07/11] xics, xics_kvm: Handle CPU unplug correctly Bharata B Rao
2016-01-12 4:19 ` David Gibson
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 08/11] target-ppc: Introduce PowerPC specific CPU core device Bharata B Rao
2016-01-12 4:24 ` David Gibson
2016-01-12 23:30 ` Alexey Kardashevskiy
2016-01-12 23:44 ` Alexey Kardashevskiy
2016-01-13 4:30 ` Bharata B Rao [this message]
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 09/11] spapr: Enable CPU hotplug for pseries-2.6 and add CPU DRC DT entries Bharata B Rao
2016-01-12 5:41 ` David Gibson
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 10/11] spapr: CPU hotplug support Bharata B Rao
2016-01-12 5:58 ` David Gibson
2016-01-13 3:55 ` Bharata B Rao
2016-01-12 23:58 ` Alexey Kardashevskiy
2016-01-13 4:01 ` Bharata B Rao
2016-01-08 6:55 ` [Qemu-devel] [PATCH v6 11/11] spapr: CPU hot unplug support Bharata B Rao
2016-01-12 6:06 ` David Gibson
2016-01-13 4:10 ` Bharata B Rao
2016-01-13 4:57 ` David Gibson
2016-01-13 7:04 ` Bharata B Rao
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=20160113043028.GF11785@in.ibm.com \
--to=bharata@linux.vnet.ibm.com \
--cc=afaerber@suse.de \
--cc=agraf@suse.de \
--cc=aik@ozlabs.ru \
--cc=david@gibson.dropbear.id.au \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=nfont@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=tyreld@linux.vnet.ibm.com \
/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).