Skip to content

Commit 46010d4

Browse files
hgao656kuba-moo
authored andcommitted
bnxt_en: Add a 'force' parameter to bnxt_free_ctx_mem()
If 'force' is false, it will keep the memory pages and all data structures for the context memory type if the memory is valid. This patch always passes true for the 'force' parameter so there is no change in behavior. Later patches will adjust the 'force' parameter for the FW log context memory types so that the logs will not be reset after FW 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 968d2cc commit 46010d4

File tree

3 files changed

+29
-19
lines changed

3 files changed

+29
-19
lines changed

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

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8233,18 +8233,20 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
82338233
{
82348234
struct hwrm_func_backing_store_qcaps_v2_output *resp;
82358235
struct hwrm_func_backing_store_qcaps_v2_input *req;
8236-
struct bnxt_ctx_mem_info *ctx;
8236+
struct bnxt_ctx_mem_info *ctx = bp->ctx;
82378237
u16 type;
82388238
int rc;
82398239

82408240
rc = hwrm_req_init(bp, req, HWRM_FUNC_BACKING_STORE_QCAPS_V2);
82418241
if (rc)
82428242
return rc;
82438243

8244-
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
8245-
if (!ctx)
8246-
return -ENOMEM;
8247-
bp->ctx = ctx;
8244+
if (!ctx) {
8245+
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
8246+
if (!ctx)
8247+
return -ENOMEM;
8248+
bp->ctx = ctx;
8249+
}
82488250

82498251
resp = hwrm_req_hold(bp, req);
82508252

@@ -8293,7 +8295,8 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
82938295
struct hwrm_func_backing_store_qcaps_input *req;
82948296
int rc;
82958297

8296-
if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) || bp->ctx)
8298+
if (bp->hwrm_spec_code < 0x10902 || BNXT_VF(bp) ||
8299+
(bp->ctx && bp->ctx->flags & BNXT_CTX_FLAG_INITED))
82978300
return 0;
82988301

82998302
if (bp->fw_cap & BNXT_FW_CAP_BACKING_STORE_V2)
@@ -8766,11 +8769,16 @@ static int bnxt_backing_store_cfg_v2(struct bnxt *bp, u32 ena)
87668769
}
87678770

87688771
static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8769-
struct bnxt_ctx_mem_type *ctxm)
8772+
struct bnxt_ctx_mem_type *ctxm, bool force)
87708773
{
87718774
struct bnxt_ctx_pg_info *ctx_pg;
87728775
int i, n = 1;
87738776

8777+
ctxm->last = 0;
8778+
8779+
if (ctxm->mem_valid && !force)
8780+
return;
8781+
87748782
ctx_pg = ctxm->pg_info;
87758783
if (ctx_pg) {
87768784
if (ctxm->instance_bmap)
@@ -8784,7 +8792,7 @@ static void bnxt_free_one_ctx_mem(struct bnxt *bp,
87848792
}
87858793
}
87868794

8787-
void bnxt_free_ctx_mem(struct bnxt *bp)
8795+
void bnxt_free_ctx_mem(struct bnxt *bp, bool force)
87888796
{
87898797
struct bnxt_ctx_mem_info *ctx = bp->ctx;
87908798
u16 type;
@@ -8793,11 +8801,13 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
87938801
return;
87948802

87958803
for (type = 0; type < BNXT_CTX_V2_MAX; type++)
8796-
bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type]);
8804+
bnxt_free_one_ctx_mem(bp, &ctx->ctx_arr[type], force);
87978805

87988806
ctx->flags &= ~BNXT_CTX_FLAG_INITED;
8799-
kfree(ctx);
8800-
bp->ctx = NULL;
8807+
if (force) {
8808+
kfree(ctx);
8809+
bp->ctx = NULL;
8810+
}
88018811
}
88028812

88038813
static int bnxt_alloc_ctx_mem(struct bnxt *bp)
@@ -11758,7 +11768,7 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
1175811768
set_bit(BNXT_STATE_FW_RESET_DET, &bp->state);
1175911769
if (!test_bit(BNXT_STATE_IN_FW_RESET, &bp->state))
1176011770
bnxt_ulp_irq_stop(bp);
11761-
bnxt_free_ctx_mem(bp);
11771+
bnxt_free_ctx_mem(bp, true);
1176211772
bnxt_dcb_free(bp);
1176311773
rc = bnxt_fw_init_one(bp);
1176411774
if (rc) {
@@ -13471,7 +13481,7 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
1347113481
bnxt_hwrm_func_drv_unrgtr(bp);
1347213482
if (pci_is_enabled(bp->pdev))
1347313483
pci_disable_device(bp->pdev);
13474-
bnxt_free_ctx_mem(bp);
13484+
bnxt_free_ctx_mem(bp, true);
1347513485
}
1347613486

1347713487
static bool is_bnxt_fw_ok(struct bnxt *bp)
@@ -15328,7 +15338,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
1532815338
kfree(bp->fw_health);
1532915339
bp->fw_health = NULL;
1533015340
bnxt_cleanup_pci(bp);
15331-
bnxt_free_ctx_mem(bp);
15341+
bnxt_free_ctx_mem(bp, true);
1533215342
bnxt_free_crash_dump_mem(bp);
1533315343
kfree(bp->rss_indir_tbl);
1533415344
bp->rss_indir_tbl = NULL;
@@ -15970,7 +15980,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
1597015980
kfree(bp->fw_health);
1597115981
bp->fw_health = NULL;
1597215982
bnxt_cleanup_pci(bp);
15973-
bnxt_free_ctx_mem(bp);
15983+
bnxt_free_ctx_mem(bp, true);
1597415984
bnxt_free_crash_dump_mem(bp);
1597515985
kfree(bp->rss_indir_tbl);
1597615986
bp->rss_indir_tbl = NULL;
@@ -16024,7 +16034,7 @@ static int bnxt_suspend(struct device *device)
1602416034
}
1602516035
bnxt_hwrm_func_drv_unrgtr(bp);
1602616036
pci_disable_device(bp->pdev);
16027-
bnxt_free_ctx_mem(bp);
16037+
bnxt_free_ctx_mem(bp, true);
1602816038
rtnl_unlock();
1602916039
return rc;
1603016040
}
@@ -16136,7 +16146,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
1613616146

1613716147
if (pci_is_enabled(pdev))
1613816148
pci_disable_device(pdev);
16139-
bnxt_free_ctx_mem(bp);
16149+
bnxt_free_ctx_mem(bp, true);
1614016150
rtnl_unlock();
1614116151

1614216152
/* Request a slot slot reset. */

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2824,7 +2824,7 @@ int bnxt_hwrm_vnic_alloc(struct bnxt *bp, struct bnxt_vnic_info *vnic,
28242824
int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings);
28252825
int bnxt_nq_rings_in_use(struct bnxt *bp);
28262826
int bnxt_hwrm_set_coal(struct bnxt *);
2827-
void bnxt_free_ctx_mem(struct bnxt *bp);
2827+
void bnxt_free_ctx_mem(struct bnxt *bp, bool force);
28282828
int bnxt_num_tx_to_cp(struct bnxt *bp, int tx);
28292829
unsigned int bnxt_get_max_func_stat_ctxs(struct bnxt *bp);
28302830
unsigned int bnxt_get_avail_stat_ctxs_for_en(struct bnxt *bp);

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);
466+
bnxt_free_ctx_mem(bp, true);
467467
break;
468468
}
469469
case DEVLINK_RELOAD_ACTION_FW_ACTIVATE: {

0 commit comments

Comments
 (0)