* [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining
@ 2023-10-04 15:50 Amelie Delaunay
2023-10-04 15:50 ` [PATCH 2/2] dmaengine: stm32-dma: fix residue " Amelie Delaunay
2023-10-09 6:12 ` [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg " Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Amelie Delaunay @ 2023-10-04 15:50 UTC (permalink / raw)
To: Vinod Koul, Maxime Coquelin, Alexandre Torgue, Amelie Delaunay
Cc: stable, dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
Current Target (CT) have to be reset when starting an MDMA chaining use
case, as Double Buffer mode is activated. It ensures the DMA will start
processing the first memory target (pointed with SxM0AR).
Fixes: 723795173ce1 ("dmaengine: stm32-dma: add support to trigger STM32 MDMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
---
drivers/dma/stm32-dma.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 5c36811aa134..7427acc82259 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1113,8 +1113,10 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg(
chan->chan_reg.dma_scr &= ~STM32_DMA_SCR_PFCTRL;
/* Activate Double Buffer Mode if DMA triggers STM32 MDMA and more than 1 sg */
- if (chan->trig_mdma && sg_len > 1)
+ if (chan->trig_mdma && sg_len > 1) {
chan->chan_reg.dma_scr |= STM32_DMA_SCR_DBM;
+ chan->chan_reg.dma_scr &= ~STM32_DMA_SCR_CT;
+ }
for_each_sg(sgl, sg, sg_len, i) {
ret = stm32_dma_set_xfer_param(chan, direction, &buswidth,
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] dmaengine: stm32-dma: fix residue in case of MDMA chaining
2023-10-04 15:50 [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining Amelie Delaunay
@ 2023-10-04 15:50 ` Amelie Delaunay
2023-10-09 6:12 ` [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg " Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Amelie Delaunay @ 2023-10-04 15:50 UTC (permalink / raw)
To: Vinod Koul, Maxime Coquelin, Alexandre Torgue, Amelie Delaunay
Cc: stable, dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
In case of MDMA chaining, DMA is configured in Double-Buffer Mode (DBM)
with two periods, but if transfer has been prepared with _prep_slave_sg(),
the transfer is not marked cyclic (=!chan->desc->cyclic). However, as DBM
is activated for MDMA chaining, residue computation must take into account
cyclic constraints.
With only two periods in MDMA chaining, and no update due to Transfer
Complete interrupt masked, n_sg is always 0. If DMA current memory address
(depending on SxCR.CT and SxM0AR/SxM1AR) does not correspond, it means n_sg
should be increased.
Then, the residue of the current period is the one read from SxNDTR and
should not be overwritten with the full period length.
Fixes: 723795173ce1 ("dmaengine: stm32-dma: add support to trigger STM32 MDMA")
Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com>
Cc: stable@vger.kernel.org
---
drivers/dma/stm32-dma.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c
index 7427acc82259..0b30151fb45c 100644
--- a/drivers/dma/stm32-dma.c
+++ b/drivers/dma/stm32-dma.c
@@ -1389,11 +1389,12 @@ static size_t stm32_dma_desc_residue(struct stm32_dma_chan *chan,
residue = stm32_dma_get_remaining_bytes(chan);
- if (chan->desc->cyclic && !stm32_dma_is_current_sg(chan)) {
+ if ((chan->desc->cyclic || chan->trig_mdma) && !stm32_dma_is_current_sg(chan)) {
n_sg++;
if (n_sg == chan->desc->num_sgs)
n_sg = 0;
- residue = sg_req->len;
+ if (!chan->trig_mdma)
+ residue = sg_req->len;
}
/*
@@ -1403,7 +1404,7 @@ static size_t stm32_dma_desc_residue(struct stm32_dma_chan *chan,
* residue = remaining bytes from NDTR + remaining
* periods/sg to be transferred
*/
- if (!chan->desc->cyclic || n_sg != 0)
+ if ((!chan->desc->cyclic && !chan->trig_mdma) || n_sg != 0)
for (i = n_sg; i < desc->num_sgs; i++)
residue += desc->sg_req[i].len;
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining
2023-10-04 15:50 [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining Amelie Delaunay
2023-10-04 15:50 ` [PATCH 2/2] dmaengine: stm32-dma: fix residue " Amelie Delaunay
@ 2023-10-09 6:12 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2023-10-09 6:12 UTC (permalink / raw)
To: Maxime Coquelin, Alexandre Torgue, Amelie Delaunay
Cc: stable, dmaengine, linux-stm32, linux-arm-kernel, linux-kernel
On Wed, 04 Oct 2023 17:50:23 +0200, Amelie Delaunay wrote:
> Current Target (CT) have to be reset when starting an MDMA chaining use
> case, as Double Buffer mode is activated. It ensures the DMA will start
> processing the first memory target (pointed with SxM0AR).
>
>
Applied, thanks!
[1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining
commit: 2df467e908ce463cff1431ca1b00f650f7a514b4
[2/2] dmaengine: stm32-dma: fix residue in case of MDMA chaining
commit: 67e13e89742c3b21ce177f612bf9ef32caae6047
Best regards,
--
~Vinod
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-09 6:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-04 15:50 [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg in case of MDMA chaining Amelie Delaunay
2023-10-04 15:50 ` [PATCH 2/2] dmaengine: stm32-dma: fix residue " Amelie Delaunay
2023-10-09 6:12 ` [PATCH 1/2] dmaengine: stm32-dma: fix stm32_dma_prep_slave_sg " Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).