@@ -50,6 +50,7 @@ struct LoongsonIPI {
MemoryRegion ipi_iocsr_mem;
MemoryRegion ipi64_iocsr_mem;
uint32_t num_cpu;
+ bool has_mmio;
IPICore *cpu;
};
@@ -307,13 +307,16 @@ static void loongson_ipi_realize(DeviceState *dev, Error **errp)
for (i = 0; i < s->num_cpu; i++) {
s->cpu[i].ipi = s;
- s->cpu[i].ipi_mmio_mem = g_new0(MemoryRegion, 1);
- g_autofree char *name = g_strdup_printf("loongson_ipi_cpu%d_mmio", i);
- memory_region_init_io(s->cpu[i].ipi_mmio_mem, OBJECT(dev),
- &loongson_ipi_core_ops, &s->cpu[i], name, 0x48);
- sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem);
-
qdev_init_gpio_out(dev, &s->cpu[i].irq, 1);
+
+ if (s->has_mmio) {
+ g_autofree char *name = g_strdup_printf("loongson_ipi_cpu%d_mmio", i);
+ s->cpu[i].ipi_mmio_mem = g_new0(MemoryRegion, 1);
+ memory_region_init_io(s->cpu[i].ipi_mmio_mem, OBJECT(dev),
+ &loongson_ipi_core_ops, &s->cpu[i],
+ name, 0x48);
+ sysbus_init_mmio(sbd, s->cpu[i].ipi_mmio_mem);
+ }
}
}
@@ -344,6 +347,7 @@ static const VMStateDescription vmstate_loongson_ipi = {
static Property ipi_properties[] = {
DEFINE_PROP_UINT32("num-cpu", LoongsonIPI, num_cpu, 1),
+ DEFINE_PROP_BOOL("has-mmio", LoongsonIPI, has_mmio, false),
DEFINE_PROP_END_OF_LIST(),
};
@@ -537,6 +537,7 @@ static void mips_loongson3_virt_init(MachineState *machine)
if (!kvm_enabled()) {
ipi = qdev_new(TYPE_LOONGSON_IPI);
qdev_prop_set_uint32(ipi, "num-cpu", machine->smp.cpus);
+ qdev_prop_set_bit(ipi, "has-mmio", true);
sysbus_realize_and_unref(SYS_BUS_DEVICE(ipi), &error_fatal);
memory_region_add_subregion(iocsr, SMP_IPI_MAILBOX,
sysbus_mmio_get_region(SYS_BUS_DEVICE(ipi), 0));