[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology
From: |
Zhao Liu |
Subject: |
[RFC 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology |
Date: |
Thu, 30 Nov 2023 22:41:49 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
Abstract the root of topology tree as a special topology device
"cpu-slot".
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
MAINTAINERS | 2 ++
hw/core/cpu-slot.c | 48 ++++++++++++++++++++++++++++++++++++++
hw/core/meson.build | 1 +
include/hw/core/cpu-slot.h | 38 ++++++++++++++++++++++++++++++
4 files changed, 89 insertions(+)
create mode 100644 hw/core/cpu-slot.c
create mode 100644 include/hw/core/cpu-slot.h
diff --git a/MAINTAINERS b/MAINTAINERS
index 4b373ff46ce3..ac08b5a8c4e0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1856,6 +1856,7 @@ R: Philippe Mathieu-Daudé <philmd@linaro.org>
R: Yanan Wang <wangyanan55@huawei.com>
S: Supported
F: hw/core/cpu.c
+F: hw/core/cpu-slot.c
F: hw/core/cpu-topo.c
F: hw/core/machine-qmp-cmds.c
F: hw/core/machine.c
@@ -1872,6 +1873,7 @@ F: qapi/machine-common.json
F: qapi/machine-target.json
F: include/hw/boards.h
F: include/hw/core/cpu.h
+F: include/hw/core/cpu-slot.h
F: include/hw/core/cpu-topo.h
F: include/hw/cpu/book.h
F: include/hw/cpu/cluster.h
diff --git a/hw/core/cpu-slot.c b/hw/core/cpu-slot.c
new file mode 100644
index 000000000000..5aef5b0189c2
--- /dev/null
+++ b/hw/core/cpu-slot.c
@@ -0,0 +1,48 @@
+/*
+ * CPU slot device abstraction
+ *
+ * Copyright (c) 2023 Intel Corporation
+ * Author: Zhao Liu <zhao1.liu@intel.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include "qemu/osdep.h"
+
+#include "hw/core/cpu-slot.h"
+
+static void cpu_slot_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);
+ dc->user_creatable = false;
+
+ tc->level = CPU_TOPO_ROOT;
+}
+
+static const TypeInfo cpu_slot_type_info = {
+ .name = TYPE_CPU_SLOT,
+ .parent = TYPE_CPU_TOPO,
+ .class_init = cpu_slot_class_init,
+ .instance_size = sizeof(CPUSlot),
+};
+
+static void cpu_slot_register_types(void)
+{
+ type_register_static(&cpu_slot_type_info);
+}
+
+type_init(cpu_slot_register_types)
diff --git a/hw/core/meson.build b/hw/core/meson.build
index 501d2529697e..3347c054e162 100644
--- a/hw/core/meson.build
+++ b/hw/core/meson.build
@@ -23,6 +23,7 @@ else
endif
common_ss.add(files('cpu-common.c'))
+common_ss.add(files('cpu-slot.c'))
common_ss.add(files('cpu-topo.c'))
common_ss.add(files('machine-smp.c'))
system_ss.add(when: 'CONFIG_FITLOADER', if_true: files('loader-fit.c'))
diff --git a/include/hw/core/cpu-slot.h b/include/hw/core/cpu-slot.h
new file mode 100644
index 000000000000..718c8ecaa751
--- /dev/null
+++ b/include/hw/core/cpu-slot.h
@@ -0,0 +1,38 @@
+/*
+ * CPU slot device abstraction
+ *
+ * Copyright (c) 2023 Intel Corporation
+ * Author: Zhao Liu <zhao1.liu@intel.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef CPU_SLOT_H
+#define CPU_SLOT_H
+
+#include "hw/core/cpu-topo.h"
+#include "hw/qdev-core.h"
+
+#define TYPE_CPU_SLOT "cpu-slot"
+
+OBJECT_DECLARE_SIMPLE_TYPE(CPUSlot, CPU_SLOT)
+
+struct CPUSlot {
+ /*< private >*/
+ CPUTopoState parent_obj;
+
+ /*< public >*/
+};
+
+#endif /* CPU_SLOT_H */
--
2.34.1
- [RFC 17/41] hw/cpu/core: Convert cpu-core from general device to topology device, (continued)
- [RFC 17/41] hw/cpu/core: Convert cpu-core from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 18/41] hw/cpu/cluster: Rename CPUClusterState to CPUCluster, Zhao Liu, 2023/11/30
- [RFC 22/41] hw/cpu/cluster: Convert cpu-cluster from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 19/41] hw/cpu/cluster: Wrap TCG related ops and props into CONFIG_TCG, Zhao Liu, 2023/11/30
- [RFC 21/41] hw/cpu/cluster: Allow cpu-cluster to be created by -device, Zhao Liu, 2023/11/30
- [RFC 20/41] hw/cpu/cluster: Descript cluster is not only used for TCG in comment, Zhao Liu, 2023/11/30
- [RFC 23/41] hw/cpu/die: Abstract cpu-die level as topology device, Zhao Liu, 2023/11/30
- [RFC 24/41] hw/cpu/socket: Abstract cpu-socket level as topology device, Zhao Liu, 2023/11/30
- [RFC 25/41] hw/cpu/book: Abstract cpu-book level as topology device, Zhao Liu, 2023/11/30
- [RFC 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device, Zhao Liu, 2023/11/30
- [RFC 27/41] hw/core/slot: Introduce CPU slot as the root of CPU topology,
Zhao Liu <=
- [RFC 28/41] hw/core/slot: Maintain the core queue in CPU slot, Zhao Liu, 2023/11/30
- [RFC 29/41] hw/core/slot: Statistics topology information in CPU slot, Zhao Liu, 2023/11/30
- [RFC 30/41] hw/core/slot: Check topology child to be added under CPU slot, Zhao Liu, 2023/11/30
- [RFC 32/41] hw/machine: Build smp topology tree from -smp, Zhao Liu, 2023/11/30
- [RFC 34/41] hw/core/topo: Implement user-child to collect topology device from cli, Zhao Liu, 2023/11/30
- [RFC 35/41] hw/i386: Make x86_cpu_new() private in x86.c, Zhao Liu, 2023/11/30
- [RFC 31/41] hw/machine: Plug cpu-slot into machine to maintain topology tree, Zhao Liu, 2023/11/30
- [RFC 33/41] hw/machine: Validate smp topology tree without -smp, Zhao Liu, 2023/11/30
- [RFC 38/41] hw/i386: Wrap apic id and topology sub ids assigning as helpers, Zhao Liu, 2023/11/30
- [RFC 36/41] hw/i386: Allow x86_cpu_new() to specify parent for new CPU, Zhao Liu, 2023/11/30