Skip to content

Commit ded6230

Browse files
ADESTMvinodkoul
authored andcommitted
dmaengine: stm32-dma: pass DMA_SxSCR value to stm32_dma_handle_chan_done()
stm32_dma_handle_chan_done() is called on Transfer Complete interrupt. As DMA_SxSCR register is read in interrupt handler, pass the value as parameter of stm32_dma_handle_chan_done(). Also return directly if chan->desc is null to remove one ident level. Then, stm32_dma_configure_next_sg() is doing something only if Double-Buffer Mode (DBM) is enabled, so, check it is enabled prior calling stm32_dma_configure_next_sg(), to remove one ident level in stm32_dma_configure_next_sg(). Signed-off-by: Amelie Delaunay <amelie.delaunay@foss.st.com> Link: https://lore.kernel.org/r/20220505115611.38845-3-amelie.delaunay@foss.st.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent db60a63 commit ded6230

1 file changed

Lines changed: 27 additions & 27 deletions

File tree

drivers/dma/stm32-dma.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -612,38 +612,38 @@ static void stm32_dma_configure_next_sg(struct stm32_dma_chan *chan)
612612
id = chan->id;
613613
dma_scr = stm32_dma_read(dmadev, STM32_DMA_SCR(id));
614614

615-
if (dma_scr & STM32_DMA_SCR_DBM) {
616-
sg_req = &chan->desc->sg_req[chan->next_sg];
617-
618-
if (dma_scr & STM32_DMA_SCR_CT) {
619-
dma_sm0ar = sg_req->chan_reg.dma_sm0ar;
620-
stm32_dma_write(dmadev, STM32_DMA_SM0AR(id), dma_sm0ar);
621-
dev_dbg(chan2dev(chan), "CT=1 <=> SM0AR: 0x%08x\n",
622-
stm32_dma_read(dmadev, STM32_DMA_SM0AR(id)));
623-
} else {
624-
dma_sm1ar = sg_req->chan_reg.dma_sm1ar;
625-
stm32_dma_write(dmadev, STM32_DMA_SM1AR(id), dma_sm1ar);
626-
dev_dbg(chan2dev(chan), "CT=0 <=> SM1AR: 0x%08x\n",
627-
stm32_dma_read(dmadev, STM32_DMA_SM1AR(id)));
628-
}
615+
sg_req = &chan->desc->sg_req[chan->next_sg];
616+
617+
if (dma_scr & STM32_DMA_SCR_CT) {
618+
dma_sm0ar = sg_req->chan_reg.dma_sm0ar;
619+
stm32_dma_write(dmadev, STM32_DMA_SM0AR(id), dma_sm0ar);
620+
dev_dbg(chan2dev(chan), "CT=1 <=> SM0AR: 0x%08x\n",
621+
stm32_dma_read(dmadev, STM32_DMA_SM0AR(id)));
622+
} else {
623+
dma_sm1ar = sg_req->chan_reg.dma_sm1ar;
624+
stm32_dma_write(dmadev, STM32_DMA_SM1AR(id), dma_sm1ar);
625+
dev_dbg(chan2dev(chan), "CT=0 <=> SM1AR: 0x%08x\n",
626+
stm32_dma_read(dmadev, STM32_DMA_SM1AR(id)));
629627
}
630628
}
631629

632-
static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan)
630+
static void stm32_dma_handle_chan_done(struct stm32_dma_chan *chan, u32 scr)
633631
{
634-
if (chan->desc) {
635-
if (chan->desc->cyclic) {
636-
vchan_cyclic_callback(&chan->desc->vdesc);
637-
stm32_dma_sg_inc(chan);
632+
if (!chan->desc)
633+
return;
634+
635+
if (chan->desc->cyclic) {
636+
vchan_cyclic_callback(&chan->desc->vdesc);
637+
stm32_dma_sg_inc(chan);
638+
if (scr & STM32_DMA_SCR_DBM)
638639
stm32_dma_configure_next_sg(chan);
639-
} else {
640-
chan->busy = false;
641-
if (chan->next_sg == chan->desc->num_sgs) {
642-
vchan_cookie_complete(&chan->desc->vdesc);
643-
chan->desc = NULL;
644-
}
645-
stm32_dma_start_transfer(chan);
640+
} else {
641+
chan->busy = false;
642+
if (chan->next_sg == chan->desc->num_sgs) {
643+
vchan_cookie_complete(&chan->desc->vdesc);
644+
chan->desc = NULL;
646645
}
646+
stm32_dma_start_transfer(chan);
647647
}
648648
}
649649

@@ -680,7 +680,7 @@ static irqreturn_t stm32_dma_chan_irq(int irq, void *devid)
680680
if (status & STM32_DMA_TCI) {
681681
stm32_dma_irq_clear(chan, STM32_DMA_TCI);
682682
if (scr & STM32_DMA_SCR_TCIE)
683-
stm32_dma_handle_chan_done(chan);
683+
stm32_dma_handle_chan_done(chan, scr);
684684
status &= ~STM32_DMA_TCI;
685685
}
686686

0 commit comments

Comments
 (0)