From: Linus Walleij <linus.walleij@linaro.org>
To: linux-kernel@vger.kernel.org, Vinod Koul <vinod.koul@intel.com>,
Dan Williams <dan.j.williams@intel.com>
Cc: shiraz.hashim@st.com, amit.goel@st.com,
Linus Walleij <linus.walleij@linaro.org>,
armando.visconti@st.com, viresh.linux@gmail.com,
linux-serial@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: [PATCH] dmaengine: implement pause and resume for dw_dmac
Date: Tue, 19 Apr 2011 02:31:32 +0200 [thread overview]
Message-ID: <1303173092-21785-1-git-send-email-linus.walleij@linaro.org> (raw)
It seems that the SPEAr needs this.
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/dma/dw_dmac.c | 22 ++++++++++++++++++++--
drivers/dma/dw_dmac_regs.h | 1 +
2 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/dw_dmac.c b/drivers/dma/dw_dmac.c
index 9c25c7d..60ac779 100644
--- a/drivers/dma/dw_dmac.c
+++ b/drivers/dma/dw_dmac.c
@@ -801,8 +801,7 @@ static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
struct dw_desc *desc, *_desc;
LIST_HEAD(list);
- /* Only supports DMA_TERMINATE_ALL */
- if (cmd != DMA_TERMINATE_ALL)
+ if (cmd != DMA_TERMINATE_ALL && cmd != DMA_PAUSE && cmd != DMA_RESUME)
return -ENXIO;
/*
@@ -813,11 +812,30 @@ static int dwc_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd,
*/
spin_lock_bh(&dwc->lock);
+ if (cmd == DMA_RESUME) {
+ if (dwc->paused) {
+ channel_set_bit(dw, CH_EN, dwc->mask);
+ while (!dma_readl(dw, CH_EN) & dwc->mask)
+ cpu_relax();
+ }
+ spin_unlock_bh(&dwc->lock);
+ return 0;
+ }
+
channel_clear_bit(dw, CH_EN, dwc->mask);
while (dma_readl(dw, CH_EN) & dwc->mask)
cpu_relax();
+ if (cmd == DMA_PAUSE) {
+ dwc->paused = true;
+ spin_unlock_bh(&dwc->lock);
+ return 0;
+ }
+
+ /* Terminating a paused transfer */
+ dwc->paused = false;
+
/* active_list entries will end up before queued entries */
list_splice_init(&dwc->queue, &list);
list_splice_init(&dwc->active_list, &list);
diff --git a/drivers/dma/dw_dmac_regs.h b/drivers/dma/dw_dmac_regs.h
index 720f821..c968597 100644
--- a/drivers/dma/dw_dmac_regs.h
+++ b/drivers/dma/dw_dmac_regs.h
@@ -138,6 +138,7 @@ struct dw_dma_chan {
void __iomem *ch_regs;
u8 mask;
u8 priority;
+ bool paused;
spinlock_t lock;
--
1.7.4
next reply other threads:[~2011-04-19 0:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-19 0:31 Linus Walleij [this message]
2011-04-19 5:29 ` [PATCH] dmaengine: implement pause and resume for dw_dmac viresh kumar
2011-04-19 6:04 ` viresh kumar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1303173092-21785-1-git-send-email-linus.walleij@linaro.org \
--to=linus.walleij@linaro.org \
--cc=amit.goel@st.com \
--cc=armando.visconti@st.com \
--cc=dan.j.williams@intel.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=shiraz.hashim@st.com \
--cc=vinod.koul@intel.com \
--cc=viresh.linux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).