Skip to content

Commit 5849704

Browse files
ADESTMvinodkoul
authored andcommitted
dmaengine: stm32-mdma: set in_flight_bytes in case CRQA flag is set
CRQA flag is set by hardware when the channel request become active and the channel is enabled. It is cleared by hardware, when the channel request is completed. So when it is set, it means MDMA is transferring bytes. This information is useful in case of STM32 DMA and MDMA chaining, especially when the user pauses DMA before stopping it, to trig one last MDMA transfer to get the latest bytes of the SRAM buffer to the destination buffer. STM32 DCMI driver can then use this to know if the last MDMA transfer in case of chaining is done. Fixes: 6968743 ("dmaengine: stm32-mdma: add support to be triggered by STM32 DMA") Signed-off-by: Amelie Delaunay <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a4b306e commit 5849704

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

drivers/dma/stm32-mdma.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1318,7 +1318,8 @@ static int stm32_mdma_slave_config(struct dma_chan *c,
13181318

13191319
static size_t stm32_mdma_desc_residue(struct stm32_mdma_chan *chan,
13201320
struct stm32_mdma_desc *desc,
1321-
u32 curr_hwdesc)
1321+
u32 curr_hwdesc,
1322+
struct dma_tx_state *state)
13221323
{
13231324
struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
13241325
struct stm32_mdma_hwdesc *hwdesc;
@@ -1342,6 +1343,10 @@ static size_t stm32_mdma_desc_residue(struct stm32_mdma_chan *chan,
13421343
cbndtr = stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id));
13431344
residue += cbndtr & STM32_MDMA_CBNDTR_BNDT_MASK;
13441345

1346+
state->in_flight_bytes = 0;
1347+
if (chan->chan_config.m2m_hw && (cisr & STM32_MDMA_CISR_CRQA))
1348+
state->in_flight_bytes = cbndtr & STM32_MDMA_CBNDTR_BNDT_MASK;
1349+
13451350
if (!chan->mem_burst)
13461351
return residue;
13471352

@@ -1371,11 +1376,10 @@ static enum dma_status stm32_mdma_tx_status(struct dma_chan *c,
13711376

13721377
vdesc = vchan_find_desc(&chan->vchan, cookie);
13731378
if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
1374-
residue = stm32_mdma_desc_residue(chan, chan->desc,
1375-
chan->curr_hwdesc);
1379+
residue = stm32_mdma_desc_residue(chan, chan->desc, chan->curr_hwdesc, state);
13761380
else if (vdesc)
1377-
residue = stm32_mdma_desc_residue(chan,
1378-
to_stm32_mdma_desc(vdesc), 0);
1381+
residue = stm32_mdma_desc_residue(chan, to_stm32_mdma_desc(vdesc), 0, state);
1382+
13791383
dma_set_residue(state, residue);
13801384

13811385
spin_unlock_irqrestore(&chan->vchan.lock, flags);

0 commit comments

Comments
 (0)