From acbd1f3fa7de4a89cfd7844ccf201362089e962c Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Tue, 2 Jan 2018 16:32:26 +0800 Subject: [PATCH] MLK-17285 dma: imx-sdma: fix sound mute in high loading SDMA channel will stop in case of cpu high loading. That caused by sdma ISR can't be handled in time while all cyclic bds consumed by sdma side, then sdma channel stopped. Re-enable channel in this case to workaound the issue. Signed-off-by: Robin Gong Reviewed-by: Shengjiu Wang (cherry picked from commit 98c43d24d19d28ae364e7fedf48d61e98a2ec9e4) (cherry picked from commit 65f426ddd092175602993cf4494e75f84f50b58a) --- drivers/dma/imx-sdma.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 31fee48d6b40..0ebf0e18faa6 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -943,6 +943,7 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac) struct sdma_buffer_descriptor *bd; int error = 0; enum dma_status old_status = sdmac->status; + int count = 0; /* * loop mode. Iterate over descriptors, re-setup them and @@ -953,6 +954,17 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac) bd = &desc->bd[desc->buf_tail]; + /* + * re-enable HSTART_HE if all bds consumed at the last time, + * that happens in high loading case which sdma_handle_channel_ + * loop can't be handled in time while all bds run out in sdma + * side, then sdma script clear HE and cause channel stop. + */ + if (count == desc->num_bd) { + dev_warn(sdmac->sdma->dev, "All bds consumed,restart now.\n"); + sdma_enable_channel(sdmac->sdma, sdmac->channel); + } + if (bd->mode.status & BD_DONE) break; @@ -978,6 +990,7 @@ static void sdma_update_channel_loop(struct sdma_channel *sdmac) bd->mode.count = desc->period_len; desc->buf_ptail = desc->buf_tail; desc->buf_tail = (desc->buf_tail + 1) % desc->num_bd; + count++; /* * The callback is called from the interrupt context in order -- 2.17.1