2023-05-21 12:31:08

by Jisheng Zhang

[permalink] [raw]
Subject: [PATCH v3 11/11] dmaengine: dw-axi-dmac: support polled mode

Run in polled mode if the DMA_PREP_INTERRUPT flag is not provided.

Signed-off-by: Jisheng Zhang <[email protected]>
---
drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c | 11 ++++++++++-
drivers/dma/dw-axi-dmac/dw-axi-dmac.h | 1 +
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 091c15c2ec31..37ab9a03d94b 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -390,7 +390,10 @@ static void axi_chan_block_xfer_start(struct axi_dma_chan *chan,
write_chan_llp(chan, first->hw_desc[0].llp | lms);

irq_mask = DWAXIDMAC_IRQ_DMA_TRF | DWAXIDMAC_IRQ_ALL_ERR;
- axi_chan_irq_sig_set(chan, irq_mask);
+ if (chan->polled)
+ axi_chan_irq_sig_set(chan, DWAXIDMAC_IRQ_NONE);
+ else
+ axi_chan_irq_sig_set(chan, irq_mask);

/* Generate 'suspend' status but don't generate interrupt */
irq_mask |= DWAXIDMAC_IRQ_SUSPENDED;
@@ -721,6 +724,7 @@ dw_axi_dma_chan_prep_cyclic(struct dma_chan *dchan, dma_addr_t dma_addr,
if (unlikely(!desc))
goto err_desc_get;

+ chan->polled = !(flags & DMA_PREP_INTERRUPT);
chan->direction = direction;
desc->chan = chan;
chan->cyclic = true;
@@ -803,6 +807,7 @@ dw_axi_dma_chan_prep_slave_sg(struct dma_chan *dchan, struct scatterlist *sgl,

desc->chan = chan;
desc->length = 0;
+ chan->polled = !(flags & DMA_PREP_INTERRUPT);
chan->direction = direction;

for_each_sg(sgl, sg, sg_len, i) {
@@ -866,6 +871,7 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr,
if (unlikely(!desc))
goto err_desc_get;

+ chan->polled = !(flags & DMA_PREP_INTERRUPT);
desc->chan = chan;
num = 0;
desc->length = 0;
@@ -1146,6 +1152,9 @@ dma_chan_tx_status(struct dma_chan *dchan, dma_cookie_t cookie,
u32 length;
u32 len;

+ if (chan->polled)
+ dw_axi_dma_handle_ch(chan);
+
status = dma_cookie_status(dchan, cookie, txstate);
if (status == DMA_COMPLETE || !txstate)
return status;
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
index 1f9772e9be30..33ae4280dacc 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac.h
@@ -55,6 +55,7 @@ struct axi_dma_chan {
bool cyclic;
/* these other elements are all protected by vc.lock */
bool is_paused;
+ bool polled;
};

struct dw_axi_dma {
--
2.40.0