All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: linux-can@vger.kernel.org
Subject: [PATCH v2] can: sja1000 fix isr hang when hw is unplugged under load
Date: Wed, 15 Feb 2012 17:51:56 +0100	[thread overview]
Message-ID: <4F3BE2AC.9020108@hartkopp.net> (raw)
In-Reply-To: <1318506157-10329-1-git-send-email-mkl@pengutronix.de>

In the case of hotplug enabled devices (PCMCIA/PCIeC) the removal of the
hardware can cause an infinite loop in the common sja1000 isr.

Use the already retrieved status register to indicate a possible hardware
removal and double check by reading the mode register in sja1000_is_absent.

v2: Create a new function to not print information in irq context.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>

---

diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c
index 04a3f1b..192b0d1 100644
--- a/drivers/net/can/sja1000/sja1000.c
+++ b/drivers/net/can/sja1000/sja1000.c
@@ -95,11 +95,16 @@ static void sja1000_write_cmdreg(struct sja1000_priv *priv, u8 val)
 	spin_unlock_irqrestore(&priv->cmdreg_lock, flags);
 }
 
+static int sja1000_is_absent(struct sja1000_priv *priv)
+{
+	return (priv->read_reg(priv, REG_MOD) == 0xFF);
+}
+
 static int sja1000_probe_chip(struct net_device *dev)
 {
 	struct sja1000_priv *priv = netdev_priv(dev);
 
-	if (priv->reg_base && (priv->read_reg(priv, 0) == 0xFF)) {
+	if (priv->reg_base && sja1000_is_absent(priv)) {
 		printk(KERN_INFO "%s: probing @0x%lX failed\n",
 		       DRV_NAME, dev->base_addr);
 		return 0;
@@ -493,6 +498,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 	while ((isrc = priv->read_reg(priv, REG_IR)) && (n < SJA1000_MAX_IRQ)) {
 		n++;
 		status = priv->read_reg(priv, REG_SR);
+		/* check for absent controller due to hw unplug */
+		if (status == 0xFF && sja1000_is_absent(priv))
+			return IRQ_NONE;
 
 		if (isrc & IRQ_WUI)
 			dev_warn(dev->dev.parent, "wakeup interrupt\n");
@@ -509,6 +517,9 @@ irqreturn_t sja1000_interrupt(int irq, void *dev_id)
 			while (status & SR_RBS) {
 				sja1000_rx(dev);
 				status = priv->read_reg(priv, REG_SR);
+				/* check for absent controller */
+				if (status == 0xFF && sja1000_is_absent(priv))
+					return IRQ_NONE;
 			}
 		}
 		if (isrc & (IRQ_DOI | IRQ_EI | IRQ_BEI | IRQ_EPI | IRQ_ALI)) {


  parent reply	other threads:[~2012-02-15 16:52 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-13 11:42 [PATCH] MAINTAINERS: can: the mailinglist moved to vger.kernel.org Marc Kleine-Budde
2011-10-13 20:17 ` Oliver Hartkopp
2011-11-02 20:55 ` [PATCH] MAINTAINERS: Add can-gw include to maintained files Oliver Hartkopp
2011-11-03 22:12   ` David Miller
2012-02-14 19:27 ` [PATCH] can: sja1000 fix isr hang when hw is unplugged under load Oliver Hartkopp
2012-02-15 16:51 ` Oliver Hartkopp [this message]
2012-02-17 20:27   ` [PATCH v2] " Marc Kleine-Budde
2012-02-18 14:19     ` Oliver Hartkopp
2012-02-18 17:00       ` Marc Kleine-Budde
2012-02-20 11:02       ` Marc Kleine-Budde
2012-02-21  8:07         ` Oliver Hartkopp
2012-02-21  9:03           ` Marc Kleine-Budde
2012-02-18 14:33     ` Wolfgang Grandegger
2012-02-18 15:34       ` Oliver Hartkopp
2012-02-18 16:44         ` Wolfgang Grandegger
2012-02-18 17:00           ` Marc Kleine-Budde
2012-02-18 17:13             ` Wolfgang Grandegger
2012-03-25  6:43 ` [PATCH] iwlwifi: fix unused variable warning Oliver Hartkopp
2012-03-26  1:49   ` Guy, Wey-Yi
2012-04-03 19:56 ` [PATCH RFC] can: add hash table for single EFF id filter list Oliver Hartkopp
2012-05-08 20:20 ` [PATCH] can: update documentation wording error frames -> error messages Oliver Hartkopp
2012-05-08 20:38   ` Marc Kleine-Budde
2012-05-09 17:09     ` Heinz-Jürgen Oertel

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=4F3BE2AC.9020108@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.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 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.