qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Bharata B Rao <bharata@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: ehabkost@redhat.com, aik@ozlabs.ru,
	Bharata B Rao <bharata@linux.vnet.ibm.com>,
	agraf@suse.de, armbru@redhat.com, pbonzini@redhat.com,
	imammedo@redhat.com, afaerber@suse.de,
	david@gibson.dropbear.id.au
Subject: [Qemu-devel] [RFC PATCH v0 5/8] spapr: Convert boot CPUs into CPU core device initialization
Date: Mon, 22 Feb 2016 10:31:22 +0530	[thread overview]
Message-ID: <1456117285-22273-6-git-send-email-bharata@linux.vnet.ibm.com> (raw)
In-Reply-To: <1456117285-22273-1-git-send-email-bharata@linux.vnet.ibm.com>

Initialize boot CPUs specified with -smp option as CPU core devices.
Create as many CPU package devices as necessary to fit in max_cpus and
populate (i,e., realize) only as many as required.

Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
---
 hw/ppc/spapr.c                     | 31 +++++++++++++++++++++++--------
 include/hw/ppc/spapr_cpu_package.h |  1 +
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 3892a99..f3913b4 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -64,6 +64,8 @@
 
 #include "hw/compat.h"
 #include "qemu-common.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "monitor/monitor.h"
 
 #include <libfdt.h>
 
@@ -1739,7 +1741,6 @@ static void ppc_spapr_init(MachineState *machine)
     const char *kernel_filename = machine->kernel_filename;
     const char *kernel_cmdline = machine->kernel_cmdline;
     const char *initrd_filename = machine->initrd_filename;
-    PowerPCCPU *cpu;
     PCIHostState *phb;
     int i;
     MemoryRegion *sysmem = get_system_memory();
@@ -1753,6 +1754,8 @@ static void ppc_spapr_init(MachineState *machine)
     long load_limit, fw_size;
     bool kernel_le = false;
     char *filename;
+    int spapr_packages = smp_cpus / smp_threads;
+    int spapr_max_packages = max_cpus / smp_threads;
 
     msi_supported = true;
 
@@ -1825,13 +1828,18 @@ static void ppc_spapr_init(MachineState *machine)
     }
     machine->cpu_type = TYPE_POWERPC_CPU;
 
-    for (i = 0; i < smp_cpus; i++) {
-        cpu = cpu_ppc_init(machine->cpu_model);
-        if (cpu == NULL) {
-            error_report("Unable to find PowerPC CPU definition");
-            exit(1);
+    /*
+     * Create enough CPU package devices for max_cpus and realize the
+     * required number of them.
+     */
+    for (i = 0; i < spapr_max_packages; i++) {
+        Object *spapr_cpu_package  =
+            cpu_package_create_object(TYPE_SPAPR_CPU_PACKAGE, i, &error_fatal);
+
+        if (i < spapr_packages) {
+            object_property_set_bool(spapr_cpu_package, true, "realized",
+                                     &error_fatal);
         }
-        spapr_cpu_init(spapr, cpu, &error_fatal);
     }
 
     if (kvm_enabled()) {
@@ -2231,6 +2239,7 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
                                       DeviceState *dev, Error **errp)
 {
     sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(qdev_get_machine());
+    sPAPRMachineState *ms = SPAPR_MACHINE(hotplug_dev);
 
     if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
         int node;
@@ -2267,6 +2276,11 @@ static void spapr_machine_device_plug(HotplugHandler *hotplug_dev,
         }
 
         spapr_memory_plug(hotplug_dev, dev, node, errp);
+    } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
+        CPUState *cs = CPU(dev);
+        PowerPCCPU *cpu = POWERPC_CPU(cs);
+
+        spapr_cpu_init(ms, cpu, errp);
     }
 }
 
@@ -2281,7 +2295,8 @@ static void spapr_machine_device_unplug(HotplugHandler *hotplug_dev,
 static HotplugHandler *spapr_get_hotpug_handler(MachineState *machine,
                                              DeviceState *dev)
 {
-    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) {
+    if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM) ||
+        object_dynamic_cast(OBJECT(dev), TYPE_CPU)) {
         return HOTPLUG_HANDLER(machine);
     }
     return NULL;
diff --git a/include/hw/ppc/spapr_cpu_package.h b/include/hw/ppc/spapr_cpu_package.h
index 547dbc1..a3810d8 100644
--- a/include/hw/ppc/spapr_cpu_package.h
+++ b/include/hw/ppc/spapr_cpu_package.h
@@ -10,6 +10,7 @@
 #define HW_SPAPR_CPU_PACKAGE_H
 
 #include "hw/qdev.h"
+#include "hw/cpu/package.h"
 
 #define TYPE_SPAPR_CPU_PACKAGE "spapr-cpu-package"
 #define SPAPR_CPU_PACKAGE(obj) \
-- 
2.1.0

  parent reply	other threads:[~2016-02-22  5:02 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-22  5:01 [Qemu-devel] [RFC PATCH v0 0/8] cpu-package hotplug Bharata B Rao
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 1/8] cpu: Store CPU typename in MachineState Bharata B Rao
2016-02-22  8:04   ` David Gibson
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 2/8] cpu: Don't realize CPU from cpu_generic_init() Bharata B Rao
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 3/8] cpu: CPU package abstract device Bharata B Rao
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device Bharata B Rao
2016-02-22  6:44   ` Andreas Färber
2016-02-22  7:47     ` David Gibson
2016-02-22 15:58       ` Andreas Färber
2016-02-22 23:24         ` David Gibson
2016-02-22  8:05     ` Bharata B Rao
2016-02-22 15:48       ` Andreas Färber
2016-02-22  5:01 ` Bharata B Rao [this message]
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 6/8] spapr: CPU hotplug support Bharata B Rao
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 7/8] qmp: Implement query cpu-packages Bharata B Rao
2016-02-22 16:49   ` Eric Blake
2016-02-23  8:37     ` Igor Mammedov
2016-02-22  5:01 ` [Qemu-devel] [RFC PATCH v0 8/8] hmp: Implement 'info cpu-slots' Bharata B Rao
2016-02-22  5:10 ` [Qemu-devel] [RFC PATCH v0 0/8] cpu-package hotplug Bharata B Rao
2016-02-22 15:32 ` Andreas Färber
2016-02-22 23:28   ` David Gibson
2016-02-23  6:11   ` 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=1456117285-22273-6-git-send-email-bharata@linux.vnet.ibm.com \
    --to=bharata@linux.vnet.ibm.com \
    --cc=afaerber@suse.de \
    --cc=agraf@suse.de \
    --cc=aik@ozlabs.ru \
    --cc=armbru@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=ehabkost@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@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).