bcm27xx: add support for linux v5.15
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0274-bcm2835-dma-Advertise-the-full-DMA-range.patch
1 From 775277f1d6585ea048c73ca001ed2867a32396a4 Mon Sep 17 00:00:00 2001
2 From: Phil Elwell <phil@raspberrypi.com>
3 Date: Wed, 22 Jul 2020 17:59:31 +0100
4 Subject: [PATCH] bcm2835-dma: Advertise the full DMA range
5
6 Unless the DMA mask is set wider than 32 bits, DMA mapping will use a
7 bounce buffer.
8
9 Signed-off-by: Phil Elwell <phil@raspberrypi.com>
10 ---
11 drivers/dma/bcm2835-dma.c | 18 +++++++++++++++---
12 1 file changed, 15 insertions(+), 3 deletions(-)
13
14 --- a/drivers/dma/bcm2835-dma.c
15 +++ b/drivers/dma/bcm2835-dma.c
16 @@ -41,6 +41,7 @@
17 #define BCM2711_DMA_MEMCPY_CHAN 14
18
19 struct bcm2835_dma_cfg_data {
20 + u64 dma_mask;
21 u32 chan_40bit_mask;
22 };
23
24 @@ -300,10 +301,12 @@ DEFINE_SPINLOCK(memcpy_lock);
25
26 static const struct bcm2835_dma_cfg_data bcm2835_dma_cfg = {
27 .chan_40bit_mask = 0,
28 + .dma_mask = DMA_BIT_MASK(32),
29 };
30
31 static const struct bcm2835_dma_cfg_data bcm2711_dma_cfg = {
32 .chan_40bit_mask = BIT(11) | BIT(12) | BIT(13) | BIT(14),
33 + .dma_mask = DMA_BIT_MASK(36),
34 };
35
36 static inline size_t bcm2835_dma_max_frame_length(struct bcm2835_chan *c)
37 @@ -1180,6 +1183,8 @@ static struct dma_chan *bcm2835_dma_xlat
38
39 static int bcm2835_dma_probe(struct platform_device *pdev)
40 {
41 + const struct bcm2835_dma_cfg_data *cfg_data;
42 + const struct of_device_id *of_id;
43 struct bcm2835_dmadev *od;
44 struct resource *res;
45 void __iomem *base;
46 @@ -1189,13 +1194,20 @@ static int bcm2835_dma_probe(struct plat
47 int irq_flags;
48 uint32_t chans_available;
49 char chan_name[BCM2835_DMA_CHAN_NAME_SIZE];
50 - const struct of_device_id *of_id;
51 int chan_count, chan_start, chan_end;
52
53 + of_id = of_match_node(bcm2835_dma_of_match, pdev->dev.of_node);
54 + if (!of_id) {
55 + dev_err(&pdev->dev, "Failed to match compatible string\n");
56 + return -EINVAL;
57 + }
58 +
59 + cfg_data = of_id->data;
60 +
61 if (!pdev->dev.dma_mask)
62 pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask;
63
64 - rc = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
65 + rc = dma_set_mask_and_coherent(&pdev->dev, cfg_data->dma_mask);
66 if (rc) {
67 dev_err(&pdev->dev, "Unable to set DMA mask\n");
68 return rc;
69 @@ -1260,7 +1272,7 @@ static int bcm2835_dma_probe(struct plat
70 return -EINVAL;
71 }
72
73 - od->cfg_data = of_id->data;
74 + od->cfg_data = cfg_data;
75
76 /* Request DMA channel mask from device tree */
77 if (of_property_read_u32(pdev->dev.of_node,