]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/net/sky2.c
sky2: backout NAPI reschedule
[linux-2.6-omap-h63xx.git] / drivers / net / sky2.c
index 67b0eab16589e57e96f473c11937b63a97e31556..76da74fbe859b16d44c1ca109c6b77bb747e8f82 100644 (file)
@@ -51,7 +51,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "1.1"
+#define DRV_VERSION            "1.2"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -925,8 +925,7 @@ static inline struct sk_buff *sky2_alloc_skb(unsigned int size, gfp_t gfp_mask)
        skb = alloc_skb(size + RX_SKB_ALIGN, gfp_mask);
        if (likely(skb)) {
                unsigned long p = (unsigned long) skb->data;
-               skb_reserve(skb,
-                       ((p + RX_SKB_ALIGN - 1) & ~(RX_SKB_ALIGN - 1)) - p);
+               skb_reserve(skb, ALIGN(p, RX_SKB_ALIGN) - p);
        }
 
        return skb;
@@ -1686,13 +1685,12 @@ static void sky2_tx_timeout(struct net_device *dev)
 }
 
 
-#define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
 /* Want receive buffer size to be multiple of 64 bits
  * and incl room for vlan and truncation
  */
 static inline unsigned sky2_buf_size(int mtu)
 {
-       return roundup(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8;
+       return ALIGN(mtu + ETH_HLEN + VLAN_HLEN, 8) + 8;
 }
 
 static int sky2_change_mtu(struct net_device *dev, int new_mtu)
@@ -2086,6 +2084,20 @@ static void sky2_descriptor_error(struct sky2_hw *hw, unsigned port,
        }
 }
 
+/* If idle then force a fake soft NAPI poll once a second
+ * to work around cases where sharing an edge triggered interrupt.
+ */
+static void sky2_idle(unsigned long arg)
+{
+       struct net_device *dev = (struct net_device *) arg;
+
+       local_irq_disable();
+       if (__netif_rx_schedule_prep(dev))
+               __netif_rx_schedule(dev);
+       local_irq_enable();
+}
+
+
 static int sky2_poll(struct net_device *dev0, int *budget)
 {
        struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
@@ -2133,6 +2145,8 @@ static int sky2_poll(struct net_device *dev0, int *budget)
                sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
        }
 
+       mod_timer(&hw->idle_timer, jiffies + HZ);
+
        netif_rx_complete(dev0);
 
        status = sky2_read32(hw, B0_Y2_SP_LISR);
@@ -2193,7 +2207,7 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
 }
 
 
-static int sky2_reset(struct sky2_hw *hw)
+static int __devinit sky2_reset(struct sky2_hw *hw)
 {
        u16 status;
        u8 t8, pmd_type;
@@ -3276,6 +3290,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
 
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
 
+       setup_timer(&hw->idle_timer, sky2_idle, (unsigned long) dev);
+
        pci_set_drvdata(pdev, hw);
 
        return 0;
@@ -3311,13 +3327,15 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
        if (!hw)
                return;
 
+       del_timer_sync(&hw->idle_timer);
+
+       sky2_write32(hw, B0_IMSK, 0);
        dev0 = hw->dev[0];
        dev1 = hw->dev[1];
        if (dev1)
                unregister_netdev(dev1);
        unregister_netdev(dev0);
 
-       sky2_write32(hw, B0_IMSK, 0);
        sky2_set_power_state(hw, PCI_D3hot);
        sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
        sky2_write8(hw, B0_CTST, CS_RST_SET);