aboutsummaryrefslogtreecommitdiff
path: root/hw/intc
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-01-07 11:08:16 +0800
committerBibo Mao <maobibo@loongson.cn>2025-01-15 14:29:14 +0800
commit14dc02b56a3d4434401ad92415cbec3e30ff3fa5 (patch)
tree6a6d77412e7a79590c13493fc7c6c82e2a6c7511 /hw/intc
parentce78dacf7e9b22dcc121dca17b1a3bcd93751680 (diff)
downloadqemu-14dc02b56a3d4434401ad92415cbec3e30ff3fa5.zip
qemu-14dc02b56a3d4434401ad92415cbec3e30ff3fa5.tar.gz
qemu-14dc02b56a3d4434401ad92415cbec3e30ff3fa5.tar.bz2
hw/intc/loongarch_ipi: Get cpu number from possible_cpu_arch_ids
Supported CPU number can be acquired from function possible_cpu_arch_ids(), cpu-num property is not necessary and can be removed. Signed-off-by: Bibo Mao <maobibo@loongson.cn> Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Diffstat (limited to 'hw/intc')
-rw-r--r--hw/intc/loongarch_ipi.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c
index 9c7636c..49b4595 100644
--- a/hw/intc/loongarch_ipi.c
+++ b/hw/intc/loongarch_ipi.c
@@ -55,6 +55,9 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
{
LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(dev);
LoongarchIPIClass *lic = LOONGARCH_IPI_GET_CLASS(dev);
+ MachineState *machine = MACHINE(qdev_get_machine());
+ MachineClass *mc = MACHINE_GET_CLASS(machine);
+ const CPUArchIdList *id_list;
Error *local_err = NULL;
int i;
@@ -64,13 +67,13 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
return;
}
- if (lics->num_cpu == 0) {
- error_setg(errp, "num-cpu must be at least 1");
- return;
- }
-
+ assert(mc->possible_cpu_arch_ids);
+ id_list = mc->possible_cpu_arch_ids(machine);
+ lics->num_cpu = id_list->len;
lics->cpu = g_new0(IPICore, lics->num_cpu);
for (i = 0; i < lics->num_cpu; i++) {
+ lics->cpu[i].arch_id = id_list->cpus[i].arch_id;
+ lics->cpu[i].cpu = CPU(id_list->cpus[i].cpu);
lics->cpu[i].ipi = lics;
qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
}