diff options
author | John W. Linville <linville@tuxdriver.com> | 2005-10-18 21:31:02 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-18 22:26:01 -0400 |
commit | 6ba98d311d0a4ff7dc36d8f435ce60174f4c30ec (patch) | |
tree | 745daba38635eca9466319f8c8940d1fb3e8ed3c | |
parent | 923833405d8d81b5be036093773d88d87fc7e1bd (diff) |
[PATCH] via-rhine: change mdelay to msleep and remove from ISR path
Get rid of the mdelay call in rhine_disable_linkmon. The function
is called from the via-rhine versions of mdio_read and mdio_write.
Those functions are indirectly called from rhine_check_media and
rhine_tx_timeout, both of which can be called in interrupt context.
So, create tx_timeout_task and check_media_task as instances of struct
work_struct inside of rhine_private. Then, change rhine_tx_timeout to
invoke schedule_work for tx_timeout_task (i.e. rhine_tx_timeout_task),
moving the work to process context. Also, change rhine_error (invoked
from rhine_interrupt) to invoke schedule_work for check_media_task
(i.e. rhine_check_media_task), which simply calls rhine_check media
in process context. Finally, add a call to flush_scheduled_work in
rhine_close to avoid any resource conflicts with pending work items.
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
-rw-r--r-- | drivers/net/via-rhine.c | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index e7b4bc3820e3..241871589283 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c | |||
@@ -490,6 +490,8 @@ struct rhine_private { | |||
490 | u8 tx_thresh, rx_thresh; | 490 | u8 tx_thresh, rx_thresh; |
491 | 491 | ||
492 | struct mii_if_info mii_if; | 492 | struct mii_if_info mii_if; |
493 | struct work_struct tx_timeout_task; | ||
494 | struct work_struct check_media_task; | ||
493 | void __iomem *base; | 495 | void __iomem *base; |
494 | }; | 496 | }; |
495 | 497 | ||
@@ -497,6 +499,8 @@ static int mdio_read(struct net_device *dev, int phy_id, int location); | |||
497 | static void mdio_write(struct net_device *dev, int phy_id, int location, int value); | 499 | static void mdio_write(struct net_device *dev, int phy_id, int location, int value); |
498 | static int rhine_open(struct net_device *dev); | 500 | static int rhine_open(struct net_device *dev); |
499 | static void rhine_tx_timeout(struct net_device *dev); | 501 | static void rhine_tx_timeout(struct net_device *dev); |
502 | static void rhine_tx_timeout_task(struct net_device *dev); | ||
503 | static void rhine_check_media_task(struct net_device *dev); | ||
500 | static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev); | 504 | static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev); |
501 | static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs); | 505 | static irqreturn_t rhine_interrupt(int irq, void *dev_instance, struct pt_regs *regs); |
502 | static void rhine_tx(struct net_device *dev); | 506 | static void rhine_tx(struct net_device *dev); |
@@ -851,6 +855,12 @@ static int __devinit rhine_init_one(struct pci_dev *pdev, | |||
851 | if (rp->quirks & rqRhineI) | 855 | if (rp->quirks & rqRhineI) |
852 | dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; | 856 | dev->features |= NETIF_F_SG|NETIF_F_HW_CSUM; |
853 | 857 | ||
858 | INIT_WORK(&rp->tx_timeout_task, | ||
859 | (void (*)(void *))rhine_tx_timeout_task, dev); | ||
860 | |||
861 | INIT_WORK(&rp->check_media_task, | ||
862 | (void (*)(void *))rhine_check_media_task, dev); | ||
863 | |||
854 | /* dev->name not defined before register_netdev()! */ | 864 | /* dev->name not defined before register_netdev()! */ |
855 | rc = register_netdev(dev); | 865 | rc = register_netdev(dev); |
856 | if (rc) | 866 | if (rc) |
@@ -1077,6 +1087,11 @@ static void rhine_check_media(struct net_device *dev, unsigned int init_media) | |||
1077 | ioaddr + ChipCmd1); | 1087 | ioaddr + ChipCmd1); |
1078 | } | 1088 | } |
1079 | 1089 | ||
1090 | static void rhine_check_media_task(struct net_device *dev) | ||
1091 | { | ||
1092 | rhine_check_media(dev, 0); | ||
1093 | } | ||
1094 | |||
1080 | static void init_registers(struct net_device *dev) | 1095 | static void init_registers(struct net_device *dev) |
1081 | { | 1096 | { |
1082 | struct rhine_private *rp = netdev_priv(dev); | 1097 | struct rhine_private *rp = netdev_priv(dev); |
@@ -1130,8 +1145,8 @@ static void rhine_disable_linkmon(void __iomem *ioaddr, u32 quirks) | |||
1130 | if (quirks & rqRhineI) { | 1145 | if (quirks & rqRhineI) { |
1131 | iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR | 1146 | iowrite8(0x01, ioaddr + MIIRegAddr); // MII_BMSR |
1132 | 1147 | ||
1133 | /* Can be called from ISR. Evil. */ | 1148 | /* Do not call from ISR! */ |
1134 | mdelay(1); | 1149 | msleep(1); |
1135 | 1150 | ||
1136 | /* 0x80 must be set immediately before turning it off */ | 1151 | /* 0x80 must be set immediately before turning it off */ |
1137 | iowrite8(0x80, ioaddr + MIICmd); | 1152 | iowrite8(0x80, ioaddr + MIICmd); |
@@ -1221,6 +1236,16 @@ static int rhine_open(struct net_device *dev) | |||
1221 | static void rhine_tx_timeout(struct net_device *dev) | 1236 | static void rhine_tx_timeout(struct net_device *dev) |
1222 | { | 1237 | { |
1223 | struct rhine_private *rp = netdev_priv(dev); | 1238 | struct rhine_private *rp = netdev_priv(dev); |
1239 | |||
1240 | /* | ||
1241 | * Move bulk of work outside of interrupt context | ||
1242 | */ | ||
1243 | schedule_work(&rp->tx_timeout_task); | ||
1244 | } | ||
1245 | |||
1246 | static void rhine_tx_timeout_task(struct net_device *dev) | ||
1247 | { | ||
1248 | struct rhine_private *rp = netdev_priv(dev); | ||
1224 | void __iomem *ioaddr = rp->base; | 1249 | void __iomem *ioaddr = rp->base; |
1225 | 1250 | ||
1226 | printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status " | 1251 | printk(KERN_WARNING "%s: Transmit timed out, status %4.4x, PHY status " |
@@ -1626,7 +1651,7 @@ static void rhine_error(struct net_device *dev, int intr_status) | |||
1626 | spin_lock(&rp->lock); | 1651 | spin_lock(&rp->lock); |
1627 | 1652 | ||
1628 | if (intr_status & IntrLinkChange) | 1653 | if (intr_status & IntrLinkChange) |
1629 | rhine_check_media(dev, 0); | 1654 | schedule_work(&rp->check_media_task); |
1630 | if (intr_status & IntrStatsMax) { | 1655 | if (intr_status & IntrStatsMax) { |
1631 | rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs); | 1656 | rp->stats.rx_crc_errors += ioread16(ioaddr + RxCRCErrs); |
1632 | rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed); | 1657 | rp->stats.rx_missed_errors += ioread16(ioaddr + RxMissed); |
@@ -1874,6 +1899,9 @@ static int rhine_close(struct net_device *dev) | |||
1874 | spin_unlock_irq(&rp->lock); | 1899 | spin_unlock_irq(&rp->lock); |
1875 | 1900 | ||
1876 | free_irq(rp->pdev->irq, dev); | 1901 | free_irq(rp->pdev->irq, dev); |
1902 | |||
1903 | flush_scheduled_work(); | ||
1904 | |||
1877 | free_rbufs(dev); | 1905 | free_rbufs(dev); |
1878 | free_tbufs(dev); | 1906 | free_tbufs(dev); |
1879 | free_ring(dev); | 1907 | free_ring(dev); |