netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Mugunthan V N <mugunthanvnm@ti.com>
Cc: netdev@vger.kernel.org, tglx@linutronix.de,
	"David S. Miller" <davem@davemloft.net>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Subject: [PATCH 1/5] net/davinci_cpdma: don't check for jiffies with interrupts
Date: Wed, 17 Apr 2013 23:52:12 +0200	[thread overview]
Message-ID: <1366235536-15744-2-git-send-email-bigeasy@linutronix.de> (raw)
In-Reply-To: <1366235536-15744-1-git-send-email-bigeasy@linutronix.de>

__cpdma_chan_process() holds the lock with interrupts off (and its
caller as well), same goes for cpdma_ctlr_start(). With interrupts off,
jiffies will not make any progress and if the wait condition never gets
true we wait for ever.
Tgis patch adds a a simple udelay and counting down attempt.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/net/ethernet/ti/davinci_cpdma.c |   20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index ee13dc7..3e34187 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -20,6 +20,7 @@
 #include <linux/err.h>
 #include <linux/dma-mapping.h>
 #include <linux/io.h>
+#include <linux/delay.h>
 
 #include "davinci_cpdma.h"
 
@@ -312,14 +313,16 @@ int cpdma_ctlr_start(struct cpdma_ctlr *ctlr)
 	}
 
 	if (ctlr->params.has_soft_reset) {
-		unsigned long timeout = jiffies + HZ/10;
+		unsigned timeout = 10 * 100;
 
 		dma_reg_write(ctlr, CPDMA_SOFTRESET, 1);
-		while (time_before(jiffies, timeout)) {
+		while (timeout) {
 			if (dma_reg_read(ctlr, CPDMA_SOFTRESET) == 0)
 				break;
+			udelay(10);
+			timeout--;
 		}
-		WARN_ON(!time_before(jiffies, timeout));
+		WARN_ON(!timeout);
 	}
 
 	for (i = 0; i < ctlr->num_chan; i++) {
@@ -868,7 +871,7 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
 	struct cpdma_desc_pool	*pool = ctlr->pool;
 	unsigned long		flags;
 	int			ret;
-	unsigned long		timeout;
+	unsigned		timeout;
 
 	spin_lock_irqsave(&chan->lock, flags);
 	if (chan->state != CPDMA_STATE_ACTIVE) {
@@ -883,14 +886,15 @@ int cpdma_chan_stop(struct cpdma_chan *chan)
 	dma_reg_write(ctlr, chan->td, chan_linear(chan));
 
 	/* wait for teardown complete */
-	timeout = jiffies + HZ/10;	/* 100 msec */
-	while (time_before(jiffies, timeout)) {
+	timeout = 100 * 100; /* 100 ms */
+	while (timeout) {
 		u32 cp = chan_read(chan, cp);
 		if ((cp & CPDMA_TEARDOWN_VALUE) == CPDMA_TEARDOWN_VALUE)
 			break;
-		cpu_relax();
+		udelay(10);
+		timeout--;
 	}
-	WARN_ON(!time_before(jiffies, timeout));
+	WARN_ON(!timeout);
 	chan_write(chan, cp, CPDMA_TEARDOWN_VALUE);
 
 	/* handle completed packets */
-- 
1.7.10.4

  reply	other threads:[~2013-04-17 21:52 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-17 21:52 my small cpsw queue Sebastian Andrzej Siewior
2013-04-17 21:52 ` Sebastian Andrzej Siewior [this message]
2013-04-18 11:49   ` [PATCH 1/5] net/davinci_cpdma: don't check for jiffies with interrupts Mugunthan V N
2013-04-17 21:52 ` [PATCH 2/5] net/cpsw: don't continue if we miss to allocate rx skbs Sebastian Andrzej Siewior
2013-04-18 11:50   ` Mugunthan V N
2013-04-18 12:09     ` Sebastian Andrzej Siewior
2013-04-19 10:40       ` Mugunthan V N
2013-04-22  8:05         ` Sebastian Andrzej Siewior
2013-04-17 21:52 ` [PATCH 3/5] net/cpsw: don't rely on netif_running() to check which device is active Sebastian Andrzej Siewior
2013-04-18 11:50   ` Mugunthan V N
2013-04-18 12:10     ` Sebastian Andrzej Siewior
2013-04-19 10:35       ` Mugunthan V N
2013-04-22  8:30         ` [PATCH 3/5 v2] net/cpsw: don't rely only " Sebastian Andrzej Siewior
2013-04-22  9:14           ` Mugunthan V N
2013-04-22  9:30             ` Sebastian Andrzej Siewior
2013-04-22  9:40               ` Mugunthan V N
2013-04-22  9:49                 ` Sebastian Andrzej Siewior
2013-04-22 10:12                   ` Mugunthan V N
2013-04-22 10:19                     ` Sebastian Andrzej Siewior
2013-04-22 19:21           ` David Miller
2013-04-19 13:10   ` [PATCH 3/5] net/cpsw: don't rely " Sergei Shtylyov
2013-04-22  8:33     ` Sebastian Andrzej Siewior
2013-04-17 21:52 ` [PATCH 4/5] net/davinci_cpdma: remove unused argument in cpdma_chan_submit() Sebastian Andrzej Siewior
2013-04-18 11:51   ` Mugunthan V N
2013-04-17 21:52 ` [PATCH 5/5] net/cpsw: redo rx skb allocation in rx path Sebastian Andrzej Siewior
2013-04-18 11:50   ` Mugunthan V N
2013-04-18 12:13     ` Sebastian Andrzej Siewior
2013-04-19 10:28       ` Mugunthan V N
2013-04-18 14:59     ` Eric Dumazet
  -- strict thread matches above, loose matches on Subject: below --
2013-04-23 17:31 cpsw queue, v2 Sebastian Andrzej Siewior
2013-04-23 17:31 ` [PATCH 1/5] net/davinci_cpdma: don't check for jiffies with interrupts Sebastian Andrzej Siewior

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=1366235536-15744-2-git-send-email-bigeasy@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=davem@davemloft.net \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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).