[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 5/8] hw/intc/loongarch_ipi: Get cpu number from possible_cpu_arch_
From: |
Bibo Mao |
Subject: |
[PULL 5/8] hw/intc/loongarch_ipi: Get cpu number from possible_cpu_arch_ids |
Date: |
Thu, 16 Jan 2025 10:17:07 +0800 |
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>
---
hw/intc/loongarch_ipi.c | 13 ++++++++-----
include/hw/intc/loongson_ipi_common.h | 2 ++
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c
index 9c7636c4d6..49b4595d90 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);
}
diff --git a/include/hw/intc/loongson_ipi_common.h
b/include/hw/intc/loongson_ipi_common.h
index df9d9c5168..4192f3d548 100644
--- a/include/hw/intc/loongson_ipi_common.h
+++ b/include/hw/intc/loongson_ipi_common.h
@@ -27,6 +27,8 @@ typedef struct IPICore {
/* 64bit buf divide into 2 32-bit buf */
uint32_t buf[IPI_MBX_NUM * 2];
qemu_irq irq;
+ uint64_t arch_id;
+ CPUState *cpu;
} IPICore;
struct LoongsonIPICommonState {
--
2.43.5
- [PULL 0/8] loongarch-to-apply queue, Bibo Mao, 2025/01/15
- [PULL 3/8] hw/intc/loongson_ipi: Remove num_cpu from loongson_ipi_common, Bibo Mao, 2025/01/15
- [PULL 8/8] hw/intc/loongarch_ipi: Use alternative implemation for cpu_by_arch_id, Bibo Mao, 2025/01/15
- [PULL 6/8] hw/intc/loongarch_ipi: Remove property num-cpu, Bibo Mao, 2025/01/15
- [PULL 1/8] target/loongarch: Add page table walker support for debugger usage, Bibo Mao, 2025/01/15
- [PULL 4/8] hw/intc/loongson_ipi: Remove property num_cpu from loongson_ipi_common, Bibo Mao, 2025/01/15
- [PULL 5/8] hw/intc/loongarch_ipi: Get cpu number from possible_cpu_arch_ids,
Bibo Mao <=
- [PULL 2/8] hw/intc/loongarch_ipi: Implement realize interface, Bibo Mao, 2025/01/15
- [PULL 7/8] hw/intc/loongson_ipi: Add more input parameter for cpu_by_arch_id, Bibo Mao, 2025/01/15
- Re: [PULL 0/8] loongarch-to-apply queue, Stefan Hajnoczi, 2025/01/16