]> err.no Git - linux-2.6/blobdiff - drivers/net/sky2.c
virtio: fix net driver loop case where we fail to restart
[linux-2.6] / drivers / net / sky2.c
index ea117fc3d5e390c6da6b763a61f6d94a071c3c86..a2070db725c903ced2fae8079cf71fd2ae32d182 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ethtool.h>
 #include <linux/pci.h>
+#include <linux/aer.h>
 #include <linux/ip.h>
 #include <net/ip.h>
 #include <linux/tcp.h>
@@ -51,7 +52,7 @@
 #include "sky2.h"
 
 #define DRV_NAME               "sky2"
-#define DRV_VERSION            "1.18"
+#define DRV_VERSION            "1.20"
 #define PFX                    DRV_NAME " "
 
 /*
@@ -120,6 +121,7 @@ static const struct pci_device_id sky2_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4354) }, /* 88E8040 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4357) }, /* 88E8042 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x435A) }, /* 88E8048 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */
@@ -133,6 +135,7 @@ static const struct pci_device_id sky2_id_table[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, /* 88EC042 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436A) }, /* 88E8058 */
        { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436B) }, /* 88E8071 */
+       { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x436C) }, /* 88E8072 */
        { 0 }
 };
 
@@ -155,7 +158,7 @@ static const char *yukon2_name[] = {
 
 static void sky2_set_multicast(struct net_device *dev);
 
-/* Access to external PHY */
+/* Access to PHY via serial interconnect */
 static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
 {
        int i;
@@ -165,13 +168,22 @@ static int gm_phy_write(struct sky2_hw *hw, unsigned port, u16 reg, u16 val)
                    GM_SMI_CT_PHY_AD(PHY_ADDR_MARV) | GM_SMI_CT_REG_AD(reg));
 
        for (i = 0; i < PHY_RETRIES; i++) {
-               if (!(gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_BUSY))
+               u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
+               if (ctrl == 0xffff)
+                       goto io_error;
+
+               if (!(ctrl & GM_SMI_CT_BUSY))
                        return 0;
-               udelay(1);
+
+               udelay(10);
        }
 
-       printk(KERN_WARNING PFX "%s: phy write timeout\n", hw->dev[port]->name);
+       dev_warn(&hw->pdev->dev,"%s: phy write timeout\n", hw->dev[port]->name);
        return -ETIMEDOUT;
+
+io_error:
+       dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
+       return -EIO;
 }
 
 static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
@@ -182,23 +194,29 @@ static int __gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg, u16 *val)
                    | GM_SMI_CT_REG_AD(reg) | GM_SMI_CT_OP_RD);
 
        for (i = 0; i < PHY_RETRIES; i++) {
-               if (gma_read16(hw, port, GM_SMI_CTRL) & GM_SMI_CT_RD_VAL) {
+               u16 ctrl = gma_read16(hw, port, GM_SMI_CTRL);
+               if (ctrl == 0xffff)
+                       goto io_error;
+
+               if (ctrl & GM_SMI_CT_RD_VAL) {
                        *val = gma_read16(hw, port, GM_SMI_DATA);
                        return 0;
                }
 
-               udelay(1);
+               udelay(10);
        }
 
+       dev_warn(&hw->pdev->dev, "%s: phy read timeout\n", hw->dev[port]->name);
        return -ETIMEDOUT;
+io_error:
+       dev_err(&hw->pdev->dev, "%s: phy I/O error\n", hw->dev[port]->name);
+       return -EIO;
 }
 
-static u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
+static inline u16 gm_phy_read(struct sky2_hw *hw, unsigned port, u16 reg)
 {
        u16 v;
-
-       if (__gm_phy_read(hw, port, reg, &v) != 0)
-               printk(KERN_WARNING PFX "%s: phy read timeout\n", hw->dev[port]->name);
+       __gm_phy_read(hw, port, reg, &v);
        return v;
 }
 
@@ -222,21 +240,22 @@ static void sky2_power_on(struct sky2_hw *hw)
                sky2_write8(hw, B2_Y2_CLK_GATE, 0);
 
        if (hw->flags & SKY2_HW_ADV_POWER_CTL) {
+               struct pci_dev *pdev = hw->pdev;
                u32 reg;
 
-               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+               pci_write_config_dword(pdev, PCI_DEV_REG3, 0);
 
-               reg = sky2_pci_read32(hw, PCI_DEV_REG4);
+               pci_read_config_dword(pdev, PCI_DEV_REG4, &reg);
                /* set all bits to 0 except bits 15..12 and 8 */
                reg &= P_ASPM_CONTROL_MSK;
-               sky2_pci_write32(hw, PCI_DEV_REG4, reg);
+               pci_write_config_dword(pdev, PCI_DEV_REG4, reg);
 
-               reg = sky2_pci_read32(hw, PCI_DEV_REG5);
+               pci_read_config_dword(pdev, PCI_DEV_REG5, &reg);
                /* set all bits to 0 except bits 28 & 27 */
                reg &= P_CTL_TIM_VMAIN_AV_MSK;
-               sky2_pci_write32(hw, PCI_DEV_REG5, reg);
+               pci_write_config_dword(pdev, PCI_DEV_REG5, reg);
 
-               sky2_pci_write32(hw, PCI_CFG_REG_1, 0);
+               pci_write_config_dword(pdev, PCI_CFG_REG_1, 0);
 
                /* Enable workaround for dev 4.107 on Yukon-Ultra & Extreme */
                reg = sky2_read32(hw, B2_GP_IO);
@@ -271,8 +290,6 @@ static void sky2_gmac_reset(struct sky2_hw *hw, unsigned port)
 
        /* disable all GMAC IRQ's */
        sky2_write8(hw, SK_REG(port, GMAC_IRQ_MSK), 0);
-       /* disable PHY IRQs */
-       gm_phy_write(hw, port, PHY_MARV_INT_MASK, 0);
 
        gma_write16(hw, port, GM_MC_ADDR_H1, 0);        /* clear MC hash */
        gma_write16(hw, port, GM_MC_ADDR_H2, 0);
@@ -294,10 +311,10 @@ static const u16 copper_fc_adv[] = {
 
 /* flow control to advertise bits when using 1000BaseX */
 static const u16 fiber_fc_adv[] = {
-       [FC_BOTH] = PHY_M_P_BOTH_MD_X,
+       [FC_NONE] = PHY_M_P_NO_PAUSE_X,
        [FC_TX]   = PHY_M_P_ASYM_MD_X,
        [FC_RX]   = PHY_M_P_SYM_MD_X,
-       [FC_NONE] = PHY_M_P_NO_PAUSE_X,
+       [FC_BOTH] = PHY_M_P_BOTH_MD_X,
 };
 
 /* flow control to GMA disable bits */
@@ -602,25 +619,24 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port)
 
 static void sky2_phy_power(struct sky2_hw *hw, unsigned port, int onoff)
 {
+       struct pci_dev *pdev = hw->pdev;
        u32 reg1;
-       static const u32 phy_power[]
-               = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD };
-
-       /* looks like this XL is back asswards .. */
-       if (hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
-               onoff = !onoff;
+       static const u32 phy_power[] = { PCI_Y2_PHY1_POWD, PCI_Y2_PHY2_POWD };
+       static const u32 coma_mode[] = { PCI_Y2_PHY1_COMA, PCI_Y2_PHY2_COMA };
 
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-       reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
+       pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1);
+       /* Turn on/off phy power saving */
        if (onoff)
-               /* Turn off phy power saving */
                reg1 &= ~phy_power[port];
        else
                reg1 |= phy_power[port];
 
-       sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
-       sky2_pci_read32(hw, PCI_DEV_REG1);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
+       if (onoff && hw->chip_id == CHIP_ID_YUKON_XL && hw->chip_rev > 1)
+               reg1 |= coma_mode[port];
+
+       pci_write_config_dword(pdev, PCI_DEV_REG1, reg1);
+       pci_read_config_dword(pdev, PCI_DEV_REG1, &reg1);
+
        udelay(100);
 }
 
@@ -688,11 +704,9 @@ static void sky2_wol_init(struct sky2_port *sky2)
        sky2_write16(hw, WOL_REGS(port, WOL_CTRL_STAT), ctrl);
 
        /* Turn on legacy PCI-Express PME mode */
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-       reg1 = sky2_pci_read32(hw, PCI_DEV_REG1);
+       pci_read_config_dword(hw->pdev, PCI_DEV_REG1, &reg1);
        reg1 |= PCI_Y2_PME_LEGACY;
-       sky2_pci_write32(hw, PCI_DEV_REG1, reg1);
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
+       pci_write_config_dword(hw->pdev, PCI_DEV_REG1, reg1);
 
        /* block receiver */
        sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_RST_SET);
@@ -1130,7 +1144,7 @@ static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp
        u16 port = sky2->port;
 
        netif_tx_lock_bh(dev);
-       netif_poll_disable(sky2->hw->dev[0]);
+       napi_disable(&hw->napi);
 
        sky2->vlgrp = grp;
        if (grp) {
@@ -1145,7 +1159,7 @@ static void sky2_vlan_rx_register(struct net_device *dev, struct vlan_group *grp
                             TX_VLAN_TAG_OFF);
        }
 
-       netif_poll_enable(sky2->hw->dev[0]);
+       napi_enable(&hw->napi);
        netif_tx_unlock_bh(dev);
 }
 #endif
@@ -1309,9 +1323,9 @@ static int sky2_up(struct net_device *dev)
                struct sky2_port *osky2 = netdev_priv(otherdev);
                u16 cmd;
 
-               cmd = sky2_pci_read16(hw, cap + PCI_X_CMD);
+               pci_read_config_word(hw->pdev, cap + PCI_X_CMD, &cmd);
                cmd &= ~PCI_X_CMD_MAX_SPLIT;
-               sky2_pci_write16(hw, cap + PCI_X_CMD, cmd);
+               pci_write_config_word(hw->pdev, cap + PCI_X_CMD, cmd);
 
                sky2->rx_csum = 0;
                osky2->rx_csum = 0;
@@ -1632,8 +1646,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
                                printk(KERN_DEBUG "%s: tx done %u\n",
                                       dev->name, idx);
 
-                       sky2->net_stats.tx_packets++;
-                       sky2->net_stats.tx_bytes += re->skb->len;
+                       dev->stats.tx_packets++;
+                       dev->stats.tx_bytes += re->skb->len;
 
                        dev_kfree_skb_any(re->skb);
                        sky2->tx_next = RING_NEXT(idx, TX_RING_SIZE);
@@ -1681,6 +1695,8 @@ static int sky2_down(struct net_device *dev)
        imask &= ~portirq_msk[port];
        sky2_write32(hw, B0_IMSK, imask);
 
+       synchronize_irq(hw->pdev->irq);
+
        sky2_gmac_reset(hw, port);
 
        /* Stop transmitter */
@@ -1694,6 +1710,9 @@ static int sky2_down(struct net_device *dev)
        ctrl &= ~(GM_GPCR_TX_ENA | GM_GPCR_RX_ENA);
        gma_write16(hw, port, GM_GP_CTRL, ctrl);
 
+       /* Make sure no packets are pending */
+       napi_synchronize(&hw->napi);
+
        sky2_write8(hw, SK_REG(port, GPHY_CTRL), GPC_RST_SET);
 
        /* Workaround shared GMAC reset */
@@ -1731,8 +1750,6 @@ static int sky2_down(struct net_device *dev)
        /* turn off LED's */
        sky2_write16(hw, B0_Y2LED, LED_STAT_OFF);
 
-       synchronize_irq(hw->pdev->irq);
-
        sky2_tx_clean(dev);
        sky2_rx_clean(sky2);
 
@@ -1803,29 +1820,6 @@ static void sky2_link_up(struct sky2_port *sky2)
        sky2_write8(hw, SK_REG(port, LNK_LED_REG),
                    LINKLED_ON | LINKLED_BLINK_OFF | LINKLED_LINKSYNC_OFF);
 
-       if (hw->flags & SKY2_HW_NEWER_PHY) {
-               u16 pg = gm_phy_read(hw, port, PHY_MARV_EXT_ADR);
-               u16 led = PHY_M_LEDC_LOS_CTRL(1);       /* link active */
-
-               switch(sky2->speed) {
-               case SPEED_10:
-                       led |= PHY_M_LEDC_INIT_CTRL(7);
-                       break;
-
-               case SPEED_100:
-                       led |= PHY_M_LEDC_STA1_CTRL(7);
-                       break;
-
-               case SPEED_1000:
-                       led |= PHY_M_LEDC_STA0_CTRL(7);
-                       break;
-               }
-
-               gm_phy_write(hw, port, PHY_MARV_EXT_ADR, 3);
-               gm_phy_write(hw, port, PHY_MARV_PHY_CTRL, led);
-               gm_phy_write(hw, port, PHY_MARV_EXT_ADR, pg);
-       }
-
        if (netif_msg_link(sky2))
                printk(KERN_INFO PFX
                       "%s: Link is up at %d Mbps, %s duplex, flow control %s\n",
@@ -2016,7 +2010,7 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
 
        dev->trans_start = jiffies;     /* prevent tx timeout */
        netif_stop_queue(dev);
-       netif_poll_disable(hw->dev[0]);
+       napi_disable(&hw->napi);
 
        synchronize_irq(hw->pdev->irq);
 
@@ -2043,12 +2037,13 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
        err = sky2_rx_start(sky2);
        sky2_write32(hw, B0_IMSK, imask);
 
+       napi_enable(&hw->napi);
+
        if (err)
                dev_close(dev);
        else {
                gma_write16(hw, port, GM_GP_CTRL, ctl);
 
-               netif_poll_enable(hw->dev[0]);
                netif_wake_queue(dev);
        }
 
@@ -2195,16 +2190,16 @@ resubmit:
 len_error:
        /* Truncation of overlength packets
           causes PHY length to not match MAC length */
-       ++sky2->net_stats.rx_length_errors;
+       ++dev->stats.rx_length_errors;
        if (netif_msg_rx_err(sky2) && net_ratelimit())
                pr_info(PFX "%s: rx length error: status %#x length %d\n",
                        dev->name, status, length);
        goto resubmit;
 
 error:
-       ++sky2->net_stats.rx_errors;
+       ++dev->stats.rx_errors;
        if (status & GMR_FS_RX_FF_OV) {
-               sky2->net_stats.rx_over_errors++;
+               dev->stats.rx_over_errors++;
                goto resubmit;
        }
 
@@ -2213,11 +2208,11 @@ error:
                       dev->name, status, length);
 
        if (status & (GMR_FS_LONG_ERR | GMR_FS_UN_SIZE))
-               sky2->net_stats.rx_length_errors++;
+               dev->stats.rx_length_errors++;
        if (status & GMR_FS_FRAGMENT)
-               sky2->net_stats.rx_frame_errors++;
+               dev->stats.rx_frame_errors++;
        if (status & GMR_FS_CRC_ERR)
-               sky2->net_stats.rx_crc_errors++;
+               dev->stats.rx_crc_errors++;
 
        goto resubmit;
 }
@@ -2235,36 +2230,40 @@ static inline void sky2_tx_done(struct net_device *dev, u16 last)
 }
 
 /* Process status response ring */
-static int sky2_status_intr(struct sky2_hw *hw, int to_do)
+static int sky2_status_intr(struct sky2_hw *hw, int to_do, u16 idx)
 {
        int work_done = 0;
        unsigned rx[2] = { 0, 0 };
-       u16 hwidx = sky2_read16(hw, STAT_PUT_IDX);
 
        rmb();
-
-       while (hw->st_idx != hwidx) {
+       do {
                struct sky2_port *sky2;
                struct sky2_status_le *le  = hw->st_le + hw->st_idx;
-               unsigned port = le->css & CSS_LINK_BIT;
+               unsigned port;
                struct net_device *dev;
                struct sk_buff *skb;
                u32 status;
                u16 length;
+               u8 opcode = le->opcode;
+
+               if (!(opcode & HW_OWNER))
+                       break;
 
                hw->st_idx = RING_NEXT(hw->st_idx, STATUS_RING_SIZE);
 
+               port = le->css & CSS_LINK_BIT;
                dev = hw->dev[port];
                sky2 = netdev_priv(dev);
                length = le16_to_cpu(le->length);
                status = le32_to_cpu(le->status);
 
-               switch (le->opcode & ~HW_OWNER) {
+               le->opcode = 0;
+               switch (opcode & ~HW_OWNER) {
                case OP_RXSTAT:
                        ++rx[port];
                        skb = sky2_receive(dev, length, status);
                        if (unlikely(!skb)) {
-                               sky2->net_stats.rx_dropped++;
+                               dev->stats.rx_dropped++;
                                break;
                        }
 
@@ -2279,8 +2278,8 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
                        }
 
                        skb->protocol = eth_type_trans(skb, dev);
-                       sky2->net_stats.rx_packets++;
-                       sky2->net_stats.rx_bytes += skb->len;
+                       dev->stats.rx_packets++;
+                       dev->stats.rx_bytes += skb->len;
                        dev->last_rx = jiffies;
 
 #ifdef SKY2_VLAN_TAG_USED
@@ -2352,9 +2351,9 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
                default:
                        if (net_ratelimit())
                                printk(KERN_WARNING PFX
-                                      "unknown status opcode 0x%x\n", le->opcode);
+                                      "unknown status opcode 0x%x\n", opcode);
                }
-       }
+       } while (hw->st_idx != idx);
 
        /* Fully processed status ring so clear irq */
        sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
@@ -2415,7 +2414,11 @@ static void sky2_hw_error(struct sky2_hw *hw, unsigned port, u32 status)
 
 static void sky2_hw_intr(struct sky2_hw *hw)
 {
+       struct pci_dev *pdev = hw->pdev;
        u32 status = sky2_read32(hw, B0_HWE_ISRC);
+       u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
+
+       status &= hwmsk;
 
        if (status & Y2_IS_TIST_OV)
                sky2_write8(hw, GMAC_TI_ST_CTRL, GMT_ST_CLR_IRQ);
@@ -2423,38 +2426,37 @@ static void sky2_hw_intr(struct sky2_hw *hw)
        if (status & (Y2_IS_MST_ERR | Y2_IS_IRQ_STAT)) {
                u16 pci_err;
 
-               pci_err = sky2_pci_read16(hw, PCI_STATUS);
+               pci_read_config_word(pdev, PCI_STATUS, &pci_err);
                if (net_ratelimit())
-                       dev_err(&hw->pdev->dev, "PCI hardware error (0x%x)\n",
+                       dev_err(&pdev->dev, "PCI hardware error (0x%x)\n",
                                pci_err);
 
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-               sky2_pci_write16(hw, PCI_STATUS,
-                                pci_err | PCI_STATUS_ERROR_BITS);
-               sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
+               pci_write_config_word(pdev, PCI_STATUS,
+                                     pci_err | PCI_STATUS_ERROR_BITS);
        }
 
        if (status & Y2_IS_PCI_EXP) {
                /* PCI-Express uncorrectable Error occurred */
-               u32 pex_err;
+               int aer = pci_find_aer_capability(hw->pdev);
+               u32 err;
 
-               pex_err = sky2_pci_read32(hw, PEX_UNC_ERR_STAT);
+               if (aer) {
+                       pci_read_config_dword(pdev, aer + PCI_ERR_UNCOR_STATUS,
+                                             &err);
+                       pci_cleanup_aer_uncorrect_error_status(pdev);
+               } else {
+                       /* Either AER not configured, or not working
+                        * because of bad MMCONFIG, so just do recover
+                        * manually.
+                        */
+                       err = sky2_read32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS);
+                       sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
+                                    0xfffffffful);
+               }
 
                if (net_ratelimit())
-                       dev_err(&hw->pdev->dev, "PCI Express error (0x%x)\n",
-                               pex_err);
-
-               /* clear the interrupt */
-               sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-               sky2_pci_write32(hw, PEX_UNC_ERR_STAT,
-                                      0xffffffffUL);
-               sky2_write32(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
-
-               if (pex_err & PEX_FATAL_ERRORS) {
-                       u32 hwmsk = sky2_read32(hw, B0_HWE_IMSK);
-                       hwmsk &= ~Y2_IS_PCI_EXP;
-                       sky2_write32(hw, B0_HWE_IMSK, hwmsk);
-               }
+                       dev_err(&pdev->dev, "PCI Express error (0x%x)\n", err);
+
        }
 
        if (status & Y2_HWE_L1_MASK)
@@ -2481,12 +2483,12 @@ static void sky2_mac_intr(struct sky2_hw *hw, unsigned port)
                gma_read16(hw, port, GM_TX_IRQ_SRC);
 
        if (status & GM_IS_RX_FF_OR) {
-               ++sky2->net_stats.rx_fifo_errors;
+               ++dev->stats.rx_fifo_errors;
                sky2_write8(hw, SK_REG(port, RX_GMF_CTRL_T), GMF_CLI_RX_FO);
        }
 
        if (status & GM_IS_TX_FF_UR) {
-               ++sky2->net_stats.tx_fifo_errors;
+               ++dev->stats.tx_fifo_errors;
                sky2_write8(hw, SK_REG(port, TX_GMF_CTRL_T), GMF_CLI_TX_FU);
        }
 }
@@ -2544,18 +2546,15 @@ static int sky2_rx_hung(struct net_device *dev)
 static void sky2_watchdog(unsigned long arg)
 {
        struct sky2_hw *hw = (struct sky2_hw *) arg;
-       struct net_device *dev;
 
        /* Check for lost IRQ once a second */
        if (sky2_read32(hw, B0_ISRC)) {
-               dev = hw->dev[0];
-               if (__netif_rx_schedule_prep(dev))
-                       __netif_rx_schedule(dev);
+               napi_schedule(&hw->napi);
        } else {
                int i, active = 0;
 
                for (i = 0; i < hw->ports; i++) {
-                       dev = hw->dev[i];
+                       struct net_device *dev = hw->dev[i];
                        if (!netif_running(dev))
                                continue;
                        ++active;
@@ -2605,11 +2604,12 @@ static void sky2_err_intr(struct sky2_hw *hw, u32 status)
                sky2_le_error(hw, 1, Q_XA2, TX_RING_SIZE);
 }
 
-static int sky2_poll(struct net_device *dev0, int *budget)
+static int sky2_poll(struct napi_struct *napi, int work_limit)
 {
-       struct sky2_hw *hw = ((struct sky2_port *) netdev_priv(dev0))->hw;
-       int work_done;
+       struct sky2_hw *hw = container_of(napi, struct sky2_hw, napi);
        u32 status = sky2_read32(hw, B0_Y2_SP_EISR);
+       int work_done = 0;
+       u16 idx;
 
        if (unlikely(status & Y2_IS_ERROR))
                sky2_err_intr(hw, status);
@@ -2620,13 +2620,12 @@ static int sky2_poll(struct net_device *dev0, int *budget)
        if (status & Y2_IS_IRQ_PHY2)
                sky2_phy_intr(hw, 1);
 
-       work_done = sky2_status_intr(hw, min(dev0->quota, *budget));
-       *budget -= work_done;
-       dev0->quota -= work_done;
+       while ((idx = sky2_read16(hw, STAT_PUT_IDX)) != hw->st_idx) {
+               work_done += sky2_status_intr(hw, work_limit - work_done, idx);
 
-       /* More work? */
-       if (hw->st_idx != sky2_read16(hw, STAT_PUT_IDX))
-               return 1;
+               if (work_done >= work_limit)
+                       goto done;
+       }
 
        /* Bug/Errata workaround?
         * Need to kick the TX irq moderation timer.
@@ -2635,16 +2634,16 @@ static int sky2_poll(struct net_device *dev0, int *budget)
                sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
                sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_START);
        }
-       netif_rx_complete(dev0);
-
+       napi_complete(napi);
        sky2_read32(hw, B0_Y2_SP_LISR);
-       return 0;
+done:
+
+       return work_done;
 }
 
 static irqreturn_t sky2_intr(int irq, void *dev_id)
 {
        struct sky2_hw *hw = dev_id;
-       struct net_device *dev0 = hw->dev[0];
        u32 status;
 
        /* Reading this mask interrupts as side effect */
@@ -2653,8 +2652,8 @@ static irqreturn_t sky2_intr(int irq, void *dev_id)
                return IRQ_NONE;
 
        prefetch(&hw->st_le[hw->st_idx]);
-       if (likely(__netif_rx_schedule_prep(dev0)))
-               __netif_rx_schedule(dev0);
+
+       napi_schedule(&hw->napi);
 
        return IRQ_HANDLED;
 }
@@ -2663,10 +2662,8 @@ static irqreturn_t sky2_intr(int irq, void *dev_id)
 static void sky2_netpoll(struct net_device *dev)
 {
        struct sky2_port *sky2 = netdev_priv(dev);
-       struct net_device *dev0 = sky2->hw->dev[0];
 
-       if (netif_running(dev) && __netif_rx_schedule_prep(dev0))
-               __netif_rx_schedule(dev0);
+       napi_schedule(&sky2->hw->napi);
 }
 #endif
 
@@ -2706,10 +2703,13 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
 
 static int __devinit sky2_init(struct sky2_hw *hw)
 {
+       int rc;
        u8 t8;
 
-       /* Enable all clocks */
-       sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+       /* Enable all clocks and check for bad PCI access */
+       rc = pci_write_config_dword(hw->pdev, PCI_DEV_REG3, 0);
+       if (rc)
+               return rc;
 
        sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
@@ -2783,8 +2783,10 @@ static int __devinit sky2_init(struct sky2_hw *hw)
 
 static void sky2_reset(struct sky2_hw *hw)
 {
+       struct pci_dev *pdev = hw->pdev;
        u16 status;
-       int i;
+       int i, cap;
+       u32 hwe_mask = Y2_HWE_ALL_MASK;
 
        /* disable ASF */
        if (hw->chip_id == CHIP_ID_YUKON_EX) {
@@ -2800,19 +2802,38 @@ static void sky2_reset(struct sky2_hw *hw)
        sky2_write8(hw, B0_CTST, CS_RST_SET);
        sky2_write8(hw, B0_CTST, CS_RST_CLR);
 
-       /* clear PCI errors, if any */
-       status = sky2_pci_read16(hw, PCI_STATUS);
-
+       /* allow writes to PCI config */
        sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
-       sky2_pci_write16(hw, PCI_STATUS, status | PCI_STATUS_ERROR_BITS);
 
+       /* clear PCI errors, if any */
+       pci_read_config_word(pdev, PCI_STATUS, &status);
+       status |= PCI_STATUS_ERROR_BITS;
+       pci_write_config_word(pdev, PCI_STATUS, status);
 
        sky2_write8(hw, B0_CTST, CS_MRST_CLR);
 
-       /* clear any PEX errors */
-       if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP))
-               sky2_pci_write32(hw, PEX_UNC_ERR_STAT, 0xffffffffUL);
+       cap = pci_find_capability(pdev, PCI_CAP_ID_EXP);
+       if (cap) {
+               if (pci_find_aer_capability(pdev)) {
+                       /* Check for advanced error reporting */
+                       pci_cleanup_aer_uncorrect_error_status(pdev);
+                       pci_cleanup_aer_correct_error_status(pdev);
+               } else {
+                       dev_warn(&pdev->dev,
+                               "PCI Express Advanced Error Reporting"
+                               " not configured or MMCONFIG problem?\n");
+
+                       sky2_write32(hw, Y2_CFG_AER + PCI_ERR_UNCOR_STATUS,
+                                    0xfffffffful);
+               }
+
+               /* If error bit is stuck on ignore it */
+               if (sky2_read32(hw, B0_HWE_ISRC) & Y2_IS_PCI_EXP)
+                       dev_info(&pdev->dev, "ignoring stuck error report bit\n");
 
+               else if (pci_enable_pcie_error_reporting(pdev))
+                       hwe_mask |= Y2_IS_PCI_EXP;
+       }
 
        sky2_power_on(hw);
 
@@ -2826,8 +2847,6 @@ static void sky2_reset(struct sky2_hw *hw)
                                     | GMC_BYP_RETR_ON);
        }
 
-       sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_OFF);
-
        /* Clear I2C IRQ noise */
        sky2_write32(hw, B2_I2C_IRQ, 1);
 
@@ -2866,7 +2885,7 @@ static void sky2_reset(struct sky2_hw *hw)
                sky2_write8(hw, RAM_BUFFER(i, B3_RI_RTO_XS2), SK_RI_TO_53);
        }
 
-       sky2_write32(hw, B0_HWE_IMSK, Y2_HWE_ALL_MASK);
+       sky2_write32(hw, B0_HWE_IMSK, hwe_mask);
 
        for (i = 0; i < hw->ports; i++)
                sky2_gmac_reset(hw, i);
@@ -2913,8 +2932,7 @@ static void sky2_restart(struct work_struct *work)
        rtnl_lock();
        sky2_write32(hw, B0_IMSK, 0);
        sky2_read32(hw, B0_IMSK);
-
-       netif_poll_disable(hw->dev[0]);
+       napi_disable(&hw->napi);
 
        for (i = 0; i < hw->ports; i++) {
                dev = hw->dev[i];
@@ -2924,7 +2942,7 @@ static void sky2_restart(struct work_struct *work)
 
        sky2_reset(hw);
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
-       netif_poll_enable(hw->dev[0]);
+       napi_enable(&hw->napi);
 
        for (i = 0; i < hw->ports; i++) {
                dev = hw->dev[i];
@@ -3192,9 +3210,14 @@ static void sky2_set_msglevel(struct net_device *netdev, u32 value)
        sky2->msg_enable = value;
 }
 
-static int sky2_get_stats_count(struct net_device *dev)
+static int sky2_get_sset_count(struct net_device *dev, int sset)
 {
-       return ARRAY_SIZE(sky2_stats);
+       switch (sset) {
+       case ETH_SS_STATS:
+               return ARRAY_SIZE(sky2_stats);
+       default:
+               return -EOPNOTSUPP;
+       }
 }
 
 static void sky2_get_ethtool_stats(struct net_device *dev,
@@ -3218,12 +3241,6 @@ static void sky2_get_strings(struct net_device *dev, u32 stringset, u8 * data)
        }
 }
 
-static struct net_device_stats *sky2_get_stats(struct net_device *dev)
-{
-       struct sky2_port *sky2 = netdev_priv(dev);
-       return &sky2->net_stats;
-}
-
 static int sky2_set_mac_address(struct net_device *dev, void *p)
 {
        struct sky2_port *sky2 = netdev_priv(dev);
@@ -3564,20 +3581,64 @@ static void sky2_get_regs(struct net_device *dev, struct ethtool_regs *regs,
 {
        const struct sky2_port *sky2 = netdev_priv(dev);
        const void __iomem *io = sky2->hw->regs;
+       unsigned int b;
 
        regs->version = 1;
-       memset(p, 0, regs->len);
-
-       memcpy_fromio(p, io, B3_RAM_ADDR);
 
-       /* skip diagnostic ram region */
-       memcpy_fromio(p + B3_RI_WTO_R1, io + B3_RI_WTO_R1, 0x2000 - B3_RI_WTO_R1);
+       for (b = 0; b < 128; b++) {
+               /* This complicated switch statement is to make sure and
+                * only access regions that are unreserved.
+                * Some blocks are only valid on dual port cards.
+                * and block 3 has some special diagnostic registers that
+                * are poison.
+                */
+               switch (b) {
+               case 3:
+                       /* skip diagnostic ram region */
+                       memcpy_fromio(p + 0x10, io + 0x10, 128 - 0x10);
+                       break;
 
-       /* copy GMAC registers */
-       memcpy_fromio(p + BASE_GMAC_1, io + BASE_GMAC_1, 0x1000);
-       if (sky2->hw->ports > 1)
-               memcpy_fromio(p + BASE_GMAC_2, io + BASE_GMAC_2, 0x1000);
+               /* dual port cards only */
+               case 5:         /* Tx Arbiter 2 */
+               case 9:         /* RX2 */
+               case 14 ... 15: /* TX2 */
+               case 17: case 19: /* Ram Buffer 2 */
+               case 22 ... 23: /* Tx Ram Buffer 2 */
+               case 25:        /* Rx MAC Fifo 1 */
+               case 27:        /* Tx MAC Fifo 2 */
+               case 31:        /* GPHY 2 */
+               case 40 ... 47: /* Pattern Ram 2 */
+               case 52: case 54: /* TCP Segmentation 2 */
+               case 112 ... 116: /* GMAC 2 */
+                       if (sky2->hw->ports == 1)
+                               goto reserved;
+                       /* fall through */
+               case 0:         /* Control */
+               case 2:         /* Mac address */
+               case 4:         /* Tx Arbiter 1 */
+               case 7:         /* PCI express reg */
+               case 8:         /* RX1 */
+               case 12 ... 13: /* TX1 */
+               case 16: case 18:/* Rx Ram Buffer 1 */
+               case 20 ... 21: /* Tx Ram Buffer 1 */
+               case 24:        /* Rx MAC Fifo 1 */
+               case 26:        /* Tx MAC Fifo 1 */
+               case 28 ... 29: /* Descriptor and status unit */
+               case 30:        /* GPHY 1*/
+               case 32 ... 39: /* Pattern Ram 1 */
+               case 48: case 50: /* TCP Segmentation 1 */
+               case 56 ... 60: /* PCI space */
+               case 80 ... 84: /* GMAC 1 */
+                       memcpy_fromio(p, io, 128);
+                       break;
+               default:
+reserved:
+                       memset(p, 0, 128);
+               }
 
+               p += 128;
+               io += 128;
+       }
 }
 
 /* In order to do Jumbo packets on these chips, need to turn off the
@@ -3613,26 +3674,31 @@ static int sky2_get_eeprom_len(struct net_device *dev)
        struct sky2_port *sky2 = netdev_priv(dev);
        u16 reg2;
 
-       reg2 = sky2_pci_read32(sky2->hw, PCI_DEV_REG2);
+       pci_read_config_word(sky2->hw->pdev, PCI_DEV_REG2, &reg2);
        return 1 << ( ((reg2 & PCI_VPD_ROM_SZ) >> 14) + 8);
 }
 
-static u32 sky2_vpd_read(struct sky2_hw *hw, int cap, u16 offset)
+static u32 sky2_vpd_read(struct pci_dev *pdev, int cap, u16 offset)
 {
-       sky2_pci_write16(hw, cap + PCI_VPD_ADDR, offset);
+       u32 val;
+
+       pci_write_config_word(pdev, cap + PCI_VPD_ADDR, offset);
 
-       while (!(sky2_pci_read16(hw, cap + PCI_VPD_ADDR) & PCI_VPD_ADDR_F))
-                       cpu_relax();
-       return sky2_pci_read32(hw, cap + PCI_VPD_DATA);
+       do {
+               pci_read_config_word(pdev, cap + PCI_VPD_ADDR, &offset);
+       } while (!(offset & PCI_VPD_ADDR_F));
+
+       pci_read_config_dword(pdev, cap + PCI_VPD_DATA, &val);
+       return val;
 }
 
-static void sky2_vpd_write(struct sky2_hw *hw, int cap, u16 offset, u32 val)
+static void sky2_vpd_write(struct pci_dev *pdev, int cap, u16 offset, u32 val)
 {
-       sky2_pci_write32(hw, cap + PCI_VPD_DATA, val);
-       sky2_pci_write16(hw, cap + PCI_VPD_ADDR, offset | PCI_VPD_ADDR_F);
+       pci_write_config_word(pdev, cap + PCI_VPD_DATA, val);
+       pci_write_config_dword(pdev, cap + PCI_VPD_ADDR, offset | PCI_VPD_ADDR_F);
        do {
-               cpu_relax();
-       } while (sky2_pci_read16(hw, cap + PCI_VPD_ADDR) & PCI_VPD_ADDR_F);
+               pci_read_config_word(pdev, cap + PCI_VPD_ADDR, &offset);
+       } while (offset & PCI_VPD_ADDR_F);
 }
 
 static int sky2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
@@ -3649,7 +3715,7 @@ static int sky2_get_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
        eeprom->magic = SKY2_EEPROM_MAGIC;
 
        while (length > 0) {
-               u32 val = sky2_vpd_read(sky2->hw, cap, offset);
+               u32 val = sky2_vpd_read(sky2->hw->pdev, cap, offset);
                int n = min_t(int, length, sizeof(val));
 
                memcpy(data, &val, n);
@@ -3679,10 +3745,10 @@ static int sky2_set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom
                int n = min_t(int, length, sizeof(val));
 
                if (n < sizeof(val))
-                       val = sky2_vpd_read(sky2->hw, cap, offset);
+                       val = sky2_vpd_read(sky2->hw->pdev, cap, offset);
                memcpy(&val, data, n);
 
-               sky2_vpd_write(sky2->hw, cap, offset, val);
+               sky2_vpd_write(sky2->hw->pdev, cap, offset, val);
 
                length -= n;
                data += n;
@@ -3707,11 +3773,8 @@ static const struct ethtool_ops sky2_ethtool_ops = {
        .get_eeprom_len = sky2_get_eeprom_len,
        .get_eeprom     = sky2_get_eeprom,
        .set_eeprom     = sky2_set_eeprom,
-       .get_sg         = ethtool_op_get_sg,
        .set_sg         = ethtool_op_set_sg,
-       .get_tx_csum    = ethtool_op_get_tx_csum,
        .set_tx_csum    = sky2_set_tx_csum,
-       .get_tso        = ethtool_op_get_tso,
        .set_tso        = sky2_set_tso,
        .get_rx_csum    = sky2_get_rx_csum,
        .set_rx_csum    = sky2_set_rx_csum,
@@ -3723,7 +3786,7 @@ static const struct ethtool_ops sky2_ethtool_ops = {
        .get_pauseparam = sky2_get_pauseparam,
        .set_pauseparam = sky2_set_pauseparam,
        .phys_id        = sky2_phys_id,
-       .get_stats_count = sky2_get_stats_count,
+       .get_sset_count = sky2_get_sset_count,
        .get_ethtool_stats = sky2_get_ethtool_stats,
 };
 
@@ -3735,7 +3798,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
 {
        struct net_device *dev = seq->private;
        const struct sky2_port *sky2 = netdev_priv(dev);
-       const struct sky2_hw *hw = sky2->hw;
+       struct sky2_hw *hw = sky2->hw;
        unsigned port = sky2->port;
        unsigned idx, last;
        int sop;
@@ -3748,7 +3811,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
                   sky2_read32(hw, B0_IMSK),
                   sky2_read32(hw, B0_Y2_SP_ICR));
 
-       netif_poll_disable(hw->dev[0]);
+       napi_disable(&hw->napi);
        last = sky2_read16(hw, STAT_PUT_IDX);
 
        if (hw->st_idx == last)
@@ -3818,7 +3881,7 @@ static int sky2_debug_show(struct seq_file *seq, void *v)
                   last = sky2_read16(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_PUT_IDX)),
                   sky2_read16(hw, Y2_QADDR(rxqaddr[port], PREF_UNIT_LAST_IDX)));
 
-       netif_poll_enable(hw->dev[0]);
+       napi_enable(&hw->napi);
        return 0;
 }
 
@@ -3843,42 +3906,34 @@ static int sky2_device_event(struct notifier_block *unused,
                             unsigned long event, void *ptr)
 {
        struct net_device *dev = ptr;
+       struct sky2_port *sky2 = netdev_priv(dev);
 
-       if (dev->open == sky2_up) {
-               struct sky2_port *sky2 = netdev_priv(dev);
+       if (dev->open != sky2_up || !sky2_debug)
+               return NOTIFY_DONE;
 
-               switch(event) {
-               case NETDEV_CHANGENAME:
-                       if (!netif_running(dev))
-                               break;
-                       /* fallthrough */
-               case NETDEV_DOWN:
-               case NETDEV_GOING_DOWN:
-                       if (sky2->debugfs) {
-                               printk(KERN_DEBUG PFX "%s: remove debugfs\n",
-                                      dev->name);
-                               debugfs_remove(sky2->debugfs);
-                               sky2->debugfs = NULL;
-                       }
+       switch(event) {
+       case NETDEV_CHANGENAME:
+               if (sky2->debugfs) {
+                       sky2->debugfs = debugfs_rename(sky2_debug, sky2->debugfs,
+                                                      sky2_debug, dev->name);
+               }
+               break;
 
-                       if (event != NETDEV_CHANGENAME)
-                               break;
-                       /* fallthrough for changename */
-               case NETDEV_UP:
-                       if (sky2_debug) {
-                               struct dentry *d;
-                               d = debugfs_create_file(dev->name, S_IRUGO,
-                                                       sky2_debug, dev,
-                                                       &sky2_debug_fops);
-                               if (d == NULL || IS_ERR(d))
-                                       printk(KERN_INFO PFX
-                                              "%s: debugfs create failed\n",
-                                              dev->name);
-                               else
-                                       sky2->debugfs = d;
-                       }
-                       break;
+       case NETDEV_GOING_DOWN:
+               if (sky2->debugfs) {
+                       printk(KERN_DEBUG PFX "%s: remove debugfs\n",
+                              dev->name);
+                       debugfs_remove(sky2->debugfs);
+                       sky2->debugfs = NULL;
                }
+               break;
+
+       case NETDEV_UP:
+               sky2->debugfs = debugfs_create_file(dev->name, S_IRUGO,
+                                                   sky2_debug, dev,
+                                                   &sky2_debug_fops);
+               if (IS_ERR(sky2->debugfs))
+                       sky2->debugfs = NULL;
        }
 
        return NOTIFY_DONE;
@@ -3925,31 +3980,23 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
        struct net_device *dev = alloc_etherdev(sizeof(*sky2));
 
        if (!dev) {
-               dev_err(&hw->pdev->dev, "etherdev alloc failed");
+               dev_err(&hw->pdev->dev, "etherdev alloc failed\n");
                return NULL;
        }
 
-       SET_MODULE_OWNER(dev);
        SET_NETDEV_DEV(dev, &hw->pdev->dev);
        dev->irq = hw->pdev->irq;
        dev->open = sky2_up;
        dev->stop = sky2_down;
        dev->do_ioctl = sky2_ioctl;
        dev->hard_start_xmit = sky2_xmit_frame;
-       dev->get_stats = sky2_get_stats;
        dev->set_multicast_list = sky2_set_multicast;
        dev->set_mac_address = sky2_set_mac_address;
        dev->change_mtu = sky2_change_mtu;
        SET_ETHTOOL_OPS(dev, &sky2_ethtool_ops);
        dev->tx_timeout = sky2_tx_timeout;
        dev->watchdog_timeo = TX_WATCHDOG;
-       if (port == 0)
-               dev->poll = sky2_poll;
-       dev->weight = NAPI_WEIGHT;
 #ifdef CONFIG_NET_POLL_CONTROLLER
-       /* Network console (only works on port 0)
-        * because netpoll makes assumptions about NAPI
-        */
        if (port == 0)
                dev->poll_controller = sky2_netpoll;
 #endif
@@ -4000,12 +4047,11 @@ static __devinit struct net_device *sky2_init_netdev(struct sky2_hw *hw,
 static void __devinit sky2_show_addr(struct net_device *dev)
 {
        const struct sky2_port *sky2 = netdev_priv(dev);
+       DECLARE_MAC_BUF(mac);
 
        if (netif_msg_probe(sky2))
-               printk(KERN_INFO PFX "%s: addr %02x:%02x:%02x:%02x:%02x:%02x\n",
-                      dev->name,
-                      dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2],
-                      dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
+               printk(KERN_INFO PFX "%s: addr %s\n",
+                      dev->name, print_mac(mac, dev->dev_addr));
 }
 
 /* Handle software interrupt used during MSI test */
@@ -4138,15 +4184,14 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
         */
        {
                u32 reg;
-               reg = sky2_pci_read32(hw, PCI_DEV_REG2);
+               pci_read_config_dword(pdev,PCI_DEV_REG2, &reg);
                reg &= ~PCI_REV_DESC;
-               sky2_pci_write32(hw, PCI_DEV_REG2, reg);
+               pci_write_config_dword(pdev, PCI_DEV_REG2, reg);
        }
 #endif
 
        /* ring for status responses */
-       hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
-                                        &hw->st_dma);
+       hw->st_le = pci_alloc_consistent(pdev, STATUS_LE_BYTES, &hw->st_dma);
        if (!hw->st_le)
                goto err_out_iounmap;
 
@@ -4181,6 +4226,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
                goto err_out_free_netdev;
        }
 
+       netif_napi_add(dev, &hw->napi, sky2_poll, NAPI_WEIGHT);
+
        err = request_irq(pdev->irq, sky2_intr,
                          (hw->flags & SKY2_HW_USE_MSI) ? 0 : IRQF_SHARED,
                          dev->name, hw);
@@ -4189,6 +4236,7 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
                goto err_out_unregister;
        }
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
+       napi_enable(&hw->napi);
 
        sky2_show_addr(dev);
 
@@ -4222,7 +4270,7 @@ err_out_free_netdev:
        free_netdev(dev);
 err_out_free_pci:
        sky2_write8(hw, B0_CTST, CS_RST_SET);
-       pci_free_consistent(hw->pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
+       pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
 err_out_iounmap:
        iounmap(hw->regs);
 err_out_free_hw:
@@ -4239,23 +4287,18 @@ err_out:
 static void __devexit sky2_remove(struct pci_dev *pdev)
 {
        struct sky2_hw *hw = pci_get_drvdata(pdev);
-       struct net_device *dev0, *dev1;
+       int i;
 
        if (!hw)
                return;
 
        del_timer_sync(&hw->watchdog_timer);
+       cancel_work_sync(&hw->restart_work);
 
-       flush_scheduled_work();
+       for (i = hw->ports-1; i >= 0; --i)
+               unregister_netdev(hw->dev[i]);
 
        sky2_write32(hw, B0_IMSK, 0);
-       synchronize_irq(hw->pdev->irq);
-
-       dev0 = hw->dev[0];
-       dev1 = hw->dev[1];
-       if (dev1)
-               unregister_netdev(dev1);
-       unregister_netdev(dev0);
 
        sky2_power_aux(hw);
 
@@ -4270,9 +4313,9 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
        pci_release_regions(pdev);
        pci_disable_device(pdev);
 
-       if (dev1)
-               free_netdev(dev1);
-       free_netdev(dev0);
+       for (i = hw->ports-1; i >= 0; --i)
+               free_netdev(hw->dev[i]);
+
        iounmap(hw->regs);
        kfree(hw);
 
@@ -4288,8 +4331,6 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
        if (!hw)
                return 0;
 
-       netif_poll_disable(hw->dev[0]);
-
        for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];
                struct sky2_port *sky2 = netdev_priv(dev);
@@ -4304,6 +4345,7 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
        }
 
        sky2_write32(hw, B0_IMSK, 0);
+       napi_disable(&hw->napi);
        sky2_power_aux(hw);
 
        pci_save_state(pdev);
@@ -4335,11 +4377,11 @@ static int sky2_resume(struct pci_dev *pdev)
        if (hw->chip_id == CHIP_ID_YUKON_EX ||
            hw->chip_id == CHIP_ID_YUKON_EC_U ||
            hw->chip_id == CHIP_ID_YUKON_FE_P)
-               sky2_pci_write32(hw, PCI_DEV_REG3, 0);
+               pci_write_config_dword(pdev, PCI_DEV_REG3, 0);
 
        sky2_reset(hw);
-
        sky2_write32(hw, B0_IMSK, Y2_IS_BASE);
+       napi_enable(&hw->napi);
 
        for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];
@@ -4356,8 +4398,6 @@ static int sky2_resume(struct pci_dev *pdev)
                }
        }
 
-       netif_poll_enable(hw->dev[0]);
-
        return 0;
 out:
        dev_err(&pdev->dev, "resume failed (%d)\n", err);
@@ -4374,7 +4414,7 @@ static void sky2_shutdown(struct pci_dev *pdev)
        if (!hw)
                return;
 
-       netif_poll_disable(hw->dev[0]);
+       del_timer_sync(&hw->watchdog_timer);
 
        for (i = 0; i < hw->ports; i++) {
                struct net_device *dev = hw->dev[i];