diff options
author | Vladislav Zolotarov <vladz@broadcom.com> | 2010-02-16 21:03:27 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-02-17 16:35:41 -0500 |
commit | 6cbe5065bb367d4c8db0a71d2e828995bcfae336 (patch) | |
tree | 8a2a715d587fb60acc66fa47f127e812fcc342a2 /drivers/net/bnx2x_main.c | |
parent | a475f603d23392f386e45cf377b17c30ed3bbb80 (diff) |
bnx2x: Properly release allocated MSI-X/MSI vectors
Bug fix: Properly release allocated MSI-X/MSI vectors if ifup failed
due to lack of memory.
Signed-off-by: Vladislav Zolotarov <vladz@broadcom.com>
Signed-off-by: Eilon Greenstein <eilong@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/bnx2x_main.c')
-rw-r--r-- | drivers/net/bnx2x_main.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/net/bnx2x_main.c b/drivers/net/bnx2x_main.c index 6d8559052ee6..d7aef840a1d5 100644 --- a/drivers/net/bnx2x_main.c +++ b/drivers/net/bnx2x_main.c | |||
@@ -6938,19 +6938,21 @@ static void bnx2x_free_msix_irqs(struct bnx2x *bp) | |||
6938 | } | 6938 | } |
6939 | } | 6939 | } |
6940 | 6940 | ||
6941 | static void bnx2x_free_irq(struct bnx2x *bp) | 6941 | static void bnx2x_free_irq(struct bnx2x *bp, bool disable_only) |
6942 | { | 6942 | { |
6943 | if (bp->flags & USING_MSIX_FLAG) { | 6943 | if (bp->flags & USING_MSIX_FLAG) { |
6944 | bnx2x_free_msix_irqs(bp); | 6944 | if (!disable_only) |
6945 | bnx2x_free_msix_irqs(bp); | ||
6945 | pci_disable_msix(bp->pdev); | 6946 | pci_disable_msix(bp->pdev); |
6946 | bp->flags &= ~USING_MSIX_FLAG; | 6947 | bp->flags &= ~USING_MSIX_FLAG; |
6947 | 6948 | ||
6948 | } else if (bp->flags & USING_MSI_FLAG) { | 6949 | } else if (bp->flags & USING_MSI_FLAG) { |
6949 | free_irq(bp->pdev->irq, bp->dev); | 6950 | if (!disable_only) |
6951 | free_irq(bp->pdev->irq, bp->dev); | ||
6950 | pci_disable_msi(bp->pdev); | 6952 | pci_disable_msi(bp->pdev); |
6951 | bp->flags &= ~USING_MSI_FLAG; | 6953 | bp->flags &= ~USING_MSI_FLAG; |
6952 | 6954 | ||
6953 | } else | 6955 | } else if (!disable_only) |
6954 | free_irq(bp->pdev->irq, bp->dev); | 6956 | free_irq(bp->pdev->irq, bp->dev); |
6955 | } | 6957 | } |
6956 | 6958 | ||
@@ -7443,8 +7445,10 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode) | |||
7443 | 7445 | ||
7444 | rc = bnx2x_set_num_queues(bp); | 7446 | rc = bnx2x_set_num_queues(bp); |
7445 | 7447 | ||
7446 | if (bnx2x_alloc_mem(bp)) | 7448 | if (bnx2x_alloc_mem(bp)) { |
7449 | bnx2x_free_irq(bp, true); | ||
7447 | return -ENOMEM; | 7450 | return -ENOMEM; |
7451 | } | ||
7448 | 7452 | ||
7449 | for_each_queue(bp, i) | 7453 | for_each_queue(bp, i) |
7450 | bnx2x_fp(bp, i, disable_tpa) = | 7454 | bnx2x_fp(bp, i, disable_tpa) = |
@@ -7459,7 +7463,7 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode) | |||
7459 | if (bp->flags & USING_MSIX_FLAG) { | 7463 | if (bp->flags & USING_MSIX_FLAG) { |
7460 | rc = bnx2x_req_msix_irqs(bp); | 7464 | rc = bnx2x_req_msix_irqs(bp); |
7461 | if (rc) { | 7465 | if (rc) { |
7462 | pci_disable_msix(bp->pdev); | 7466 | bnx2x_free_irq(bp, true); |
7463 | goto load_error1; | 7467 | goto load_error1; |
7464 | } | 7468 | } |
7465 | } else { | 7469 | } else { |
@@ -7471,8 +7475,7 @@ static int bnx2x_nic_load(struct bnx2x *bp, int load_mode) | |||
7471 | rc = bnx2x_req_irq(bp); | 7475 | rc = bnx2x_req_irq(bp); |
7472 | if (rc) { | 7476 | if (rc) { |
7473 | BNX2X_ERR("IRQ request failed rc %d, aborting\n", rc); | 7477 | BNX2X_ERR("IRQ request failed rc %d, aborting\n", rc); |
7474 | if (bp->flags & USING_MSI_FLAG) | 7478 | bnx2x_free_irq(bp, true); |
7475 | pci_disable_msi(bp->pdev); | ||
7476 | goto load_error1; | 7479 | goto load_error1; |
7477 | } | 7480 | } |
7478 | if (bp->flags & USING_MSI_FLAG) { | 7481 | if (bp->flags & USING_MSI_FLAG) { |
@@ -7664,7 +7667,7 @@ load_error3: | |||
7664 | bnx2x_free_rx_sge_range(bp, bp->fp + i, NUM_RX_SGE); | 7667 | bnx2x_free_rx_sge_range(bp, bp->fp + i, NUM_RX_SGE); |
7665 | load_error2: | 7668 | load_error2: |
7666 | /* Release IRQs */ | 7669 | /* Release IRQs */ |
7667 | bnx2x_free_irq(bp); | 7670 | bnx2x_free_irq(bp, false); |
7668 | load_error1: | 7671 | load_error1: |
7669 | bnx2x_napi_disable(bp); | 7672 | bnx2x_napi_disable(bp); |
7670 | for_each_queue(bp, i) | 7673 | for_each_queue(bp, i) |
@@ -7855,7 +7858,7 @@ static int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode) | |||
7855 | bnx2x_stats_handle(bp, STATS_EVENT_STOP); | 7858 | bnx2x_stats_handle(bp, STATS_EVENT_STOP); |
7856 | 7859 | ||
7857 | /* Release IRQs */ | 7860 | /* Release IRQs */ |
7858 | bnx2x_free_irq(bp); | 7861 | bnx2x_free_irq(bp, false); |
7859 | 7862 | ||
7860 | /* Wait until tx fastpath tasks complete */ | 7863 | /* Wait until tx fastpath tasks complete */ |
7861 | for_each_queue(bp, i) { | 7864 | for_each_queue(bp, i) { |
@@ -12299,7 +12302,7 @@ static int bnx2x_eeh_nic_unload(struct bnx2x *bp) | |||
12299 | DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); | 12302 | DP(BNX2X_MSG_STATS, "stats_state - DISABLED\n"); |
12300 | 12303 | ||
12301 | /* Release IRQs */ | 12304 | /* Release IRQs */ |
12302 | bnx2x_free_irq(bp); | 12305 | bnx2x_free_irq(bp, false); |
12303 | 12306 | ||
12304 | if (CHIP_IS_E1(bp)) { | 12307 | if (CHIP_IS_E1(bp)) { |
12305 | struct mac_configuration_cmd *config = | 12308 | struct mac_configuration_cmd *config = |