From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751623AbZHZH7D (ORCPT ); Wed, 26 Aug 2009 03:59:03 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750821AbZHZH7B (ORCPT ); Wed, 26 Aug 2009 03:59:01 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:51456 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750803AbZHZH7A (ORCPT ); Wed, 26 Aug 2009 03:59:00 -0400 To: Francois Romieu Cc: David Dillow , Michael Riepe , Michael Buesch , Rui Santos , Michael B??ker , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH] r8169: Reduce looping in the interrupt handler. References: <1250895567.23419.1.camel@obelisk.thedillows.org> <1250897657.23419.5.camel@obelisk.thedillows.org> <1250973787.3582.14.camel@obelisk.thedillows.org> <1251169150.4023.11.camel@obelisk.thedillows.org> <1251232848.9607.15.camel@lap75545.ornl.gov> <20090825221903.GA13630@electric-eye.fr.zoreil.com> From: ebiederm@xmission.com (Eric W. Biederman) Date: Wed, 26 Aug 2009 00:58:56 -0700 In-Reply-To: <20090825221903.GA13630@electric-eye.fr.zoreil.com> (Francois Romieu's message of "Wed\, 26 Aug 2009 00\:19\:03 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-XM-SPF: eid=;;;mid=;;;hst=in02.mta.xmission.com;;;ip=76.21.114.89;;;frm=ebiederm@xmission.com;;;spf=neutral X-SA-Exim-Connect-IP: 76.21.114.89 X-SA-Exim-Rcpt-To: romieu@fr.zoreil.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, m.bueker@berlin.de, rsantos@grupopie.com, mb@bu3sch.de, michael.riepe@googlemail.com, dave@thedillows.org X-SA-Exim-Mail-From: ebiederm@xmission.com X-SA-Exim-Version: 4.2.1 (built Thu, 25 Oct 2007 00:26:12 +0000) X-SA-Exim-Scanned: No (on in02.mta.xmission.com); Unknown failure Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As of 2.6.30 I have been observing soft lockups and netdev watchdog timeouts caused by looping in the r8169 interrupt handler. - Introduce a hard limit to the maximum number of times we will loop in the interrupt handler, and print a message when we hit it. - Break out of the loop if after looking none of the events in status are events we expect to be delivered by an interrupt. With just the hard limit and message bits of my patch in my test case I get hit my limit of 10 loops 12 times. After filtering by intr_mask and intr_event I don't get any warnings. Any complaints from those who know the driver better than I? Signed-off-by: Eric W. Biederman --- drivers/net/r8169.c | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 3b19e0c..2214945 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c @@ -61,6 +61,8 @@ static const int multicast_filter_limit = 32; /* MAC address length */ #define MAC_ADDR_LEN 6 +#define MAX_INTR_LOOPS 10 /* Limit the msi acking loop from going crazy */ + #define MAX_READ_REQUEST_SHIFT 12 #define RX_FIFO_THRESH 7 /* 7 means NO threshold, Rx buffer level before first PCI xfer. */ #define RX_DMA_BURST 6 /* Maximum PCI burst, '6' is 1024 */ @@ -3552,6 +3554,7 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) void __iomem *ioaddr = tp->mmio_addr; int handled = 0; int status; + int count = 0; /* loop handling interrupts until we have no new ones or * we hit a invalid/hotplug case. @@ -3560,6 +3563,17 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) while (status && status != 0xffff) { handled = 1; + if (count++ >= MAX_INTR_LOOPS) { + if (netif_msg_intr(tp) && net_ratelimit()) { + printk(KERN_INFO " %s Screaming irq " + "status %08x mask %08x event %08x " + "napi %08x\n", + dev->name, status, tp->intr_mask, + tp->intr_event, tp->napi_event); + } + break; + } + /* Handle all of the error cases first. These will reset * the chip, so just exit the loop. */ @@ -3609,6 +3623,13 @@ static irqreturn_t rtl8169_interrupt(int irq, void *dev_instance) RTL_W16(IntrStatus, (status & RxFIFOOver) ? (status | RxOverflow) : status); status = RTL_R16(IntrStatus); + + /* Ignore the parts of status that reflect more than + * the enabled interrupts. + */ + smp_rmb(); + if (!(status & tp->intr_mask & tp->intr_event)) + break; } return IRQ_RETVAL(handled); -- 1.6.2.5