linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wolfgang Grandegger <wg@grandegger.com>
To: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: Pavel Pisa <pisa@cmp.felk.cvut.cz>,
	Austin Schuh <austin@peloton-tech.com>,
	linux-can@vger.kernel.org
Subject: Re: sja1000 interrupt problem
Date: Sun, 17 Nov 2013 21:46:25 +0100	[thread overview]
Message-ID: <52892B21.9000501@grandegger.com> (raw)
In-Reply-To: <5288FB91.9050703@grandegger.com>

On 11/17/2013 06:23 PM, Wolfgang Grandegger wrote:
> On 11/17/2013 03:27 PM, Oliver Hartkopp wrote:
>>
>>
>> On 17.11.2013 09:18, Wolfgang Grandegger wrote:
>>>
>>> On Sat, 16 Nov 2013 22:42:10 +0100, Oliver Hartkopp
>>
>>
>>>> Btw. I would try two more things with the sja1000.c driver:
>>>
>>>>
>>>
>>>> 1. Print the corresponding CAN device name and the point in the code
>>>
>>> before
>>>
>>>> returning IRQ_NONE to catch the problematic return site.
>>>
>>>>
>>>
>>>> 2. Replace all IRQ_NONE with IRQ_HANDLED for a test ...
>>>
>>>>
>>>
>>>> Any other ideas?
>>>
>>>
>>>
>>> A function trace is still the first thing to take. Be aware that the
>>>
>>> tasks are running on more than one CPU. It's just to establish a good
>>>
>>> trigger.
>>>
>>
>> Yes. But so far the function trace only showed the fact of simultaneous irq
>> treads for the two CAN interfaces - what we were expecting :-)
> 
> Yes, because the trigger was not good so far.
> 
>> IMO it's interesting to get the concrete return site from where the IRQ_NONE
>> is returned. Maybe one of the other interfaces / bits in PITA are enabled
>> which we did not see so far.
> 
> The problem is that the IRQs are shared, also with the ATA disk. There
> it's normal to see unhandled interrupts. My idea was to trigger a
> "tracing_off" after 10 IRQ_NONE in sequence.

See my patch below. @Austin, you may want to give it a try.

Wolfgang.

From eac2b63d114bc83544f806a549fe7339d54c031f Mon Sep 17 00:00:00 2001
From: Wolfgang Grandegger <wg@grandegger.com>
Date: Sun, 17 Nov 2013 21:39:05 +0100
Subject: [PATCH] sja1000: debugging code to inspect too much unhandeled irq

If more than "IRQ_NONE_COUNT_MAX" unhandled interrupts are detected
in sequence, ftracing will be stopped.
---
 drivers/net/can/sja1000/sja1000.c |   34 +++++++++++++++++++++++++++-------
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 7164a99..80e8d84 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -486,6 +486,9 @@ static int sja1000_err(struct net_device *dev, uint8_t isrc, uint8_t status)
 	return 0;
 }
 
+#define IRQ_NONE_COUNT_MAX 5
+static int irq_none_count;
+
 irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 {
 	struct net_device *dev = (struct net_device *)dev_id;
@@ -496,7 +499,7 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 
 	/* Shared interrupts and IRQ off? */
 	if (priv->read_reg(priv, SJA1000_IER) == IRQ_OFF)
-		return IRQ_NONE;
+		goto out;
 
 	if (priv->pre_irq)
 		priv->pre_irq(priv);
@@ -506,8 +509,11 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 		n++;
 		status = priv->read_reg(priv, SJA1000_SR);
 		/* check for absent controller due to hw unplug */
-		if (status == 0xFF && sja1000_is_absent(priv))
-			return IRQ_NONE;
+		if (status == 0xFF && sja1000_is_absent(priv)) {
+			netdev_warn(dev, "controller lost (n=%d)\n", n);
+			n = 0;
+			goto out;
+		}
 
 		if (isrc & IRQ_WUI)
 			netdev_warn(dev, "wakeup interrupt\n");
@@ -534,8 +540,11 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 				sja1000_rx(dev);
 				status = priv->read_reg(priv, SJA1000_SR);
 				/* check for absent controller */
-				if (status == 0xFF && sja1000_is_absent(priv))
-					return IRQ_NONE;
+				if (status == 0xFF && sja1000_is_absent(priv)) {
+					netdev_warn(dev, "controller lost (n=%d)\n", n);
+					n = 0;
+					goto out;
+				}
 			}
 		}
 		if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {
@@ -547,11 +556,22 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 
 	if (priv->post_irq)
 		priv->post_irq(priv);
-
 	if (n >= SJA1000_MAX_IRQ)
 		netdev_dbg(dev, "%d messages handled in ISR", n);
 
-	return (n) ? IRQ_HANDLED : IRQ_NONE;
+out:
+	if (n) {
+		irq_none_count = 0;
+		return IRQ_HANDLED;
+	} else {
+		irq_none_count++;
+		if (irq_none_count >= IRQ_NONE_COUNT_MAX) {
+			netdev_info(dev, "tracing stopped after %d unhandled irqs)\n",
+				    irq_none_count);
+			tracing_off();
+		}
+		return IRQ_NONE;
+	}
 }
 EXPORT_SYMBOL_GPL(sja1000_interrupt);
 
-- 
1.7.9.5





  reply	other threads:[~2013-11-17 20:46 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-08  0:47 sja1000 interrupt problem Austin Schuh
2013-10-08  6:32 ` Wolfgang Grandegger
2013-10-08  6:58   ` Oliver Hartkopp
2013-10-08 18:48     ` Austin Schuh
2013-10-08 19:44       ` Wolfgang Grandegger
2013-10-08 20:47         ` Austin Schuh
2013-10-09  6:21           ` Wolfgang Grandegger
2013-10-09  6:31           ` Wolfgang Grandegger
2013-10-09  6:47           ` Wolfgang Grandegger
     [not found]             ` <CANGgnMZpPGctUWGcg7Lp-QFPc7d6A5GeL9KQYnpeYMR8WukgdA@mail.gmail.com>
2013-11-07  8:15               ` Wolfgang Grandegger
2013-11-07 23:43                 ` Austin Schuh
2013-11-09 14:21                   ` Oliver Hartkopp
2013-11-12  2:59                     ` Austin Schuh
2013-11-12 21:26                       ` Oliver Hartkopp
2013-11-12 23:22                         ` Austin Schuh
2013-11-13  3:41                           ` Austin Schuh
2013-11-13  6:58                             ` Oliver Hartkopp
2013-11-13  9:48                               ` Kurt Van Dijck
2013-11-13  6:44                           ` Oliver Hartkopp
2013-11-13  8:11                             ` Wolfgang Grandegger
2013-11-13  9:08                               ` Pavel Pisa
2013-11-13  9:52                                 ` Wolfgang Grandegger
2013-11-13 18:41                                   ` Oliver Hartkopp
2013-11-13 19:29                                     ` Wolfgang Grandegger
2013-11-13 22:00                                       ` Oliver Hartkopp
2013-11-13 11:02                                 ` Kurt Van Dijck
2013-11-16 21:42                                 ` Oliver Hartkopp
2013-11-17  8:18                                   ` Wolfgang Grandegger
2013-11-17 14:27                                     ` Oliver Hartkopp
2013-11-17 17:23                                       ` Wolfgang Grandegger
2013-11-17 20:46                                         ` Wolfgang Grandegger [this message]
2013-11-18 17:08                                           ` Austin Schuh
2013-12-09 21:54                                             ` Austin Schuh
2013-12-09 21:54                                               ` Austin Schuh
2013-12-10  7:49                                               ` Wolfgang Grandegger
2013-12-10  8:05                                                 ` Austin Schuh
2013-12-10  9:32                                                   ` Wolfgang Grandegger
2013-12-10 13:47                                                     ` Oliver Hartkopp
2013-12-10 14:23                                                       ` Oliver Hartkopp
2013-12-10 14:41                                                       ` Wolfgang Grandegger
2013-12-10 16:05                                                         ` Oliver Hartkopp
2013-12-10 21:12                                                           ` Wolfgang Grandegger
2013-12-11 16:59                                                             ` Oliver Hartkopp
2013-12-11 19:27                                                               ` Wolfgang Grandegger
2013-12-12  6:13                                                                 ` Oliver Hartkopp
2013-12-12 17:38                                                                   ` Oliver Hartkopp
2013-12-12 22:56                                                                     ` Wolfgang Grandegger
2013-12-13  0:07                                                                       ` Austin Schuh
2013-12-13 16:16                                                                         ` Oliver Hartkopp
2013-12-13  9:38                                                                       ` Oliver Hartkopp
2013-12-13 10:04                                                                         ` Wolfgang Grandegger
2013-12-13 10:09                                                                           ` Wolfgang Grandegger
2013-12-13 16:25                                                                             ` Oliver Hartkopp
2013-12-13 17:33                                                                               ` Wolfgang Grandegger
2013-12-13 10:07                                                                         ` Marc Kleine-Budde
2013-12-13 16:22                                                                           ` Oliver Hartkopp
2013-12-13 17:14                                                                             ` Oliver Hartkopp
2013-12-13 21:14                                                                               ` Oliver Hartkopp
2013-12-14  9:51                                                                                 ` Oliver Hartkopp
2013-12-20 23:13                                                                                   ` Austin Schuh
2013-12-21  8:29                                                                                     ` Wolfgang Grandegger
2013-12-21 13:12                                                                                       ` Oliver Hartkopp
2013-12-21 12:55                                                                                     ` Oliver Hartkopp
2013-12-23 15:58                                                                                       ` Oliver Hartkopp
2013-11-09 19:42                   ` Wolfgang Grandegger
     [not found]                     ` <CANGgnMbb+VResUC6h+cK6Hfe5PLJx9R9ao6bMdJM2e5BPaDamw@mail.gmail.com>
2013-11-12 22:15                       ` Wolfgang Grandegger

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=52892B21.9000501@grandegger.com \
    --to=wg@grandegger.com \
    --cc=austin@peloton-tech.com \
    --cc=linux-can@vger.kernel.org \
    --cc=pisa@cmp.felk.cvut.cz \
    --cc=socketcan@hartkopp.net \
    /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).