Skip to content

Commit c81dba6

Browse files
FRASTMfabiobaltieri
authored andcommitted
drivers: dma stm32U5 GPDMA keeps the channel busy if overriden
For the stm32U5 serie, the busy flag is handled as other serie. When the DMA is overriden by other HAL drivers, the busy flag is not considered. Refer to #47645 There is no Mux for this GPDMA and fixed 16 channels. Signed-off-by: Francois Ramu <[email protected]>
1 parent e24c525 commit c81dba6

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

drivers/dma/dma_stm32u5.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,12 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id)
230230
__ASSERT_NO_MSG(id < config->max_streams);
231231

232232
stream = &config->streams[id];
233-
/* Exit if stream is no more busy */
234-
if (stream->busy == false) {
233+
/* The busy channel is pertinent if not overridden by the HAL */
234+
if ((stream->hal_override != true) && (stream->busy == false)) {
235+
/*
236+
* When DMA channel is not overridden by HAL,
237+
* ignore irq if the channel is not busy anymore
238+
*/
235239
dma_stm32_clear_stream_irq(dev, id);
236240
return;
237241
}
@@ -246,9 +250,6 @@ static void dma_stm32_irq_handler(const struct device *dev, uint32_t id)
246250
}
247251
stream->dma_callback(dev, stream->user_data, callback_arg, 0);
248252
} else if (stm32_dma_is_tc_irq_active(dma, id)) {
249-
#ifdef CONFIG_DMAMUX_STM32
250-
stream->busy = false;
251-
#endif
252253
/* Let HAL DMA handle flags on its own */
253254
if (!stream->hal_override) {
254255
dma_stm32_clear_tc(dma, id);
@@ -540,6 +541,9 @@ static int dma_stm32_reload(const struct device *dev, uint32_t id,
540541
size / stream->dst_size);
541542
}
542543

544+
/* When reloading the dma, the stream is busy again before enabling */
545+
stream->busy = true;
546+
543547
stm32_dma_enable_stream(dma, id);
544548

545549
return 0;
@@ -549,6 +553,7 @@ static int dma_stm32_start(const struct device *dev, uint32_t id)
549553
{
550554
const struct dma_stm32_config *config = dev->config;
551555
DMA_TypeDef *dma = (DMA_TypeDef *)(config->base);
556+
struct dma_stm32_stream *stream;
552557

553558
/* Give channel from index 0 */
554559
id = id - STM32_DMA_STREAM_OFFSET;
@@ -558,6 +563,10 @@ static int dma_stm32_start(const struct device *dev, uint32_t id)
558563
return -EINVAL;
559564
}
560565

566+
/* When starting the dma, the stream is busy before enabling */
567+
stream = &config->streams[id];
568+
stream->busy = true;
569+
561570
dma_stm32_clear_stream_irq(dev, id);
562571

563572
stm32_dma_enable_stream(dma, id);
@@ -578,11 +587,11 @@ static int dma_stm32_stop(const struct device *dev, uint32_t id)
578587
return -EINVAL;
579588
}
580589

590+
LL_DMA_DisableIT_TC(dma, dma_stm32_id_to_stream(id));
591+
581592
dma_stm32_clear_stream_irq(dev, id);
582593
dma_stm32_disable_stream(dma, id);
583594

584-
LL_DMA_DisableIT_TC(dma, dma_stm32_id_to_stream(id));
585-
586595
/* Finally, flag stream as free */
587596
stream->busy = false;
588597

@@ -715,16 +724,9 @@ static void dma_stm32_config_irq_0(const struct device *dev)
715724
DMA_STM32_IRQ_CONNECT(0, 2);
716725
DMA_STM32_IRQ_CONNECT(0, 3);
717726
DMA_STM32_IRQ_CONNECT(0, 4);
718-
#if DT_INST_IRQ_HAS_IDX(0, 5)
719727
DMA_STM32_IRQ_CONNECT(0, 5);
720-
#if DT_INST_IRQ_HAS_IDX(0, 6)
721728
DMA_STM32_IRQ_CONNECT(0, 6);
722-
#if DT_INST_IRQ_HAS_IDX(0, 7)
723729
DMA_STM32_IRQ_CONNECT(0, 7);
724-
#endif /* DT_INST_IRQ_HAS_IDX(0, 5) */
725-
#endif /* DT_INST_IRQ_HAS_IDX(0, 6) */
726-
#endif /* DT_INST_IRQ_HAS_IDX(0, 7) */
727-
/* Either 5 or 6 or 7 or 8 channels for DMA across all stm32 series. */
728730
DMA_STM32_IRQ_CONNECT(0, 8);
729731
DMA_STM32_IRQ_CONNECT(0, 9);
730732
DMA_STM32_IRQ_CONNECT(0, 10);

0 commit comments

Comments
 (0)