diff options
author | David S. Miller <davem@davemloft.net> | 2017-02-20 21:59:16 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-02-20 21:59:16 -0500 |
commit | 836dacdd5b932f8ed8ca9f90e7b7e6751f478627 (patch) | |
tree | 60ec6dda407753d540aa5e28b407e7e449f14a8c | |
parent | 5a4dcdcac8e591e235943998caffdf6ac421a422 (diff) | |
parent | 17086399c113d933e1202697f85b8f0f82fcb8ce (diff) |
Merge branch 'bnxt_en-probe-and-open-bugs'
Michael Chan says:
====================
bnxt_en: Fix probe and open bugs.
Fix 3 issues related to bnxt_init_one() and bnxt_open(). Don't probe
bridge devices and fixup some error code paths.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/broadcom/bnxt/bnxt.c | 82 |
1 files changed, 43 insertions, 39 deletions
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 71f9a1894db9..6dacdf1e4d26 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c | |||
@@ -3134,8 +3134,10 @@ static void bnxt_disable_int(struct bnxt *bp) | |||
3134 | for (i = 0; i < bp->cp_nr_rings; i++) { | 3134 | for (i = 0; i < bp->cp_nr_rings; i++) { |
3135 | struct bnxt_napi *bnapi = bp->bnapi[i]; | 3135 | struct bnxt_napi *bnapi = bp->bnapi[i]; |
3136 | struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; | 3136 | struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; |
3137 | struct bnxt_ring_struct *ring = &cpr->cp_ring_struct; | ||
3137 | 3138 | ||
3138 | BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons); | 3139 | if (ring->fw_ring_id != INVALID_HW_RING_ID) |
3140 | BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons); | ||
3139 | } | 3141 | } |
3140 | } | 3142 | } |
3141 | 3143 | ||
@@ -6674,6 +6676,31 @@ int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, int tcs, int tx_xdp) | |||
6674 | return 0; | 6676 | return 0; |
6675 | } | 6677 | } |
6676 | 6678 | ||
6679 | static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev) | ||
6680 | { | ||
6681 | if (bp->bar2) { | ||
6682 | pci_iounmap(pdev, bp->bar2); | ||
6683 | bp->bar2 = NULL; | ||
6684 | } | ||
6685 | |||
6686 | if (bp->bar1) { | ||
6687 | pci_iounmap(pdev, bp->bar1); | ||
6688 | bp->bar1 = NULL; | ||
6689 | } | ||
6690 | |||
6691 | if (bp->bar0) { | ||
6692 | pci_iounmap(pdev, bp->bar0); | ||
6693 | bp->bar0 = NULL; | ||
6694 | } | ||
6695 | } | ||
6696 | |||
6697 | static void bnxt_cleanup_pci(struct bnxt *bp) | ||
6698 | { | ||
6699 | bnxt_unmap_bars(bp, bp->pdev); | ||
6700 | pci_release_regions(bp->pdev); | ||
6701 | pci_disable_device(bp->pdev); | ||
6702 | } | ||
6703 | |||
6677 | static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) | 6704 | static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) |
6678 | { | 6705 | { |
6679 | int rc; | 6706 | int rc; |
@@ -6761,25 +6788,10 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) | |||
6761 | bp->current_interval = BNXT_TIMER_INTERVAL; | 6788 | bp->current_interval = BNXT_TIMER_INTERVAL; |
6762 | 6789 | ||
6763 | clear_bit(BNXT_STATE_OPEN, &bp->state); | 6790 | clear_bit(BNXT_STATE_OPEN, &bp->state); |
6764 | |||
6765 | return 0; | 6791 | return 0; |
6766 | 6792 | ||
6767 | init_err_release: | 6793 | init_err_release: |
6768 | if (bp->bar2) { | 6794 | bnxt_unmap_bars(bp, pdev); |
6769 | pci_iounmap(pdev, bp->bar2); | ||
6770 | bp->bar2 = NULL; | ||
6771 | } | ||
6772 | |||
6773 | if (bp->bar1) { | ||
6774 | pci_iounmap(pdev, bp->bar1); | ||
6775 | bp->bar1 = NULL; | ||
6776 | } | ||
6777 | |||
6778 | if (bp->bar0) { | ||
6779 | pci_iounmap(pdev, bp->bar0); | ||
6780 | bp->bar0 = NULL; | ||
6781 | } | ||
6782 | |||
6783 | pci_release_regions(pdev); | 6795 | pci_release_regions(pdev); |
6784 | 6796 | ||
6785 | init_err_disable: | 6797 | init_err_disable: |
@@ -7184,17 +7196,12 @@ static void bnxt_remove_one(struct pci_dev *pdev) | |||
7184 | bnxt_hwrm_func_drv_unrgtr(bp); | 7196 | bnxt_hwrm_func_drv_unrgtr(bp); |
7185 | bnxt_free_hwrm_resources(bp); | 7197 | bnxt_free_hwrm_resources(bp); |
7186 | bnxt_dcb_free(bp); | 7198 | bnxt_dcb_free(bp); |
7187 | pci_iounmap(pdev, bp->bar2); | ||
7188 | pci_iounmap(pdev, bp->bar1); | ||
7189 | pci_iounmap(pdev, bp->bar0); | ||
7190 | kfree(bp->edev); | 7199 | kfree(bp->edev); |
7191 | bp->edev = NULL; | 7200 | bp->edev = NULL; |
7192 | if (bp->xdp_prog) | 7201 | if (bp->xdp_prog) |
7193 | bpf_prog_put(bp->xdp_prog); | 7202 | bpf_prog_put(bp->xdp_prog); |
7203 | bnxt_cleanup_pci(bp); | ||
7194 | free_netdev(dev); | 7204 | free_netdev(dev); |
7195 | |||
7196 | pci_release_regions(pdev); | ||
7197 | pci_disable_device(pdev); | ||
7198 | } | 7205 | } |
7199 | 7206 | ||
7200 | static int bnxt_probe_phy(struct bnxt *bp) | 7207 | static int bnxt_probe_phy(struct bnxt *bp) |
@@ -7400,7 +7407,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7400 | struct bnxt *bp; | 7407 | struct bnxt *bp; |
7401 | int rc, max_irqs; | 7408 | int rc, max_irqs; |
7402 | 7409 | ||
7403 | if (pdev->device == 0x16cd && pci_is_bridge(pdev)) | 7410 | if (pci_is_bridge(pdev)) |
7404 | return -ENODEV; | 7411 | return -ENODEV; |
7405 | 7412 | ||
7406 | if (version_printed++ == 0) | 7413 | if (version_printed++ == 0) |
@@ -7426,17 +7433,16 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7426 | dev->netdev_ops = &bnxt_netdev_ops; | 7433 | dev->netdev_ops = &bnxt_netdev_ops; |
7427 | dev->watchdog_timeo = BNXT_TX_TIMEOUT; | 7434 | dev->watchdog_timeo = BNXT_TX_TIMEOUT; |
7428 | dev->ethtool_ops = &bnxt_ethtool_ops; | 7435 | dev->ethtool_ops = &bnxt_ethtool_ops; |
7429 | |||
7430 | pci_set_drvdata(pdev, dev); | 7436 | pci_set_drvdata(pdev, dev); |
7431 | 7437 | ||
7432 | rc = bnxt_alloc_hwrm_resources(bp); | 7438 | rc = bnxt_alloc_hwrm_resources(bp); |
7433 | if (rc) | 7439 | if (rc) |
7434 | goto init_err; | 7440 | goto init_err_pci_clean; |
7435 | 7441 | ||
7436 | mutex_init(&bp->hwrm_cmd_lock); | 7442 | mutex_init(&bp->hwrm_cmd_lock); |
7437 | rc = bnxt_hwrm_ver_get(bp); | 7443 | rc = bnxt_hwrm_ver_get(bp); |
7438 | if (rc) | 7444 | if (rc) |
7439 | goto init_err; | 7445 | goto init_err_pci_clean; |
7440 | 7446 | ||
7441 | bnxt_hwrm_fw_set_time(bp); | 7447 | bnxt_hwrm_fw_set_time(bp); |
7442 | 7448 | ||
@@ -7480,11 +7486,11 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7480 | 7486 | ||
7481 | rc = bnxt_hwrm_func_drv_rgtr(bp); | 7487 | rc = bnxt_hwrm_func_drv_rgtr(bp); |
7482 | if (rc) | 7488 | if (rc) |
7483 | goto init_err; | 7489 | goto init_err_pci_clean; |
7484 | 7490 | ||
7485 | rc = bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0); | 7491 | rc = bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0); |
7486 | if (rc) | 7492 | if (rc) |
7487 | goto init_err; | 7493 | goto init_err_pci_clean; |
7488 | 7494 | ||
7489 | bp->ulp_probe = bnxt_ulp_probe; | 7495 | bp->ulp_probe = bnxt_ulp_probe; |
7490 | 7496 | ||
@@ -7494,7 +7500,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7494 | netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", | 7500 | netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", |
7495 | rc); | 7501 | rc); |
7496 | rc = -1; | 7502 | rc = -1; |
7497 | goto init_err; | 7503 | goto init_err_pci_clean; |
7498 | } | 7504 | } |
7499 | 7505 | ||
7500 | rc = bnxt_hwrm_queue_qportcfg(bp); | 7506 | rc = bnxt_hwrm_queue_qportcfg(bp); |
@@ -7502,7 +7508,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7502 | netdev_err(bp->dev, "hwrm query qportcfg failure rc: %x\n", | 7508 | netdev_err(bp->dev, "hwrm query qportcfg failure rc: %x\n", |
7503 | rc); | 7509 | rc); |
7504 | rc = -1; | 7510 | rc = -1; |
7505 | goto init_err; | 7511 | goto init_err_pci_clean; |
7506 | } | 7512 | } |
7507 | 7513 | ||
7508 | bnxt_hwrm_func_qcfg(bp); | 7514 | bnxt_hwrm_func_qcfg(bp); |
@@ -7516,7 +7522,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7516 | if (rc) { | 7522 | if (rc) { |
7517 | netdev_err(bp->dev, "Not enough rings available.\n"); | 7523 | netdev_err(bp->dev, "Not enough rings available.\n"); |
7518 | rc = -ENOMEM; | 7524 | rc = -ENOMEM; |
7519 | goto init_err; | 7525 | goto init_err_pci_clean; |
7520 | } | 7526 | } |
7521 | 7527 | ||
7522 | /* Default RSS hash cfg. */ | 7528 | /* Default RSS hash cfg. */ |
@@ -7546,15 +7552,15 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7546 | 7552 | ||
7547 | rc = bnxt_probe_phy(bp); | 7553 | rc = bnxt_probe_phy(bp); |
7548 | if (rc) | 7554 | if (rc) |
7549 | goto init_err; | 7555 | goto init_err_pci_clean; |
7550 | 7556 | ||
7551 | rc = bnxt_hwrm_func_reset(bp); | 7557 | rc = bnxt_hwrm_func_reset(bp); |
7552 | if (rc) | 7558 | if (rc) |
7553 | goto init_err; | 7559 | goto init_err_pci_clean; |
7554 | 7560 | ||
7555 | rc = bnxt_init_int_mode(bp); | 7561 | rc = bnxt_init_int_mode(bp); |
7556 | if (rc) | 7562 | if (rc) |
7557 | goto init_err; | 7563 | goto init_err_pci_clean; |
7558 | 7564 | ||
7559 | rc = register_netdev(dev); | 7565 | rc = register_netdev(dev); |
7560 | if (rc) | 7566 | if (rc) |
@@ -7571,10 +7577,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
7571 | init_err_clr_int: | 7577 | init_err_clr_int: |
7572 | bnxt_clear_int_mode(bp); | 7578 | bnxt_clear_int_mode(bp); |
7573 | 7579 | ||
7574 | init_err: | 7580 | init_err_pci_clean: |
7575 | pci_iounmap(pdev, bp->bar0); | 7581 | bnxt_cleanup_pci(bp); |
7576 | pci_release_regions(pdev); | ||
7577 | pci_disable_device(pdev); | ||
7578 | 7582 | ||
7579 | init_err_free: | 7583 | init_err_free: |
7580 | free_netdev(dev); | 7584 | free_netdev(dev); |