Skip to content

Commit 0edddb7

Browse files
committed
bnx2x: new flag for track HW resource allocation
jira LE-1907 Rebuild_History Non-Buildable kernel-4.18.0-553.8.1.el8_10 commit-author Thinh Tran <[email protected]> commit bf23ffc While injecting PCIe errors to the upstream PCIe switch of a BCM57810 NIC, system hangs/crashes were observed. After several calls to bnx2x_tx_timout() complete, bnx2x_nic_unload() is called to free up HW resources and bnx2x_napi_disable() is called to release NAPI objects. Later, when the EEH driver calls bnx2x_io_slot_reset() to complete the recovery process, bnx2x attempts to disable NAPI again by calling bnx2x_napi_disable() and freeing resources which have already been freed, resulting in a hang or crash. Introduce a new flag to track the HW resource and NAPI allocation state, refactor duplicated code into a single function, check page pool allocation status before freeing, and reduces debug output when a TX timeout event occurs. Reviewed-by: Manish Chopra <[email protected]> Tested-by: Abdul Haleem <[email protected]> Tested-by: David Christensen <[email protected]> Reviewed-by: Simon Horman <[email protected]> Tested-by: Venkata Sai Duggi <[email protected]> Signed-off-by: Thinh Tran <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> (cherry picked from commit bf23ffc) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 5c2600a commit 0edddb7

File tree

4 files changed

+44
-28
lines changed

4 files changed

+44
-28
lines changed

drivers/net/ethernet/broadcom/bnx2x/bnx2x.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,6 +1503,8 @@ struct bnx2x {
15031503
bool cnic_loaded;
15041504
struct cnic_eth_dev *(*cnic_probe)(struct net_device *);
15051505

1506+
bool nic_stopped;
1507+
15061508
/* Flag that indicates that we can start looking for FCoE L2 queue
15071509
* completions in the default status block.
15081510
*/

drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,6 +2701,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
27012701
bnx2x_add_all_napi(bp);
27022702
DP(NETIF_MSG_IFUP, "napi added\n");
27032703
bnx2x_napi_enable(bp);
2704+
bp->nic_stopped = false;
27042705

27052706
if (IS_PF(bp)) {
27062707
/* set pf load just before approaching the MCP */
@@ -2946,6 +2947,7 @@ int bnx2x_nic_load(struct bnx2x *bp, int load_mode)
29462947
load_error1:
29472948
bnx2x_napi_disable(bp);
29482949
bnx2x_del_all_napi(bp);
2950+
bp->nic_stopped = true;
29492951

29502952
/* clear pf_load status, as it was already set */
29512953
if (IS_PF(bp))
@@ -3081,14 +3083,17 @@ int bnx2x_nic_unload(struct bnx2x *bp, int unload_mode, bool keep_link)
30813083
if (!CHIP_IS_E1x(bp))
30823084
bnx2x_pf_disable(bp);
30833085

3084-
/* Disable HW interrupts, NAPI */
3085-
bnx2x_netif_stop(bp, 1);
3086-
/* Delete all NAPI objects */
3087-
bnx2x_del_all_napi(bp);
3088-
if (CNIC_LOADED(bp))
3089-
bnx2x_del_all_napi_cnic(bp);
3090-
/* Release IRQs */
3091-
bnx2x_free_irq(bp);
3086+
if (!bp->nic_stopped) {
3087+
/* Disable HW interrupts, NAPI */
3088+
bnx2x_netif_stop(bp, 1);
3089+
/* Delete all NAPI objects */
3090+
bnx2x_del_all_napi(bp);
3091+
if (CNIC_LOADED(bp))
3092+
bnx2x_del_all_napi_cnic(bp);
3093+
/* Release IRQs */
3094+
bnx2x_free_irq(bp);
3095+
bp->nic_stopped = true;
3096+
}
30923097

30933098
/* Report UNLOAD_DONE to MCP */
30943099
bnx2x_send_unload_done(bp, false);

drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9481,15 +9481,18 @@ void bnx2x_chip_cleanup(struct bnx2x *bp, int unload_mode, bool keep_link)
94819481
}
94829482
}
94839483

9484-
/* Disable HW interrupts, NAPI */
9485-
bnx2x_netif_stop(bp, 1);
9486-
/* Delete all NAPI objects */
9487-
bnx2x_del_all_napi(bp);
9488-
if (CNIC_LOADED(bp))
9489-
bnx2x_del_all_napi_cnic(bp);
9484+
if (!bp->nic_stopped) {
9485+
/* Disable HW interrupts, NAPI */
9486+
bnx2x_netif_stop(bp, 1);
9487+
/* Delete all NAPI objects */
9488+
bnx2x_del_all_napi(bp);
9489+
if (CNIC_LOADED(bp))
9490+
bnx2x_del_all_napi_cnic(bp);
94909491

9491-
/* Release IRQs */
9492-
bnx2x_free_irq(bp);
9492+
/* Release IRQs */
9493+
bnx2x_free_irq(bp);
9494+
bp->nic_stopped = true;
9495+
}
94939496

94949497
/* Reset the chip, unless PCI function is offline. If we reach this
94959498
* point following a PCI error handling, it means device is really
@@ -14264,13 +14267,16 @@ static pci_ers_result_t bnx2x_io_slot_reset(struct pci_dev *pdev)
1426414267
}
1426514268
bnx2x_drain_tx_queues(bp);
1426614269
bnx2x_send_unload_req(bp, UNLOAD_RECOVERY);
14267-
bnx2x_netif_stop(bp, 1);
14268-
bnx2x_del_all_napi(bp);
14270+
if (!bp->nic_stopped) {
14271+
bnx2x_netif_stop(bp, 1);
14272+
bnx2x_del_all_napi(bp);
1426914273

14270-
if (CNIC_LOADED(bp))
14271-
bnx2x_del_all_napi_cnic(bp);
14274+
if (CNIC_LOADED(bp))
14275+
bnx2x_del_all_napi_cnic(bp);
1427214276

14273-
bnx2x_free_irq(bp);
14277+
bnx2x_free_irq(bp);
14278+
bp->nic_stopped = true;
14279+
}
1427414280

1427514281
/* Report UNLOAD_DONE to MCP */
1427614282
bnx2x_send_unload_done(bp, true);

drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,16 @@ void bnx2x_vfpf_close_vf(struct bnx2x *bp)
530530
bnx2x_vfpf_finalize(bp, &req->first_tlv);
531531

532532
free_irq:
533-
/* Disable HW interrupts, NAPI */
534-
bnx2x_netif_stop(bp, 0);
535-
/* Delete all NAPI objects */
536-
bnx2x_del_all_napi(bp);
537-
538-
/* Release IRQs */
539-
bnx2x_free_irq(bp);
533+
if (!bp->nic_stopped) {
534+
/* Disable HW interrupts, NAPI */
535+
bnx2x_netif_stop(bp, 0);
536+
/* Delete all NAPI objects */
537+
bnx2x_del_all_napi(bp);
538+
539+
/* Release IRQs */
540+
bnx2x_free_irq(bp);
541+
bp->nic_stopped = true;
542+
}
540543
}
541544

542545
static void bnx2x_leading_vfq_init(struct bnx2x *bp, struct bnx2x_virtf *vf,

0 commit comments

Comments
 (0)