Skip to content

Commit 14dc02b

Browse files
committed
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 <[email protected]> Reviewed-by: Bibo Mao <[email protected]>
1 parent ce78dac commit 14dc02b

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

hw/intc/loongarch_ipi.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
5555
{
5656
LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(dev);
5757
LoongarchIPIClass *lic = LOONGARCH_IPI_GET_CLASS(dev);
58+
MachineState *machine = MACHINE(qdev_get_machine());
59+
MachineClass *mc = MACHINE_GET_CLASS(machine);
60+
const CPUArchIdList *id_list;
5861
Error *local_err = NULL;
5962
int i;
6063

@@ -64,13 +67,13 @@ static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
6467
return;
6568
}
6669

67-
if (lics->num_cpu == 0) {
68-
error_setg(errp, "num-cpu must be at least 1");
69-
return;
70-
}
71-
70+
assert(mc->possible_cpu_arch_ids);
71+
id_list = mc->possible_cpu_arch_ids(machine);
72+
lics->num_cpu = id_list->len;
7273
lics->cpu = g_new0(IPICore, lics->num_cpu);
7374
for (i = 0; i < lics->num_cpu; i++) {
75+
lics->cpu[i].arch_id = id_list->cpus[i].arch_id;
76+
lics->cpu[i].cpu = CPU(id_list->cpus[i].cpu);
7477
lics->cpu[i].ipi = lics;
7578
qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
7679
}

include/hw/intc/loongson_ipi_common.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ typedef struct IPICore {
2727
/* 64bit buf divide into 2 32-bit buf */
2828
uint32_t buf[IPI_MBX_NUM * 2];
2929
qemu_irq irq;
30+
uint64_t arch_id;
31+
CPUState *cpu;
3032
} IPICore;
3133

3234
struct LoongsonIPICommonState {

0 commit comments

Comments
 (0)