From patchwork Mon Feb 22 05:01:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bharata B Rao X-Patchwork-Id: 8371831 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1B86E9F314 for ; Mon, 22 Feb 2016 05:04:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6280D2039E for ; Mon, 22 Feb 2016 05:04:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E20E20380 for ; Mon, 22 Feb 2016 05:04:56 +0000 (UTC) Received: from localhost ([::1]:47048 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXig3-0005OI-TM for patchwork-qemu-devel@patchwork.kernel.org; Mon, 22 Feb 2016 00:04:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXidt-0001Yo-T7 for qemu-devel@nongnu.org; Mon, 22 Feb 2016 00:02:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aXidq-0004lv-MN for qemu-devel@nongnu.org; Mon, 22 Feb 2016 00:02:41 -0500 Received: from e23smtp03.au.ibm.com ([202.81.31.145]:55685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aXidq-0004lU-5f for qemu-devel@nongnu.org; Mon, 22 Feb 2016 00:02:38 -0500 Received: from localhost by e23smtp03.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 22 Feb 2016 15:02:36 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp03.au.ibm.com (202.81.31.209) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 22 Feb 2016 15:02:33 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: bharata@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org Received: from d23relay07.au.ibm.com (d23relay07.au.ibm.com [9.190.26.37]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id B8DED2CE8059 for ; Mon, 22 Feb 2016 16:02:32 +1100 (EST) Received: from d23av03.au.ibm.com (d23av03.au.ibm.com [9.190.234.97]) by d23relay07.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u1M52Ovg41877590 for ; Mon, 22 Feb 2016 16:02:32 +1100 Received: from d23av03.au.ibm.com (localhost [127.0.0.1]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u1M520PM014972 for ; Mon, 22 Feb 2016 16:02:00 +1100 Received: from bharata.in.ibm.com ([9.124.35.110]) by d23av03.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u1M51kl4013892; Mon, 22 Feb 2016 16:01:58 +1100 From: Bharata B Rao To: qemu-devel@nongnu.org Date: Mon, 22 Feb 2016 10:31:21 +0530 Message-Id: <1456117285-22273-5-git-send-email-bharata@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1456117285-22273-1-git-send-email-bharata@linux.vnet.ibm.com> References: <1456117285-22273-1-git-send-email-bharata@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16022205-0009-0000-0000-000003066D14 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 202.81.31.145 Cc: ehabkost@redhat.com, aik@ozlabs.ru, Bharata B Rao , 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 4/8] spapr: Introduce CPU core device X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 + * + * 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 +#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 + * + * 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