All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS
@ 2022-06-24 19:52 Andrey Makarov
  2022-06-26 10:16 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Andrey Makarov @ 2022-06-24 19:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: Andrey Makarov

All Raspberry Pi models 1-3 (based on bcm2835) have
Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):

    /* dma channel 11-14 share one irq */

which mismatched the Qemu model.
In this patch channels 0--10 and 11--14 are handled separately.

Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
---
 hw/arm/bcm2835_peripherals.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
index 48538c9360..3d808b0e31 100644
--- a/hw/arm/bcm2835_peripherals.c
+++ b/hw/arm/bcm2835_peripherals.c
@@ -322,13 +322,21 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
     memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
                 sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
 
-    for (n = 0; n <= 12; n++) {
+    for (n = 0; n <= 10; n++) {
         sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
                            qdev_get_gpio_in_named(DEVICE(&s->ic),
                                                   BCM2835_IC_GPU_IRQ,
                                                   INTERRUPT_DMA0 + n));
     }
 
+    /* According to DTS, dma channels 11-14 share one irq */
+    for (n = 11; n <= 14; n++) {
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
+                           qdev_get_gpio_in_named(DEVICE(&s->ic),
+                                                  BCM2835_IC_GPU_IRQ,
+                                                  INTERRUPT_DMA0 + 11));
+    }
+
     /* THERMAL */
     if (!sysbus_realize(SYS_BUS_DEVICE(&s->thermal), errp)) {
         return;
-- 
2.30.2



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

* Re: [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS
  2022-06-24 19:52 [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS Andrey Makarov
@ 2022-06-26 10:16 ` Peter Maydell
  2022-06-30  8:32   ` Makarov, Andrey
  2022-07-12 22:30   ` Philippe Mathieu-Daudé via
  0 siblings, 2 replies; 4+ messages in thread
From: Peter Maydell @ 2022-06-26 10:16 UTC (permalink / raw)
  To: Andrey Makarov; +Cc: qemu-devel, Andrey Makarov

On Fri, 24 Jun 2022 at 21:54, Andrey Makarov <ph.makarov@gmail.com> wrote:
>
> All Raspberry Pi models 1-3 (based on bcm2835) have
> Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):
>
>     /* dma channel 11-14 share one irq */
>
> which mismatched the Qemu model.
> In this patch channels 0--10 and 11--14 are handled separately.

Is there any hardware documentation that says whether QEMU or
the DTB is correct? The device tree is at best a secondary source...

> Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
> ---
>  hw/arm/bcm2835_peripherals.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
> index 48538c9360..3d808b0e31 100644
> --- a/hw/arm/bcm2835_peripherals.c
> +++ b/hw/arm/bcm2835_peripherals.c
> @@ -322,13 +322,21 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
>      memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
>                  sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
>
> -    for (n = 0; n <= 12; n++) {
> +    for (n = 0; n <= 10; n++) {
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
>                             qdev_get_gpio_in_named(DEVICE(&s->ic),
>                                                    BCM2835_IC_GPU_IRQ,
>                                                    INTERRUPT_DMA0 + n));
>      }
>
> +    /* According to DTS, dma channels 11-14 share one irq */
> +    for (n = 11; n <= 14; n++) {
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
> +                           qdev_get_gpio_in_named(DEVICE(&s->ic),
> +                                                  BCM2835_IC_GPU_IRQ,
> +                                                  INTERRUPT_DMA0 + 11));

You can't connect multiple qemu_irq lines to one like this.
If the hardware behaves this way then you need to create
an OR gate, wire all the lines from the devices to the
OR gate inputs, and wire the OR gate output to the destination.

thanks
-- PMM


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

* Re: [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS
  2022-06-26 10:16 ` Peter Maydell
@ 2022-06-30  8:32   ` Makarov, Andrey
  2022-07-12 22:30   ` Philippe Mathieu-Daudé via
  1 sibling, 0 replies; 4+ messages in thread
From: Makarov, Andrey @ 2022-06-30  8:32 UTC (permalink / raw)
  To: Peter Maydell, Andrey Makarov; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 3004 bytes --]

> Is there any hardware documentation that says whether QEMU or
> the DTB is correct? The device tree is at best a secondary source...


No. It should have been in the "BCM2835 ARM Peripherals" datasheet but the appropriate "ARM peripherals interrupt table" there is nearly empty.


> You can't connect multiple qemu_irq lines to one like this.
> If the hardware behaves this way then you need to create
> an OR gate, wire all the lines from the devices to the
> OR gate inputs, and wire the OR gate output to the destination.


Thank you for this correction, I will send another version of patch.


Andrey Makarov,

Team Lead


________________________________
From: Peter Maydell <peter.maydell@linaro.org>
Sent: Sunday, June 26, 2022 1:16:18 PM
To: Andrey Makarov
Cc: qemu-devel@nongnu.org; Makarov, Andrey
Subject: Re: [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS

On Fri, 24 Jun 2022 at 21:54, Andrey Makarov <ph.makarov@gmail.com> wrote:
>
> All Raspberry Pi models 1-3 (based on bcm2835) have
> Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):
>
>     /* dma channel 11-14 share one irq */
>
> which mismatched the Qemu model.
> In this patch channels 0--10 and 11--14 are handled separately.

Is there any hardware documentation that says whether QEMU or
the DTB is correct? The device tree is at best a secondary source...

> Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
> ---
>  hw/arm/bcm2835_peripherals.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
> index 48538c9360..3d808b0e31 100644
> --- a/hw/arm/bcm2835_peripherals.c
> +++ b/hw/arm/bcm2835_peripherals.c
> @@ -322,13 +322,21 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
>      memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
>                  sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
>
> -    for (n = 0; n <= 12; n++) {
> +    for (n = 0; n <= 10; n++) {
>          sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
>                             qdev_get_gpio_in_named(DEVICE(&s->ic),
>                                                    BCM2835_IC_GPU_IRQ,
>                                                    INTERRUPT_DMA0 + n));
>      }
>
> +    /* According to DTS, dma channels 11-14 share one irq */
> +    for (n = 11; n <= 14; n++) {
> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
> +                           qdev_get_gpio_in_named(DEVICE(&s->ic),
> +                                                  BCM2835_IC_GPU_IRQ,
> +                                                  INTERRUPT_DMA0 + 11));

You can't connect multiple qemu_irq lines to one like this.
If the hardware behaves this way then you need to create
an OR gate, wire all the lines from the devices to the
OR gate inputs, and wire the OR gate output to the destination.

thanks
-- PMM

[-- Attachment #2: Type: text/html, Size: 6858 bytes --]

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

* Re: [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS
  2022-06-26 10:16 ` Peter Maydell
  2022-06-30  8:32   ` Makarov, Andrey
@ 2022-07-12 22:30   ` Philippe Mathieu-Daudé via
  1 sibling, 0 replies; 4+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-07-12 22:30 UTC (permalink / raw)
  To: Peter Maydell, Andrey Makarov
  Cc: qemu-devel, Andrey Makarov, Jeremy Linton, Pete Batard

+Pete/Jeremy

On 26/6/22 12:16, Peter Maydell wrote:
> On Fri, 24 Jun 2022 at 21:54, Andrey Makarov <ph.makarov@gmail.com> wrote:
>>
>> All Raspberry Pi models 1-3 (based on bcm2835) have
>> Linux device tree (arch/arm/boot/dts/bcm2835-common.dtsi +25):
>>
>>      /* dma channel 11-14 share one irq */
>>
>> which mismatched the Qemu model.
>> In this patch channels 0--10 and 11--14 are handled separately.
> 
> Is there any hardware documentation that says whether QEMU or
> the DTB is correct? The device tree is at best a secondary source...

There are 10 DMA channels, one is labelled "reserved".

EDK2 lists it too:
https://github.com/tianocore/edk2-platforms/blob/master/Platform/RaspberryPi/AcpiTables/AcpiTables.h#L57

I couldn't find any precise information regarding channels 11-14.

>> Signed-off-by: Andrey Makarov <andrey.makarov@auriga.com>
>> ---
>>   hw/arm/bcm2835_peripherals.c | 10 +++++++++-
>>   1 file changed, 9 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/arm/bcm2835_peripherals.c b/hw/arm/bcm2835_peripherals.c
>> index 48538c9360..3d808b0e31 100644
>> --- a/hw/arm/bcm2835_peripherals.c
>> +++ b/hw/arm/bcm2835_peripherals.c
>> @@ -322,13 +322,21 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
>>       memory_region_add_subregion(&s->peri_mr, DMA15_OFFSET,
>>                   sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->dma), 1));
>>
>> -    for (n = 0; n <= 12; n++) {
>> +    for (n = 0; n <= 10; n++) {
>>           sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
>>                              qdev_get_gpio_in_named(DEVICE(&s->ic),
>>                                                     BCM2835_IC_GPU_IRQ,
>>                                                     INTERRUPT_DMA0 + n));
>>       }
>>
>> +    /* According to DTS, dma channels 11-14 share one irq */
>> +    for (n = 11; n <= 14; n++) {
>> +        sysbus_connect_irq(SYS_BUS_DEVICE(&s->dma), n,
>> +                           qdev_get_gpio_in_named(DEVICE(&s->ic),
>> +                                                  BCM2835_IC_GPU_IRQ,
>> +                                                  INTERRUPT_DMA0 + 11));
> 
> You can't connect multiple qemu_irq lines to one like this.
> If the hardware behaves this way then you need to create
> an OR gate, wire all the lines from the devices to the
> OR gate inputs, and wire the OR gate output to the destination.
> 
> thanks
> -- PMM
> 



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

end of thread, other threads:[~2022-07-12 23:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-24 19:52 [PATCH] Align Raspberry Pi DMA interrupts with Linux DTS Andrey Makarov
2022-06-26 10:16 ` Peter Maydell
2022-06-30  8:32   ` Makarov, Andrey
2022-07-12 22:30   ` Philippe Mathieu-Daudé via

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.