mbox series

[0/2] hw/intc/loongson_ipi: Fix for LoongArch

Message ID 20240627-ipi-fixes-v1-0-9b061dc28a3a@flygoat.com (mailing list archive)
Headers show
Series hw/intc/loongson_ipi: Fix for LoongArch | expand

Message

Jiaxun Yang June 27, 2024, 4:13 a.m. UTC
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
---
Jiaxun Yang (2):
      hw/intc/loongson_ipi: Gate MMIO regions creation with property
      MAINTAINERS: Add myself as a reviewer of LoongArch virt machine

 MAINTAINERS                    |  1 +
 hw/intc/loongson_ipi.c         | 23 ++++++++++++++---------
 hw/mips/loongson3_virt.c       |  1 +
 include/hw/intc/loongson_ipi.h |  1 +
 4 files changed, 17 insertions(+), 9 deletions(-)
---
base-commit: 3f044554b94fc0756d5b3cdbf84501e0eea0e629
change-id: 20240627-ipi-fixes-13eaf1b8815a

Best regards,

Comments

Philippe Mathieu-Daudé June 27, 2024, 6:38 a.m. UTC | #1
On 27/6/24 06:13, Jiaxun Yang wrote:
> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
> ---
> Jiaxun Yang (2):
>        hw/intc/loongson_ipi: Gate MMIO regions creation with property
>        MAINTAINERS: Add myself as a reviewer of LoongArch virt machine

Maybe s/has-mmio/use-mmio/? Otherwise series:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Song Gao June 27, 2024, 12:13 p.m. UTC | #2
在 2024/6/27 下午2:38, Philippe Mathieu-Daudé 写道:
> On 27/6/24 06:13, Jiaxun Yang wrote:
>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>> ---
>> Jiaxun Yang (2):
>>        hw/intc/loongson_ipi: Gate MMIO regions creation with property
>>        MAINTAINERS: Add myself as a reviewer of LoongArch virt machine
>
> Maybe s/has-mmio/use-mmio/? Otherwise series:
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>
Hi,

If we had done a simple test, we should have found the following 
problem, but obviously we didn't .

root@loongson-KVM:~/work/code/clean/github/qemu# . /kernel.sh
Unexpected error in object_property_find_err() at . /qom/object.c:1357.
qemu-system-loongarch64: Property 'loongson_ipi.unnamed-gpio-out[0]' not 
found
. /kernel.sh: line 16: 117708 Aborted (core dumped) . 
/build/qemu-system-loongarch64 -machine virt -m 8G -cpu la464 -smp 8 
-kernel ~/vmlinux -initrd ramdisk -serial stdio -monitor 
telnet:localhost. 4418,server,nowait -net nic -net user -device 
virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device 
usb-tablet,id=tablet,bus=xhci.0, port=1 -device 
usb-tablet,id=tablet,bus=xhci.0, -device usb-tablet,id=tablet,bus=xhci. 
port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -append 
"root=/dev/ram rdinit=/sbin/init console=ttyS0,115200 
earlycon=uart,mmio. 0x1fe001e0" --nographic


So to minimize interactions with the MIPS architecture, I'll submit a 
patch to restore loongarch_ipi for LoongArch.

Thanks.
Song Gao
Philippe Mathieu-Daudé June 27, 2024, 12:55 p.m. UTC | #3
On 27/6/24 14:13, gaosong wrote:
> 
> 
> 在 2024/6/27 下午2:38, Philippe Mathieu-Daudé 写道:
>> On 27/6/24 06:13, Jiaxun Yang wrote:
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> ---
>>> Jiaxun Yang (2):
>>>        hw/intc/loongson_ipi: Gate MMIO regions creation with property
>>>        MAINTAINERS: Add myself as a reviewer of LoongArch virt machine
>>
>> Maybe s/has-mmio/use-mmio/? Otherwise series:
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>
> Hi,
> 
> If we had done a simple test, we should have found the following 
> problem, but obviously we didn't .
> 
> root@loongson-KVM:~/work/code/clean/github/qemu# . /kernel.sh
> Unexpected error in object_property_find_err() at . /qom/object.c:1357.
> qemu-system-loongarch64: Property 'loongson_ipi.unnamed-gpio-out[0]' not 
> found
> . /kernel.sh: line 16: 117708 Aborted (core dumped) . 
> /build/qemu-system-loongarch64 -machine virt -m 8G -cpu la464 -smp 8 
> -kernel ~/vmlinux -initrd ramdisk -serial stdio -monitor 
> telnet:localhost. 4418,server,nowait -net nic -net user -device 
> virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device 
> usb-tablet,id=tablet,bus=xhci.0, port=1 -device 
> usb-tablet,id=tablet,bus=xhci.0, -device usb-tablet,id=tablet,bus=xhci. 
> port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -append 
> "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200 
> earlycon=uart,mmio. 0x1fe001e0" --nographic

Works for me squashing:

-- >8 --
diff --git a/hw/intc/loongson_ipi.c b/hw/intc/loongson_ipi.c
index 6e92a50349..ce845aecda 100644
--- a/hw/intc/loongson_ipi.c
+++ b/hw/intc/loongson_ipi.c
@@ -305,18 +305,18 @@ static void loongson_ipi_realize(DeviceState *dev, 
Error **errp)
          return;
      }

-    if (s->has_mmio) {
-        for (i = 0; i < s->num_cpu; i++) {
-            s->cpu[i].ipi = s;
+    for (i = 0; i < s->num_cpu; i++) {
+        s->cpu[i].ipi = s;
+        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);
-            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);
          }
      }
  }
---
Jiaxun Yang June 27, 2024, 3:12 p.m. UTC | #4
在2024年6月27日六月 下午4:13,gaosong写道:
> 在 2024/6/27 下午2:38, Philippe Mathieu-Daudé 写道:
>> On 27/6/24 06:13, Jiaxun Yang wrote:
>>> Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
>>> ---
>>> Jiaxun Yang (2):
>>>        hw/intc/loongson_ipi: Gate MMIO regions creation with property
>>>        MAINTAINERS: Add myself as a reviewer of LoongArch virt machine
>>
>> Maybe s/has-mmio/use-mmio/? Otherwise series:
>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>>
> Hi,
>
> If we had done a simple test, we should have found the following 
> problem, but obviously we didn't .

My bad, I’m currently traveling and sent that in rush.

I do boot tested with CI and I trust CI can catch those issues.


>
> root@loongson-KVM:~/work/code/clean/github/qemu# . /kernel.sh
> Unexpected error in object_property_find_err() at . /qom/object.c:1357.
> qemu-system-loongarch64: Property 'loongson_ipi.unnamed-gpio-out[0]' not 
> found
> . /kernel.sh: line 16: 117708 Aborted (core dumped) . 
> /build/qemu-system-loongarch64 -machine virt -m 8G -cpu la464 -smp 8 
> -kernel ~/vmlinux -initrd ramdisk -serial stdio -monitor 
> telnet:localhost. 4418,server,nowait -net nic -net user -device 
> virtio-gpu-pci -device nec-usb-xhci,id=xhci,addr=0x1b -device 
> usb-tablet,id=tablet,bus=xhci.0, port=1 -device 
> usb-tablet,id=tablet,bus=xhci.0, -device usb-tablet,id=tablet,bus=xhci. 
> port=1 -device usb-kbd,id=keyboard,bus=xhci.0,port=2 -append 
> "root=/dev/ram rdinit=/sbin/init console=ttyS0,115200 
> earlycon=uart,mmio. 0x1fe001e0" --nographic
>
>
> So to minimize interactions with the MIPS architecture, I'll submit a 
> patch to restore loongarch_ipi for LoongArch.
>
> Thanks.
> Song Gao