Skip to content

Commit 9df3bd5

Browse files
stmordretVinod Koul
authored andcommitted
dmaengine: stm32-dma: properly mask irq bits
A single register of the controller holds the information for four dma channels. The functions stm32_dma_irq_status() don't mask the relevant bits after the shift, thus adjacent channel's status is also reported in the returned value. Fixed by masking the value before returning it. Similarly, the function stm32_dma_irq_clear() don't mask the input value before shifting it, thus an incorrect input value could disable the interrupts of adjacent channels. Fixed by masking the input value before using it. Signed-off-by: Pierre-Yves MORDRET <[email protected]> Signed-off-by: Antonio Borneo <[email protected]> Signed-off-by: Vinod Koul <[email protected]>
1 parent 80a7695 commit 9df3bd5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/dma/stm32-dma.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
#define STM32_DMA_TEI BIT(3) /* Transfer Error Interrupt */
3939
#define STM32_DMA_DMEI BIT(2) /* Direct Mode Error Interrupt */
4040
#define STM32_DMA_FEI BIT(0) /* FIFO Error Interrupt */
41+
#define STM32_DMA_MASKI (STM32_DMA_TCI \
42+
| STM32_DMA_TEI \
43+
| STM32_DMA_DMEI \
44+
| STM32_DMA_FEI)
4145

4246
/* DMA Stream x Configuration Register */
4347
#define STM32_DMA_SCR(x) (0x0010 + 0x18 * (x)) /* x = 0..7 */
@@ -405,7 +409,7 @@ static u32 stm32_dma_irq_status(struct stm32_dma_chan *chan)
405409

406410
flags = dma_isr >> (((chan->id & 2) << 3) | ((chan->id & 1) * 6));
407411

408-
return flags;
412+
return flags & STM32_DMA_MASKI;
409413
}
410414

411415
static void stm32_dma_irq_clear(struct stm32_dma_chan *chan, u32 flags)
@@ -420,6 +424,7 @@ static void stm32_dma_irq_clear(struct stm32_dma_chan *chan, u32 flags)
420424
* If (ch % 4) is 2 or 3, left shift the mask by 16 bits.
421425
* If (ch % 4) is 1 or 3, additionally left shift the mask by 6 bits.
422426
*/
427+
flags &= STM32_DMA_MASKI;
423428
dma_ifcr = flags << (((chan->id & 2) << 3) | ((chan->id & 1) * 6));
424429

425430
if (chan->id & 4)

0 commit comments

Comments
 (0)