[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 6/7] Add support of *unrealize* for Loongarch cpu
From: |
xianglai li |
Subject: |
[PATCH v3 6/7] Add support of *unrealize* for Loongarch cpu |
Date: |
Tue, 26 Sep 2023 17:54:31 +0800 |
Add the unrealize function to the Loongarch CPU for cpu hot-(un)plug
Cc: "Bernhard Beschow" <shentey@gmail.com>
Cc: "Salil Mehta" <salil.mehta@opnsrc.net>
Cc: "Salil Mehta" <salil.mehta@huawei.com>
Cc: Xiaojuan Yang <yangxiaojuan@loongson.cn>
Cc: Song Gao <gaosong@loongson.cn>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Igor Mammedov <imammedo@redhat.com>
Cc: Ani Sinha <anisinha@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <richard.henderson@linaro.org>
Cc: Eduardo Habkost <eduardo@habkost.net>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: Yanan Wang <wangyanan55@huawei.com>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: xianglai li <lixianglai@loongson.cn>
---
target/loongarch/cpu.c | 20 ++++++++++++++++++++
target/loongarch/cpu.h | 1 +
2 files changed, 21 insertions(+)
diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c
index 40b856554f..92fb23704f 100644
--- a/target/loongarch/cpu.c
+++ b/target/loongarch/cpu.c
@@ -576,6 +576,22 @@ static void loongarch_cpu_realizefn(DeviceState *dev,
Error **errp)
lacc->parent_realize(dev, errp);
}
+static void loongarch_cpu_unrealizefn(DeviceState *dev)
+{
+ LoongArchCPUClass *mcc = LOONGARCH_CPU_GET_CLASS(dev);
+
+#ifndef CONFIG_USER_ONLY
+ LoongArchCPU *cpu = LOONGARCH_CPU(dev);
+ CPULoongArchState *env = &cpu->env;
+
+ cpu_remove_sync(CPU(dev));
+ address_space_destroy(&env->address_space_iocsr);
+ memory_region_del_subregion(&env->system_iocsr, &env->iocsr_mem);
+#endif
+
+ mcc->parent_unrealize(dev);
+}
+
#ifndef CONFIG_USER_ONLY
static void loongarch_qemu_write(void *opaque, hwaddr addr,
uint64_t val, unsigned size)
@@ -756,6 +772,9 @@ static void loongarch_cpu_class_init(ObjectClass *c, void
*data)
device_class_set_props(dc, loongarch_cpu_properties);
device_class_set_parent_realize(dc, loongarch_cpu_realizefn,
&lacc->parent_realize);
+ device_class_set_parent_unrealize(dc, loongarch_cpu_unrealizefn,
+ &lacc->parent_unrealize);
+
resettable_class_set_parent_phases(rc, NULL, loongarch_cpu_reset_hold,
NULL,
&lacc->parent_phases);
@@ -777,6 +796,7 @@ static void loongarch_cpu_class_init(ObjectClass *c, void
*data)
#ifdef CONFIG_TCG
cc->tcg_ops = &loongarch_tcg_ops;
#endif
+ dc->user_creatable = true;
}
static gchar *loongarch32_gdb_arch_name(CPUState *cs)
diff --git a/target/loongarch/cpu.h b/target/loongarch/cpu.h
index 838492f014..ec4a9ff166 100644
--- a/target/loongarch/cpu.h
+++ b/target/loongarch/cpu.h
@@ -414,6 +414,7 @@ struct LoongArchCPUClass {
/*< public >*/
DeviceRealize parent_realize;
+ DeviceUnrealize parent_unrealize;
ResettablePhases parent_phases;
};
--
2.39.1
[PATCH v3 5/7] Add basic CPU hot-(un)plug support for Loongarch, xianglai li, 2023/09/26
[PATCH v3 6/7] Add support of *unrealize* for Loongarch cpu,
xianglai li <=
[PATCH v3 4/7] Optimize loongarch_irq_init function implementation, xianglai li, 2023/09/26
[PATCH v3 7/7] Update the ACPI table for the Loongarch CPU, xianglai li, 2023/09/26
[PATCH v3 3/7] Added CPU topology support for Loongarch, xianglai li, 2023/09/26
[PATCH v3 2/7] Update CPUs AML with cpu-(ctrl)dev change, xianglai li, 2023/09/26