[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equ
From: |
Zhao Liu |
Subject: |
[RFC 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal |
Date: |
Thu, 30 Nov 2023 22:41:38 +0800 |
From: Zhao Liu <zhao1.liu@intel.com>
PPC supports CPU hotplug at core granularity, thus ppc-core only accepts
all CPUs in a core are plugged.
Check if plugged_threads and nr_threads are equal when ppc-core
realizes.
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
---
hw/ppc/ppc_core.c | 18 ++++++++++++++++++
include/hw/ppc/ppc_core.h | 1 +
2 files changed, 19 insertions(+)
diff --git a/hw/ppc/ppc_core.c b/hw/ppc/ppc_core.c
index 4433b54af506..3857f3150052 100644
--- a/hw/ppc/ppc_core.c
+++ b/hw/ppc/ppc_core.c
@@ -53,20 +53,38 @@ static void powerpc_core_prop_set_core_id(Object *obj,
Visitor *v,
core->core_id = value;
}
+static void powerpc_core_realize(DeviceState *dev, Error **errp)
+{
+ CPUCore *core = CPU_CORE(dev);
+ PowerPCCoreClass *ppc_class = POWERPC_CORE_GET_CLASS(dev);
+
+ if (core->plugged_threads != -1 &&
+ core->nr_threads != core->plugged_threads) {
+ error_setg(errp, "nr_threads and plugged-threads must be equal");
+ return;
+ }
+
+ ppc_class->parent_realize(dev, errp);
+}
+
static void powerpc_core_class_init(ObjectClass *oc, void *data)
{
DeviceClass *dc = DEVICE_CLASS(oc);
+ PowerPCCoreClass *ppc_class = POWERPC_CORE_CLASS(oc);
object_class_property_add(oc, "core-id", "int",
powerpc_core_prop_get_core_id,
powerpc_core_prop_set_core_id,
NULL, NULL);
+ device_class_set_parent_realize(dc, powerpc_core_realize,
+ &ppc_class->parent_realize);
}
static const TypeInfo powerpc_core_type_info = {
.name = TYPE_POWERPC_CORE,
.parent = TYPE_CPU_CORE,
.abstract = true,
+ .class_size = sizeof(PowerPCCoreClass),
.class_init = powerpc_core_class_init,
.instance_size = sizeof(PowerPCCore),
};
diff --git a/include/hw/ppc/ppc_core.h b/include/hw/ppc/ppc_core.h
index bcc83e426e3f..1207d220872a 100644
--- a/include/hw/ppc/ppc_core.h
+++ b/include/hw/ppc/ppc_core.h
@@ -34,6 +34,7 @@ struct PowerPCCoreClass {
CPUCoreClass parent_class;
/*< public >*/
+ DeviceRealize parent_realize;
};
struct PowerPCCore {
--
2.34.1
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, (continued)
- [RFC 06/41] qdev: Introduce user-child interface to collect devices from -device, Zhao Liu, 2023/11/30
- [RFC 07/41] qdev: Introduce parent option in -device, Zhao Liu, 2023/11/30
- [RFC 08/41] hw/core/topo: Introduce CPU topology device abstraction, Zhao Liu, 2023/11/30
- [RFC 09/41] hw/core/topo: Support topology index for topology device, 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 11/41] hw/core/topo: Add virtual method to check topology child, Zhao Liu, 2023/11/30
- [RFC 12/41] hw/core/topo: Add helpers to traverse the CPU topology tree, Zhao Liu, 2023/11/30
- [RFC 13/41] hw/core/cpu: Convert CPU from general device to topology device, Zhao Liu, 2023/11/30
- [RFC 14/41] PPC/ppc-core: Offload core-id to PPC specific core abstarction, 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 16/41] PPC/ppc-core: Limit plugged-threads and nr-threads to be equal,
Zhao Liu <=
- [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