aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@pobox.com>2006-02-07 02:06:12 -0500
committerJeff Garzik <jgarzik@pobox.com>2006-02-07 02:06:12 -0500
commit23a56e2cbec2860ef02d6720508fbcb07accc8b4 (patch)
treea05a6b49944202b492ae492434a25f849e2616ba /drivers
parent6bd0e10e53cc4824cd8cdaab8c370e53ab2e23c2 (diff)
parent3cfc15103aa56c2c7ee6dd312c24a8d1697bade1 (diff)
Merge branch 'upstream-fixes'
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/8139too.c38
-rw-r--r--drivers/net/bonding/bond_main.c15
-rw-r--r--drivers/net/bonding/bond_sysfs.c6
-rw-r--r--drivers/net/e100.c2
-rw-r--r--drivers/net/gianfar.c24
-rw-r--r--drivers/net/gianfar.h8
-rw-r--r--drivers/net/gianfar_ethtool.c8
-rw-r--r--drivers/net/gianfar_mii.c17
-rw-r--r--drivers/net/r8169.c13
-rw-r--r--drivers/net/sis900.h1
-rw-r--r--drivers/net/sky2.c186
-rw-r--r--drivers/net/sky2.h9
-rw-r--r--drivers/net/wan/dscc4.c2
13 files changed, 220 insertions, 109 deletions
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c
index adfba44dac5a..2beac55b57d6 100644
--- a/drivers/net/8139too.c
+++ b/drivers/net/8139too.c
@@ -586,6 +586,7 @@ struct rtl8139_private {
586 dma_addr_t tx_bufs_dma; 586 dma_addr_t tx_bufs_dma;
587 signed char phys[4]; /* MII device addresses. */ 587 signed char phys[4]; /* MII device addresses. */
588 char twistie, twist_row, twist_col; /* Twister tune state. */ 588 char twistie, twist_row, twist_col; /* Twister tune state. */
589 unsigned int watchdog_fired : 1;
589 unsigned int default_port : 4; /* Last dev->if_port value. */ 590 unsigned int default_port : 4; /* Last dev->if_port value. */
590 unsigned int have_thread : 1; 591 unsigned int have_thread : 1;
591 spinlock_t lock; 592 spinlock_t lock;
@@ -638,6 +639,7 @@ static void rtl8139_set_rx_mode (struct net_device *dev);
638static void __set_rx_mode (struct net_device *dev); 639static void __set_rx_mode (struct net_device *dev);
639static void rtl8139_hw_start (struct net_device *dev); 640static void rtl8139_hw_start (struct net_device *dev);
640static void rtl8139_thread (void *_data); 641static void rtl8139_thread (void *_data);
642static void rtl8139_tx_timeout_task(void *_data);
641static struct ethtool_ops rtl8139_ethtool_ops; 643static struct ethtool_ops rtl8139_ethtool_ops;
642 644
643/* write MMIO register, with flush */ 645/* write MMIO register, with flush */
@@ -1598,13 +1600,14 @@ static void rtl8139_thread (void *_data)
1598{ 1600{
1599 struct net_device *dev = _data; 1601 struct net_device *dev = _data;
1600 struct rtl8139_private *tp = netdev_priv(dev); 1602 struct rtl8139_private *tp = netdev_priv(dev);
1601 unsigned long thr_delay; 1603 unsigned long thr_delay = next_tick;
1602 1604
1603 if (rtnl_shlock_nowait() == 0) { 1605 if (tp->watchdog_fired) {
1606 tp->watchdog_fired = 0;
1607 rtl8139_tx_timeout_task(_data);
1608 } else if (rtnl_shlock_nowait() == 0) {
1604 rtl8139_thread_iter (dev, tp, tp->mmio_addr); 1609 rtl8139_thread_iter (dev, tp, tp->mmio_addr);
1605 rtnl_unlock (); 1610 rtnl_unlock ();
1606
1607 thr_delay = next_tick;
1608 } else { 1611 } else {
1609 /* unlikely race. mitigate with fast poll. */ 1612 /* unlikely race. mitigate with fast poll. */
1610 thr_delay = HZ / 2; 1613 thr_delay = HZ / 2;
@@ -1631,7 +1634,8 @@ static void rtl8139_stop_thread(struct rtl8139_private *tp)
1631 if (tp->have_thread) { 1634 if (tp->have_thread) {
1632 cancel_rearming_delayed_work(&tp->thread); 1635 cancel_rearming_delayed_work(&tp->thread);
1633 tp->have_thread = 0; 1636 tp->have_thread = 0;
1634 } 1637 } else
1638 flush_scheduled_work();
1635} 1639}
1636 1640
1637static inline void rtl8139_tx_clear (struct rtl8139_private *tp) 1641static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
@@ -1642,14 +1646,13 @@ static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
1642 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */ 1646 /* XXX account for unsent Tx packets in tp->stats.tx_dropped */
1643} 1647}
1644 1648
1645 1649static void rtl8139_tx_timeout_task (void *_data)
1646static void rtl8139_tx_timeout (struct net_device *dev)
1647{ 1650{
1651 struct net_device *dev = _data;
1648 struct rtl8139_private *tp = netdev_priv(dev); 1652 struct rtl8139_private *tp = netdev_priv(dev);
1649 void __iomem *ioaddr = tp->mmio_addr; 1653 void __iomem *ioaddr = tp->mmio_addr;
1650 int i; 1654 int i;
1651 u8 tmp8; 1655 u8 tmp8;
1652 unsigned long flags;
1653 1656
1654 printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x " 1657 printk (KERN_DEBUG "%s: Transmit timeout, status %2.2x %4.4x %4.4x "
1655 "media %2.2x.\n", dev->name, RTL_R8 (ChipCmd), 1658 "media %2.2x.\n", dev->name, RTL_R8 (ChipCmd),
@@ -1670,23 +1673,34 @@ static void rtl8139_tx_timeout (struct net_device *dev)
1670 if (tmp8 & CmdTxEnb) 1673 if (tmp8 & CmdTxEnb)
1671 RTL_W8 (ChipCmd, CmdRxEnb); 1674 RTL_W8 (ChipCmd, CmdRxEnb);
1672 1675
1673 spin_lock(&tp->rx_lock); 1676 spin_lock_bh(&tp->rx_lock);
1674 /* Disable interrupts by clearing the interrupt mask. */ 1677 /* Disable interrupts by clearing the interrupt mask. */
1675 RTL_W16 (IntrMask, 0x0000); 1678 RTL_W16 (IntrMask, 0x0000);
1676 1679
1677 /* Stop a shared interrupt from scavenging while we are. */ 1680 /* Stop a shared interrupt from scavenging while we are. */
1678 spin_lock_irqsave (&tp->lock, flags); 1681 spin_lock_irq(&tp->lock);
1679 rtl8139_tx_clear (tp); 1682 rtl8139_tx_clear (tp);
1680 spin_unlock_irqrestore (&tp->lock, flags); 1683 spin_unlock_irq(&tp->lock);
1681 1684
1682 /* ...and finally, reset everything */ 1685 /* ...and finally, reset everything */
1683 if (netif_running(dev)) { 1686 if (netif_running(dev)) {
1684 rtl8139_hw_start (dev); 1687 rtl8139_hw_start (dev);
1685 netif_wake_queue (dev); 1688 netif_wake_queue (dev);
1686 } 1689 }
1687 spin_unlock(&tp->rx_lock); 1690 spin_unlock_bh(&tp->rx_lock);
1688} 1691}
1689 1692
1693static void rtl8139_tx_timeout (struct net_device *dev)
1694{
1695 struct rtl8139_private *tp = netdev_priv(dev);
1696
1697 if (!tp->have_thread) {
1698 INIT_WORK(&tp->thread, rtl8139_tx_timeout_task, dev);
1699 schedule_delayed_work(&tp->thread, next_tick);
1700 } else
1701 tp->watchdog_fired = 1;
1702
1703}
1690 1704
1691static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) 1705static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
1692{ 1706{
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4ff006c37626..e0f51afec778 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1145,7 +1145,8 @@ int bond_sethwaddr(struct net_device *bond_dev, struct net_device *slave_dev)
1145} 1145}
1146 1146
1147#define BOND_INTERSECT_FEATURES \ 1147#define BOND_INTERSECT_FEATURES \
1148 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM) 1148 (NETIF_F_SG|NETIF_F_IP_CSUM|NETIF_F_NO_CSUM|NETIF_F_HW_CSUM|\
1149 NETIF_F_TSO|NETIF_F_UFO)
1149 1150
1150/* 1151/*
1151 * Compute the common dev->feature set available to all slaves. Some 1152 * Compute the common dev->feature set available to all slaves. Some
@@ -1168,6 +1169,16 @@ static int bond_compute_features(struct bonding *bond)
1168 NETIF_F_HW_CSUM))) 1169 NETIF_F_HW_CSUM)))
1169 features &= ~NETIF_F_SG; 1170 features &= ~NETIF_F_SG;
1170 1171
1172 /*
1173 * features will include NETIF_F_TSO (NETIF_F_UFO) iff all
1174 * slave devices support NETIF_F_TSO (NETIF_F_UFO), which
1175 * implies that all slaves also support scatter-gather
1176 * (NETIF_F_SG), which implies that features also includes
1177 * NETIF_F_SG. So no need to check whether we have an
1178 * illegal combination of NETIF_F_{TSO,UFO} and
1179 * !NETIF_F_SG
1180 */
1181
1171 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES); 1182 features |= (bond_dev->features & ~BOND_INTERSECT_FEATURES);
1172 bond_dev->features = features; 1183 bond_dev->features = features;
1173 1184
@@ -4080,6 +4091,8 @@ static void bond_ethtool_get_drvinfo(struct net_device *bond_dev,
4080 4091
4081static struct ethtool_ops bond_ethtool_ops = { 4092static struct ethtool_ops bond_ethtool_ops = {
4082 .get_tx_csum = ethtool_op_get_tx_csum, 4093 .get_tx_csum = ethtool_op_get_tx_csum,
4094 .get_tso = ethtool_op_get_tso,
4095 .get_ufo = ethtool_op_get_ufo,
4083 .get_sg = ethtool_op_get_sg, 4096 .get_sg = ethtool_op_get_sg,
4084 .get_drvinfo = bond_ethtool_get_drvinfo, 4097 .get_drvinfo = bond_ethtool_get_drvinfo,
4085}; 4098};
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 32d13da43a0b..041bcc583557 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -260,7 +260,7 @@ static ssize_t bonding_store_slaves(struct class_device *cd, const char *buffer,
260 char *ifname; 260 char *ifname;
261 int i, res, found, ret = count; 261 int i, res, found, ret = count;
262 struct slave *slave; 262 struct slave *slave;
263 struct net_device *dev = 0; 263 struct net_device *dev = NULL;
264 struct bonding *bond = to_bond(cd); 264 struct bonding *bond = to_bond(cd);
265 265
266 /* Quick sanity check -- is the bond interface up? */ 266 /* Quick sanity check -- is the bond interface up? */
@@ -995,7 +995,7 @@ static ssize_t bonding_store_primary(struct class_device *cd, const char *buf, s
995 printk(KERN_INFO DRV_NAME 995 printk(KERN_INFO DRV_NAME
996 ": %s: Setting primary slave to None.\n", 996 ": %s: Setting primary slave to None.\n",
997 bond->dev->name); 997 bond->dev->name);
998 bond->primary_slave = 0; 998 bond->primary_slave = NULL;
999 bond_select_active_slave(bond); 999 bond_select_active_slave(bond);
1000 } else { 1000 } else {
1001 printk(KERN_INFO DRV_NAME 1001 printk(KERN_INFO DRV_NAME
@@ -1123,7 +1123,7 @@ static ssize_t bonding_store_active_slave(struct class_device *cd, const char *b
1123 printk(KERN_INFO DRV_NAME 1123 printk(KERN_INFO DRV_NAME
1124 ": %s: Setting active slave to None.\n", 1124 ": %s: Setting active slave to None.\n",
1125 bond->dev->name); 1125 bond->dev->name);
1126 bond->primary_slave = 0; 1126 bond->primary_slave = NULL;
1127 bond_select_active_slave(bond); 1127 bond_select_active_slave(bond);
1128 } else { 1128 } else {
1129 printk(KERN_INFO DRV_NAME 1129 printk(KERN_INFO DRV_NAME
diff --git a/drivers/net/e100.c b/drivers/net/e100.c
index bf1fd2b98bf8..24253c807e55 100644
--- a/drivers/net/e100.c
+++ b/drivers/net/e100.c
@@ -2752,8 +2752,6 @@ static int e100_resume(struct pci_dev *pdev)
2752 retval = pci_enable_wake(pdev, 0, 0); 2752 retval = pci_enable_wake(pdev, 0, 0);
2753 if (retval) 2753 if (retval)
2754 DPRINTK(PROBE,ERR, "Error clearing wake events\n"); 2754 DPRINTK(PROBE,ERR, "Error clearing wake events\n");
2755 if(e100_hw_init(nic))
2756 DPRINTK(HW, ERR, "e100_hw_init failed\n");
2757 2755
2758 netif_device_attach(netdev); 2756 netif_device_attach(netdev);
2759 if(netif_running(netdev)) 2757 if(netif_running(netdev))
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
index 0c18dbd67d3b..0e8e3fcde9ff 100644
--- a/drivers/net/gianfar.c
+++ b/drivers/net/gianfar.c
@@ -199,8 +199,7 @@ static int gfar_probe(struct platform_device *pdev)
199 199
200 /* get a pointer to the register memory */ 200 /* get a pointer to the register memory */
201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 201 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
202 priv->regs = (struct gfar *) 202 priv->regs = ioremap(r->start, sizeof (struct gfar));
203 ioremap(r->start, sizeof (struct gfar));
204 203
205 if (NULL == priv->regs) { 204 if (NULL == priv->regs) {
206 err = -ENOMEM; 205 err = -ENOMEM;
@@ -369,7 +368,7 @@ static int gfar_probe(struct platform_device *pdev)
369 return 0; 368 return 0;
370 369
371register_fail: 370register_fail:
372 iounmap((void *) priv->regs); 371 iounmap(priv->regs);
373regs_fail: 372regs_fail:
374 free_netdev(dev); 373 free_netdev(dev);
375 return err; 374 return err;
@@ -382,7 +381,7 @@ static int gfar_remove(struct platform_device *pdev)
382 381
383 platform_set_drvdata(pdev, NULL); 382 platform_set_drvdata(pdev, NULL);
384 383
385 iounmap((void *) priv->regs); 384 iounmap(priv->regs);
386 free_netdev(dev); 385 free_netdev(dev);
387 386
388 return 0; 387 return 0;
@@ -454,8 +453,7 @@ static void init_registers(struct net_device *dev)
454 453
455 /* Zero out the rmon mib registers if it has them */ 454 /* Zero out the rmon mib registers if it has them */
456 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 455 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
457 memset((void *) &(priv->regs->rmon), 0, 456 memset_io(&(priv->regs->rmon), 0, sizeof (struct rmon_mib));
458 sizeof (struct rmon_mib));
459 457
460 /* Mask off the CAM interrupts */ 458 /* Mask off the CAM interrupts */
461 gfar_write(&priv->regs->rmon.cam1, 0xffffffff); 459 gfar_write(&priv->regs->rmon.cam1, 0xffffffff);
@@ -477,7 +475,7 @@ static void init_registers(struct net_device *dev)
477void gfar_halt(struct net_device *dev) 475void gfar_halt(struct net_device *dev)
478{ 476{
479 struct gfar_private *priv = netdev_priv(dev); 477 struct gfar_private *priv = netdev_priv(dev);
480 struct gfar *regs = priv->regs; 478 struct gfar __iomem *regs = priv->regs;
481 u32 tempval; 479 u32 tempval;
482 480
483 /* Mask all interrupts */ 481 /* Mask all interrupts */
@@ -507,7 +505,7 @@ void gfar_halt(struct net_device *dev)
507void stop_gfar(struct net_device *dev) 505void stop_gfar(struct net_device *dev)
508{ 506{
509 struct gfar_private *priv = netdev_priv(dev); 507 struct gfar_private *priv = netdev_priv(dev);
510 struct gfar *regs = priv->regs; 508 struct gfar __iomem *regs = priv->regs;
511 unsigned long flags; 509 unsigned long flags;
512 510
513 phy_stop(priv->phydev); 511 phy_stop(priv->phydev);
@@ -590,7 +588,7 @@ static void free_skb_resources(struct gfar_private *priv)
590void gfar_start(struct net_device *dev) 588void gfar_start(struct net_device *dev)
591{ 589{
592 struct gfar_private *priv = netdev_priv(dev); 590 struct gfar_private *priv = netdev_priv(dev);
593 struct gfar *regs = priv->regs; 591 struct gfar __iomem *regs = priv->regs;
594 u32 tempval; 592 u32 tempval;
595 593
596 /* Enable Rx and Tx in MACCFG1 */ 594 /* Enable Rx and Tx in MACCFG1 */
@@ -624,7 +622,7 @@ int startup_gfar(struct net_device *dev)
624 unsigned long vaddr; 622 unsigned long vaddr;
625 int i; 623 int i;
626 struct gfar_private *priv = netdev_priv(dev); 624 struct gfar_private *priv = netdev_priv(dev);
627 struct gfar *regs = priv->regs; 625 struct gfar __iomem *regs = priv->regs;
628 int err = 0; 626 int err = 0;
629 u32 rctrl = 0; 627 u32 rctrl = 0;
630 u32 attrs = 0; 628 u32 attrs = 0;
@@ -1622,7 +1620,7 @@ static irqreturn_t gfar_interrupt(int irq, void *dev_id, struct pt_regs *regs)
1622static void adjust_link(struct net_device *dev) 1620static void adjust_link(struct net_device *dev)
1623{ 1621{
1624 struct gfar_private *priv = netdev_priv(dev); 1622 struct gfar_private *priv = netdev_priv(dev);
1625 struct gfar *regs = priv->regs; 1623 struct gfar __iomem *regs = priv->regs;
1626 unsigned long flags; 1624 unsigned long flags;
1627 struct phy_device *phydev = priv->phydev; 1625 struct phy_device *phydev = priv->phydev;
1628 int new_state = 0; 1626 int new_state = 0;
@@ -1703,7 +1701,7 @@ static void gfar_set_multi(struct net_device *dev)
1703{ 1701{
1704 struct dev_mc_list *mc_ptr; 1702 struct dev_mc_list *mc_ptr;
1705 struct gfar_private *priv = netdev_priv(dev); 1703 struct gfar_private *priv = netdev_priv(dev);
1706 struct gfar *regs = priv->regs; 1704 struct gfar __iomem *regs = priv->regs;
1707 u32 tempval; 1705 u32 tempval;
1708 1706
1709 if(dev->flags & IFF_PROMISC) { 1707 if(dev->flags & IFF_PROMISC) {
@@ -1842,7 +1840,7 @@ static void gfar_set_mac_for_addr(struct net_device *dev, int num, u8 *addr)
1842 int idx; 1840 int idx;
1843 char tmpbuf[MAC_ADDR_LEN]; 1841 char tmpbuf[MAC_ADDR_LEN];
1844 u32 tempval; 1842 u32 tempval;
1845 u32 *macptr = &priv->regs->macstnaddr1; 1843 u32 __iomem *macptr = &priv->regs->macstnaddr1;
1846 1844
1847 macptr += num*2; 1845 macptr += num*2;
1848 1846
diff --git a/drivers/net/gianfar.h b/drivers/net/gianfar.h
index cb9d66ac3ab9..d37d5401be6e 100644
--- a/drivers/net/gianfar.h
+++ b/drivers/net/gianfar.h
@@ -682,8 +682,8 @@ struct gfar_private {
682 struct rxbd8 *cur_rx; /* Next free rx ring entry */ 682 struct rxbd8 *cur_rx; /* Next free rx ring entry */
683 struct txbd8 *cur_tx; /* Next free ring entry */ 683 struct txbd8 *cur_tx; /* Next free ring entry */
684 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */ 684 struct txbd8 *dirty_tx; /* The Ring entry to be freed. */
685 struct gfar *regs; /* Pointer to the GFAR memory mapped Registers */ 685 struct gfar __iomem *regs; /* Pointer to the GFAR memory mapped Registers */
686 u32 *hash_regs[16]; 686 u32 __iomem *hash_regs[16];
687 int hash_width; 687 int hash_width;
688 struct net_device_stats stats; /* linux network statistics */ 688 struct net_device_stats stats; /* linux network statistics */
689 struct gfar_extra_stats extra_stats; 689 struct gfar_extra_stats extra_stats;
@@ -718,14 +718,14 @@ struct gfar_private {
718 uint32_t msg_enable; 718 uint32_t msg_enable;
719}; 719};
720 720
721static inline u32 gfar_read(volatile unsigned *addr) 721static inline u32 gfar_read(volatile unsigned __iomem *addr)
722{ 722{
723 u32 val; 723 u32 val;
724 val = in_be32(addr); 724 val = in_be32(addr);
725 return val; 725 return val;
726} 726}
727 727
728static inline void gfar_write(volatile unsigned *addr, u32 val) 728static inline void gfar_write(volatile unsigned __iomem *addr, u32 val)
729{ 729{
730 out_be32(addr, val); 730 out_be32(addr, val);
731} 731}
diff --git a/drivers/net/gianfar_ethtool.c b/drivers/net/gianfar_ethtool.c
index 765e810620fe..5de7b2e259dc 100644
--- a/drivers/net/gianfar_ethtool.c
+++ b/drivers/net/gianfar_ethtool.c
@@ -144,11 +144,11 @@ static void gfar_fill_stats(struct net_device *dev, struct ethtool_stats *dummy,
144 u64 *extra = (u64 *) & priv->extra_stats; 144 u64 *extra = (u64 *) & priv->extra_stats;
145 145
146 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) { 146 if (priv->einfo->device_flags & FSL_GIANFAR_DEV_HAS_RMON) {
147 u32 *rmon = (u32 *) & priv->regs->rmon; 147 u32 __iomem *rmon = (u32 __iomem *) & priv->regs->rmon;
148 struct gfar_stats *stats = (struct gfar_stats *) buf; 148 struct gfar_stats *stats = (struct gfar_stats *) buf;
149 149
150 for (i = 0; i < GFAR_RMON_LEN; i++) 150 for (i = 0; i < GFAR_RMON_LEN; i++)
151 stats->rmon[i] = (u64) (rmon[i]); 151 stats->rmon[i] = (u64) gfar_read(&rmon[i]);
152 152
153 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++) 153 for (i = 0; i < GFAR_EXTRA_STATS_LEN; i++)
154 stats->extra[i] = extra[i]; 154 stats->extra[i] = extra[i];
@@ -221,11 +221,11 @@ static void gfar_get_regs(struct net_device *dev, struct ethtool_regs *regs, voi
221{ 221{
222 int i; 222 int i;
223 struct gfar_private *priv = netdev_priv(dev); 223 struct gfar_private *priv = netdev_priv(dev);
224 u32 *theregs = (u32 *) priv->regs; 224 u32 __iomem *theregs = (u32 __iomem *) priv->regs;
225 u32 *buf = (u32 *) regbuf; 225 u32 *buf = (u32 *) regbuf;
226 226
227 for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++) 227 for (i = 0; i < sizeof (struct gfar) / sizeof (u32); i++)
228 buf[i] = theregs[i]; 228 buf[i] = gfar_read(&theregs[i]);
229} 229}
230 230
231/* Convert microseconds to ethernet clock ticks, which changes 231/* Convert microseconds to ethernet clock ticks, which changes
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c
index 74e52fcbf806..c6b725529af5 100644
--- a/drivers/net/gianfar_mii.c
+++ b/drivers/net/gianfar_mii.c
@@ -50,7 +50,7 @@
50 * All PHY configuration is done through the TSEC1 MIIM regs */ 50 * All PHY configuration is done through the TSEC1 MIIM regs */
51int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value) 51int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)
52{ 52{
53 struct gfar_mii *regs = bus->priv; 53 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
54 54
55 /* Set the PHY address and the register address we want to write */ 55 /* Set the PHY address and the register address we want to write */
56 gfar_write(&regs->miimadd, (mii_id << 8) | regnum); 56 gfar_write(&regs->miimadd, (mii_id << 8) | regnum);
@@ -70,7 +70,7 @@ int gfar_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value)
70 * configuration has to be done through the TSEC1 MIIM regs */ 70 * configuration has to be done through the TSEC1 MIIM regs */
71int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum) 71int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
72{ 72{
73 struct gfar_mii *regs = bus->priv; 73 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
74 u16 value; 74 u16 value;
75 75
76 /* Set the PHY address and the register address we want to read */ 76 /* Set the PHY address and the register address we want to read */
@@ -94,7 +94,7 @@ int gfar_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
94/* Reset the MIIM registers, and wait for the bus to free */ 94/* Reset the MIIM registers, and wait for the bus to free */
95int gfar_mdio_reset(struct mii_bus *bus) 95int gfar_mdio_reset(struct mii_bus *bus)
96{ 96{
97 struct gfar_mii *regs = bus->priv; 97 struct gfar_mii __iomem *regs = (void __iomem *)bus->priv;
98 unsigned int timeout = PHY_INIT_TIMEOUT; 98 unsigned int timeout = PHY_INIT_TIMEOUT;
99 99
100 spin_lock_bh(&bus->mdio_lock); 100 spin_lock_bh(&bus->mdio_lock);
@@ -126,7 +126,7 @@ int gfar_mdio_probe(struct device *dev)
126{ 126{
127 struct platform_device *pdev = to_platform_device(dev); 127 struct platform_device *pdev = to_platform_device(dev);
128 struct gianfar_mdio_data *pdata; 128 struct gianfar_mdio_data *pdata;
129 struct gfar_mii *regs; 129 struct gfar_mii __iomem *regs;
130 struct mii_bus *new_bus; 130 struct mii_bus *new_bus;
131 struct resource *r; 131 struct resource *r;
132 int err = 0; 132 int err = 0;
@@ -155,15 +155,14 @@ int gfar_mdio_probe(struct device *dev)
155 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 155 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
156 156
157 /* Set the PHY base address */ 157 /* Set the PHY base address */
158 regs = (struct gfar_mii *) ioremap(r->start, 158 regs = ioremap(r->start, sizeof (struct gfar_mii));
159 sizeof (struct gfar_mii));
160 159
161 if (NULL == regs) { 160 if (NULL == regs) {
162 err = -ENOMEM; 161 err = -ENOMEM;
163 goto reg_map_fail; 162 goto reg_map_fail;
164 } 163 }
165 164
166 new_bus->priv = regs; 165 new_bus->priv = (void __force *)regs;
167 166
168 new_bus->irq = pdata->irq; 167 new_bus->irq = pdata->irq;
169 168
@@ -181,7 +180,7 @@ int gfar_mdio_probe(struct device *dev)
181 return 0; 180 return 0;
182 181
183bus_register_fail: 182bus_register_fail:
184 iounmap((void *) regs); 183 iounmap(regs);
185reg_map_fail: 184reg_map_fail:
186 kfree(new_bus); 185 kfree(new_bus);
187 186
@@ -197,7 +196,7 @@ int gfar_mdio_remove(struct device *dev)
197 196
198 dev_set_drvdata(dev, NULL); 197 dev_set_drvdata(dev, NULL);
199 198
200 iounmap((void *) (&bus->priv)); 199 iounmap((void __iomem *)bus->priv);
201 bus->priv = NULL; 200 bus->priv = NULL;
202 kfree(bus); 201 kfree(bus);
203 202
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c
index 2e1bed153c39..6e1018448eea 100644
--- a/drivers/net/r8169.c
+++ b/drivers/net/r8169.c
@@ -484,13 +484,12 @@ static void mdio_write(void __iomem *ioaddr, int RegAddr, int value)
484 int i; 484 int i;
485 485
486 RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value); 486 RTL_W32(PHYAR, 0x80000000 | (RegAddr & 0xFF) << 16 | value);
487 udelay(1000);
488 487
489 for (i = 2000; i > 0; i--) { 488 for (i = 20; i > 0; i--) {
490 /* Check if the RTL8169 has completed writing to the specified MII register */ 489 /* Check if the RTL8169 has completed writing to the specified MII register */
491 if (!(RTL_R32(PHYAR) & 0x80000000)) 490 if (!(RTL_R32(PHYAR) & 0x80000000))
492 break; 491 break;
493 udelay(100); 492 udelay(25);
494 } 493 }
495} 494}
496 495
@@ -499,15 +498,14 @@ static int mdio_read(void __iomem *ioaddr, int RegAddr)
499 int i, value = -1; 498 int i, value = -1;
500 499
501 RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16); 500 RTL_W32(PHYAR, 0x0 | (RegAddr & 0xFF) << 16);
502 udelay(1000);
503 501
504 for (i = 2000; i > 0; i--) { 502 for (i = 20; i > 0; i--) {
505 /* Check if the RTL8169 has completed retrieving data from the specified MII register */ 503 /* Check if the RTL8169 has completed retrieving data from the specified MII register */
506 if (RTL_R32(PHYAR) & 0x80000000) { 504 if (RTL_R32(PHYAR) & 0x80000000) {
507 value = (int) (RTL_R32(PHYAR) & 0xFFFF); 505 value = (int) (RTL_R32(PHYAR) & 0xFFFF);
508 break; 506 break;
509 } 507 }
510 udelay(100); 508 udelay(25);
511 } 509 }
512 return value; 510 return value;
513} 511}
@@ -677,6 +675,9 @@ static int rtl8169_set_speed_xmii(struct net_device *dev,
677 675
678 if (duplex == DUPLEX_HALF) 676 if (duplex == DUPLEX_HALF)
679 auto_nego &= ~(PHY_Cap_10_Full | PHY_Cap_100_Full); 677 auto_nego &= ~(PHY_Cap_10_Full | PHY_Cap_100_Full);
678
679 if (duplex == DUPLEX_FULL)
680 auto_nego &= ~(PHY_Cap_10_Half | PHY_Cap_100_Half);
680 } 681 }
681 682
682 tp->phy_auto_nego_reg = auto_nego; 683 tp->phy_auto_nego_reg = auto_nego;
diff --git a/drivers/net/sis900.h b/drivers/net/sis900.h
index 4233ea55670f..50323941e3c0 100644
--- a/drivers/net/sis900.h
+++ b/drivers/net/sis900.h
@@ -33,7 +33,6 @@ enum sis900_registers {
33 rxcfg=0x34, //Receive Configuration Register 33 rxcfg=0x34, //Receive Configuration Register
34 flctrl=0x38, //Flow Control Register 34 flctrl=0x38, //Flow Control Register
35 rxlen=0x3c, //Receive Packet Length Register 35 rxlen=0x3c, //Receive Packet Length Register
36 cfgpmcsr=0x44, //Configuration Power Management Control/Status Register
37 rfcr=0x48, //Receive Filter Control Register 36 rfcr=0x48, //Receive Filter Control Register
38 rfdr=0x4C, //Receive Filter Data Register 37 rfdr=0x4C, //Receive Filter Data Register
39 pmctrl=0xB0, //Power Management Control Register 38 pmctrl=0xB0, //Power Management Control Register
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index f8b973a04b65..cae2edf23004 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -23,12 +23,6 @@
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 */ 24 */
25 25
26/*
27 * TOTEST
28 * - speed setting
29 * - suspend/resume
30 */
31
32#include <linux/config.h> 26#include <linux/config.h>
33#include <linux/crc32.h> 27#include <linux/crc32.h>
34#include <linux/kernel.h> 28#include <linux/kernel.h>
@@ -57,7 +51,7 @@
57#include "sky2.h" 51#include "sky2.h"
58 52
59#define DRV_NAME "sky2" 53#define DRV_NAME "sky2"
60#define DRV_VERSION "0.13" 54#define DRV_VERSION "0.15"
61#define PFX DRV_NAME " " 55#define PFX DRV_NAME " "
62 56
63/* 57/*
@@ -102,6 +96,10 @@ static int copybreak __read_mostly = 256;
102module_param(copybreak, int, 0); 96module_param(copybreak, int, 0);
103MODULE_PARM_DESC(copybreak, "Receive copy threshold"); 97MODULE_PARM_DESC(copybreak, "Receive copy threshold");
104 98
99static int disable_msi = 0;
100module_param(disable_msi, int, 0);
101MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
102
105static const struct pci_device_id sky2_id_table[] = { 103static const struct pci_device_id sky2_id_table[] = {
106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, 104 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) },
107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, 105 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) },
@@ -198,7 +196,7 @@ static int sky2_set_power_state(struct sky2_hw *hw, pci_power_t state)
198 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 196 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
199 197
200 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control); 198 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_PMC, &power_control);
201 vaux = (sky2_read8(hw, B0_CTST) & Y2_VAUX_AVAIL) && 199 vaux = (sky2_read16(hw, B0_CTST) & Y2_VAUX_AVAIL) &&
202 (power_control & PCI_PM_CAP_PME_D3cold); 200 (power_control & PCI_PM_CAP_PME_D3cold);
203 201
204 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control); 202 pci_read_config_word(hw->pdev, hw->pm_cap + PCI_PM_CTRL, &power_control);
@@ -1834,6 +1832,8 @@ static int sky2_poll(struct net_device *dev0, int *budget)
1834 u16 hwidx; 1832 u16 hwidx;
1835 u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS }; 1833 u16 tx_done[2] = { TX_NO_STATUS, TX_NO_STATUS };
1836 1834
1835 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1836
1837 hwidx = sky2_read16(hw, STAT_PUT_IDX); 1837 hwidx = sky2_read16(hw, STAT_PUT_IDX);
1838 BUG_ON(hwidx >= STATUS_RING_SIZE); 1838 BUG_ON(hwidx >= STATUS_RING_SIZE);
1839 rmb(); 1839 rmb();
@@ -1913,12 +1913,10 @@ static int sky2_poll(struct net_device *dev0, int *budget)
1913 } 1913 }
1914 1914
1915exit_loop: 1915exit_loop:
1916 sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
1917
1918 sky2_tx_check(hw, 0, tx_done[0]); 1916 sky2_tx_check(hw, 0, tx_done[0]);
1919 sky2_tx_check(hw, 1, tx_done[1]); 1917 sky2_tx_check(hw, 1, tx_done[1]);
1920 1918
1921 if (sky2_read16(hw, STAT_PUT_IDX) == hw->st_idx) { 1919 if (likely(work_done < to_do)) {
1922 /* need to restart TX timer */ 1920 /* need to restart TX timer */
1923 if (is_ec_a1(hw)) { 1921 if (is_ec_a1(hw)) {
1924 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP); 1922 sky2_write8(hw, STAT_TX_TIMER_CTRL, TIM_STOP);
@@ -2141,14 +2139,12 @@ static inline u32 sky2_clk2us(const struct sky2_hw *hw, u32 clk)
2141 2139
2142static int sky2_reset(struct sky2_hw *hw) 2140static int sky2_reset(struct sky2_hw *hw)
2143{ 2141{
2144 u32 ctst;
2145 u16 status; 2142 u16 status;
2146 u8 t8, pmd_type; 2143 u8 t8, pmd_type;
2147 int i; 2144 int i, err;
2148
2149 ctst = sky2_read32(hw, B0_CTST);
2150 2145
2151 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2146 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2147
2152 hw->chip_id = sky2_read8(hw, B2_CHIP_ID); 2148 hw->chip_id = sky2_read8(hw, B2_CHIP_ID);
2153 if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) { 2149 if (hw->chip_id < CHIP_ID_YUKON_XL || hw->chip_id > CHIP_ID_YUKON_FE) {
2154 printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n", 2150 printk(KERN_ERR PFX "%s: unsupported chip type 0x%x\n",
@@ -2156,12 +2152,6 @@ static int sky2_reset(struct sky2_hw *hw)
2156 return -EOPNOTSUPP; 2152 return -EOPNOTSUPP;
2157 } 2153 }
2158 2154
2159 /* ring for status responses */
2160 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
2161 &hw->st_dma);
2162 if (!hw->st_le)
2163 return -ENOMEM;
2164
2165 /* disable ASF */ 2155 /* disable ASF */
2166 if (hw->chip_id <= CHIP_ID_YUKON_EC) { 2156 if (hw->chip_id <= CHIP_ID_YUKON_EC) {
2167 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET); 2157 sky2_write8(hw, B28_Y2_ASF_STAT_CMD, Y2_ASF_RESET);
@@ -2173,19 +2163,24 @@ static int sky2_reset(struct sky2_hw *hw)
2173 sky2_write8(hw, B0_CTST, CS_RST_CLR); 2163 sky2_write8(hw, B0_CTST, CS_RST_CLR);
2174 2164
2175 /* clear PCI errors, if any */ 2165 /* clear PCI errors, if any */
2176 pci_read_config_word(hw->pdev, PCI_STATUS, &status); 2166 err = pci_read_config_word(hw->pdev, PCI_STATUS, &status);
2167 if (err)
2168 goto pci_err;
2169
2177 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON); 2170 sky2_write8(hw, B2_TST_CTRL1, TST_CFG_WRITE_ON);
2178 pci_write_config_word(hw->pdev, PCI_STATUS, 2171 err = pci_write_config_word(hw->pdev, PCI_STATUS,
2179 status | PCI_STATUS_ERROR_BITS); 2172 status | PCI_STATUS_ERROR_BITS);
2173 if (err)
2174 goto pci_err;
2180 2175
2181 sky2_write8(hw, B0_CTST, CS_MRST_CLR); 2176 sky2_write8(hw, B0_CTST, CS_MRST_CLR);
2182 2177
2183 /* clear any PEX errors */ 2178 /* clear any PEX errors */
2184 if (is_pciex(hw)) { 2179 if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) {
2185 u16 lstat; 2180 err = pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT,
2186 pci_write_config_dword(hw->pdev, PEX_UNC_ERR_STAT, 2181 0xffffffffUL);
2187 0xffffffffUL); 2182 if (err)
2188 pci_read_config_word(hw->pdev, PEX_LNK_STAT, &lstat); 2183 goto pci_err;
2189 } 2184 }
2190 2185
2191 pmd_type = sky2_read8(hw, B2_PMD_TYP); 2186 pmd_type = sky2_read8(hw, B2_PMD_TYP);
@@ -2297,6 +2292,14 @@ static int sky2_reset(struct sky2_hw *hw)
2297 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); 2292 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2298 2293
2299 return 0; 2294 return 0;
2295
2296pci_err:
2297 /* This is to catch a BIOS bug workaround where
2298 * mmconfig table doesn't have other buses.
2299 */
2300 printk(KERN_ERR PFX "%s: can't access PCI config space\n",
2301 pci_name(hw->pdev));
2302 return err;
2300} 2303}
2301 2304
2302static u32 sky2_supported_modes(const struct sky2_hw *hw) 2305static u32 sky2_supported_modes(const struct sky2_hw *hw)
@@ -2551,19 +2554,24 @@ static struct net_device_stats *sky2_get_stats(struct net_device *dev)
2551static int sky2_set_mac_address(struct net_device *dev, void *p) 2554static int sky2_set_mac_address(struct net_device *dev, void *p)
2552{ 2555{
2553 struct sky2_port *sky2 = netdev_priv(dev); 2556 struct sky2_port *sky2 = netdev_priv(dev);
2554 struct sockaddr *addr = p; 2557 struct sky2_hw *hw = sky2->hw;
2558 unsigned port = sky2->port;
2559 const struct sockaddr *addr = p;
2555 2560
2556 if (!is_valid_ether_addr(addr->sa_data)) 2561 if (!is_valid_ether_addr(addr->sa_data))
2557 return -EADDRNOTAVAIL; 2562 return -EADDRNOTAVAIL;
2558 2563
2559 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); 2564 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
2560 memcpy_toio(sky2->hw->regs + B2_MAC_1 + sky2->port * 8, 2565 memcpy_toio(hw->regs + B2_MAC_1 + port * 8,
2561 dev->dev_addr, ETH_ALEN); 2566 dev->dev_addr, ETH_ALEN);
2562 memcpy_toio(sky2->hw->regs + B2_MAC_2 + sky2->port * 8, 2567 memcpy_toio(hw->regs + B2_MAC_2 + port * 8,
2563 dev->dev_addr, ETH_ALEN); 2568 dev->dev_addr, ETH_ALEN);
2564 2569
2565 if (netif_running(dev)) 2570 /* virtual address for data */
2566 sky2_phy_reinit(sky2); 2571 gma_set_addr(hw, port, GM_SRC_ADDR_2L, dev->dev_addr);
2572
2573 /* physical address: used for pause frames */
2574 gma_set_addr(hw, port, GM_SRC_ADDR_1L, dev->dev_addr);
2567 2575
2568 return 0; 2576 return 0;
2569} 2577}
@@ -2843,7 +2851,7 @@ static int sky2_set_coalesce(struct net_device *dev,
2843 if (ecmd->rx_coalesce_usecs_irq == 0) 2851 if (ecmd->rx_coalesce_usecs_irq == 0)
2844 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP); 2852 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_STOP);
2845 else { 2853 else {
2846 sky2_write32(hw, STAT_TX_TIMER_INI, 2854 sky2_write32(hw, STAT_ISR_TIMER_INI,
2847 sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq)); 2855 sky2_us2clk(hw, ecmd->rx_coalesce_usecs_irq));
2848 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START); 2856 sky2_write8(hw, STAT_ISR_TIMER_CTRL, TIM_START);
2849 } 2857 }
@@ -3055,6 +3063,61 @@ static void __devinit sky2_show_addr(struct net_device *dev)
3055 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); 3063 dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]);
3056} 3064}
3057 3065
3066/* Handle software interrupt used during MSI test */
3067static irqreturn_t __devinit sky2_test_intr(int irq, void *dev_id,
3068 struct pt_regs *regs)
3069{
3070 struct sky2_hw *hw = dev_id;
3071 u32 status = sky2_read32(hw, B0_Y2_SP_ISRC2);
3072
3073 if (status == 0)
3074 return IRQ_NONE;
3075
3076 if (status & Y2_IS_IRQ_SW) {
3077 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3078 hw->msi = 1;
3079 }
3080 sky2_write32(hw, B0_Y2_SP_ICR, 2);
3081
3082 sky2_read32(hw, B0_IMSK);
3083 return IRQ_HANDLED;
3084}
3085
3086/* Test interrupt path by forcing a a software IRQ */
3087static int __devinit sky2_test_msi(struct sky2_hw *hw)
3088{
3089 struct pci_dev *pdev = hw->pdev;
3090 int i, err;
3091
3092 sky2_write32(hw, B0_IMSK, Y2_IS_IRQ_SW);
3093
3094 err = request_irq(pdev->irq, sky2_test_intr, SA_SHIRQ, DRV_NAME, hw);
3095 if (err) {
3096 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3097 pci_name(pdev), pdev->irq);
3098 return err;
3099 }
3100
3101 sky2_write8(hw, B0_CTST, CS_ST_SW_IRQ);
3102 wmb();
3103
3104 for (i = 0; i < 10; i++) {
3105 barrier();
3106 if (hw->msi)
3107 goto found;
3108 mdelay(1);
3109 }
3110
3111 err = -EOPNOTSUPP;
3112 sky2_write8(hw, B0_CTST, CS_CL_SW_IRQ);
3113 found:
3114 sky2_write32(hw, B0_IMSK, 0);
3115
3116 free_irq(pdev->irq, hw);
3117
3118 return err;
3119}
3120
3058static int __devinit sky2_probe(struct pci_dev *pdev, 3121static int __devinit sky2_probe(struct pci_dev *pdev,
3059 const struct pci_device_id *ent) 3122 const struct pci_device_id *ent)
3060{ 3123{
@@ -3135,6 +3198,12 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3135 } 3198 }
3136 hw->pm_cap = pm_cap; 3199 hw->pm_cap = pm_cap;
3137 3200
3201 /* ring for status responses */
3202 hw->st_le = pci_alloc_consistent(hw->pdev, STATUS_LE_BYTES,
3203 &hw->st_dma);
3204 if (!hw->st_le)
3205 goto err_out_iounmap;
3206
3138 err = sky2_reset(hw); 3207 err = sky2_reset(hw);
3139 if (err) 3208 if (err)
3140 goto err_out_iounmap; 3209 goto err_out_iounmap;
@@ -3169,7 +3238,22 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3169 } 3238 }
3170 } 3239 }
3171 3240
3172 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ, DRV_NAME, hw); 3241 if (!disable_msi && pci_enable_msi(pdev) == 0) {
3242 err = sky2_test_msi(hw);
3243 if (err == -EOPNOTSUPP) {
3244 /* MSI test failed, go back to INTx mode */
3245 printk(KERN_WARNING PFX "%s: No interrupt was generated using MSI, "
3246 "switching to INTx mode. Please report this failure to "
3247 "the PCI maintainer and include system chipset information.\n",
3248 pci_name(pdev));
3249 pci_disable_msi(pdev);
3250 }
3251 else if (err)
3252 goto err_out_unregister;
3253 }
3254
3255 err = request_irq(pdev->irq, sky2_intr, SA_SHIRQ | SA_SAMPLE_RANDOM,
3256 DRV_NAME, hw);
3173 if (err) { 3257 if (err) {
3174 printk(KERN_ERR PFX "%s: cannot assign irq %d\n", 3258 printk(KERN_ERR PFX "%s: cannot assign irq %d\n",
3175 pci_name(pdev), pdev->irq); 3259 pci_name(pdev), pdev->irq);
@@ -3184,6 +3268,8 @@ static int __devinit sky2_probe(struct pci_dev *pdev,
3184 return 0; 3268 return 0;
3185 3269
3186err_out_unregister: 3270err_out_unregister:
3271 if (hw->msi)
3272 pci_disable_msi(pdev);
3187 if (dev1) { 3273 if (dev1) {
3188 unregister_netdev(dev1); 3274 unregister_netdev(dev1);
3189 free_netdev(dev1); 3275 free_netdev(dev1);
@@ -3226,6 +3312,8 @@ static void __devexit sky2_remove(struct pci_dev *pdev)
3226 sky2_read8(hw, B0_CTST); 3312 sky2_read8(hw, B0_CTST);
3227 3313
3228 free_irq(pdev->irq, hw); 3314 free_irq(pdev->irq, hw);
3315 if (hw->msi)
3316 pci_disable_msi(pdev);
3229 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma); 3317 pci_free_consistent(pdev, STATUS_LE_BYTES, hw->st_le, hw->st_dma);
3230 pci_release_regions(pdev); 3318 pci_release_regions(pdev);
3231 pci_disable_device(pdev); 3319 pci_disable_device(pdev);
@@ -3263,25 +3351,33 @@ static int sky2_suspend(struct pci_dev *pdev, pm_message_t state)
3263static int sky2_resume(struct pci_dev *pdev) 3351static int sky2_resume(struct pci_dev *pdev)
3264{ 3352{
3265 struct sky2_hw *hw = pci_get_drvdata(pdev); 3353 struct sky2_hw *hw = pci_get_drvdata(pdev);
3266 int i; 3354 int i, err;
3267 3355
3268 pci_restore_state(pdev); 3356 pci_restore_state(pdev);
3269 pci_enable_wake(pdev, PCI_D0, 0); 3357 pci_enable_wake(pdev, PCI_D0, 0);
3270 sky2_set_power_state(hw, PCI_D0); 3358 err = sky2_set_power_state(hw, PCI_D0);
3359 if (err)
3360 goto out;
3271 3361
3272 sky2_reset(hw); 3362 err = sky2_reset(hw);
3363 if (err)
3364 goto out;
3273 3365
3274 for (i = 0; i < 2; i++) { 3366 for (i = 0; i < 2; i++) {
3275 struct net_device *dev = hw->dev[i]; 3367 struct net_device *dev = hw->dev[i];
3276 if (dev) { 3368 if (dev && netif_running(dev)) {
3277 if (netif_running(dev)) { 3369 netif_device_attach(dev);
3278 netif_device_attach(dev); 3370 err = sky2_up(dev);
3279 if (sky2_up(dev)) 3371 if (err) {
3280 dev_close(dev); 3372 printk(KERN_ERR PFX "%s: could not up: %d\n",
3373 dev->name, err);
3374 dev_close(dev);
3375 break;
3281 } 3376 }
3282 } 3377 }
3283 } 3378 }
3284 return 0; 3379out:
3380 return err;
3285} 3381}
3286#endif 3382#endif
3287 3383
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h
index 95518921001c..fd12c289a238 100644
--- a/drivers/net/sky2.h
+++ b/drivers/net/sky2.h
@@ -1841,6 +1841,7 @@ struct sky2_hw {
1841 struct net_device *dev[2]; 1841 struct net_device *dev[2];
1842 1842
1843 int pm_cap; 1843 int pm_cap;
1844 int msi;
1844 u8 chip_id; 1845 u8 chip_id;
1845 u8 chip_rev; 1846 u8 chip_rev;
1846 u8 copper; 1847 u8 copper;
@@ -1867,14 +1868,6 @@ static inline u8 sky2_read8(const struct sky2_hw *hw, unsigned reg)
1867 return readb(hw->regs + reg); 1868 return readb(hw->regs + reg);
1868} 1869}
1869 1870
1870/* This should probably go away, bus based tweeks suck */
1871static inline int is_pciex(const struct sky2_hw *hw)
1872{
1873 u32 status;
1874 pci_read_config_dword(hw->pdev, PCI_DEV_STATUS, &status);
1875 return (status & PCI_OS_PCI_X) == 0;
1876}
1877
1878static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val) 1871static inline void sky2_write32(const struct sky2_hw *hw, unsigned reg, u32 val)
1879{ 1872{
1880 writel(val, hw->regs + reg); 1873 writel(val, hw->regs + reg);
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 2f61a47b4716..1ff5de076d21 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -1943,7 +1943,7 @@ static int dscc4_init_ring(struct net_device *dev)
1943 (++i%TX_RING_SIZE)*sizeof(*tx_fd)); 1943 (++i%TX_RING_SIZE)*sizeof(*tx_fd));
1944 } while (i < TX_RING_SIZE); 1944 } while (i < TX_RING_SIZE);
1945 1945
1946 if (dscc4_init_dummy_skb(dpriv) < 0) 1946 if (!dscc4_init_dummy_skb(dpriv))
1947 goto err_free_dma_tx; 1947 goto err_free_dma_tx;
1948 1948
1949 memset(dpriv->rx_skbuff, 0, sizeof(struct sk_buff *)*RX_RING_SIZE); 1949 memset(dpriv->rx_skbuff, 0, sizeof(struct sk_buff *)*RX_RING_SIZE);