bcm27xx: 6.1: add kernel patches
[openwrt/staging/stintel.git] / target / linux / bcm27xx / patches-6.1 / 950-0710-bcm2835-dma-Derive-slave-DMA-addresses-correctly.patch
1 From 6d317d92627736a94e6c1c4b49c3f63cc33c28aa Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Thu, 11 May 2023 10:00:01 +0100
4 Subject: [PATCH] bcm2835-dma: Derive slave DMA addresses correctly
5
6 Slave addresses for DMA are meant to be supplied as physical addresses
7 (contrary to what struct snd_dmaengine_dai_dma_data does). It is up to
8 the DMA controller driver to perform the translation based on its own
9 view of the world, as described in Device Tree.
10
11 Now that the Pi Device Trees have the correct peripheral mappings,
12 replace the hacky address munging with phys_to_dma().
13
14 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
15 ---
16 drivers/dma/bcm2835-dma.c | 23 +++++------------------
17 1 file changed, 5 insertions(+), 18 deletions(-)
18
19 --- a/drivers/dma/bcm2835-dma.c
20 +++ b/drivers/dma/bcm2835-dma.c
21 @@ -18,6 +18,7 @@
22 * Copyright 2012 Marvell International Ltd.
23 */
24 #include <linux/dmaengine.h>
25 +#include <linux/dma-direct.h>
26 #include <linux/dma-mapping.h>
27 #include <linux/dmapool.h>
28 #include <linux/err.h>
29 @@ -910,22 +911,12 @@ static struct dma_async_tx_descriptor *b
30 if (direction == DMA_DEV_TO_MEM) {
31 if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
32 return NULL;
33 - src = c->cfg.src_addr;
34 - /*
35 - * One would think it ought to be possible to get the physical
36 - * to dma address mapping information from the dma-ranges DT
37 - * property, but I've not found a way yet that doesn't involve
38 - * open-coding the whole thing.
39 - */
40 - if (c->is_40bit_channel)
41 - src |= 0x400000000ull;
42 + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
43 info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
44 } else {
45 if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
46 return NULL;
47 - dst = c->cfg.dst_addr;
48 - if (c->is_40bit_channel)
49 - dst |= 0x400000000ull;
50 + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
51 info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
52 }
53
54 @@ -994,17 +985,13 @@ static struct dma_async_tx_descriptor *b
55 if (direction == DMA_DEV_TO_MEM) {
56 if (c->cfg.src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
57 return NULL;
58 - src = c->cfg.src_addr;
59 - if (c->is_40bit_channel)
60 - src |= 0x400000000ull;
61 + src = phys_to_dma(chan->device->dev, c->cfg.src_addr);
62 dst = buf_addr;
63 info |= BCM2835_DMA_S_DREQ | BCM2835_DMA_D_INC;
64 } else {
65 if (c->cfg.dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES)
66 return NULL;
67 - dst = c->cfg.dst_addr;
68 - if (c->is_40bit_channel)
69 - dst |= 0x400000000ull;
70 + dst = phys_to_dma(chan->device->dev, c->cfg.dst_addr);
71 src = buf_addr;
72 info |= BCM2835_DMA_D_DREQ | BCM2835_DMA_S_INC;
73