From patchwork Thu Nov 30 14:41:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhao Liu X-Patchwork-Id: 13474548 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.gnu.org (lists.gnu.org [209.51.188.17]) (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 E4807C07CA9 for ; Thu, 30 Nov 2023 14:39:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r8i7p-00083I-DR; Thu, 30 Nov 2023 09:34:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8i7n-00080q-R2; Thu, 30 Nov 2023 09:34:43 -0500 Received: from mgamail.intel.com ([192.55.52.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r8i7l-0001Un-Kd; Thu, 30 Nov 2023 09:34:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701354881; x=1732890881; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RiCVpo1qnLcoDF3gFOkmvt/7Et6vXhRGVnHUCJw060w=; b=DCaN5qDATQyJxyi5gUcdmjMm8JnLJssgdRJJA3N+79HDjnWgthCcf6Tu uBeZyZYnTpjL5mCu6q6tPfINqWjoldZaLOtjZx0x5jQXWphP4NgkK6MIF stXxOSuRz016iY4o82UgvvJ6dJEmy1j3/rnkOpSlXpMkX9fW98CuuoeCU 3wJv6KfiB3MiQBR/smlhiVuyU0WkEz3CbD9AfnAn5T55RGbEHUAXwH8ku dQVqMHPN+MTVTwz/bua6rdNAhdELPRg7f9qk+3UAP8ELbSBfyvIWfZ2nV Mf0mpZuSb8q9xbi0ifgiuYhOFuh1dST6TvHjmSzYpXu8ICvPq0Uz9vWvJ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="479532239" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="479532239" 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:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10910"; a="942730101" X-IronPort-AV: E=Sophos;i="6.04,239,1695711600"; d="scan'208";a="942730101" Received: from liuzhao-optiplex-7080.sh.intel.com ([10.239.160.36]) by orsmga005.jf.intel.com with ESMTP; 30 Nov 2023 06:34:28 -0800 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 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device Date: Thu, 30 Nov 2023 22:41:48 +0800 Message-Id: <20231130144203.2307629-27-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 Received-SPF: none client-ip=192.55.52.43; envelope-from=zhao1.liu@linux.intel.com; helo=mgamail.intel.com X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Zhao Liu Abstract drawer level as a topology device "cpu-drawer" to allow user to create drawer level topology from cli and later the cpu-drawers could be added into topology tree. In addition, mark the cpu-drawer 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/drawer.c | 46 +++++++++++++++++++++++++++++++++++++++++ hw/cpu/meson.build | 2 +- include/hw/cpu/drawer.h | 38 ++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/cpu/drawer.c create mode 100644 include/hw/cpu/drawer.h diff --git a/MAINTAINERS b/MAINTAINERS index dd5adfda64cc..4b373ff46ce3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1865,6 +1865,7 @@ F: hw/core/numa.c F: hw/cpu/book.c F: hw/cpu/cluster.c F: hw/cpu/die.c +F: hw/cpu/drawer.c F: hw/cpu/socket.c F: qapi/machine.json F: qapi/machine-common.json @@ -1875,6 +1876,7 @@ F: include/hw/core/cpu-topo.h F: include/hw/cpu/book.h F: include/hw/cpu/cluster.h F: include/hw/cpu/die.h +F: include/hw/cpu/drawer.h F: include/hw/cpu/socket.h F: include/sysemu/numa.h F: tests/unit/test-smp-parse.c diff --git a/hw/cpu/drawer.c b/hw/cpu/drawer.c new file mode 100644 index 000000000000..f1ccfd153284 --- /dev/null +++ b/hw/cpu/drawer.c @@ -0,0 +1,46 @@ +/* + * CPU drawer 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/drawer.h" + +static void cpu_drawer_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_DRAWER; +} + +static const TypeInfo cpu_drawer_type_info = { + .name = TYPE_CPU_DRAWER, + .parent = TYPE_CPU_TOPO, + .class_init = cpu_drawer_class_init, + .instance_size = sizeof(CPUDrawer), +}; + +static void cpu_drawer_register_types(void) +{ + type_register_static(&cpu_drawer_type_info); +} + +type_init(cpu_drawer_register_types) diff --git a/hw/cpu/meson.build b/hw/cpu/meson.build index c44b54c5abb0..0dea39364b98 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', 'socket.c', 'book.c')) +system_ss.add(files('core.c', 'cluster.c', 'die.c', 'socket.c', 'book.c', 'drawer.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/include/hw/cpu/drawer.h b/include/hw/cpu/drawer.h new file mode 100644 index 000000000000..34ae089d33bf --- /dev/null +++ b/include/hw/cpu/drawer.h @@ -0,0 +1,38 @@ +/* + * CPU drawer 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_DRAWER_H +#define HW_CPU_DRAWER_H + +#include "hw/core/cpu-topo.h" +#include "hw/qdev-core.h" + +#define TYPE_CPU_DRAWER "cpu-drawer" + +OBJECT_DECLARE_SIMPLE_TYPE(CPUDrawer, CPU_DRAWER) + +struct CPUDrawer { + /*< private >*/ + CPUTopoState obj; + + /*< public >*/ +}; + +#endif /* HW_CPU_DRAWER_H */