summary refs log tree commit diff stats
path: root/hw/intc/loongarch_ipi.c
diff options
context:
space:
mode:
authorBibo Mao <maobibo@loongson.cn>2025-01-07 11:08:14 +0800
committerBibo Mao <maobibo@loongson.cn>2025-01-15 14:21:59 +0800
commit5b82177addba2487c3c0e1b1974c0076a5a36342 (patch)
tree3472a3bcca9ca04b76ecb20f98412bf8c3721298 /hw/intc/loongarch_ipi.c
parent59c54c1ceb1d84cb48d27a5b26d6f21cb76ee9e1 (diff)
downloadfocaccia-qemu-5b82177addba2487c3c0e1b1974c0076a5a36342.tar.gz
focaccia-qemu-5b82177addba2487c3c0e1b1974c0076a5a36342.zip
hw/intc/loongson_ipi: Remove num_cpu from loongson_ipi_common
With mips64 loongson ipi, num_cpu property is used. With loongarch
ipi, num_cpu can be acquired from possible_cpu_arch_ids.

Here remove num_cpu setting from loongson_ipi_common, and this piece
of code is put into loongson and loongarch ipi separately.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Bibo Mao <maobibo@loongson.cn>
Diffstat (limited to 'hw/intc/loongarch_ipi.c')
-rw-r--r--hw/intc/loongarch_ipi.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/intc/loongarch_ipi.c b/hw/intc/loongarch_ipi.c
index 4e2f9acddf..e6126e4fbc 100644
--- a/hw/intc/loongarch_ipi.c
+++ b/hw/intc/loongarch_ipi.c
@@ -52,14 +52,27 @@ static CPUState *loongarch_cpu_by_arch_id(int64_t arch_id)
 
 static void loongarch_ipi_realize(DeviceState *dev, Error **errp)
 {
+    LoongsonIPICommonState *lics = LOONGSON_IPI_COMMON(dev);
     LoongarchIPIClass *lic = LOONGARCH_IPI_GET_CLASS(dev);
     Error *local_err = NULL;
+    int i;
 
     lic->parent_realize(dev, &local_err);
     if (local_err) {
         error_propagate(errp, local_err);
         return;
     }
+
+    if (lics->num_cpu == 0) {
+        error_setg(errp, "num-cpu must be at least 1");
+        return;
+    }
+
+    lics->cpu = g_new0(IPICore, lics->num_cpu);
+    for (i = 0; i < lics->num_cpu; i++) {
+        lics->cpu[i].ipi = lics;
+        qdev_init_gpio_out(dev, &lics->cpu[i].irq, 1);
+    }
 }
 
 static void loongarch_ipi_class_init(ObjectClass *klass, void *data)