All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@stericsson.com>
To: Dan Williams <dan.j.williams@intel.com>
Cc: <linux-kernel@vger.kernel.org>, Lee Jones <lee.jones@linaro.org>,
	Rabin Vincent <rabin.vincent@stericsson.com>,
	Linus Walleij <linus.walleij@stericsson.com>
Subject: [PATCH 02/32] dma40: ensure event lines get enabled
Date: Tue, 25 Jan 2011 11:18:05 +0100	[thread overview]
Message-ID: <1295950715-22340-3-git-send-email-linus.walleij@stericsson.com> (raw)
In-Reply-To: <1295950715-22340-1-git-send-email-linus.walleij@stericsson.com>

From: Rabin Vincent <rabin.vincent@stericsson.com>

The controller sometimes fails to register the enable of the event line when
both src and dst event lines are used on the same logical channel.  Implement
the recommended software workaround, which is to retry the write until it
works.

Acked-by: Per Forlin <per.forlin@stericsson.com>
Acked-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com>
Signed-off-by: Linus Walleij <linus.walleij@stericsson.com>
---
 drivers/dma/ste_dma40.c |   63 ++++++++++++++++++++++++++++++++++------------
 1 files changed, 46 insertions(+), 17 deletions(-)

diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 52013ed..42c88fc 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -303,6 +303,11 @@ struct d40_reg_val {
 	unsigned int val;
 };
 
+static struct device *chan2dev(struct d40_chan *d40c)
+{
+	return &d40c->chan.dev->device;
+}
+
 static int d40_pool_lli_alloc(struct d40_desc *d40d,
 			      int lli_len, bool is_log)
 {
@@ -701,17 +706,46 @@ static void d40_term_all(struct d40_chan *d40c)
 	d40c->busy = false;
 }
 
+static void __d40_config_set_event(struct d40_chan *d40c, bool enable,
+				   u32 event, int reg)
+{
+	void __iomem *addr = d40c->base->virtbase + D40_DREG_PCBASE
+			     + d40c->phy_chan->num * D40_DREG_PCDELTA + reg;
+	int tries;
+
+	if (!enable) {
+		writel((D40_DEACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event))
+		       | ~D40_EVENTLINE_MASK(event), addr);
+		return;
+	}
+
+	/*
+	 * The hardware sometimes doesn't register the enable when src and dst
+	 * event lines are active on the same logical channel.  Retry to ensure
+	 * it does.  Usually only one retry is sufficient.
+	 */
+	tries = 100;
+	while (--tries) {
+		writel((D40_ACTIVATE_EVENTLINE << D40_EVENTLINE_POS(event))
+		       | ~D40_EVENTLINE_MASK(event), addr);
+
+		if (readl(addr) & D40_EVENTLINE_MASK(event))
+			break;
+	}
+
+	if (tries != 99)
+		dev_dbg(chan2dev(d40c),
+			"[%s] workaround enable S%cLNK (%d tries)\n",
+			__func__, reg == D40_CHAN_REG_SSLNK ? 'S' : 'D',
+			100 - tries);
+
+	WARN_ON(!tries);
+}
+
 static void d40_config_set_event(struct d40_chan *d40c, bool do_enable)
 {
-	u32 val;
 	unsigned long flags;
 
-	/* Notice, that disable requires the physical channel to be stopped */
-	if (do_enable)
-		val = D40_ACTIVATE_EVENTLINE;
-	else
-		val = D40_DEACTIVATE_EVENTLINE;
-
 	spin_lock_irqsave(&d40c->phy_chan->lock, flags);
 
 	/* Enable event line connected to device (or memcpy) */
@@ -719,20 +753,15 @@ static void d40_config_set_event(struct d40_chan *d40c, bool do_enable)
 	    (d40c->dma_cfg.dir == STEDMA40_PERIPH_TO_PERIPH)) {
 		u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.src_dev_type);
 
-		writel((val << D40_EVENTLINE_POS(event)) |
-		       ~D40_EVENTLINE_MASK(event),
-		       d40c->base->virtbase + D40_DREG_PCBASE +
-		       d40c->phy_chan->num * D40_DREG_PCDELTA +
-		       D40_CHAN_REG_SSLNK);
+		__d40_config_set_event(d40c, do_enable, event,
+				       D40_CHAN_REG_SSLNK);
 	}
+
 	if (d40c->dma_cfg.dir !=  STEDMA40_PERIPH_TO_MEM) {
 		u32 event = D40_TYPE_TO_EVENT(d40c->dma_cfg.dst_dev_type);
 
-		writel((val << D40_EVENTLINE_POS(event)) |
-		       ~D40_EVENTLINE_MASK(event),
-		       d40c->base->virtbase + D40_DREG_PCBASE +
-		       d40c->phy_chan->num * D40_DREG_PCDELTA +
-		       D40_CHAN_REG_SDLNK);
+		__d40_config_set_event(d40c, do_enable, event,
+				       D40_CHAN_REG_SDLNK);
 	}
 
 	spin_unlock_irqrestore(&d40c->phy_chan->lock, flags);
-- 
1.7.3.2


  parent reply	other threads:[~2011-01-25 10:19 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-25 10:18 DMA40 improvements Linus Walleij
2011-01-25 10:18 ` [PATCH 01/32] dma40: make init function static Linus Walleij
2011-01-25 10:18 ` Linus Walleij [this message]
2011-01-25 10:18 ` [PATCH 03/32] dma40: remove "hardware link with previous jobs" code Linus Walleij
2011-01-25 10:18 ` [PATCH 04/32] dma40: use helper for channel registers base Linus Walleij
2011-01-25 10:18 ` [PATCH 05/32] dma40: use helpers for channel type check Linus Walleij
2011-01-25 10:18 ` [PATCH 06/32] dma40: use helpers for error functions Linus Walleij
2011-01-25 10:18 ` [PATCH 07/32] dma40: fix comment to refer to SOCs rather than boards Linus Walleij
2011-01-25 10:18 ` [PATCH 08/32] dma40: allow realtime and priority for event lines Linus Walleij
2011-01-25 10:18 ` [PATCH 09/32] dma40: remove unnecessary ALIGN()s Linus Walleij
2011-01-25 10:18 ` [PATCH 10/32] dma40: use sg_dma_address() instead of sg_phys() Linus Walleij
2011-01-25 10:18 ` [PATCH 11/32] dma40: fix DMA API usage for LCLA Linus Walleij
2011-01-25 10:18 ` [PATCH 12/32] dma40: fix DMA API usage for LLIs Linus Walleij
2011-01-25 10:18 ` [PATCH 13/32] dma40: remove unnecessary casts Linus Walleij
2011-01-25 10:18 ` [PATCH 14/32] dma40: implement prep_memcpy as a wrapper around memcpy_sg Linus Walleij
2011-01-25 10:18 ` [PATCH 15/32] dma40: combine desc init functions Linus Walleij
2011-01-25 10:18 ` [PATCH 16/32] dma40: combine duplicated d40_pool_lli_alloc() calls Linus Walleij
2011-01-25 10:18 ` [PATCH 17/32] dma40: remove duplicated dev addr code Linus Walleij
2011-01-25 10:18 ` [PATCH 18/32] dma40: combine mem and slave sg-to-lli functions Linus Walleij
2011-01-25 10:18 ` [PATCH 19/32] dma40: remove export of stedma40_memcpy_sg Linus Walleij
2011-01-25 10:18 ` [PATCH 20/32] dma40: combine mem and slave prep_sg functions Linus Walleij
2011-01-25 10:18 ` [PATCH 21/32] dma40: move lli_load to main source file Linus Walleij
2011-01-25 10:18 ` [PATCH 22/32] dma40: combine duplicated code in log_sg_to_dev Linus Walleij
2011-01-25 10:18 ` [PATCH 23/32] dma40: unify d40_log_sg_to_lli funcs for mem and slave Linus Walleij
2011-01-25 10:18 ` [PATCH 24/32] dma40: pass the info pointer all the way to reduce argument count Linus Walleij
2011-01-25 10:18 ` [PATCH 25/32] dma40: unify src/dst addr check Linus Walleij
2011-01-25 10:18 ` [PATCH 26/32] dma40: make d40_log_buf_to_lli static Linus Walleij
2011-01-25 10:18 ` [PATCH 27/32] dma40: use flags to reduce parameter count Linus Walleij
2011-01-25 10:18 ` [PATCH 28/32] dma40: extract lcla code into separate function Linus Walleij
2011-01-25 10:18 ` [PATCH 29/32] dma40: handle failure to allocate first LCLA Linus Walleij
2011-01-25 10:18 ` [PATCH 30/32] dma40: fix DMA_SG capability and channels Linus Walleij
2011-01-25 10:18 ` [PATCH 31/32] dma40: stop ongoing transfers in DMA_TERMINATE_ALL Linus Walleij
2011-01-25 10:18 ` [PATCH 32/32] dma40: cyclic xfer support Linus Walleij
2011-01-31  6:17 ` DMA40 improvements Dan Williams
2011-01-31  6:21   ` Dan Williams
2011-01-31 11:14   ` Linus Walleij

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=1295950715-22340-3-git-send-email-linus.walleij@stericsson.com \
    --to=linus.walleij@stericsson.com \
    --cc=dan.j.williams@intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rabin.vincent@stericsson.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.