diff options
author | Michael Chan <mchan@broadcom.com> | 2009-08-14 11:49:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-08-15 21:50:44 -0400 |
commit | c5a889508203446c1abc1d670599b3a816841813 (patch) | |
tree | 9e03c5f9a1dd88bcf8e277cdabbde49f1a6ab3e3 /drivers/net/bnx2.c | |
parent | a3059b12adae868c42629ecf058a94195ef1e958 (diff) |
bnx2: Use mutex on slow path cnic calls.
The slow path calls to the cnic driver are sleepable calls so we
cannot use rcu_read_lock(). Use mutex for these slow path calls
instead.
Signed-off-by: Michael Chan <mchan@broadcom.com>
Reviewed-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2.c')
-rw-r--r-- | drivers/net/bnx2.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c index b70cc99962fc..06b901152d44 100644 --- a/drivers/net/bnx2.c +++ b/drivers/net/bnx2.c | |||
@@ -399,9 +399,11 @@ static int bnx2_unregister_cnic(struct net_device *dev) | |||
399 | struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; | 399 | struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; |
400 | struct cnic_eth_dev *cp = &bp->cnic_eth_dev; | 400 | struct cnic_eth_dev *cp = &bp->cnic_eth_dev; |
401 | 401 | ||
402 | mutex_lock(&bp->cnic_lock); | ||
402 | cp->drv_state = 0; | 403 | cp->drv_state = 0; |
403 | bnapi->cnic_present = 0; | 404 | bnapi->cnic_present = 0; |
404 | rcu_assign_pointer(bp->cnic_ops, NULL); | 405 | rcu_assign_pointer(bp->cnic_ops, NULL); |
406 | mutex_unlock(&bp->cnic_lock); | ||
405 | synchronize_rcu(); | 407 | synchronize_rcu(); |
406 | return 0; | 408 | return 0; |
407 | } | 409 | } |
@@ -429,13 +431,13 @@ bnx2_cnic_stop(struct bnx2 *bp) | |||
429 | struct cnic_ops *c_ops; | 431 | struct cnic_ops *c_ops; |
430 | struct cnic_ctl_info info; | 432 | struct cnic_ctl_info info; |
431 | 433 | ||
432 | rcu_read_lock(); | 434 | mutex_lock(&bp->cnic_lock); |
433 | c_ops = rcu_dereference(bp->cnic_ops); | 435 | c_ops = bp->cnic_ops; |
434 | if (c_ops) { | 436 | if (c_ops) { |
435 | info.cmd = CNIC_CTL_STOP_CMD; | 437 | info.cmd = CNIC_CTL_STOP_CMD; |
436 | c_ops->cnic_ctl(bp->cnic_data, &info); | 438 | c_ops->cnic_ctl(bp->cnic_data, &info); |
437 | } | 439 | } |
438 | rcu_read_unlock(); | 440 | mutex_unlock(&bp->cnic_lock); |
439 | } | 441 | } |
440 | 442 | ||
441 | static void | 443 | static void |
@@ -444,8 +446,8 @@ bnx2_cnic_start(struct bnx2 *bp) | |||
444 | struct cnic_ops *c_ops; | 446 | struct cnic_ops *c_ops; |
445 | struct cnic_ctl_info info; | 447 | struct cnic_ctl_info info; |
446 | 448 | ||
447 | rcu_read_lock(); | 449 | mutex_lock(&bp->cnic_lock); |
448 | c_ops = rcu_dereference(bp->cnic_ops); | 450 | c_ops = bp->cnic_ops; |
449 | if (c_ops) { | 451 | if (c_ops) { |
450 | if (!(bp->flags & BNX2_FLAG_USING_MSIX)) { | 452 | if (!(bp->flags & BNX2_FLAG_USING_MSIX)) { |
451 | struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; | 453 | struct bnx2_napi *bnapi = &bp->bnx2_napi[0]; |
@@ -455,7 +457,7 @@ bnx2_cnic_start(struct bnx2 *bp) | |||
455 | info.cmd = CNIC_CTL_START_CMD; | 457 | info.cmd = CNIC_CTL_START_CMD; |
456 | c_ops->cnic_ctl(bp->cnic_data, &info); | 458 | c_ops->cnic_ctl(bp->cnic_data, &info); |
457 | } | 459 | } |
458 | rcu_read_unlock(); | 460 | mutex_unlock(&bp->cnic_lock); |
459 | } | 461 | } |
460 | 462 | ||
461 | #else | 463 | #else |
@@ -7663,6 +7665,9 @@ bnx2_init_board(struct pci_dev *pdev, struct net_device *dev) | |||
7663 | 7665 | ||
7664 | spin_lock_init(&bp->phy_lock); | 7666 | spin_lock_init(&bp->phy_lock); |
7665 | spin_lock_init(&bp->indirect_lock); | 7667 | spin_lock_init(&bp->indirect_lock); |
7668 | #ifdef BCM_CNIC | ||
7669 | mutex_init(&bp->cnic_lock); | ||
7670 | #endif | ||
7666 | INIT_WORK(&bp->reset_task, bnx2_reset_task); | 7671 | INIT_WORK(&bp->reset_task, bnx2_reset_task); |
7667 | 7672 | ||
7668 | dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); | 7673 | dev->base_addr = dev->mem_start = pci_resource_start(pdev, 0); |