From patchwork Thu Nov 30 14:41:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 13474569 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83277C4167B for ; Thu, 30 Nov 2023 14:39:37 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.644793.1006393 (Exim 4.92) (envelope-from ) id 1r8iCL-0006rY-63; Thu, 30 Nov 2023 14:39:25 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 644793.1006393; Thu, 30 Nov 2023 14:39:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8iCJ-0006lI-Ph; Thu, 30 Nov 2023 14:39:23 +0000 Received: by outflank-mailman (input) for mailman id 644793; Thu, 30 Nov 2023 14:34:23 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1r8i7T-0008Nr-3q for xen-devel@lists.xenproject.org; Thu, 30 Nov 2023 14:34:23 +0000 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.43]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8c0dd47a-8f8d-11ee-9b0f-b553b5be7939; Thu, 30 Nov 2023 15:34:21 +0100 (CET) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Nov 2023 06:34:19 -0800 Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga005.jf.intel.com with ESMTP; 30 Nov 2023 06:34:09 -0800 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8c0dd47a-8f8d-11ee-9b0f-b553b5be7939 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701354861; x=1732890861; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KYdyPQbbzxDFAf7dgOGDTufkcJTYeF0L4udr4i03f58=; b=IrrMURKaH6rhRM63ns4KlXXO2WYmftjGoMKijoPv+1OILwu1B+Nmk9BT oyQqhfeID8eu/0CQmhfj3cBwtHrerKvSXs3woyC+4wAK8tErD/iyvr5WM WJ3CZO6DQk20W/4SrdEUEdXIPidaenVHPLGckSLjyGSAUxS7NqUy+f48z GH+cDdhNpYdMgQNNvC10tdANFaubzouYuX1tlVhk92AsAdOBOlOSYw/gk oCiGMCCARgR6zx+ghi1JR5ynzJwDdXbpMa6VyLsgBLkU6Sjuf134BS53v c+chkMY3qmXkRhS1SYsSdQ4a159bRBS0JYKXuAY4okyNk1mHiWTwQSv7s Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="479532185" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="479532185" X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="942730082" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="942730082" From: Zhao Liu To: Paolo Bonzini , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Richard Henderson , "Michael S . Tsirkin" , Jason Wang , Nicholas Piggin , Daniel Henrique Barboza , Igor Mammedov , =?utf-8?q?C=C3=A9dric_Le_Goater?= , =?utf-8?b?RnLDqWTDqXJp?= =?utf-8?b?YyBCYXJyYXQ=?= , David Gibson , Harsh Prateek Bora , Stefano Stabellini , Anthony Perard , Paul Durrant , Gerd Hoffmann , Peter Maydell , Alistair Francis , "Edgar E . Iglesias" , =?utf-8?q?Daniel_P_=2E_Ber?= =?utf-8?q?rang=C3=A9?= , Bin Meng , Palmer Dabbelt , Weiwei Li , Liu Zhiwei , qemu-devel@nongnu.org, kvm@vger.kernel.org, qemu-ppc@nongnu.org, xen-devel@lists.xenproject.org, qemu-arm@nongnu.org, qemu-riscv@nongnu.org, qemu-s390x@nongnu.org Cc: Nina Schoetterl-Glausch , Thomas Huth , Zhiyuan Lv , Zhenyu Wang , Yongwei Ma , Zhao Liu Subject: [RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device Date: Thu, 30 Nov 2023 22:41:46 +0800 Message-Id: <20231130144203.2307629-25-zhao1.liu@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> References: <20231130144203.2307629-1-zhao1.liu@linux.intel.com> MIME-Version: 1.0 From: Zhao Liu Abstract socket level as a topology device "cpu-socket" to allow user to create socket level topology from cli and later the cpu-sockets could be added into topology tree. In addition, mark the cpu-socket as DEVICE_CATEGORY_CPU_DEF category to indicate it belongs to the basic CPU definition and should be created from cli before board initialization. Signed-off-by: Zhao Liu --- MAINTAINERS | 2 ++ hw/cpu/meson.build | 2 +- hw/cpu/socket.c | 46 +++++++++++++++++++++++++++++++++++++++++ include/hw/cpu/socket.h | 38 ++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/cpu/socket.c create mode 100644 include/hw/cpu/socket.h diff --git a/MAINTAINERS b/MAINTAINERS index 91d0936edb32..6a9fa0aeed0c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1864,6 +1864,7 @@ F: hw/core/null-machine.c F: hw/core/numa.c F: hw/cpu/cluster.c F: hw/cpu/die.c +F: hw/cpu/socket.c F: qapi/machine.json F: qapi/machine-common.json F: qapi/machine-target.json @@ -1872,6 +1873,7 @@ F: include/hw/core/cpu.h F: include/hw/core/cpu-topo.h F: include/hw/cpu/cluster.h F: include/hw/cpu/die.h +F: include/hw/cpu/socket.h F: include/sysemu/numa.h F: tests/unit/test-smp-parse.c T: git https://gitlab.com/ehabkost/qemu.git machine-next diff --git a/hw/cpu/meson.build b/hw/cpu/meson.build index e685fe1c7d8a..251724fea86c 100644 --- a/hw/cpu/meson.build +++ b/hw/cpu/meson.build @@ -1,4 +1,4 @@ -system_ss.add(files('core.c', 'cluster.c', 'die.c')) +system_ss.add(files('core.c', 'cluster.c', 'die.c', 'socket.c')) system_ss.add(when: 'CONFIG_ARM11MPCORE', if_true: files('arm11mpcore.c')) system_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview_mpcore.c')) diff --git a/hw/cpu/socket.c b/hw/cpu/socket.c new file mode 100644 index 000000000000..afd29f8a91c1 --- /dev/null +++ b/hw/cpu/socket.c @@ -0,0 +1,46 @@ +/* + * CPU socket abstract device + * + * Copyright (c) 2023 Intel Corporation + * Author: Zhao Liu + * + * 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/socket.h" + +static void cpu_socket_class_init(ObjectClass *oc, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(oc); + CPUTopoClass *tc = CPU_TOPO_CLASS(oc); + + set_bit(DEVICE_CATEGORY_CPU_DEF, dc->categories); + + tc->level = CPU_TOPO_SOCKET; +} + +static const TypeInfo cpu_socket_type_info = { + .name = TYPE_CPU_SOCKET, + .parent = TYPE_CPU_TOPO, + .class_init = cpu_socket_class_init, + .instance_size = sizeof(CPUSocket), +}; + +static void cpu_socket_register_types(void) +{ + type_register_static(&cpu_socket_type_info); +} + +type_init(cpu_socket_register_types) diff --git a/include/hw/cpu/socket.h b/include/hw/cpu/socket.h new file mode 100644 index 000000000000..897852903cd2 --- /dev/null +++ b/include/hw/cpu/socket.h @@ -0,0 +1,38 @@ +/* + * CPU socket abstract device + * + * Copyright (c) 2023 Intel Corporation + * Author: Zhao Liu + * + * 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_SOCKET_H +#define HW_CPU_SOCKET_H + +#include "hw/core/cpu-topo.h" +#include "hw/qdev-core.h" + +#define TYPE_CPU_SOCKET "cpu-socket" + +OBJECT_DECLARE_SIMPLE_TYPE(CPUSocket, CPU_SOCKET) + +struct CPUSocket { + /*< private >*/ + CPUTopoState parent_obj; + + /*< public >*/ +}; + +#endif /* HW_CPU_SOCKET_H */