aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/smc91x.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-06-12 05:22:02 -0400
committerDavid S. Miller <davem@davemloft.net>2008-06-12 05:22:02 -0400
commit4bb073c0e32a0862bdb5215d11af19f6c0180c98 (patch)
tree009d95592e3813346c75129bb19d140d393ca913 /drivers/net/smc91x.c
parent7afb380db43ed137b7f67e0e3c3e5afd1ecde730 (diff)
net: Eliminate flush_scheduled_work() calls while RTNL is held.
If the RTNL is held when we invoke flush_scheduled_work() we could deadlock. One such case is linkwatch, it is a work struct which tries to grab the RTNL semaphore. The most common case are net driver ->stop() methods. The simplest conversion is to instead use cancel_{delayed_}work_sync() explicitly on the various work struct the driver uses. This is an OK transformation because these work structs are doing things like resetting the chip, restarting link negotiation, and so forth. And if we're bringing down the device, we're about to turn the chip off and reset it anways. So if we cancel a pending work event, that's fine here. Some drivers were working around this deadlock by using a msleep() polling loop of some sort, and those cases are converted to instead use cancel_{delayed_}work_sync() as well. Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/smc91x.c')
-rw-r--r--drivers/net/smc91x.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c
index a188e33484e6..f2051b209da2 100644
--- a/drivers/net/smc91x.c
+++ b/drivers/net/smc91x.c
@@ -1016,15 +1016,8 @@ static void smc_phy_powerdown(struct net_device *dev)
1016 1016
1017 /* We need to ensure that no calls to smc_phy_configure are 1017 /* We need to ensure that no calls to smc_phy_configure are
1018 pending. 1018 pending.
1019
1020 flush_scheduled_work() cannot be called because we are
1021 running with the netlink semaphore held (from
1022 devinet_ioctl()) and the pending work queue contains
1023 linkwatch_event() (scheduled by netif_carrier_off()
1024 above). linkwatch_event() also wants the netlink semaphore.
1025 */ 1019 */
1026 while(lp->work_pending) 1020 cancel_work_sync(&lp->phy_configure);
1027 yield();
1028 1021
1029 bmcr = smc_phy_read(dev, phy, MII_BMCR); 1022 bmcr = smc_phy_read(dev, phy, MII_BMCR);
1030 smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN); 1023 smc_phy_write(dev, phy, MII_BMCR, bmcr | BMCR_PDOWN);
@@ -1161,7 +1154,6 @@ static void smc_phy_configure(struct work_struct *work)
1161smc_phy_configure_exit: 1154smc_phy_configure_exit:
1162 SMC_SELECT_BANK(lp, 2); 1155 SMC_SELECT_BANK(lp, 2);
1163 spin_unlock_irq(&lp->lock); 1156 spin_unlock_irq(&lp->lock);
1164 lp->work_pending = 0;
1165} 1157}
1166 1158
1167/* 1159/*
@@ -1389,11 +1381,8 @@ static void smc_timeout(struct net_device *dev)
1389 * smc_phy_configure() calls msleep() which calls schedule_timeout() 1381 * smc_phy_configure() calls msleep() which calls schedule_timeout()
1390 * which calls schedule(). Hence we use a work queue. 1382 * which calls schedule(). Hence we use a work queue.
1391 */ 1383 */
1392 if (lp->phy_type != 0) { 1384 if (lp->phy_type != 0)
1393 if (schedule_work(&lp->phy_configure)) { 1385 schedule_work(&lp->phy_configure);
1394 lp->work_pending = 1;
1395 }
1396 }
1397 1386
1398 /* We can accept TX packets again */ 1387 /* We can accept TX packets again */
1399 dev->trans_start = jiffies; 1388 dev->trans_start = jiffies;