[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device
From: |
Bharata B Rao |
Subject: |
[Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device |
Date: |
Mon, 22 Feb 2016 10:31:21 +0530 |
sPAPR CPU core device is a container of CPU thread devices. CPU hotplug is
performed in the granularity of CPU core device by setting the "realized"
property of this device to "true". When hotplugged, CPU core creates CPU
thread devices.
TODO: Right now allows for only homogeneous configurations as we depend
on global smp_threads and machine->cpu_model.
Signed-off-by: Bharata B Rao <address@hidden>
---
hw/ppc/Makefile.objs | 1 +
hw/ppc/spapr_cpu_package.c | 50 ++++++++++++++++++++++++++++++++++++++
include/hw/ppc/spapr_cpu_package.h | 26 ++++++++++++++++++++
3 files changed, 77 insertions(+)
create mode 100644 hw/ppc/spapr_cpu_package.c
create mode 100644 include/hw/ppc/spapr_cpu_package.h
diff --git a/hw/ppc/Makefile.objs b/hw/ppc/Makefile.objs
index c1ffc77..3000982 100644
--- a/hw/ppc/Makefile.objs
+++ b/hw/ppc/Makefile.objs
@@ -4,6 +4,7 @@ obj-y += ppc.o ppc_booke.o
obj-$(CONFIG_PSERIES) += spapr.o spapr_vio.o spapr_events.o
obj-$(CONFIG_PSERIES) += spapr_hcall.o spapr_iommu.o spapr_rtas.o
obj-$(CONFIG_PSERIES) += spapr_pci.o spapr_rtc.o spapr_drc.o spapr_rng.o
+obj-$(CONFIG_PSERIES) += spapr_cpu_package.o
ifeq ($(CONFIG_PCI)$(CONFIG_PSERIES)$(CONFIG_LINUX), yyy)
obj-y += spapr_pci_vfio.o
endif
diff --git a/hw/ppc/spapr_cpu_package.c b/hw/ppc/spapr_cpu_package.c
new file mode 100644
index 0000000..3120a16
--- /dev/null
+++ b/hw/ppc/spapr_cpu_package.c
@@ -0,0 +1,50 @@
+/*
+ * sPAPR CPU package device, acts as container of CPU thread devices.
+ *
+ * Copyright (C) 2016 Bharata B Rao <address@hidden>
+ *
+ * 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/cpu/package.h"
+#include "hw/ppc/spapr_cpu_package.h"
+#include "hw/boards.h"
+#include <sysemu/cpus.h>
+#include "qemu/error-report.h"
+
+static void spapr_cpu_package_instance_init(Object *obj)
+{
+ int i;
+ CPUState *cpu;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ sPAPRCPUPackage *package = SPAPR_CPU_PACKAGE(obj);
+
+ /* Create as many CPU threads as specified in the topology */
+ for (i = 0; i < smp_threads; i++) {
+ cpu = cpu_generic_init(machine->cpu_type, machine->cpu_model);
+ if (!cpu) {
+ error_setg(&error_fatal, "Unable to find CPU definition: %s\n",
+ machine->cpu_model);
+ }
+ object_property_add_child(obj, "thread[*]", OBJECT(cpu), &error_fatal);
+ object_unref(OBJECT(cpu));
+ DEVICE(OBJECT(cpu))->hotplugged = true;
+ if (!i) {
+ package->thread0 = POWERPC_CPU(cpu);
+ }
+ }
+}
+
+static const TypeInfo spapr_cpu_package_type_info = {
+ .name = TYPE_SPAPR_CPU_PACKAGE,
+ .parent = TYPE_CPU_PACKAGE,
+ .instance_init = spapr_cpu_package_instance_init,
+ .instance_size = sizeof(sPAPRCPUPackage),
+};
+
+static void spapr_cpu_package_register_types(void)
+{
+ type_register_static(&spapr_cpu_package_type_info);
+}
+
+type_init(spapr_cpu_package_register_types)
diff --git a/include/hw/ppc/spapr_cpu_package.h
b/include/hw/ppc/spapr_cpu_package.h
new file mode 100644
index 0000000..547dbc1
--- /dev/null
+++ b/include/hw/ppc/spapr_cpu_package.h
@@ -0,0 +1,26 @@
+/*
+ * sPAPR CPU package device.
+ *
+ * Copyright (C) 2016 Bharata B Rao <address@hidden>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef HW_SPAPR_CPU_PACKAGE_H
+#define HW_SPAPR_CPU_PACKAGE_H
+
+#include "hw/qdev.h"
+
+#define TYPE_SPAPR_CPU_PACKAGE "spapr-cpu-package"
+#define SPAPR_CPU_PACKAGE(obj) \
+ OBJECT_CHECK(sPAPRCPUPackage, (obj), TYPE_SPAPR_CPU_PACKAGE)
+
+typedef struct sPAPRCPUPackage {
+ /*< private >*/
+ DeviceState parent_obj;
+
+ /*< public >*/
+ PowerPCCPU *thread0;
+} sPAPRCPUPackage;
+
+#endif
--
2.1.0
- [Qemu-devel] [RFC PATCH v0 0/8] cpu-package hotplug, Bharata B Rao, 2016/02/22
- [Qemu-devel] [RFC PATCH v0 1/8] cpu: Store CPU typename in MachineState, Bharata B Rao, 2016/02/22
- [Qemu-devel] [RFC PATCH v0 2/8] cpu: Don't realize CPU from cpu_generic_init(), Bharata B Rao, 2016/02/22
- [Qemu-devel] [RFC PATCH v0 3/8] cpu: CPU package abstract device, Bharata B Rao, 2016/02/22
- [Qemu-devel] [RFC PATCH v0 5/8] spapr: Convert boot CPUs into CPU core device initialization, Bharata B Rao, 2016/02/22
- [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device,
Bharata B Rao <=
- Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device, Bharata B Rao, 2016/02/22
- Re: [Qemu-devel] [RFC PATCH v0 4/8] spapr: Introduce CPU core device, Andreas Färber, 2016/02/22
[Qemu-devel] [RFC PATCH v0 6/8] spapr: CPU hotplug support, Bharata B Rao, 2016/02/22
[Qemu-devel] [RFC PATCH v0 7/8] qmp: Implement query cpu-packages, Bharata B Rao, 2016/02/22