From: Lukasz Czerwinski <l.czerwinski@samsung.com>
To: djbw@fb.com, linux-kernel@vger.kernel.org
Cc: s.nawrocki@samsung.com, m.szyprowski@samsung.com
Subject: [RFC PATCH] dma: pl330: Change pl330_tx_status()
Date: Mon, 09 Dec 2013 12:19:26 +0100 [thread overview]
Message-ID: <1386587966-27635-1-git-send-email-l.czerwinski@samsung.com> (raw)
This patch adds possibility to read status of unfinished transfers
before termination.
Signed-off-by: Lukasz Czerwinski <l.czerwinski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
I tested patch with Exynos4 board. This is only proof of concept.
Any comments are welcome.
Thanks
Lukasz
drivers/dma/pl330.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 60 insertions(+), 1 deletion(-)
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 24f8ae3..c88c36e 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -566,6 +566,7 @@ struct dma_pl330_chan {
/* For D-to-M and M-to-D channels */
int burst_sz; /* the peripheral fifo width */
int burst_len; /* the number of burst */
+ int transfered;
dma_addr_t fifo_addr;
/* for cyclic capability */
@@ -602,6 +603,9 @@ struct dma_pl330_desc {
enum desc_status status;
+ int bytes_requested;
+ int direction;
+
/* The channel which currently holds this desc */
struct dma_pl330_chan *pchan;
};
@@ -2366,6 +2370,29 @@ static int pl330_alloc_chan_resources(struct dma_chan *chan)
return 1;
}
+int pl330_get_current_xferred_count(struct dma_pl330_chan *pch,
+ struct dma_pl330_desc *desc)
+{
+ u32 val, addr;
+ struct pl330_thread *thrd = pch->pl330_chid;
+ void __iomem *regs = thrd->dmac->pinfo->base;
+
+ val = addr = 0;
+ switch (desc->direction) {
+ case DMA_MEM_TO_DEV:
+ val = readl(regs + SA(thrd->id));
+ addr = desc->px.src_addr;
+ break;
+ case DMA_DEV_TO_MEM:
+ val = readl(regs + DA(thrd->id));
+ addr = desc->px.dst_addr;
+ break;
+ default:
+ break;
+ }
+ return val - addr;
+}
+
static int pl330_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, unsigned long arg)
{
struct dma_pl330_chan *pch = to_pchan(chan);
@@ -2446,7 +2473,33 @@ static enum dma_status
pl330_tx_status(struct dma_chan *chan, dma_cookie_t cookie,
struct dma_tx_state *txstate)
{
- return dma_cookie_status(chan, cookie, txstate);
+ enum dma_status ret;
+ unsigned long flags;
+ struct dma_pl330_desc *desc;
+ struct dma_pl330_chan *pch = to_pchan(chan);
+ unsigned int bytes_transferred;
+ unsigned int residual;
+
+ /* Check in pending list */
+ spin_lock_irqsave(&pch->lock, flags);
+ list_for_each_entry(desc, &pch->work_list, node) {
+ if (desc->txd.cookie == cookie) {
+ bytes_transferred =
+ pl330_get_current_xferred_count(pch, desc);
+ residual = desc->bytes_requested -
+ bytes_transferred % desc->bytes_requested;
+ dma_set_residue(txstate, residual);
+ ret = desc->status;
+ spin_unlock_irqrestore(&pch->lock, flags);
+ return ret;
+ }
+ }
+ spin_unlock_irqrestore(&pch->lock, flags);
+
+ ret = dma_cookie_status(chan, cookie, txstate);
+ dma_set_residue(txstate, pch->transfered);
+
+ return ret;
}
static void pl330_issue_pending(struct dma_chan *chan)
@@ -2717,9 +2770,12 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic(
break;
}
+ desc->direction = direction;
desc->rqcfg.brst_size = pch->burst_sz;
desc->rqcfg.brst_len = 1;
+ desc->bytes_requested = period_len;
fill_px(&desc->px, dst, src, period_len);
+ pch->transfered = 0;
if (!first)
first = desc;
@@ -2853,8 +2909,11 @@ pl330_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
sg_dma_address(sg), addr, sg_dma_len(sg));
}
+ desc->direction = direction;
desc->rqcfg.brst_size = pch->burst_sz;
desc->rqcfg.brst_len = 1;
+ desc->bytes_requested = sg_dma_len(sg);
+ pch->transfered = 0;
}
/* Return the last desc in the chain */
--
1.7.9.5
next reply other threads:[~2013-12-09 11:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-09 11:19 Lukasz Czerwinski [this message]
2013-12-09 12:00 ` Lars-Peter Clausen
2013-12-13 15:33 ` Lukasz Czerwinski
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=1386587966-27635-1-git-send-email-l.czerwinski@samsung.com \
--to=l.czerwinski@samsung.com \
--cc=djbw@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=s.nawrocki@samsung.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
all inboxes | Powered by JetHome®