From nobody Tue Apr 15 14:46:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1546879040529247.1802575997524; Mon, 7 Jan 2019 08:37:20 -0800 (PST) Received: from localhost ([127.0.0.1]:43566 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXte-0000EH-C6 for importer@patchew.org; Mon, 07 Jan 2019 11:37:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggXoG-0004mj-Cl for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggXoE-0001b5-ME for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:28 -0500 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]:40571) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggXoE-0001Zk-D1 for qemu-devel@nongnu.org; Mon, 07 Jan 2019 11:31:26 -0500 Received: by mail-wr1-x429.google.com with SMTP id p4so1062139wrt.7 for ; Mon, 07 Jan 2019 08:31:26 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id j14sm46039759wrv.96.2019.01.07.08.31.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Jan 2019 08:31:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5VuVI331ytNyDlTx9NKnef1XgHmbGjUAdHkiXIl1t78=; b=JPEJhmgNkL+40L5rlrapeRorywEUpFJ4D5hCYENdHjAKedOy1VV09iy1f4Udhi7Em7 HuNR9BI/8DPoKc/S9PfjXAlgceSScmSMNq2gNx4NGugoPICemJufXISiUizCH54SL5rH lFGxsaLeeGfeDKvvXh2Sn2LNZMKhFVEPc2Olk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5VuVI331ytNyDlTx9NKnef1XgHmbGjUAdHkiXIl1t78=; b=s5ZgQuMNH/SeAWNr8gDBWWOewARgeiOAGOcAA5VVh+riAvkgmb+S4noc3DJ5IfqgIH iZUvn0ZTDGN6+xGcVt8vA4S2j6O4tiDRvT4dV8YvGJYpnHfpOOzBL4YDOv0HBNxV/udu 97vFlUgkAeL2gp8N+l42DaylbZOiLaLqZWtHClZImTeIXpB04zjsSt9zvrfmj+wnlh4U eSpZG/6a+13LNQDpNeiotN++sUhoyexhb0kXcCUkJLjnQJRuUNZhZfskqPxb+3sVNx/a MZ6RfTWD1MkY0PqFEvYE4rG1DoDuXdayURhxmtAZXSr4KLLbClmEIyNR0JajXGHIbCBj 9M2g== X-Gm-Message-State: AJcUukeLMMdmLKawmodY3ttyWJ+29PZ2bsKnlDfmuAB0C2Dt4itaZctb donwFXPny+inERk7OWjTfgTGVOrzsPKktA== X-Google-Smtp-Source: ALg8bN7kZVQCSHAG6mCFYCjIlY1a9FwAeF3rOdhSnrpuJoEFNiKs+2ABfRQi5Ram+IX02OGvz8rRDg== X-Received: by 2002:a5d:6244:: with SMTP id m4mr41722713wrv.314.1546878684935; Mon, 07 Jan 2019 08:31:24 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 7 Jan 2019 16:30:43 +0000 Message-Id: <20190107163117.16269-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190107163117.16269-1-peter.maydell@linaro.org> References: <20190107163117.16269-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::429 Subject: [Qemu-devel] [PULL 03/37] hw/cpu: introduce CPU clusters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Luc Michel This commit adds the cpu-cluster type. It aims at gathering CPUs from the same cluster in a machine. For now it only has a `cluster-id` property. Documentation in cluster.h written with the help of Peter Maydell. Signed-off-by: Luc Michel Reviewed-by: Alistair Francis Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Edgar E. Iglesias Message-id: 20181207090135.7651-2-luc.michel@greensocs.com Signed-off-by: Peter Maydell --- hw/cpu/Makefile.objs | 2 +- include/hw/cpu/cluster.h | 58 ++++++++++++++++++++++++++++++++++++++++ hw/cpu/cluster.c | 50 ++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 ++ 4 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 include/hw/cpu/cluster.h create mode 100644 hw/cpu/cluster.c diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs index cd52d20b652..8db9e8a7b3c 100644 --- a/hw/cpu/Makefile.objs +++ b/hw/cpu/Makefile.objs @@ -2,4 +2,4 @@ obj-$(CONFIG_ARM11MPCORE) +=3D arm11mpcore.o obj-$(CONFIG_REALVIEW) +=3D realview_mpcore.o obj-$(CONFIG_A9MPCORE) +=3D a9mpcore.o obj-$(CONFIG_A15MPCORE) +=3D a15mpcore.o -common-obj-y +=3D core.o +common-obj-y +=3D core.o cluster.o diff --git a/include/hw/cpu/cluster.h b/include/hw/cpu/cluster.h new file mode 100644 index 00000000000..73818232437 --- /dev/null +++ b/include/hw/cpu/cluster.h @@ -0,0 +1,58 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ +#ifndef HW_CPU_CLUSTER_H +#define HW_CPU_CLUSTER_H + +#include "qemu/osdep.h" +#include "hw/qdev.h" + +/* + * CPU Cluster type + * + * A cluster is a group of CPUs which are all identical and have the same = view + * of the rest of the system. It is mainly an internal QEMU representation= and + * does not necessarily match with the notion of clusters on the real hard= ware. + * + * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs = in an + * Arm big.LITTLE system) they should be in different clusters. If the CPU= s do + * not have the same view of memory (for example the main CPU and a manage= ment + * controller processor) they should be in different clusters. + */ + +#define TYPE_CPU_CLUSTER "cpu-cluster" +#define CPU_CLUSTER(obj) \ + OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER) + +/** + * CPUClusterState: + * @cluster_id: The cluster ID. This value is for internal use only and sh= ould + * not be exposed directly to the user or to the guest. + * + * State of a CPU cluster. + */ +typedef struct CPUClusterState { + /*< private >*/ + DeviceState parent_obj; + + /*< public >*/ + uint32_t cluster_id; +} CPUClusterState; + +#endif diff --git a/hw/cpu/cluster.c b/hw/cpu/cluster.c new file mode 100644 index 00000000000..9d50a235d5c --- /dev/null +++ b/hw/cpu/cluster.c @@ -0,0 +1,50 @@ +/* + * QEMU CPU cluster + * + * Copyright (c) 2018 GreenSocs SAS + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see + * + */ + +#include "qemu/osdep.h" +#include "hw/cpu/cluster.h" +#include "qapi/error.h" +#include "qemu/module.h" + +static Property cpu_cluster_properties[] =3D { + DEFINE_PROP_UINT32("cluster-id", CPUClusterState, cluster_id, 0), + DEFINE_PROP_END_OF_LIST() +}; + +static void cpu_cluster_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->props =3D cpu_cluster_properties; +} + +static const TypeInfo cpu_cluster_type_info =3D { + .name =3D TYPE_CPU_CLUSTER, + .parent =3D TYPE_DEVICE, + .instance_size =3D sizeof(CPUClusterState), + .class_init =3D cpu_cluster_class_init, +}; + +static void cpu_cluster_register_types(void) +{ + type_register_static(&cpu_cluster_type_info); +} + +type_init(cpu_cluster_register_types) diff --git a/MAINTAINERS b/MAINTAINERS index 19792cfb2da..471161742de 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1195,7 +1195,9 @@ M: Marcel Apfelbaum S: Supported F: hw/core/machine.c F: hw/core/null-machine.c +F: hw/cpu/cluster.c F: include/hw/boards.h +F: include/hw/cpu/cluster.h T: git https://github.com/ehabkost/qemu.git machine-next =20 Xtensa Machines --=20 2.19.2