diff options
author | Pierre-Yves MORDRET <pierre-yves.mordret@st.com> | 2018-04-13 15:52:12 +0200 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2018-04-25 14:39:53 +0530 |
commit | ee6de9ac527f0630d496303df3f270678128e6c6 (patch) | |
tree | 45a44a4550501ff4b5f86e18422984722525538b /drivers/dma | |
parent | 60cc43fc888428bb2f18f08997432d426a243338 (diff) |
dmaengine: stm32-mdma: align TLEN and buffer length on burst
Both buffer Transfer Length (TLEN if any) and transfer size have to be
aligned on burst size (burst beats*bus width).
Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com>
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/stm32-mdma.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/dma/stm32-mdma.c b/drivers/dma/stm32-mdma.c index daa1602eb9f5..4c7634ca62a7 100644 --- a/drivers/dma/stm32-mdma.c +++ b/drivers/dma/stm32-mdma.c @@ -410,13 +410,10 @@ static enum dma_slave_buswidth stm32_mdma_get_max_width(dma_addr_t addr, static u32 stm32_mdma_get_best_burst(u32 buf_len, u32 tlen, u32 max_burst, enum dma_slave_buswidth width) { - u32 best_burst = max_burst; - u32 burst_len = best_burst * width; + u32 best_burst; - while ((burst_len > 0) && (tlen % burst_len)) { - best_burst = best_burst >> 1; - burst_len = best_burst * width; - } + best_burst = min((u32)1 << __ffs(tlen | buf_len), + max_burst * width) / width; return (best_burst > 0) ? best_burst : 1; } |