[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 3/8] hw/intc/loongson_ipi: Remove num_cpu from loongson_ipi_common
From: |
Bibo Mao |
Subject: |
[PULL 3/8] hw/intc/loongson_ipi: Remove num_cpu from loongson_ipi_common |
Date: |
Thu, 16 Jan 2025 10:17:05 +0800 |
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>
---
hw/intc/loongarch_ipi.c | 13 +++++++++++++
hw/intc/loongson_ipi.c | 14 +++++++++++++-
hw/intc/loongson_ipi_common.c | 14 --------------
3 files changed, 26 insertions(+), 15 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)
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index 4e08f03510..1ed39b90ea 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -36,6 +36,7 @@ static void loongson_ipi_realize(DeviceState *dev, Error
**errp)
LoongsonIPIClass *lic = LOONGSON_IPI_GET_CLASS(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
Error *local_err = NULL;
+ int i;
lic->parent_realize(dev, &local_err);
if (local_err) {
@@ -43,8 +44,19 @@ static void loongson_ipi_realize(DeviceState *dev, Error
**errp)
return;
}
+ if (sc->num_cpu == 0) {
+ error_setg(errp, "num-cpu must be at least 1");
+ return;
+ }
+
+ sc->cpu = g_new0(IPICore, sc->num_cpu);
+ for (i = 0; i < sc->num_cpu; i++) {
+ sc->cpu[i].ipi = sc;
+ qdev_init_gpio_out(dev, &sc->cpu[i].irq, 1);
+ }
+
s->ipi_mmio_mem = g_new0(MemoryRegion, sc->num_cpu);
- for (unsigned i = 0; i < sc->num_cpu; i++) {
+ for (i = 0; i < sc->num_cpu; i++) {
g_autofree char *name = g_strdup_printf("loongson_ipi_cpu%d_mmio", i);
memory_region_init_io(&s->ipi_mmio_mem[i], OBJECT(dev),
diff --git a/hw/intc/loongson_ipi_common.c b/hw/intc/loongson_ipi_common.c
index 9a081565f5..5d46679ea1 100644
--- a/hw/intc/loongson_ipi_common.c
+++ b/hw/intc/loongson_ipi_common.c
@@ -10,7 +10,6 @@
#include "hw/intc/loongson_ipi_common.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
-#include "qapi/error.h"
#include "qemu/log.h"
#include "migration/vmstate.h"
#include "trace.h"
@@ -253,12 +252,6 @@ static void loongson_ipi_common_realize(DeviceState *dev,
Error **errp)
{
LoongsonIPICommonState *s = LOONGSON_IPI_COMMON(dev);
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- int i;
-
- if (s->num_cpu == 0) {
- error_setg(errp, "num-cpu must be at least 1");
- return;
- }
memory_region_init_io(&s->ipi_iocsr_mem, OBJECT(dev),
&loongson_ipi_iocsr_ops,
@@ -273,13 +266,6 @@ static void loongson_ipi_common_realize(DeviceState *dev,
Error **errp)
&loongson_ipi64_ops,
s, "loongson_ipi64_iocsr", 0x118);
sysbus_init_mmio(sbd, &s->ipi64_iocsr_mem);
-
- s->cpu = g_new0(IPICore, s->num_cpu);
- for (i = 0; i < s->num_cpu; i++) {
- s->cpu[i].ipi = s;
-
- qdev_init_gpio_out(dev, &s->cpu[i].irq, 1);
- }
}
static void loongson_ipi_common_unrealize(DeviceState *dev)
--
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 <=
- [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, 2025/01/15
- [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