mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Francois Romieu <romieu@fr.zoreil.com>
To: Andrew Morton <akpm@osdl.org>
Cc: linux-kernel@vger.kernel.org, netdev@oss.sgi.com,
	jdmason@us.ibm.com, rich@phekda.gotadsl.co.uk, jgarzik@pobox.com
Subject: [patch 2.6.11-rc4-mm1 1/2] r8169: IRQ races during change of mtu
Date: Wed, 23 Feb 2005 21:58:53 +0100	[thread overview]
Message-ID: <20050223205853.GA30109@electric-eye.fr.zoreil.com> (raw)
In-Reply-To: <20050223010948.6f2aa542.akpm@osdl.org>

IRQ races during change of mtu
- NAPI poll must be enabled prior to IRQ activation or the IRQ handler
  will not know what to do with an incoming packet;
- rtl8169_down() needs to try twice to sync with the IRQ handler when
  it is not issued under !netif_running() protection.

Both changes make it safe to request a change of mtu on a live device.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>

diff -puN drivers/net/r8169.c~r8169-450 drivers/net/r8169.c
--- a/drivers/net/r8169.c~r8169-450	2005-02-23 21:35:21.112521942 +0100
+++ b/drivers/net/r8169.c	2005-02-23 21:35:21.117521120 +0100
@@ -1648,10 +1648,10 @@ static int rtl8169_change_mtu(struct net
 	if (ret < 0)
 		goto out;
 
-	rtl8169_hw_start(dev);
-
 	netif_poll_enable(dev);
 
+	rtl8169_hw_start(dev);
+
 	rtl8169_request_timer(dev);
 
 out:
@@ -2352,6 +2352,7 @@ static void rtl8169_down(struct net_devi
 {
 	struct rtl8169_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
+	unsigned int poll_locked = 0;
 
 	rtl8169_delete_timer(dev);
 
@@ -2359,6 +2360,7 @@ static void rtl8169_down(struct net_devi
 
 	flush_scheduled_work();
 
+core_down:
 	spin_lock_irq(&tp->lock);
 
 	/* Stop the chip's Tx and Rx DMA processes. */
@@ -2375,11 +2377,28 @@ static void rtl8169_down(struct net_devi
 
 	synchronize_irq(dev->irq);
 
-	netif_poll_disable(dev);
+	if (!poll_locked) {
+		netif_poll_disable(dev);
+		poll_locked++;
+	}
 
 	/* Give a racing hard_start_xmit a few cycles to complete. */
 	synchronize_kernel();
 
+	/*
+	 * And now for the 50k$ question: are IRQ disabled or not ?
+	 *
+	 * Two paths lead here:
+	 * 1) dev->close
+	 *    -> netif_running() is available to sync the current code and the
+	 *       IRQ handler. See rtl8169_interrupt for details.
+	 * 2) dev->change_mtu
+	 *    -> rtl8169_poll can not be issued again and re-enable the
+	 *       interruptions. Let's simply issue the IRQ down sequence again.
+	 */
+	if (RTL_R16(IntrMask))
+		goto core_down;
+
 	rtl8169_tx_clear(tp);
 
 	rtl8169_rx_clear(tp);

_

  reply	other threads:[~2005-02-23 21:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-22 23:48 [rft/update] r8169 changes in 2.6.x Francois Romieu
2005-02-23  1:29 ` Andrew Morton
2005-02-23  1:26   ` Jeff Garzik
2005-02-23  8:59   ` Francois Romieu
2005-02-23  9:09     ` Andrew Morton
2005-02-23 20:58       ` Francois Romieu [this message]
2005-02-23 21:03         ` [patch 2.6.11-rc4-mm1 2/2] r8169: factor out some code Francois Romieu

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=20050223205853.GA30109@electric-eye.fr.zoreil.com \
    --to=romieu@fr.zoreil.com \
    --cc=akpm@osdl.org \
    --cc=jdmason@us.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@oss.sgi.com \
    --cc=rich@phekda.gotadsl.co.uk \
    /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

all inboxes | Powered by JetHome®