Skip to content

Commit cc832dc

Browse files
stmordretvinodkoul
authored andcommitted
dmaengine: stm32-dma: check whether length is aligned on FIFO threshold
When a period length is not multiple of FIFO some data may be stuck within FIFO. Burst/FIFO Threshold/Period or buffer length check has to be hardened In any case DMA will grant any request from client but will degraded any parameters whether awkward. Signed-off-by: Pierre-Yves MORDRET <pierre-yves.mordret@st.com> Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 5b394b2 commit cc832dc

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

drivers/dma/stm32-dma.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -308,20 +308,12 @@ static bool stm32_dma_fifo_threshold_is_allowed(u32 burst, u32 threshold,
308308

309309
static bool stm32_dma_is_burst_possible(u32 buf_len, u32 threshold)
310310
{
311-
switch (threshold) {
312-
case STM32_DMA_FIFO_THRESHOLD_FULL:
313-
if (buf_len >= STM32_DMA_MAX_BURST)
314-
return true;
315-
else
316-
return false;
317-
case STM32_DMA_FIFO_THRESHOLD_HALFFULL:
318-
if (buf_len >= STM32_DMA_MAX_BURST / 2)
319-
return true;
320-
else
321-
return false;
322-
default:
323-
return false;
324-
}
311+
/*
312+
* Buffer or period length has to be aligned on FIFO depth.
313+
* Otherwise bytes may be stuck within FIFO at buffer or period
314+
* length.
315+
*/
316+
return ((buf_len % ((threshold + 1) * 4)) == 0);
325317
}
326318

327319
static u32 stm32_dma_get_best_burst(u32 buf_len, u32 max_burst, u32 threshold,

0 commit comments

Comments
 (0)