DMAEngine: sirf: add DMA pause/resume support
PATCH 1/1 DMAEngine: sirf: add DMA pause/resume support
From: Barry Song <[email protected]>
pause/resume are important for users like sound drivers, this patches make the sirf prima2/marco support
--- drivers/dma/sirf-dma.c | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
drivers/dma/sirf-dma.c +36 -0
@@ -313,6 +313,38 @@ static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan)return 0 ; } +static int sirfsoc_dma_pause_chan (struct sirfsoc_dma_chan *schan) +{ +struct sirfsoc_dma *sdma =dma_chan_to_sirfsoc_dma (&schan->chan); +int cid = schan->chan.chan_id; + +if (!sdma->is_marco) +writel_relaxed (readl_relaxed (sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ) + & ~((1 << cid) |1 << (cid +16 )), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ); +else +writel_relaxed ((1 << cid) |1 << (cid +16 ), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL_CLR ); + +return 0 ; +} + +static int sirfsoc_dma_resume_chan (struct sirfsoc_dma_chan *schan) +{ +struct sirfsoc_dma *sdma =dma_chan_to_sirfsoc_dma (&schan->chan); +int cid = schan->chan.chan_id; + +if (!sdma->is_marco) +writel_relaxed (readl_relaxed (sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ) + | ((1 << cid) |1 << (cid +16 )), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ); +else +writel_relaxed ((1 << cid) |1 << (cid +16 ), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ); + +return 0 ; +} +static int sirfsoc_dma_control (struct dma_chan *chan,enum dma_ctrl_cmd cmd,unsigned long arg) {
@@ -320,6 +352,10 @@ static int sirfsoc_dma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,struct sirfsoc_dma_chan *schan =dma_chan_to_sirfsoc_dma_chan (chan);switch (cmd) { +case DMA_PAUSE : +return sirfsoc_dma_pause_chan (schan); +case DMA_RESUME : +return sirfsoc_dma_resume_chan (schan);case DMA_TERMINATE_ALL :return sirfsoc_dma_terminate_all (schan);case DMA_SLAVE_CONFIG :
Signature · 6 lines
1.7.5.4 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
PATCH 1/1 DMAEngine: sirf: add DMA pause/resume support
Quoted 10 lines · Barry Song
drivers/dma/sirf-dma.c +2
-0@@ -313,6 +313,38 @@ static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan)return 0 ; } +static int sirfsoc_dma_pause_chan (struct sirfsoc_dma_chan *schan) +{
drivers/dma/sirf-dma.c static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan) · line 327
Quoted 10 lines
drivers/dma/sirf-dma.c +10
-0+struct sirfsoc_dma *sdma =dma_chan_to_sirfsoc_dma (&schan->chan); +int cid = schan->chan.chan_id; + +if (!sdma->is_marco) +writel_relaxed (readl_relaxed (sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ) + & ~((1 << cid) |1 << (cid +16 )), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ); +else +writel_relaxed ((1 << cid) |1 << (cid +16 ), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL_CLR );
You're doing a read-modify-write to what looks like a shared register. What makes this code safe in a preempt or SMP environment?
PATCH 1/1 DMAEngine: sirf: add DMA pause/resume support
2012/12/14, Russell King - ARM Linux <[email protected]>:
Quoted 10 lines · Barry Song
Quoted 9 lines
drivers/dma/sirf-dma.c +0
-0@@ -313,6 +313,38 @@ static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan)return 0 ; }
Quoted 15 lines
drivers/dma/sirf-dma.c static int sirfsoc_dma_terminate_all(struct sirfsoc_dma_chan *schan) · line 327
Quoted 12 lines
drivers/dma/sirf-dma.c +12
-0+static int sirfsoc_dma_pause_chan (struct sirfsoc_dma_chan *schan) +{ +struct sirfsoc_dma *sdma =dma_chan_to_sirfsoc_dma (&schan->chan); +int cid = schan->chan.chan_id; + +if (!sdma->is_marco) +writel_relaxed (readl_relaxed (sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ) + & ~((1 << cid) |1 << (cid +16 )), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL ); +else +writel_relaxed ((1 << cid) |1 << (cid +16 ), + sdma->base +SIRFSOC_DMA_CH_LOOP_CTRL_CLR );You're doing a read-modify-write to what looks like a shared register. What makes this code safe in a preempt or SMP environment?
the new registers of SiRFmarco split into SET and CLR instead of old read-modify-write. anyway, here i missed holding a spinlock for SiRFprimaII.
-barry