Skip to content

Commit de99936

Browse files
hgao656kuba-moo
authored andcommitted
bnxt_en: Do not free FW log context memory
If FW supports appending new FW logs to an offset in the context memory after FW reset, then do not free this type of context memory during reset. The driver will provide the initial offset to the FW when configuring this type of context memory. This way, we don't lose the older FW logs after reset. Signed-off-by: Hongguang Gao <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 84fcd94 commit de99936

File tree

2 files changed

+36
-9
lines changed

2 files changed

+36
-9
lines changed

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

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8300,6 +8300,9 @@ static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp, int ctx_max)
83008300
return 0;
83018301
}
83028302

8303+
static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8304+
struct bnxt_ctx_mem_type *ctxm, bool force);
8305+
83038306
#define BNXT_CTX_INIT_VALID(flags) \
83048307
(!!((flags) & \
83058308
FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_ENABLE_CTX_KIND_INIT))
@@ -8328,6 +8331,8 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
83288331
for (type = 0; type < BNXT_CTX_V2_MAX; ) {
83298332
struct bnxt_ctx_mem_type *ctxm = &ctx->ctx_arr[type];
83308333
u8 init_val, init_off, i;
8334+
u32 max_entries;
8335+
u16 entry_size;
83318336
__le32 *p;
83328337
u32 flags;
83338338

@@ -8337,15 +8342,26 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
83378342
goto ctx_done;
83388343
flags = le32_to_cpu(resp->flags);
83398344
type = le16_to_cpu(resp->next_valid_type);
8340-
if (!(flags & FUNC_BACKING_STORE_QCAPS_V2_RESP_FLAGS_TYPE_VALID))
8345+
if (!(flags & BNXT_CTX_MEM_TYPE_VALID)) {
8346+
bnxt_free_one_ctx_mem(bp, ctxm, true);
83418347
continue;
8342-
8348+
}
8349+
entry_size = le16_to_cpu(resp->entry_size);
8350+
max_entries = le32_to_cpu(resp->max_num_entries);
8351+
if (ctxm->mem_valid) {
8352+
if (!(flags & BNXT_CTX_MEM_PERSIST) ||
8353+
ctxm->entry_size != entry_size ||
8354+
ctxm->max_entries != max_entries)
8355+
bnxt_free_one_ctx_mem(bp, ctxm, true);
8356+
else
8357+
continue;
8358+
}
83438359
ctxm->type = le16_to_cpu(resp->type);
8344-
ctxm->entry_size = le16_to_cpu(resp->entry_size);
8360+
ctxm->entry_size = entry_size;
83458361
ctxm->flags = flags;
83468362
ctxm->instance_bmap = le32_to_cpu(resp->instance_bit_map);
83478363
ctxm->entry_multiple = resp->entry_multiple;
8348-
ctxm->max_entries = le32_to_cpu(resp->max_num_entries);
8364+
ctxm->max_entries = max_entries;
83498365
ctxm->min_entries = le32_to_cpu(resp->min_num_entries);
83508366
init_val = resp->ctx_init_value;
83518367
init_off = resp->ctx_init_offset;
@@ -8790,6 +8806,16 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
87908806
hwrm_req_hold(bp, req);
87918807
req->type = cpu_to_le16(ctxm->type);
87928808
req->entry_size = cpu_to_le16(ctxm->entry_size);
8809+
if ((ctxm->flags & BNXT_CTX_MEM_PERSIST) &&
8810+
bnxt_bs_trace_avail(bp, ctxm->type)) {
8811+
struct bnxt_bs_trace_info *bs_trace;
8812+
u32 enables;
8813+
8814+
enables = FUNC_BACKING_STORE_CFG_V2_REQ_ENABLES_NEXT_BS_OFFSET;
8815+
req->enables = cpu_to_le32(enables);
8816+
bs_trace = &bp->bs_trace[bnxt_bstore_to_trace[ctxm->type]];
8817+
req->next_bs_offset = cpu_to_le32(bs_trace->last_offset);
8818+
}
87938819
req->subtype_valid_cnt = ctxm->split_entry_cnt;
87948820
for (i = 0, p = &req->split_entry_0; i < ctxm->split_entry_cnt; i++)
87958821
p[i] = cpu_to_le32(ctxm->split[i]);
@@ -8884,6 +8910,7 @@ static void bnxt_free_one_ctx_mem(struct bnxt *bp,
88848910
ctxm->pg_info = NULL;
88858911
ctxm->mem_valid = 0;
88868912
}
8913+
memset(ctxm, 0, sizeof(*ctxm));
88878914
}
88888915

88898916
void bnxt_free_ctx_mem(struct bnxt *bp, bool force)
@@ -11862,7 +11889,7 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
1186211889
set_bit(BNXT_STATE_FW_RESET_DET, &bp->state);
1186311890
if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
1186411891
bnxt_ulp_irq_stop(bp);
11865-
bnxt_free_ctx_mem(bp, true);
11892+
bnxt_free_ctx_mem(bp, false);
1186611893
bnxt_dcb_free(bp);
1186711894
rc = bnxt_fw_init_one(bp);
1186811895
if (rc) {
@@ -13575,7 +13602,7 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
1357513602
bnxt_hwrm_func_drv_unrgtr(bp);
1357613603
if (pci_is_enabled(bp->pdev))
1357713604
pci_disable_device(bp->pdev);
13578-
bnxt_free_ctx_mem(bp, true);
13605+
bnxt_free_ctx_mem(bp, false);
1357913606
}
1358013607

1358113608
static bool is_bnxt_fw_ok(struct bnxt *bp)
@@ -16128,7 +16155,7 @@ static int bnxt_suspend(struct device *device)
1612816155
}
1612916156
bnxt_hwrm_func_drv_unrgtr(bp);
1613016157
pci_disable_device(bp->pdev);
16131-
bnxt_free_ctx_mem(bp, true);
16158+
bnxt_free_ctx_mem(bp, false);
1613216159
rtnl_unlock();
1613316160
return rc;
1613416161
}
@@ -16240,7 +16267,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
1624016267

1624116268
if (pci_is_enabled(pdev))
1624216269
pci_disable_device(pdev);
16243-
bnxt_free_ctx_mem(bp, true);
16270+
bnxt_free_ctx_mem(bp, false);
1624416271
rtnl_unlock();
1624516272

1624616273
/* Request a slot slot reset. */

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static int bnxt_dl_reload_down(struct devlink *dl, bool netns_change,
463463
break;
464464
}
465465
bnxt_cancel_reservations(bp, false);
466-
bnxt_free_ctx_mem(bp, true);
466+
bnxt_free_ctx_mem(bp, false);
467467
break;
468468
}
469469
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: {

0 commit comments

Comments
 (0)