Skip to content

Commit 1d62059

Browse files
committed
bnxt_en: Fix DIM shutdown
JIRA: https://issues.redhat.com/browse/RHEL-72033 commit 4045296 Author: Michael Chan <michael.chan@broadcom.com> Date: Fri Jan 3 20:38:48 2025 -0800 bnxt_en: Fix DIM shutdown DIM work will call the firmware to adjust the coalescing parameters on the RX rings. We should cancel DIM work before we call the firmware to free the RX rings. Otherwise, FW will reject the call from DIM work if the RX ring has been freed. This will generate an error message like this: bnxt_en 0000:21:00.1 ens2f1np1: hwrm req_type 0x53 seq id 0x6fca error 0x2 and cause unnecessary concern for the user. It is also possible to modify the coalescing parameters of the wrong ring if the ring has been re-allocated. To prevent this, cancel DIM work right before freeing the RX rings. We also have to add a check in NAPI poll to not schedule DIM if the RX rings are shutting down. Check that the VNIC is active before we schedule DIM. The VNIC is always disabled before we free the RX rings. Fixes: 0bc0b97 ("bnxt_en: cleanup DIM work on device shutdown") Reviewed-by: Hongguang Gao <hongguang.gao@broadcom.com> Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com> Reviewed-by: Somnath Kotur <somnath.kotur@broadcom.com> Signed-off-by: Michael Chan <michael.chan@broadcom.com> Link: https://patch.msgid.link/20250104043849.3482067-3-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Michal Schmidt <mschmidt@redhat.com>
1 parent 0a9e17f commit 1d62059

File tree

1 file changed

+33
-5
lines changed
  • drivers/net/ethernet/broadcom/bnxt

1 file changed

+33
-5
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,13 @@ static int bnxt_hwrm_handler(struct bnxt *bp, struct tx_cmp *txcmp)
28262826
return 0;
28272827
}
28282828

2829+
static bool bnxt_vnic_is_active(struct bnxt *bp)
2830+
{
2831+
struct bnxt_vnic_info *vnic = &bp->vnic_info[0];
2832+
2833+
return vnic->fw_vnic_id != INVALID_HW_RING_ID && vnic->mru > 0;
2834+
}
2835+
28292836
static irqreturn_t bnxt_msix(int irq, void *dev_instance)
28302837
{
28312838
struct bnxt_napi *bnapi = dev_instance;
@@ -3093,7 +3100,7 @@ static int bnxt_poll(struct napi_struct *napi, int budget)
30933100
break;
30943101
}
30953102
}
3096-
if (bp->flags & BNXT_FLAG_DIM) {
3103+
if ((bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) {
30973104
struct dim_sample dim_sample = {};
30983105

30993106
dim_update_sample(cpr->event_ctr,
@@ -3224,7 +3231,7 @@ static int bnxt_poll_p5(struct napi_struct *napi, int budget)
32243231
poll_done:
32253232
cpr_rx = &cpr->cp_ring_arr[0];
32263233
if (cpr_rx->cp_ring_type == BNXT_NQ_HDL_TYPE_RX &&
3227-
(bp->flags & BNXT_FLAG_DIM)) {
3234+
(bp->flags & BNXT_FLAG_DIM) && bnxt_vnic_is_active(bp)) {
32283235
struct dim_sample dim_sample = {};
32293236

32303237
dim_update_sample(cpr->event_ctr,
@@ -7116,6 +7123,26 @@ static int bnxt_hwrm_ring_alloc(struct bnxt *bp)
71167123
return rc;
71177124
}
71187125

7126+
static void bnxt_cancel_dim(struct bnxt *bp)
7127+
{
7128+
int i;
7129+
7130+
/* DIM work is initialized in bnxt_enable_napi(). Proceed only
7131+
* if NAPI is enabled.
7132+
*/
7133+
if (!bp->bnapi || test_bit(BNXT_STATE_NAPI_DISABLED, &bp->state))
7134+
return;
7135+
7136+
/* Make sure NAPI sees that the VNIC is disabled */
7137+
synchronize_net();
7138+
for (i = 0; i < bp->rx_nr_rings; i++) {
7139+
struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
7140+
struct bnxt_napi *bnapi = rxr->bnapi;
7141+
7142+
cancel_work_sync(&bnapi->cp_ring.dim.work);
7143+
}
7144+
}
7145+
71197146
static int hwrm_ring_free_send_msg(struct bnxt *bp,
71207147
struct bnxt_ring_struct *ring,
71217148
u32 ring_type, int cmpl_ring_id)
@@ -7216,6 +7243,7 @@ static void bnxt_hwrm_ring_free(struct bnxt *bp, bool close_path)
72167243
}
72177244
}
72187245

7246+
bnxt_cancel_dim(bp);
72197247
for (i = 0; i < bp->rx_nr_rings; i++) {
72207248
bnxt_hwrm_rx_ring_free(bp, &bp->rx_ring[i], close_path);
72217249
bnxt_hwrm_rx_agg_ring_free(bp, &bp->rx_ring[i], close_path);
@@ -11012,8 +11040,6 @@ static void bnxt_disable_napi(struct bnxt *bp)
1101211040
if (bnapi->in_reset)
1101311041
cpr->sw_stats->rx.rx_resets++;
1101411042
napi_disable(&bnapi->napi);
11015-
if (bnapi->rx_ring)
11016-
cancel_work_sync(&cpr->dim.work);
1101711043
}
1101811044
}
1101911045

@@ -15269,8 +15295,10 @@ static int bnxt_queue_stop(struct net_device *dev, void *qmem, int idx)
1526915295
bnxt_hwrm_vnic_update(bp, vnic,
1527015296
VNIC_UPDATE_REQ_ENABLES_MRU_VALID);
1527115297
}
15272-
15298+
/* Make sure NAPI sees that the VNIC is disabled */
15299+
synchronize_net();
1527315300
rxr = &bp->rx_ring[idx];
15301+
cancel_work_sync(&rxr->bnapi->cp_ring.dim.work);
1527415302
bnxt_hwrm_rx_ring_free(bp, rxr, false);
1527515303
bnxt_hwrm_rx_agg_ring_free(bp, rxr, false);
1527615304
rxr->rx_next_cons = 0;

0 commit comments

Comments
 (0)