mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
dmaengine: stm32-mdma: set in_flight_bytes in case CRQA flag is set
commit5849704217upstream. 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:6968743227("dmaengine: stm32-mdma: add support to be triggered by STM32 DMA") Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20231004163531.2864160-3-amelie.delaunay@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
721dbbabf1
commit
f049b10aff
@@ -1319,7 +1319,8 @@ static int stm32_mdma_slave_config(struct dma_chan *c,
|
|||||||
|
|
||||||
static size_t stm32_mdma_desc_residue(struct stm32_mdma_chan *chan,
|
static size_t stm32_mdma_desc_residue(struct stm32_mdma_chan *chan,
|
||||||
struct stm32_mdma_desc *desc,
|
struct stm32_mdma_desc *desc,
|
||||||
u32 curr_hwdesc)
|
u32 curr_hwdesc,
|
||||||
|
struct dma_tx_state *state)
|
||||||
{
|
{
|
||||||
struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
|
struct stm32_mdma_device *dmadev = stm32_mdma_get_dev(chan);
|
||||||
struct stm32_mdma_hwdesc *hwdesc;
|
struct stm32_mdma_hwdesc *hwdesc;
|
||||||
@@ -1343,6 +1344,10 @@ static size_t stm32_mdma_desc_residue(struct stm32_mdma_chan *chan,
|
|||||||
cbndtr = stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id));
|
cbndtr = stm32_mdma_read(dmadev, STM32_MDMA_CBNDTR(chan->id));
|
||||||
residue += cbndtr & STM32_MDMA_CBNDTR_BNDT_MASK;
|
residue += cbndtr & STM32_MDMA_CBNDTR_BNDT_MASK;
|
||||||
|
|
||||||
|
state->in_flight_bytes = 0;
|
||||||
|
if (chan->chan_config.m2m_hw && (cisr & STM32_MDMA_CISR_CRQA))
|
||||||
|
state->in_flight_bytes = cbndtr & STM32_MDMA_CBNDTR_BNDT_MASK;
|
||||||
|
|
||||||
if (!chan->mem_burst)
|
if (!chan->mem_burst)
|
||||||
return residue;
|
return residue;
|
||||||
|
|
||||||
@@ -1372,11 +1377,10 @@ static enum dma_status stm32_mdma_tx_status(struct dma_chan *c,
|
|||||||
|
|
||||||
vdesc = vchan_find_desc(&chan->vchan, cookie);
|
vdesc = vchan_find_desc(&chan->vchan, cookie);
|
||||||
if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
|
if (chan->desc && cookie == chan->desc->vdesc.tx.cookie)
|
||||||
residue = stm32_mdma_desc_residue(chan, chan->desc,
|
residue = stm32_mdma_desc_residue(chan, chan->desc, chan->curr_hwdesc, state);
|
||||||
chan->curr_hwdesc);
|
|
||||||
else if (vdesc)
|
else if (vdesc)
|
||||||
residue = stm32_mdma_desc_residue(chan,
|
residue = stm32_mdma_desc_residue(chan, to_stm32_mdma_desc(vdesc), 0, state);
|
||||||
to_stm32_mdma_desc(vdesc), 0);
|
|
||||||
dma_set_residue(state, residue);
|
dma_set_residue(state, residue);
|
||||||
|
|
||||||
spin_unlock_irqrestore(&chan->vchan.lock, flags);
|
spin_unlock_irqrestore(&chan->vchan.lock, flags);
|
||||||
|
|||||||
Reference in New Issue
Block a user