[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 11/41] hw/core/topo: Add virtual method to check topology child
From: |
Zhao Liu |
Subject: |
[RFC 11/41] hw/core/topo: Add virtual method to check topology child |
Date: |
Thu, 30 Nov 2023 22:41:33 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
When a new topology child is to be inserted into the topology tree, its
parents (including non-direct parents) need to check if this child is
supported.
Add the virtual method to allow topology device to check the support for
their topology children.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/core/cpu-topo.c | 22 ++++++++++++++++++++++
include/hw/core/cpu-topo.h | 4 ++++
2 files changed, 26 insertions(+)
diff --git a/hw/core/cpu-topo.c b/hw/core/cpu-topo.c
index e244f0a3564e..cba2dc747e74 100644
--- a/hw/core/cpu-topo.c
+++ b/hw/core/cpu-topo.c
@@ -168,6 +168,23 @@ static void cpu_topo_update_info(CPUTopoState *topo, bool
is_realize)
}
}
+static void cpu_topo_check_support(CPUTopoState *topo, Error **errp)
+{
+ CPUTopoState *parent = topo->parent;
+ CPUTopoClass *tc;
+
+ while (parent) {
+ tc = CPU_TOPO_GET_CLASS(parent);
+ if (tc->check_topo_child) {
+ tc->check_topo_child(parent, topo, errp);
+ if (*errp) {
+ return;
+ }
+ }
+ parent = parent->parent;
+ }
+}
+
static void cpu_topo_set_parent(CPUTopoState *topo, Error **errp)
{
Object *obj = OBJECT(topo);
@@ -191,6 +208,11 @@ static void cpu_topo_set_parent(CPUTopoState *topo, Error
**errp)
}
if (topo->parent) {
+ cpu_topo_check_support(topo, errp);
+ if (*errp) {
+ return;
+ }
+
cpu_topo_build_hierarchy(topo, errp);
if (*errp) {
return;
diff --git a/include/hw/core/cpu-topo.h b/include/hw/core/cpu-topo.h
index 79cd8606feca..1ffdb0be6d38 100644
--- a/include/hw/core/cpu-topo.h
+++ b/include/hw/core/cpu-topo.h
@@ -46,6 +46,8 @@ OBJECT_DECLARE_TYPE(CPUTopoState, CPUTopoClass, CPU_TOPO)
* @level: Topology level for this CPUTopoClass.
* @update_topo_info: Method to update topology information statistics when
* new child (including direct child and non-direct child) is added.
+ * @check_topo_child: Method to check the support for new child (including
+ * direct child and non-direct child) to be added.
*/
struct CPUTopoClass {
/*< private >*/
@@ -55,6 +57,8 @@ struct CPUTopoClass {
CPUTopoLevel level;
void (*update_topo_info)(CPUTopoState *parent, CPUTopoState *child,
bool is_realize);
+ void (*check_topo_child)(CPUTopoState *parent, CPUTopoState *child,
+ Error **errp);
};
/**
--
2.34.1
- [RFC 25/41] hw/cpu/book: Abstract cpu-book level as topology device, (continued)
- [RFC 25/41] hw/cpu/book: Abstract cpu-book level as topology device, Zhao Liu, 2023/11/30
- [RFC 40/41] hw/i386: Support QOM topology, Zhao Liu, 2023/11/30
- [RFC 10/41] hw/core/topo: Add virtual method to update topology info for parent, Zhao Liu, 2023/11/30
- [RFC 15/41] hw/cpu/core: Allow to configure plugged threads for cpu-core, Zhao Liu, 2023/11/30
- [RFC 18/41] hw/cpu/cluster: Rename CPUClusterState to CPUCluster, 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 26/41] hw/cpu/drawer: Abstract cpu-drawer level as topology device, Zhao Liu, 2023/11/30
- [RFC 35/41] hw/i386: Make x86_cpu_new() private in x86.c, Zhao Liu, 2023/11/30
- [RFC 04/41] qom/object: Introduce helper to resolve path from non-direct parent, Zhao Liu, 2023/11/30
- [RFC 11/41] hw/core/topo: Add virtual method to check topology child,
Zhao Liu <=
- [RFC 24/41] hw/cpu/socket: Abstract cpu-socket 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, 2023/11/30
- [RFC 29/41] hw/core/slot: Statistics topology information in CPU slot, 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 32/41] hw/machine: Build smp topology tree from -smp, Zhao Liu, 2023/11/30
- [RFC 33/41] hw/machine: Validate smp topology tree without -smp, Zhao Liu, 2023/11/30
- [RFC 39/41] hw/i386: Add the interface to search parent for QOM topology, Zhao Liu, 2023/11/30
- [RFC 05/41] qdev: Set device parent and id after setting properties, Zhao Liu, 2023/11/30
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, Zhao Liu, 2023/11/30
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30