ARM: dts: integrator: Fix DMA ranges
authorLinus Walleij <linus.walleij@linaro.org>
Mon, 26 Sep 2022 07:33:11 +0000 (09:33 +0200)
committerArnd Bergmann <arnd@arndb.de>
Mon, 26 Sep 2022 21:05:58 +0000 (23:05 +0200)
A recent change affecting the behaviour of phys_to_dma() to
actually require the device tree ranges to work unmasked a
bug in the Integrator DMA ranges.

The PL110 uses the CMA allocator to obtain coherent allocations
from a dedicated 1MB video memory, leading to the following
call chain:

drm_gem_cma_create()
  dma_alloc_attrs()
    dma_alloc_from_dev_coherent()
      __dma_alloc_from_coherent()
        dma_get_device_base()
          phys_to_dma()
            translate_phys_to_dma()

phys_to_dma() by way of translate_phys_to_dma() will nowadays not
provide 1:1 mappings unless the ranges are properly defined in
the device tree and reflected into the dev->dma_range_map.

There is a bug in the device trees because the DMA ranges are
incorrectly specified, and the patch uncovers this bug.

Solution:

- Fix the LB (logic bus) ranges to be 1-to-1 like they should
  have always been.
- Provide a 1:1 dma-ranges attribute to the PL110.
- Mark the PL110 display controller as DMA coherent.

This makes the DMA ranges work right and makes the PL110
framebuffer work again.

Fixes: af6f23b88e95 ("ARM/dma-mapping: use the generic versions of dma_to_phys/phys_to_dma by default")
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/r/20220926073311.1610568-1-linus.walleij@linaro.org'
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
arch/arm/boot/dts/integratorap-im-pd1.dts
arch/arm/boot/dts/integratorap.dts

index 4c22e44362718377625345785e1954ae5e1ec5b2..cc514cf07bff7dcab39cb2b33f87b43ad0c4d0b0 100644 (file)
                /* 640x480 16bpp @ 25.175MHz is 36827428 bytes/s */
                max-memory-bandwidth = <40000000>;
                memory-region = <&impd1_ram>;
+               dma-ranges;
 
                port@0 {
                        #address-cells = <1>;
index c983435ed492e393b2f9a2709232686df78be1c1..9148287fa0a930de7c329d412cde880740256469 100644 (file)
                lm0: bus@c0000000 {
                        compatible = "simple-bus";
                        ranges = <0x00000000 0xc0000000 0x10000000>;
-                       dma-ranges = <0x00000000 0x80000000 0x10000000>;
+                       dma-ranges = <0x00000000 0xc0000000 0x10000000>;
                        reg = <0xc0000000 0x10000000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                lm1: bus@d0000000 {
                        compatible = "simple-bus";
                        ranges = <0x00000000 0xd0000000 0x10000000>;
-                       dma-ranges = <0x00000000 0x80000000 0x10000000>;
+                       dma-ranges = <0x00000000 0xd0000000 0x10000000>;
                        reg = <0xd0000000 0x10000000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                lm2: bus@e0000000 {
                        compatible = "simple-bus";
                        ranges = <0x00000000 0xe0000000 0x10000000>;
-                       dma-ranges = <0x00000000 0x80000000 0x10000000>;
+                       dma-ranges = <0x00000000 0xe0000000 0x10000000>;
                        reg = <0xe0000000 0x10000000>;
                        #address-cells = <1>;
                        #size-cells = <1>;
                lm3: bus@f0000000 {
                        compatible = "simple-bus";
                        ranges = <0x00000000 0xf0000000 0x10000000>;
-                       dma-ranges = <0x00000000 0x80000000 0x10000000>;
+                       dma-ranges = <0x00000000 0xf0000000 0x10000000>;
                        reg = <0xf0000000 0x10000000>;
                        #address-cells = <1>;
                        #size-cells = <1>;