@@ -8233,18 +8233,20 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
8233
8233
{
8234
8234
struct hwrm_func_backing_store_qcaps_v2_output * resp ;
8235
8235
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 ;
8237
8237
u16 type ;
8238
8238
int rc ;
8239
8239
8240
8240
rc = hwrm_req_init (bp , req , HWRM_FUNC_BACKING_STORE_QCAPS_V2 );
8241
8241
if (rc )
8242
8242
return rc ;
8243
8243
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
+ }
8248
8250
8249
8251
resp = hwrm_req_hold (bp , req );
8250
8252
@@ -8293,7 +8295,8 @@ static int bnxt_hwrm_func_backing_store_qcaps(struct bnxt *bp)
8293
8295
struct hwrm_func_backing_store_qcaps_input * req ;
8294
8296
int rc ;
8295
8297
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 ))
8297
8300
return 0 ;
8298
8301
8299
8302
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)
8766
8769
}
8767
8770
8768
8771
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 )
8770
8773
{
8771
8774
struct bnxt_ctx_pg_info * ctx_pg ;
8772
8775
int i , n = 1 ;
8773
8776
8777
+ ctxm -> last = 0 ;
8778
+
8779
+ if (ctxm -> mem_valid && !force )
8780
+ return ;
8781
+
8774
8782
ctx_pg = ctxm -> pg_info ;
8775
8783
if (ctx_pg ) {
8776
8784
if (ctxm -> instance_bmap )
@@ -8784,7 +8792,7 @@ static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8784
8792
}
8785
8793
}
8786
8794
8787
- void bnxt_free_ctx_mem (struct bnxt * bp )
8795
+ void bnxt_free_ctx_mem (struct bnxt * bp , bool force )
8788
8796
{
8789
8797
struct bnxt_ctx_mem_info * ctx = bp -> ctx ;
8790
8798
u16 type ;
@@ -8793,11 +8801,13 @@ void bnxt_free_ctx_mem(struct bnxt *bp)
8793
8801
return ;
8794
8802
8795
8803
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 );
8797
8805
8798
8806
ctx -> flags &= ~BNXT_CTX_FLAG_INITED ;
8799
- kfree (ctx );
8800
- bp -> ctx = NULL ;
8807
+ if (force ) {
8808
+ kfree (ctx );
8809
+ bp -> ctx = NULL ;
8810
+ }
8801
8811
}
8802
8812
8803
8813
static int bnxt_alloc_ctx_mem (struct bnxt * bp )
@@ -11758,7 +11768,7 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up)
11758
11768
set_bit (BNXT_STATE_FW_RESET_DET , & bp -> state );
11759
11769
if (!test_bit (BNXT_STATE_IN_FW_RESET , & bp -> state ))
11760
11770
bnxt_ulp_irq_stop (bp );
11761
- bnxt_free_ctx_mem (bp );
11771
+ bnxt_free_ctx_mem (bp , true );
11762
11772
bnxt_dcb_free (bp );
11763
11773
rc = bnxt_fw_init_one (bp );
11764
11774
if (rc ) {
@@ -13471,7 +13481,7 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
13471
13481
bnxt_hwrm_func_drv_unrgtr (bp );
13472
13482
if (pci_is_enabled (bp -> pdev ))
13473
13483
pci_disable_device (bp -> pdev );
13474
- bnxt_free_ctx_mem (bp );
13484
+ bnxt_free_ctx_mem (bp , true );
13475
13485
}
13476
13486
13477
13487
static bool is_bnxt_fw_ok (struct bnxt * bp )
@@ -15328,7 +15338,7 @@ static void bnxt_remove_one(struct pci_dev *pdev)
15328
15338
kfree (bp -> fw_health );
15329
15339
bp -> fw_health = NULL ;
15330
15340
bnxt_cleanup_pci (bp );
15331
- bnxt_free_ctx_mem (bp );
15341
+ bnxt_free_ctx_mem (bp , true );
15332
15342
bnxt_free_crash_dump_mem (bp );
15333
15343
kfree (bp -> rss_indir_tbl );
15334
15344
bp -> rss_indir_tbl = NULL ;
@@ -15970,7 +15980,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
15970
15980
kfree (bp -> fw_health );
15971
15981
bp -> fw_health = NULL ;
15972
15982
bnxt_cleanup_pci (bp );
15973
- bnxt_free_ctx_mem (bp );
15983
+ bnxt_free_ctx_mem (bp , true );
15974
15984
bnxt_free_crash_dump_mem (bp );
15975
15985
kfree (bp -> rss_indir_tbl );
15976
15986
bp -> rss_indir_tbl = NULL ;
@@ -16024,7 +16034,7 @@ static int bnxt_suspend(struct device *device)
16024
16034
}
16025
16035
bnxt_hwrm_func_drv_unrgtr (bp );
16026
16036
pci_disable_device (bp -> pdev );
16027
- bnxt_free_ctx_mem (bp );
16037
+ bnxt_free_ctx_mem (bp , true );
16028
16038
rtnl_unlock ();
16029
16039
return rc ;
16030
16040
}
@@ -16136,7 +16146,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
16136
16146
16137
16147
if (pci_is_enabled (pdev ))
16138
16148
pci_disable_device (pdev );
16139
- bnxt_free_ctx_mem (bp );
16149
+ bnxt_free_ctx_mem (bp , true );
16140
16150
rtnl_unlock ();
16141
16151
16142
16152
/* Request a slot slot reset. */
0 commit comments