Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=069f8256362b7a17da532f0631cee73b4cfee65b
Commit:     069f8256362b7a17da532f0631cee73b4cfee65b
Parent:     14fdd90ef2ec1878d6851ec4dd8d5abb2cef098c
Author:     [EMAIL PROTECTED] <[EMAIL PROTECTED]>
AuthorDate: Wed Mar 14 19:49:14 2007 +0000
Committer:  Jeff Garzik <[EMAIL PROTECTED]>
CommitDate: Thu Mar 15 10:59:54 2007 -0400

    natsemi: Fix NAPI for interrupt sharing
    
    The interrupt status register for the natsemi chips is clear on read and
    was read unconditionally from both the interrupt and from the NAPI poll
    routine, meaning that if the interrupt service routine was called (for
    example, due to a shared interrupt) while a NAPI poll was scheduled
    interrupts could be missed.  This patch fixes that by ensuring that the
    interrupt status register is only read by the interrupt handler when
    interrupts are enabled from the chip.
    
    It also reverts a workaround for this problem from the netpoll hook and
    improves the trace for interrupt events.
    
    Thanks to Sergei Shtylyov <[EMAIL PROTECTED]> for spotting the
    issue, Mark Huth <[EMAIL PROTECTED]> for a simpler method and Simon
    Blake <[EMAIL PROTECTED]> for testing resources.
    
    Signed-Off-By: Mark Brown <[EMAIL PROTECTED]>
    
    Signed-off-by: Jeff Garzik <[EMAIL PROTECTED]>
---
 drivers/net/natsemi.c |   38 ++++++++++++++++++++------------------
 1 files changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c
index 2888880..5f88200 100644
--- a/drivers/net/natsemi.c
+++ b/drivers/net/natsemi.c
@@ -2119,28 +2119,35 @@ static irqreturn_t intr_handler(int irq, void 
*dev_instance)
        struct netdev_private *np = netdev_priv(dev);
        void __iomem * ioaddr = ns_ioaddr(dev);
 
-       if (np->hands_off)
+       /* Reading IntrStatus automatically acknowledges so don't do
+        * that while interrupts are disabled, (for example, while a
+        * poll is scheduled).  */
+       if (np->hands_off || !readl(ioaddr + IntrEnable))
                return IRQ_NONE;
 
-       /* Reading automatically acknowledges. */
        np->intr_status = readl(ioaddr + IntrStatus);
 
+       if (!np->intr_status)
+               return IRQ_NONE;
+
        if (netif_msg_intr(np))
                printk(KERN_DEBUG
                       "%s: Interrupt, status %#08x, mask %#08x.\n",
                       dev->name, np->intr_status,
                       readl(ioaddr + IntrMask));
 
-       if (!np->intr_status)
-               return IRQ_NONE;
-
        prefetch(&np->rx_skbuff[np->cur_rx % RX_RING_SIZE]);
 
        if (netif_rx_schedule_prep(dev)) {
                /* Disable interrupts and register for poll */
                natsemi_irq_disable(dev);
                __netif_rx_schedule(dev);
-       }
+       } else
+               printk(KERN_WARNING
+                      "%s: Ignoring interrupt, status %#08x, mask %#08x.\n",
+                      dev->name, np->intr_status,
+                      readl(ioaddr + IntrMask));
+
        return IRQ_HANDLED;
 }
 
@@ -2156,6 +2163,12 @@ static int natsemi_poll(struct net_device *dev, int 
*budget)
        int work_done = 0;
 
        do {
+               if (netif_msg_intr(np))
+                       printk(KERN_DEBUG
+                              "%s: Poll, status %#08x, mask %#08x.\n",
+                              dev->name, np->intr_status,
+                              readl(ioaddr + IntrMask));
+
                if (np->intr_status &
                    (IntrTxDone | IntrTxIntr | IntrTxIdle | IntrTxErr)) {
                        spin_lock(&np->lock);
@@ -2399,19 +2412,8 @@ static struct net_device_stats *get_stats(struct 
net_device *dev)
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void natsemi_poll_controller(struct net_device *dev)
 {
-       struct netdev_private *np = netdev_priv(dev);
-
        disable_irq(dev->irq);
-
-       /*
-        * A real interrupt might have already reached us at this point
-        * but NAPI might still haven't called us back.  As the interrupt
-        * status register is cleared by reading, we should prevent an
-        * interrupt loss in this case...
-        */
-       if (!np->intr_status)
-               intr_handler(dev->irq, dev);
-
+       intr_handler(dev->irq, dev);
        enable_irq(dev->irq);
 }
 #endif
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to