qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch
@ 2024-06-27 12:58 Philippe Mathieu-Daudé
  2024-06-27 12:58 ` [PATCH v2 1/1] hw/intc/loongson_ipi: Gate MMIO regions creation with property Philippe Mathieu-Daudé
  2024-07-15  9:57 ` [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
  0 siblings, 2 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-27 12:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jiaxun Yang, Song Gao, maobibo, Huacai Chen,
	Philippe Mathieu-Daudé

v2:
- Only skip mmio-related code in loongson_ipi_realize()

Jiaxun Yang (1):
  hw/intc/loongson_ipi: Gate MMIO regions creation with property

 include/hw/intc/loongson_ipi.h |  1 +
 hw/intc/loongson_ipi.c         | 16 ++++++++++------
 hw/mips/loongson3_virt.c       |  1 +
 3 files changed, 12 insertions(+), 6 deletions(-)

-- 
2.41.0



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v2 1/1] hw/intc/loongson_ipi: Gate MMIO regions creation with property
  2024-06-27 12:58 [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
@ 2024-06-27 12:58 ` Philippe Mathieu-Daudé
  2024-07-15  9:57 ` [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
  1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-06-27 12:58 UTC (permalink / raw)
  To: qemu-devel
  Cc: Jiaxun Yang, Song Gao, maobibo, Huacai Chen,
	Philippe Mathieu-Daudé

From: Jiaxun Yang <jiaxun.yang@flygoat.com>

Commit 49eba52a52fe ("hw/intc/loongson_ipi: Provide per core MMIO address
spaces") implemented per core MMIO spaces for IPI registers.

However on LoongArch system emulation with high core count it may exhaust
QDEV_MAX_MMIO and trigger assertion.

Given that MMIO region is unused for LoongArch system emulation (we do have
it on hardware but kernel is in favor of IOCSR), gate MMIO regions creation
with "has-mmio" property and only set if for loongson3-virt machine to avoid
such limitation on LoongArch.

Reported-by: Bibo Mao <maobibo@loongson.cn>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/intc/loongson_ipi.h |  1 +
 hw/intc/loongson_ipi.c         | 16 ++++++++++------
 hw/mips/loongson3_virt.c       |  1 +
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/include/hw/intc/loongson_ipi.h b/include/hw/intc/loongson_ipi.h
index 3f795edbf3..0e35674e7a 100644
--- a/include/hw/intc/loongson_ipi.h
+++ b/include/hw/intc/loongson_ipi.h
@@ -50,6 +50,7 @@ struct LoongsonIPI {
     MemoryRegion ipi_iocsr_mem;
     MemoryRegion ipi64_iocsr_mem;
     uint32_t num_cpu;
+    bool has_mmio;
     IPICore *cpu;
 };
 
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index e6a7142480..d1b7a80d7b 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -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(),
 };
 
diff --git a/hw/mips/loongson3_virt.c b/hw/mips/loongson3_virt.c
index 4ad36f0c5b..a27b30ab31 100644
--- a/hw/mips/loongson3_virt.c
+++ b/hw/mips/loongson3_virt.c
@@ -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));
-- 
2.41.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch
  2024-06-27 12:58 [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
  2024-06-27 12:58 ` [PATCH v2 1/1] hw/intc/loongson_ipi: Gate MMIO regions creation with property Philippe Mathieu-Daudé
@ 2024-07-15  9:57 ` Philippe Mathieu-Daudé
  2024-07-15 10:08   ` maobibo
  1 sibling, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15  9:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jiaxun Yang, Song Gao, maobibo, Huacai Chen

On 27/6/24 14:58, Philippe Mathieu-Daudé wrote:
> v2:
> - Only skip mmio-related code in loongson_ipi_realize()
> 
> Jiaxun Yang (1):
>    hw/intc/loongson_ipi: Gate MMIO regions creation with property
> 
>   include/hw/intc/loongson_ipi.h |  1 +
>   hw/intc/loongson_ipi.c         | 16 ++++++++++------
>   hw/mips/loongson3_virt.c       |  1 +
>   3 files changed, 12 insertions(+), 6 deletions(-)
> 

ping?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch
  2024-07-15  9:57 ` [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
@ 2024-07-15 10:08   ` maobibo
  2024-07-15 10:15     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: maobibo @ 2024-07-15 10:08 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, qemu-devel
  Cc: Jiaxun Yang, Song Gao, Huacai Chen



On 2024/7/15 下午5:57, Philippe Mathieu-Daudé wrote:
> On 27/6/24 14:58, Philippe Mathieu-Daudé wrote:
>> v2:
>> - Only skip mmio-related code in loongson_ipi_realize()
>>
>> Jiaxun Yang (1):
>>    hw/intc/loongson_ipi: Gate MMIO regions creation with property
>>
>>   include/hw/intc/loongson_ipi.h |  1 +
>>   hw/intc/loongson_ipi.c         | 16 ++++++++++------
>>   hw/mips/loongson3_virt.c       |  1 +
>>   3 files changed, 12 insertions(+), 6 deletions(-)
>>
> 
> ping?
Hi Philippe,

It is only temporary fix, in the long term we hope that interrupt 
controller emulation is similar with other architectures in directory
hw/intc/, and we post the patch at website:

https://lore.kernel.org/qemu-devel/20240704033802.3838618-1-maobibo@loongson.cn/

Regards
Bibo Mao



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch
  2024-07-15 10:08   ` maobibo
@ 2024-07-15 10:15     ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-07-15 10:15 UTC (permalink / raw)
  To: maobibo, qemu-devel; +Cc: Jiaxun Yang, Song Gao, Huacai Chen

On 15/7/24 12:08, maobibo wrote:
> 
> 
> On 2024/7/15 下午5:57, Philippe Mathieu-Daudé wrote:
>> On 27/6/24 14:58, Philippe Mathieu-Daudé wrote:
>>> v2:
>>> - Only skip mmio-related code in loongson_ipi_realize()
>>>
>>> Jiaxun Yang (1):
>>>    hw/intc/loongson_ipi: Gate MMIO regions creation with property
>>>
>>>   include/hw/intc/loongson_ipi.h |  1 +
>>>   hw/intc/loongson_ipi.c         | 16 ++++++++++------
>>>   hw/mips/loongson3_virt.c       |  1 +
>>>   3 files changed, 12 insertions(+), 6 deletions(-)
>>>
>>
>> ping?
> Hi Philippe,
> 
> It is only temporary fix, in the long term we hope that interrupt 
> controller emulation is similar with other architectures in directory
> hw/intc/, and we post the patch at website:
> 
> https://lore.kernel.org/qemu-devel/20240704033802.3838618-1-maobibo@loongson.cn/

I missed that, thanks for pointing the series.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-07-15 10:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 12:58 [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
2024-06-27 12:58 ` [PATCH v2 1/1] hw/intc/loongson_ipi: Gate MMIO regions creation with property Philippe Mathieu-Daudé
2024-07-15  9:57 ` [PATCH v2 0/1] hw/intc/loongson_ipi: Fix for LoongArch Philippe Mathieu-Daudé
2024-07-15 10:08   ` maobibo
2024-07-15 10:15     ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).