Commit 836dacdd authored by David S. Miller's avatar David S. Miller

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: default avatarDavid S. Miller <davem@davemloft.net>
parents 5a4dcdca 17086399
...@@ -3134,7 +3134,9 @@ static void bnxt_disable_int(struct bnxt *bp) ...@@ -3134,7 +3134,9 @@ static void bnxt_disable_int(struct bnxt *bp)
for (i = 0; i < bp->cp_nr_rings; i++) { for (i = 0; i < bp->cp_nr_rings; i++) {
struct bnxt_napi *bnapi = bp->bnapi[i]; struct bnxt_napi *bnapi = bp->bnapi[i];
struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring; struct bnxt_cp_ring_info *cpr = &bnapi->cp_ring;
struct bnxt_ring_struct *ring = &cpr->cp_ring_struct;
if (ring->fw_ring_id != INVALID_HW_RING_ID)
BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons); BNXT_CP_DB(cpr->cp_doorbell, cpr->cp_raw_cons);
} }
} }
...@@ -6674,6 +6676,31 @@ int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, int tcs, int tx_xdp) ...@@ -6674,6 +6676,31 @@ int bnxt_reserve_rings(struct bnxt *bp, int tx, int rx, int tcs, int tx_xdp)
return 0; return 0;
} }
static void bnxt_unmap_bars(struct bnxt *bp, struct pci_dev *pdev)
{
if (bp->bar2) {
pci_iounmap(pdev, bp->bar2);
bp->bar2 = NULL;
}
if (bp->bar1) {
pci_iounmap(pdev, bp->bar1);
bp->bar1 = NULL;
}
if (bp->bar0) {
pci_iounmap(pdev, bp->bar0);
bp->bar0 = NULL;
}
}
static void bnxt_cleanup_pci(struct bnxt *bp)
{
bnxt_unmap_bars(bp, bp->pdev);
pci_release_regions(bp->pdev);
pci_disable_device(bp->pdev);
}
static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
{ {
int rc; int rc;
...@@ -6761,25 +6788,10 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev) ...@@ -6761,25 +6788,10 @@ static int bnxt_init_board(struct pci_dev *pdev, struct net_device *dev)
bp->current_interval = BNXT_TIMER_INTERVAL; bp->current_interval = BNXT_TIMER_INTERVAL;
clear_bit(BNXT_STATE_OPEN, &bp->state); clear_bit(BNXT_STATE_OPEN, &bp->state);
return 0; return 0;
init_err_release: init_err_release:
if (bp->bar2) { bnxt_unmap_bars(bp, pdev);
pci_iounmap(pdev, bp->bar2);
bp->bar2 = NULL;
}
if (bp->bar1) {
pci_iounmap(pdev, bp->bar1);
bp->bar1 = NULL;
}
if (bp->bar0) {
pci_iounmap(pdev, bp->bar0);
bp->bar0 = NULL;
}
pci_release_regions(pdev); pci_release_regions(pdev);
init_err_disable: init_err_disable:
...@@ -7184,17 +7196,12 @@ static void bnxt_remove_one(struct pci_dev *pdev) ...@@ -7184,17 +7196,12 @@ static void bnxt_remove_one(struct pci_dev *pdev)
bnxt_hwrm_func_drv_unrgtr(bp); bnxt_hwrm_func_drv_unrgtr(bp);
bnxt_free_hwrm_resources(bp); bnxt_free_hwrm_resources(bp);
bnxt_dcb_free(bp); bnxt_dcb_free(bp);
pci_iounmap(pdev, bp->bar2);
pci_iounmap(pdev, bp->bar1);
pci_iounmap(pdev, bp->bar0);
kfree(bp->edev); kfree(bp->edev);
bp->edev = NULL; bp->edev = NULL;
if (bp->xdp_prog) if (bp->xdp_prog)
bpf_prog_put(bp->xdp_prog); bpf_prog_put(bp->xdp_prog);
bnxt_cleanup_pci(bp);
free_netdev(dev); free_netdev(dev);
pci_release_regions(pdev);
pci_disable_device(pdev);
} }
static int bnxt_probe_phy(struct bnxt *bp) 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,7 +7407,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
struct bnxt *bp; struct bnxt *bp;
int rc, max_irqs; int rc, max_irqs;
if (pdev->device == 0x16cd && pci_is_bridge(pdev)) if (pci_is_bridge(pdev))
return -ENODEV; return -ENODEV;
if (version_printed++ == 0) if (version_printed++ == 0)
...@@ -7426,17 +7433,16 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -7426,17 +7433,16 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
dev->netdev_ops = &bnxt_netdev_ops; dev->netdev_ops = &bnxt_netdev_ops;
dev->watchdog_timeo = BNXT_TX_TIMEOUT; dev->watchdog_timeo = BNXT_TX_TIMEOUT;
dev->ethtool_ops = &bnxt_ethtool_ops; dev->ethtool_ops = &bnxt_ethtool_ops;
pci_set_drvdata(pdev, dev); pci_set_drvdata(pdev, dev);
rc = bnxt_alloc_hwrm_resources(bp); rc = bnxt_alloc_hwrm_resources(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
mutex_init(&bp->hwrm_cmd_lock); mutex_init(&bp->hwrm_cmd_lock);
rc = bnxt_hwrm_ver_get(bp); rc = bnxt_hwrm_ver_get(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
bnxt_hwrm_fw_set_time(bp); bnxt_hwrm_fw_set_time(bp);
...@@ -7480,11 +7486,11 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -7480,11 +7486,11 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = bnxt_hwrm_func_drv_rgtr(bp); rc = bnxt_hwrm_func_drv_rgtr(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
rc = bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0); rc = bnxt_hwrm_func_rgtr_async_events(bp, NULL, 0);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
bp->ulp_probe = bnxt_ulp_probe; bp->ulp_probe = bnxt_ulp_probe;
...@@ -7494,7 +7500,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -7494,7 +7500,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev_err(bp->dev, "hwrm query capability failure rc: %x\n", netdev_err(bp->dev, "hwrm query capability failure rc: %x\n",
rc); rc);
rc = -1; rc = -1;
goto init_err; goto init_err_pci_clean;
} }
rc = bnxt_hwrm_queue_qportcfg(bp); 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,7 +7508,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
netdev_err(bp->dev, "hwrm query qportcfg failure rc: %x\n", netdev_err(bp->dev, "hwrm query qportcfg failure rc: %x\n",
rc); rc);
rc = -1; rc = -1;
goto init_err; goto init_err_pci_clean;
} }
bnxt_hwrm_func_qcfg(bp); 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,7 +7522,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) { if (rc) {
netdev_err(bp->dev, "Not enough rings available.\n"); netdev_err(bp->dev, "Not enough rings available.\n");
rc = -ENOMEM; rc = -ENOMEM;
goto init_err; goto init_err_pci_clean;
} }
/* Default RSS hash cfg. */ /* Default RSS hash cfg. */
...@@ -7546,15 +7552,15 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -7546,15 +7552,15 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
rc = bnxt_probe_phy(bp); rc = bnxt_probe_phy(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
rc = bnxt_hwrm_func_reset(bp); rc = bnxt_hwrm_func_reset(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
rc = bnxt_init_int_mode(bp); rc = bnxt_init_int_mode(bp);
if (rc) if (rc)
goto init_err; goto init_err_pci_clean;
rc = register_netdev(dev); rc = register_netdev(dev);
if (rc) if (rc)
...@@ -7571,10 +7577,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -7571,10 +7577,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
init_err_clr_int: init_err_clr_int:
bnxt_clear_int_mode(bp); bnxt_clear_int_mode(bp);
init_err: init_err_pci_clean:
pci_iounmap(pdev, bp->bar0); bnxt_cleanup_pci(bp);
pci_release_regions(pdev);
pci_disable_device(pdev);
init_err_free: init_err_free:
free_netdev(dev); free_netdev(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment