public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael Buesch <mb@bu3sch•de>
To: David Miller <davem@davemloft•net>
Cc: dave@thedillows•org, michael.riepe@googlemail•com,
	romieu@fr•zoreil.com, rsantos@grupopie•com, m.bueker@berlin•de,
	linux-kernel@vger•kernel.org, netdev@vger•kernel.org
Subject: Re: [PATCH 2.6.30-rc4] r8169: avoid losing MSI interrupts
Date: Wed, 27 May 2009 18:19:00 +0200	[thread overview]
Message-ID: <200905271819.01479.mb@bu3sch.de> (raw)
In-Reply-To: <20090526.151410.109935435.davem@davemloft.net>

On Wednesday 27 May 2009 00:14:10 David Miller wrote:
> From: David Miller <davem@davemloft•net>
> Date: Tue, 26 May 2009 14:52:11 -0700 (PDT)
> 
> > From: Michael Buesch <mb@bu3sch•de>
> > Date: Tue, 26 May 2009 20:22:23 +0200
> > 
> >> I didn't notice a CC:stable.
> >> I think this should also go to stable.
> >> Does somebody take care?
> > 
> > I'll queue it up.
> 
> Actually, this patch doesn't even remotely come close to applying
> to 2.6.29.4

Wiggle is able to apply it cleanly.
I already posted a wiggle'd patch.
It's also attached to this mail.


Index: linux-2.6.29/drivers/net/r8169.c
===================================================================
--- linux-2.6.29.orig/drivers/net/r8169.c	2009-05-23 11:06:22.000000000 +0200
+++ linux-2.6.29/drivers/net/r8169.c	2009-05-23 11:08:17.000000000 +0200
@@ -3554,54 +3554,64 @@
 	int handled = 0;
 	int status;
 
+	/* loop handling interrupts until we have no new ones or
+	 * we hit a invalid/hotplug case.
+	 */
 	status = RTL_R16(IntrStatus);
+	while (status && status != 0xffff) {
+		handled = 1;
 
-	/* hotplug/major error/no more work/shared irq */
-	if ((status == 0xffff) || !status)
-		goto out;
-
-	handled = 1;
+		/* Handle all of the error cases first. These will reset
+		 * the chip, so just exit the loop.
+		 */
+		if (unlikely(!netif_running(dev))) {
+			rtl8169_asic_down(ioaddr);
+			break;
+		}
 
-	if (unlikely(!netif_running(dev))) {
-		rtl8169_asic_down(ioaddr);
-		goto out;
-	}
+		/* Work around for rx fifo overflow */
+		if (unlikely(status & RxFIFOOver) &&
+	    	(tp->mac_version == RTL_GIGA_MAC_VER_11)) {
+			netif_stop_queue(dev);
+			rtl8169_tx_timeout(dev);
+			break;
+		}
 
-	status &= tp->intr_mask;
-	RTL_W16(IntrStatus,
-		(status & RxFIFOOver) ? (status | RxOverflow) : status);
+		if (unlikely(status & SYSErr)) {
+			rtl8169_pcierr_interrupt(dev);
+			break;
+		}
 
-	if (!(status & tp->intr_event))
-		goto out;
+		if (status & LinkChg)
+			rtl8169_check_link_status(dev, tp, ioaddr);
 
-	/* Work around for rx fifo overflow */
-	if (unlikely(status & RxFIFOOver) &&
-	    (tp->mac_version == RTL_GIGA_MAC_VER_11)) {
-		netif_stop_queue(dev);
-		rtl8169_tx_timeout(dev);
-		goto out;
-	}
+		/* We need to see the lastest version of tp->intr_mask to
+		 * avoid ignoring an MSI interrupt and having to wait for
+		 * another event which may never come.
+		 */
+		smp_rmb();
+		if (status & tp->intr_mask & tp->napi_event) {
+			RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event);
+			tp->intr_mask = ~tp->napi_event;
+
+			if (likely(netif_rx_schedule_prep(&tp->napi)))
+				__netif_rx_schedule(&tp->napi);
+			else if (netif_msg_intr(tp)) {
+				printk(KERN_INFO "%s: interrupt %04x in poll\n",
+			       	dev->name, status);
+			}
+		}
 
-	if (unlikely(status & SYSErr)) {
-		rtl8169_pcierr_interrupt(dev);
-		goto out;
+		/* We only get a new MSI interrupt when all active irq
+		 * sources on the chip have been acknowledged. So, ack
+		 * everything we've seen and check if new sources have become
+		 * active to avoid blocking all interrupts from the chip.
+		 */
+		RTL_W16(IntrStatus,
+			(status & RxFIFOOver) ? (status | RxOverflow) : status);
+		status = RTL_R16(IntrStatus);
 	}
 
-	if (status & LinkChg)
-		rtl8169_check_link_status(dev, tp, ioaddr);
-
-	if (status & tp->napi_event) {
-		RTL_W16(IntrMask, tp->intr_event & ~tp->napi_event);
-		tp->intr_mask = ~tp->napi_event;
-
-		if (likely(netif_rx_schedule_prep(&tp->napi)))
-			__netif_rx_schedule(&tp->napi);
-		else if (netif_msg_intr(tp)) {
-			printk(KERN_INFO "%s: interrupt %04x in poll\n",
-			       dev->name, status);
-		}
-	}
-out:
 	return IRQ_RETVAL(handled);
 }
 
@@ -3617,13 +3627,15 @@
 
 	if (work_done < budget) {
 		netif_rx_complete(napi);
-		tp->intr_mask = 0xffff;
-		/*
-		 * 20040426: the barrier is not strictly required but the
-		 * behavior of the irq handler could be less predictable
-		 * without it. Btw, the lack of flush for the posted pci
-		 * write is safe - FR
+
+		/* We need for force the visibility of tp->intr_mask
+		 * for other CPUs, as we can loose an MSI interrupt
+		 * and potentially wait for a retransmit timeout if we don't.
+		 * The posted write to IntrMask is safe, as it will
+		 * eventually make it to the chip and we won't loose anything
+		 * until it does.
 		 */
+		tp->intr_mask = 0xffff;
 		smp_wmb();
 		RTL_W16(IntrMask, tp->intr_event);
 	}


-- 
Greetings, Michael.

  parent reply	other threads:[~2009-05-27 16:19 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <200903041828.49972.m.bueker@berlin.de>
     [not found] ` <20090322211159.GA23042@electric-eye.fr.zoreil.com>
     [not found]   ` <49CA1822.6050902@grupopie.com>
     [not found]     ` <200904041950.04324.mb@bu3sch.de>
     [not found]       ` <4A06D8D2.4010505@googlemail.com>
2009-05-11  0:29         ` 2.6.27.19 + 28.7: network timeouts for r8169 and 8139too David Dillow
2009-05-11 20:48           ` Michael Buesch
2009-05-11 21:10             ` Michael Buesch
2009-05-11 21:29               ` David Dillow
2009-05-11 21:59                 ` Michael Buesch
2009-05-12 20:29                 ` Michael Riepe
2009-05-14  2:38                   ` David Dillow
2009-05-14 18:37                     ` Michael Riepe
2009-05-14 19:14                       ` David Dillow
2009-05-14 19:42                         ` Michael Riepe
2009-05-23  1:29                           ` [PATCH 2.6.30-rc4] r8169: avoid losing MSI interrupts David Dillow
2009-05-23  9:24                             ` Michael Buesch
2009-05-23 14:35                               ` Michael Riepe
2009-05-23 14:44                                 ` Michael Buesch
2009-05-23 15:01                                   ` Michael Riepe
2009-05-23 16:40                                     ` Michael Buesch
2009-05-23 14:51                                 ` David Dillow
2009-05-23 16:12                                   ` Michael Riepe
2009-05-23 16:45                                     ` Michael Buesch
2009-05-23 16:46                                     ` David Dillow
2009-05-23 16:50                                       ` Michael Buesch
2009-05-23 16:53                                       ` Michael Riepe
2009-05-23 17:03                                         ` David Dillow
2009-05-24 21:15                             ` Francois Romieu
2009-05-24 22:55                               ` David Dillow
2009-05-26  5:55                             ` David Miller
2009-05-26 18:22                               ` Michael Buesch
2009-05-26 21:52                                 ` David Miller
2009-05-26 22:14                                   ` David Miller
2009-05-26 22:40                                     ` Michael Riepe
2009-05-26 22:43                                       ` David Miller
2009-05-26 23:10                                         ` David Miller
2009-05-27 16:19                                     ` Michael Buesch [this message]
2009-06-16 19:32                                     ` Rui Santos
2009-08-21 20:57                             ` Eric W. Biederman
2009-08-21 21:22                               ` Michael Riepe
2009-08-21 22:59                               ` David Dillow
2009-08-21 23:34                                 ` David Dillow
2009-08-22  0:24                                   ` Eric W. Biederman
2009-08-22 11:48                                   ` Eric W. Biederman
2009-08-22 12:07                                     ` Eric W. Biederman
2009-08-22 20:43                                       ` David Dillow
2009-08-23 17:17                                         ` Jarek Poplawski
2009-08-23 17:43                                           ` Michal Soltys
2009-08-23 17:54                                             ` Jarek Poplawski
2009-08-24  2:37                                         ` Eric W. Biederman
2009-08-25  0:51                                         ` Eric W. Biederman
2009-08-25  2:59                                           ` David Dillow
2009-08-25 20:22                                             ` Eric W. Biederman
2009-08-25 20:40                                               ` David Dillow
2009-08-25 21:24                                                 ` Eric W. Biederman
2009-08-25 21:46                                                   ` David Dillow
2009-08-25 22:19                                                   ` Francois Romieu
2009-08-26  3:47                                                     ` Eric W. Biederman
2009-08-26  7:58                                                     ` [PATCH] r8169: Reduce looping in the interrupt handler Eric W. Biederman
2009-08-26 13:56                                                       ` David Dillow
2009-08-26 13:59                                                         ` David Dillow
2009-08-26 20:02                                                           ` Eric W. Biederman
2009-08-26 21:30                                                             ` Francois Romieu
2009-08-26 21:40                                                               ` Eric W. Biederman
2009-08-27  5:24                                                                 ` Francois Romieu
2009-08-27  5:38                                                                   ` Eric W. Biederman
2009-08-27 23:20                                                                     ` Francois Romieu
2009-08-28  1:17                                                                       ` Eric W. Biederman
2009-08-28  1:29                                                                         ` David Dillow
2009-08-30 20:37                                                                           ` Francois Romieu
2009-08-30 20:53                                                                             ` Eric W. Biederman
2009-09-01  3:33                                                                               ` David Dillow
2009-09-01  9:20                                                                                 ` Francois Romieu
2009-08-25 21:37                                             ` [PATCH 2.6.30-rc4] r8169: avoid losing MSI interrupts Eric W. Biederman
2009-08-25 21:54                                               ` David Dillow
2009-08-25 23:11                                                 ` Francois Romieu
2009-05-12 11:10             ` 2.6.27.19 + 28.7: network timeouts for r8169 and 8139too Krzysztof Halasa
2009-05-12 21:45               ` Michael Riepe
2009-05-13  6:11                 ` Francois Romieu
2009-05-13  6:27                   ` Michael Riepe
2009-05-13 19:34                 ` Krzysztof Halasa

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=200905271819.01479.mb@bu3sch.de \
    --to=mb@bu3sch$(echo .)de \
    --cc=dave@thedillows$(echo .)org \
    --cc=davem@davemloft$(echo .)net \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=m.bueker@berlin$(echo .)de \
    --cc=michael.riepe@googlemail$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=romieu@fr$(echo .)zoreil.com \
    --cc=rsantos@grupopie$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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