fa0d998a2d93e68b369c8e386928fb1234bbbc29
[openwrt/staging/chunkeey.git] / target / linux / brcm2708 / patches-4.9 / 950-0187-dmaengine-bcm2835-Fix-cyclic-DMA-period-splitting.patch
1 From 9fd7a158ec098ab05b8d3ec2c2973b3dc7e498f3 Mon Sep 17 00:00:00 2001
2 From: Matthias Reichl <hias@horus.com>
3 Date: Mon, 20 Feb 2017 20:01:16 +0100
4 Subject: [PATCH] dmaengine: bcm2835: Fix cyclic DMA period splitting
5
6 The code responsible for splitting periods into chunks that
7 can be handled by the DMA controller missed to update total_len,
8 the number of bytes processed in the current period, when there
9 are more chunks to follow.
10
11 Therefore total_len was stuck at 0 and the code didn't work at all.
12 This resulted in a wrong control block layout and audio issues because
13 the cyclic DMA callback wasn't executing on period boundaries.
14
15 Fix this by adding the missing total_len update.
16
17 Signed-off-by: Matthias Reichl <hias@horus.com>
18 Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
19 Tested-by: Clive Messer <clive.messer@digitaldreamtime.co.uk>
20 Reviewed-by: Eric Anholt <eric@anholt.net>
21 ---
22 drivers/dma/bcm2835-dma.c | 5 ++++-
23 1 file changed, 4 insertions(+), 1 deletion(-)
24
25 --- a/drivers/dma/bcm2835-dma.c
26 +++ b/drivers/dma/bcm2835-dma.c
27 @@ -253,8 +253,11 @@ static void bcm2835_dma_create_cb_set_le
28 */
29
30 /* have we filled in period_length yet? */
31 - if (*total_len + control_block->length < period_len)
32 + if (*total_len + control_block->length < period_len) {
33 + /* update number of bytes in this period so far */
34 + *total_len += control_block->length;
35 return;
36 + }
37
38 /* calculate the length that remains to reach period_length */
39 control_block->length = period_len - *total_len;