aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bnx2.c
diff options
context:
space:
mode:
authorMichael Chan <mchan@broadcom.com>2011-07-15 02:53:58 -0400
committerDavid S. Miller <davem@davemloft.net>2011-07-16 13:13:19 -0400
commitcd6340199f65cad63262db0fd561bdcfd69df3bd (patch)
tree860d6188cf381bb0c3a8de0f2a133e8e954b5586 /drivers/net/bnx2.c
parent25009a1ae1171eda6bff44b7e44eb0e076713811 (diff)
bnx2: Close device if tx_timeout reset fails
Based on original patch and description from Flavio Leitner <fbl@redhat.com> When bnx2_reset_task() is called, it will stop, (re)initialize and start the interface to restore the working condition. The bnx2_init_nic() calls bnx2_reset_nic() which will reset the chip and then calls bnx2_free_skbs() to free all the skbs. The problem happens when bnx2_init_chip() fails because bnx2_reset_nic() will just return skipping the ring initializations at bnx2_init_all_rings(). Later, the reset task starts the interface again and the system crashes due a NULL pointer access (no skb in the ring). To fix it, we call dev_close() if bnx2_init_nic() fails. One minor wrinkle to deal with is the cancel_work_sync() call in bnx2_close() to cancel bnx2_reset_task(). The call will wait forever because it is trying to cancel itself and the workqueue will be stuck. Since bnx2_reset_task() holds the rtnl_lock() and checks for netif_running() before proceeding, there is no need to cancel bnx2_reset_task() in bnx2_close() even if bnx2_close() and bnx2_reset_task() are running concurrently. The rtnl_lock() serializes the 2 calls. We need to move the cancel_work_sync() call to bnx2_remove_one() to make sure it is canceled before freeing the netdev struct. Signed-off-by: Michael Chan <mchan@broadcom.com> Signed-off-by: Matt Carlson <mcarlson@broadcom.com> Cc: Flavio Leitner <fbl@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r--drivers/net/bnx2.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 4816d6a5fe62..3ad9b70ef1b2 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -6342,6 +6342,7 @@ static void
6342bnx2_reset_task(struct work_struct *work) 6342bnx2_reset_task(struct work_struct *work)
6343{ 6343{
6344 struct bnx2 *bp = container_of(work, struct bnx2, reset_task); 6344 struct bnx2 *bp = container_of(work, struct bnx2, reset_task);
6345 int rc;
6345 6346
6346 rtnl_lock(); 6347 rtnl_lock();
6347 if (!netif_running(bp->dev)) { 6348 if (!netif_running(bp->dev)) {
@@ -6351,7 +6352,14 @@ bnx2_reset_task(struct work_struct *work)
6351 6352
6352 bnx2_netif_stop(bp, true); 6353 bnx2_netif_stop(bp, true);
6353 6354
6354 bnx2_init_nic(bp, 1); 6355 rc = bnx2_init_nic(bp, 1);
6356 if (rc) {
6357 netdev_err(bp->dev, "failed to reset NIC, closing\n");
6358 bnx2_napi_enable(bp);
6359 dev_close(bp->dev);
6360 rtnl_unlock();
6361 return;
6362 }
6355 6363
6356 atomic_set(&bp->intr_sem, 1); 6364 atomic_set(&bp->intr_sem, 1);
6357 bnx2_netif_start(bp, true); 6365 bnx2_netif_start(bp, true);
@@ -6573,8 +6581,6 @@ bnx2_close(struct net_device *dev)
6573{ 6581{
6574 struct bnx2 *bp = netdev_priv(dev); 6582 struct bnx2 *bp = netdev_priv(dev);
6575 6583
6576 cancel_work_sync(&bp->reset_task);
6577
6578 bnx2_disable_int_sync(bp); 6584 bnx2_disable_int_sync(bp);
6579 bnx2_napi_disable(bp); 6585 bnx2_napi_disable(bp);
6580 del_timer_sync(&bp->timer); 6586 del_timer_sync(&bp->timer);
@@ -8404,6 +8410,7 @@ bnx2_remove_one(struct pci_dev *pdev)
8404 unregister_netdev(dev); 8410 unregister_netdev(dev);
8405 8411
8406 del_timer_sync(&bp->timer); 8412 del_timer_sync(&bp->timer);
8413 cancel_work_sync(&bp->reset_task);
8407 8414
8408 if (bp->mips_firmware) 8415 if (bp->mips_firmware)
8409 release_firmware(bp->mips_firmware); 8416 release_firmware(bp->mips_firmware);