linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: fabio.baltieri@linaro.org (Fabio Baltieri)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 10/16] dmaengine: ste_dma40: add a done queue for completed descriptors
Date: Mon,  7 Jan 2013 12:21:52 +0100	[thread overview]
Message-ID: <1357557718-15676-11-git-send-email-fabio.baltieri@linaro.org> (raw)
In-Reply-To: <1357557718-15676-1-git-send-email-fabio.baltieri@linaro.org>

This is to keep the active queue for only those transfers which are
actually active in the hardware.  Descriptors will be moved to the done
queue after they are completed in the hardware (interrupt handler) but
before all the cleanup work has been completed (tasklet).

Mostly based on a previous patch by Rabin Vincent.

Cc: Rabin Vincent <rabin.vincent@stericsson.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Fabio Baltieri <fabio.baltieri@linaro.org>
---
 drivers/dma/ste_dma40.c | 37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 67e565b..ff21dcb 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -382,6 +382,7 @@ struct d40_base;
  * @client: Cliented owned descriptor list.
  * @pending_queue: Submitted jobs, to be issued by issue_pending()
  * @active: Active descriptor.
+ * @done: Completed jobs
  * @queue: Queued jobs.
  * @prepare_queue: Prepared jobs.
  * @dma_cfg: The client configuration of this dma channel.
@@ -407,6 +408,7 @@ struct d40_chan {
 	struct list_head		 client;
 	struct list_head		 pending_queue;
 	struct list_head		 active;
+	struct list_head		 done;
 	struct list_head		 queue;
 	struct list_head		 prepare_queue;
 	struct stedma40_chan_cfg	 dma_cfg;
@@ -754,6 +756,11 @@ static void d40_phy_lli_load(struct d40_chan *chan, struct d40_desc *desc)
 	writel(lli_dst->reg_lnk, base + D40_CHAN_REG_SDLNK);
 }
 
+static void d40_desc_done(struct d40_chan *d40c, struct d40_desc *desc)
+{
+	list_add_tail(&desc->node, &d40c->done);
+}
+
 static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
 {
 	struct d40_lcla_pool *pool = &chan->base->lcla_pool;
@@ -914,6 +921,14 @@ static struct d40_desc *d40_first_queued(struct d40_chan *d40c)
 	return d;
 }
 
+static struct d40_desc *d40_first_done(struct d40_chan *d40c)
+{
+	if (list_empty(&d40c->done))
+		return NULL;
+
+	return list_first_entry(&d40c->done, struct d40_desc, node);
+}
+
 static int d40_psize_2_burst_size(bool is_log, int psize)
 {
 	if (is_log) {
@@ -1104,6 +1119,12 @@ static void d40_term_all(struct d40_chan *d40c)
 	struct d40_desc *d40d;
 	struct d40_desc *_d;
 
+	/* Release completed descriptors */
+	while ((d40d = d40_first_done(d40c))) {
+		d40_desc_remove(d40d);
+		d40_desc_free(d40c, d40d);
+	}
+
 	/* Release active descriptors */
 	while ((d40d = d40_first_active_get(d40c))) {
 		d40_desc_remove(d40d);
@@ -1541,6 +1562,9 @@ static void dma_tc_handle(struct d40_chan *d40c)
 		pm_runtime_put_autosuspend(d40c->base->dev);
 	}
 
+	d40_desc_remove(d40d);
+	d40_desc_done(d40c, d40d);
+
 	d40c->pending_tx++;
 	tasklet_schedule(&d40c->tasklet);
 
@@ -1556,10 +1580,14 @@ static void dma_tasklet(unsigned long data)
 
 	spin_lock_irqsave(&d40c->lock, flags);
 
-	/* Get first active entry from list */
-	d40d = d40_first_active_get(d40c);
-	if (d40d == NULL)
-		goto err;
+	/* Get first entry from the done list */
+	d40d = d40_first_done(d40c);
+	if (d40d == NULL) {
+		/* Check if we have reached here for cyclic job */
+		d40d = d40_first_active_get(d40c);
+		if (d40d == NULL || !d40d->cyclic)
+			goto err;
+	}
 
 	if (!d40d->cyclic)
 		dma_cookie_complete(&d40d->txd);
@@ -2823,6 +2851,7 @@ static void __init d40_chan_init(struct d40_base *base, struct dma_device *dma,
 
 		d40c->log_num = D40_PHY_CHAN;
 
+		INIT_LIST_HEAD(&d40c->done);
 		INIT_LIST_HEAD(&d40c->active);
 		INIT_LIST_HEAD(&d40c->queue);
 		INIT_LIST_HEAD(&d40c->pending_queue);
-- 
1.7.12.1

  parent reply	other threads:[~2013-01-07 11:21 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-07 11:21 [PATCH v2 00/16] various fixes and updates for ste_dma40 Fabio Baltieri
2013-01-07 11:21 ` [PATCH 01/16] dmaengine: ste_dma40: reset priority bit for logical channels Fabio Baltieri
2013-01-07 11:21 ` [PATCH 02/16] dmaengine: ste_dma40: use writel_relaxed for lcxa Fabio Baltieri
2013-01-07 11:21 ` [PATCH 03/16] dmaengine: ste_dma40: set dma max seg size Fabio Baltieri
2013-01-07 11:21 ` [PATCH 04/16] dmaengine: ste_dma40: limit burst size to 16 Fabio Baltieri
2013-01-07 11:21 ` [PATCH 05/16] dmaengine: ste_dma40: don't check for pm_runtime_suspended() Fabio Baltieri
2013-01-07 11:21 ` [PATCH 06/16] dmaengine: ste_dma40: don't allow high priority dest event lines Fabio Baltieri
2013-01-07 11:21 ` [PATCH 07/16] dmaengine: ste_dma40: support fixed physical channel allocation Fabio Baltieri
2013-01-07 11:21 ` [PATCH 08/16] dmaengine: ste_dma40: physical channels number correction Fabio Baltieri
2013-01-07 11:21 ` [PATCH 09/16] dmaengine: ste_dma40: support more than 128 event lines Fabio Baltieri
2013-01-07 11:21 ` Fabio Baltieri [this message]
2013-01-07 11:21 ` [PATCH 11/16] dmaengine: ste_dma40: add missing kernel-doc entry Fabio Baltieri
2013-01-07 11:21 ` [PATCH 12/16] dmaengine: ste_dma40: minor cosmetic fixes Fabio Baltieri
2013-01-07 11:21 ` [PATCH 13/16] dmaengine: ste_dma40: minor code readability fixes Fabio Baltieri
2013-01-07 11:21 ` [PATCH 14/16] dmaengine: ste_dma40: add software lli support Fabio Baltieri
2013-01-07 11:21 ` [PATCH 15/16] dmaengine: set_dma40: ignore spurious interrupts Fabio Baltieri
2013-01-07 11:21 ` [PATCH 16/16] dmaengine: set_dma40: balance clock in probe fail code Fabio Baltieri
2013-01-07 14:33 ` [PATCH v2 00/16] various fixes and updates for ste_dma40 Vinod Koul
2013-01-07 16:59   ` Fabio Baltieri

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=1357557718-15676-11-git-send-email-fabio.baltieri@linaro.org \
    --to=fabio.baltieri@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).