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>
This commit is contained in:
Bibo Mao 2025-01-07 11:08:16 +08:00
parent ce78dacf7e
commit 14dc02b56a
2 changed files with 10 additions and 5 deletions

View file

@ -55,6 +55,9 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
{ {
LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(dev); LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(dev);
LoongarchIPIClass *lic = LOONGARCH_IPI_GET_CLASS(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; Error *local_err = NULL;
int i; int i;
@ -64,13 +67,13 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
return; return;
} }
if (lics->num_cpu == 0) { assert(mc->possible_cpu_arch_ids);
error_setg(errp, "num-cpu must be at least 1"); id_list = mc->possible_cpu_arch_ids(machine);
return; lics->num_cpu = id_list->len;
}
lics->cpu = g_new0(IPICore, lics->num_cpu); lics->cpu = g_new0(IPICore, lics->num_cpu);
for (i = 0; i < lics->num_cpu; i++) { 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; lics->cpu[i].ipi = lics;
qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1); qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
} }

View file

@ -27,6 +27,8 @@ typedef struct IPICore {
/* 64bit buf divide into 2 32-bit buf */ /* 64bit buf divide into 2 32-bit buf */
uint32_t buf[IPI_MBX_NUM * 2]; uint32_t buf[IPI_MBX_NUM * 2];
qemu_irq irq; qemu_irq irq;
uint64_t arch_id;
CPUState *cpu;
} IPICore; } IPICore;
struct LoongsonIPICommonState { struct LoongsonIPICommonState {