kernel: bump kernel 4.4 to 4.4.129 for 17.01
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.4 / 0398-dmaengine-bcm2835-add-dma_memcopy-support-to-bcm2835.patch
1 From 764cf7045e6338c1ca850ef1fce522b31440dab9 Mon Sep 17 00:00:00 2001
2 From: Martin Sperl <kernel@martin.sperl.org>
3 Date: Wed, 16 Mar 2016 12:25:02 -0700
4 Subject: [PATCH] dmaengine: bcm2835: add dma_memcopy support to bcm2835-dma
5
6 Also added check for an error condition in bcm2835_dma_create_cb_chain
7 that showed up during development of this patch.
8
9 Tested using dmatest for all enabled channels.
10
11 Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
12 Reviewed-by: Eric Anholt <eric@anholt.net>
13 Signed-off-by: Eric Anholt <eric@anholt.net>
14 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
15 ---
16 drivers/dma/bcm2835-dma.c | 36 +++++++++++++++++++++++++++++++++++-
17 1 file changed, 35 insertions(+), 1 deletion(-)
18
19 --- a/drivers/dma/bcm2835-dma.c
20 +++ b/drivers/dma/bcm2835-dma.c
21 @@ -310,6 +310,9 @@ static struct bcm2835_desc *bcm2835_dma_
22 struct bcm2835_cb_entry *cb_entry;
23 struct bcm2835_dma_cb *control_block;
24
25 + if (!frames)
26 + return NULL;
27 +
28 /* allocate and setup the descriptor. */
29 d = kzalloc(sizeof(*d) + frames * sizeof(struct bcm2835_cb_entry),
30 gfp);
31 @@ -597,6 +600,34 @@ static void bcm2835_dma_issue_pending(st
32 spin_unlock_irqrestore(&c->vc.lock, flags);
33 }
34
35 +struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
36 + struct dma_chan *chan, dma_addr_t dst, dma_addr_t src,
37 + size_t len, unsigned long flags)
38 +{
39 + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
40 + struct bcm2835_desc *d;
41 + u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
42 + u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
43 + size_t max_len = bcm2835_dma_max_frame_length(c);
44 + size_t frames;
45 +
46 + /* if src, dst or len is not given return with an error */
47 + if (!src || !dst || !len)
48 + return NULL;
49 +
50 + /* calculate number of frames */
51 + frames = bcm2835_dma_frames_for_length(len, max_len);
52 +
53 + /* allocate the CB chain - this also fills in the pointers */
54 + d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false,
55 + info, extra, frames,
56 + src, dst, len, 0, GFP_KERNEL);
57 + if (!d)
58 + return NULL;
59 +
60 + return vchan_tx_prep(&c->vc, &d->vd, flags);
61 +}
62 +
63 static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
64 struct dma_chan *chan,
65 struct scatterlist *sgl, unsigned int sg_len,
66 @@ -880,17 +911,20 @@ static int bcm2835_dma_probe(struct plat
67 dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
68 dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
69 dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
70 + dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask);
71 od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources;
72 od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources;
73 od->ddev.device_tx_status = bcm2835_dma_tx_status;
74 od->ddev.device_issue_pending = bcm2835_dma_issue_pending;
75 od->ddev.device_prep_dma_cyclic = bcm2835_dma_prep_dma_cyclic;
76 od->ddev.device_prep_slave_sg = bcm2835_dma_prep_slave_sg;
77 + od->ddev.device_prep_dma_memcpy = bcm2835_dma_prep_dma_memcpy;
78 od->ddev.device_config = bcm2835_dma_slave_config;
79 od->ddev.device_terminate_all = bcm2835_dma_terminate_all;
80 od->ddev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
81 od->ddev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
82 - od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
83 + od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) |
84 + BIT(DMA_MEM_TO_MEM);
85 od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
86 od->ddev.dev = &pdev->dev;
87 INIT_LIST_HEAD(&od->ddev.channels);