[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 4/6] hw/intc/loongarch_extioi: Get cpu number from possible_cpu_ar
From: |
Bibo Mao |
Subject: |
[PULL 4/6] hw/intc/loongarch_extioi: Get cpu number from possible_cpu_arch_ids |
Date: |
Thu, 9 Jan 2025 14:58:02 +0800 |
Supported CPU number can be acquired from function
possible_cpu_arch_ids(), cpu-num property is not necessary.
Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
---
hw/intc/loongarch_extioi.c | 6 ------
hw/intc/loongarch_extioi_common.c | 17 +++++++++++++++--
include/hw/intc/loongarch_extioi_common.h | 2 ++
3 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/hw/intc/loongarch_extioi.c b/hw/intc/loongarch_extioi.c
index 4a1a7c357c..d18f47def7 100644
--- a/hw/intc/loongarch_extioi.c
+++ b/hw/intc/loongarch_extioi.c
@@ -347,12 +347,6 @@ static void loongarch_extioi_realize(DeviceState *dev,
Error **errp)
s->status |= BIT(EXTIOI_ENABLE);
}
- s->cpu = g_new0(ExtIOICore, s->num_cpu);
- if (s->cpu == NULL) {
- error_setg(errp, "Memory allocation for ExtIOICore faile");
- return;
- }
-
for (i = 0; i < s->num_cpu; i++) {
for (pin = 0; pin < LS3A_INTC_IP; pin++) {
qdev_init_gpio_out(dev, &s->cpu[i].parent_irq[pin], 1);
diff --git a/hw/intc/loongarch_extioi_common.c
b/hw/intc/loongarch_extioi_common.c
index e4c1cc3c98..99a091e30b 100644
--- a/hw/intc/loongarch_extioi_common.c
+++ b/hw/intc/loongarch_extioi_common.c
@@ -13,11 +13,24 @@
static void loongarch_extioi_common_realize(DeviceState *dev, Error **errp)
{
LoongArchExtIOICommonState *s = (LoongArchExtIOICommonState *)dev;
+ MachineState *machine = MACHINE(qdev_get_machine());
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+ const CPUArchIdList *id_list;
+ int i;
- if (s->num_cpu == 0) {
- error_setg(errp, "num-cpu must be at least 1");
+ assert(mc->possible_cpu_arch_ids);
+ id_list = mc->possible_cpu_arch_ids(machine);
+ s->num_cpu = id_list->len;
+ s->cpu = g_new0(ExtIOICore, s->num_cpu);
+ if (s->cpu == NULL) {
+ error_setg(errp, "Memory allocation for ExtIOICore faile");
return;
}
+
+ for (i = 0; i < s->num_cpu; i++) {
+ s->cpu[i].arch_id = id_list->cpus[i].arch_id;
+ s->cpu[i].cpu = CPU(id_list->cpus[i].cpu);
+ }
}
static int loongarch_extioi_common_pre_save(void *opaque)
diff --git a/include/hw/intc/loongarch_extioi_common.h
b/include/hw/intc/loongarch_extioi_common.h
index f6bc778a85..22d7880977 100644
--- a/include/hw/intc/loongarch_extioi_common.h
+++ b/include/hw/intc/loongarch_extioi_common.h
@@ -65,6 +65,8 @@ typedef struct ExtIOICore {
uint32_t coreisr[EXTIOI_IRQS_GROUP_COUNT];
DECLARE_BITMAP(sw_isr[LS3A_INTC_IP], EXTIOI_IRQS);
qemu_irq parent_irq[LS3A_INTC_IP];
+ uint64_t arch_id;
+ CPUState *cpu;
} ExtIOICore;
struct LoongArchExtIOICommonState {
--
2.43.5
- [PULL 0/6] loongarch-to-apply queue, Bibo Mao, 2025/01/09
- [PULL 6/6] hw/intc/loongarch_extioi: Add irq routing support from physical id, Bibo Mao, 2025/01/09
- [PULL 1/6] hw/core/loader: Use ssize_t for efi zboot unpacker, Bibo Mao, 2025/01/09
- [PULL 4/6] hw/intc/loongarch_extioi: Get cpu number from possible_cpu_arch_ids,
Bibo Mao <=
- [PULL 5/6] hw/intc/loongarch_extioi: Remove num-cpu property, Bibo Mao, 2025/01/09
- [PULL 2/6] hw/loongarch/boot: Support Linux raw boot image, Bibo Mao, 2025/01/09
- [PULL 3/6] target/loongarch: Only support 64bit pte width, Bibo Mao, 2025/01/09
- Re: [PULL 0/6] loongarch-to-apply queue, Stefan Hajnoczi, 2025/01/09