netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Valerie Henson <val_henson@linux.intel.com>
To: Grant Grundler <grundler@parisc-linux.org>
Cc: Jeff Garzik <jgarzik@pobox.com>, Andrew Morton <akpm@osdl.org>,
	netdev@vger.kernel.org
Subject: [PATCH] Fix tulip shutdown DMA/irq race
Date: Mon, 26 Jun 2006 15:31:58 -0700	[thread overview]
Message-ID: <20060626223157.GH19196@goober> (raw)
In-Reply-To: <20060623050029.GB23383@colo.lackof.org>

From: Grant Grundler <grundler@parisc-linux.org>

IRQs are racing with tulip_down(). DMA can be restarted by the
interrupt handler _after_ we call tulip_stop_rxtx() and the DMA
buffers are unmapped.  The result is an MCA (hard crash on ia64)
because of an IO TLB miss.  The long-term fix is to make the interrupt
handler shutdown aware.

Signed-off-by: Grant Grundler <grundler@parisc-linux.org>
Acked-by: Valerie Henson <val_henson@linux.intel.com>

---

 tulip_core.c |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff -Nru a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
--- a/drivers/net/tulip/tulip_core.c	2006-06-22 16:24:11 -07:00
+++ b/drivers/net/tulip/tulip_core.c	2006-06-22 16:24:11 -07:00
@@ -18,11 +18,11 @@
 
 #define DRV_NAME	"tulip"
 #ifdef CONFIG_TULIP_NAPI
-#define DRV_VERSION    "1.1.13-NAPI" /* Keep at least for test */
+#define DRV_VERSION    "1.1.14-NAPI" /* Keep at least for test */
 #else
-#define DRV_VERSION	"1.1.13"
+#define DRV_VERSION	"1.1.14"
 #endif
-#define DRV_RELDATE	"May 11, 2002"
+#define DRV_RELDATE	"May 6, 2006"
 
 
 #include <linux/module.h>
@@ -739,23 +739,36 @@
 #endif
 	spin_lock_irqsave (&tp->lock, flags);
 
+	/*
+	  FIXME: We should really add a shutdown-in-progress flag and
+	  check it in the interrupt handler to see whether we should
+	  reenable DMA or not.  The preferred ordering here would be:
+	 
+	  stop DMA engine
+	  disable interrupts
+	  remove DMA resources
+	  free_irq()
+
+	  The below works but is non-obvious and doesn't match the
+	  ordering of bring-up. -VAL
+	*/
+
 	/* Disable interrupts by clearing the interrupt mask. */
 	iowrite32 (0x00000000, ioaddr + CSR7);
+	ioread32 (ioaddr + CSR7);	/* flush posted write */
 
-	/* Stop the Tx and Rx processes. */
-	tulip_stop_rxtx(tp);
+	spin_unlock_irqrestore (&tp->lock, flags);
 
-	/* prepare receive buffers */
-	tulip_refill_rx(dev);
+	free_irq (dev->irq, dev);	/* no more races after this */
+	tulip_stop_rxtx(tp);		/* Stop DMA */
 
-	/* release any unconsumed transmit buffers */
-	tulip_clean_tx_ring(tp);
+	/* Put driver back into the state we start with */
+	tulip_refill_rx(dev);		/* prepare RX buffers */
+	tulip_clean_tx_ring(tp);	/* clean up unsent TX buffers */
 
 	if (ioread32 (ioaddr + CSR6) != 0xffffffff)
 		tp->stats.rx_missed_errors += ioread32 (ioaddr + CSR8) & 0xffff;
 
-	spin_unlock_irqrestore (&tp->lock, flags);
-
 	init_timer(&tp->timer);
 	tp->timer.data = (unsigned long)dev;
 	tp->timer.function = tulip_tbl[tp->chip_id].media_timer;
@@ -781,7 +794,6 @@
 		printk (KERN_DEBUG "%s: Shutting down ethercard, status was %2.2x.\n",
 			dev->name, ioread32 (ioaddr + CSR5));
 
-	free_irq (dev->irq, dev);
 
 	/* Free all the skbuffs in the Rx queue. */
 	for (i = 0; i < RX_RING_SIZE; i++) {
@@ -1752,7 +1764,6 @@
 		tulip_down(dev);
 
 	netif_device_detach(dev);
-	free_irq(dev->irq, dev);
 
 	pci_save_state(pdev);
 	pci_disable_device(pdev);

      reply	other threads:[~2006-06-26 22:33 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-31 19:52 PATCH 2.6.17-rc5 tulip free_irq() called too late Grant Grundler
2006-06-08 14:43 ` Jeff Garzik
2006-06-08 15:22   ` Grant Grundler
2006-06-08 15:32     ` Grant Grundler
2006-06-08 15:38       ` Jeff Garzik
2006-06-08 15:47         ` Grant Grundler
2006-06-08 15:32     ` Jeff Garzik
2006-06-08 15:36       ` Grant Grundler
2006-06-08 17:01   ` Grant Grundler
2006-06-13 23:55     ` PATCHv3 " Grant Grundler
2006-06-14  0:06       ` Valerie Henson
2006-06-14  0:33       ` Jeff Garzik
2006-06-14  4:44         ` Grant Grundler
2006-06-14 13:05           ` Kyle McMartin
2006-06-14 14:54             ` Grant Grundler
2006-06-14 15:03           ` Jeff Garzik
2006-06-14 18:14             ` Grant Grundler
2006-06-14 19:51               ` Jeff Garzik
2006-06-14 22:25                 ` Grant Grundler
2006-06-14 20:47               ` Francois Romieu
2006-06-14 22:30                 ` Grant Grundler
2006-06-15 20:30                   ` Francois Romieu
2006-06-16  5:47                     ` Grant Grundler
2006-06-16  7:32                       ` Jeff Garzik
2006-06-16 15:25                         ` Grant Grundler
     [not found]                         ` <20060616152400.GA7868@colo.lackof.org>
     [not found]                           ` <4492CE98.50900@pobox.com>
2006-06-16 16:06                             ` Grant Grundler
2006-06-16 16:16                               ` Jeff Garzik
2006-06-22  0:43       ` Valerie Henson
2006-06-23  5:00         ` Grant Grundler
2006-06-26 22:31           ` Valerie Henson [this message]

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=20060626223157.GH19196@goober \
    --to=val_henson@linux.intel.com \
    --cc=akpm@osdl.org \
    --cc=grundler@parisc-linux.org \
    --cc=jgarzik@pobox.com \
    --cc=netdev@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 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).