@@ -8300,6 +8300,9 @@ static int bnxt_alloc_all_ctx_pg_info(struct bnxt *bp, int ctx_max)
8300
8300
return 0 ;
8301
8301
}
8302
8302
8303
+ static void bnxt_free_one_ctx_mem (struct bnxt * bp ,
8304
+ struct bnxt_ctx_mem_type * ctxm , bool force );
8305
+
8303
8306
#define BNXT_CTX_INIT_VALID (flags ) \
8304
8307
(!!((flags) & \
8305
8308
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)
8328
8331
for (type = 0 ; type < BNXT_CTX_V2_MAX ; ) {
8329
8332
struct bnxt_ctx_mem_type * ctxm = & ctx -> ctx_arr [type ];
8330
8333
u8 init_val , init_off , i ;
8334
+ u32 max_entries ;
8335
+ u16 entry_size ;
8331
8336
__le32 * p ;
8332
8337
u32 flags ;
8333
8338
@@ -8337,15 +8342,26 @@ static int bnxt_hwrm_func_backing_store_qcaps_v2(struct bnxt *bp)
8337
8342
goto ctx_done ;
8338
8343
flags = le32_to_cpu (resp -> flags );
8339
8344
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);
8341
8347
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
+ }
8343
8359
ctxm -> type = le16_to_cpu (resp -> type );
8344
- ctxm -> entry_size = le16_to_cpu ( resp -> entry_size ) ;
8360
+ ctxm -> entry_size = entry_size ;
8345
8361
ctxm -> flags = flags ;
8346
8362
ctxm -> instance_bmap = le32_to_cpu (resp -> instance_bit_map );
8347
8363
ctxm -> entry_multiple = resp -> entry_multiple ;
8348
- ctxm -> max_entries = le32_to_cpu ( resp -> max_num_entries ) ;
8364
+ ctxm -> max_entries = max_entries ;
8349
8365
ctxm -> min_entries = le32_to_cpu (resp -> min_num_entries );
8350
8366
init_val = resp -> ctx_init_value ;
8351
8367
init_off = resp -> ctx_init_offset ;
@@ -8790,6 +8806,16 @@ static int bnxt_hwrm_func_backing_store_cfg_v2(struct bnxt *bp,
8790
8806
hwrm_req_hold (bp , req );
8791
8807
req -> type = cpu_to_le16 (ctxm -> type );
8792
8808
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
+ }
8793
8819
req -> subtype_valid_cnt = ctxm -> split_entry_cnt ;
8794
8820
for (i = 0 , p = & req -> split_entry_0 ; i < ctxm -> split_entry_cnt ; i ++ )
8795
8821
p [i ] = cpu_to_le32 (ctxm -> split [i ]);
@@ -8884,6 +8910,7 @@ static void bnxt_free_one_ctx_mem(struct bnxt *bp,
8884
8910
ctxm -> pg_info = NULL ;
8885
8911
ctxm -> mem_valid = 0 ;
8886
8912
}
8913
+ memset (ctxm , 0 , sizeof (* ctxm ));
8887
8914
}
8888
8915
8889
8916
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)
11862
11889
set_bit (BNXT_STATE_FW_RESET_DET , & bp -> state );
11863
11890
if (!test_bit (BNXT_STATE_IN_FW_RESET , & bp -> state ))
11864
11891
bnxt_ulp_irq_stop (bp );
11865
- bnxt_free_ctx_mem (bp , true );
11892
+ bnxt_free_ctx_mem (bp , false );
11866
11893
bnxt_dcb_free (bp );
11867
11894
rc = bnxt_fw_init_one (bp );
11868
11895
if (rc ) {
@@ -13575,7 +13602,7 @@ static void bnxt_fw_reset_close(struct bnxt *bp)
13575
13602
bnxt_hwrm_func_drv_unrgtr (bp );
13576
13603
if (pci_is_enabled (bp -> pdev ))
13577
13604
pci_disable_device (bp -> pdev );
13578
- bnxt_free_ctx_mem (bp , true );
13605
+ bnxt_free_ctx_mem (bp , false );
13579
13606
}
13580
13607
13581
13608
static bool is_bnxt_fw_ok (struct bnxt * bp )
@@ -16128,7 +16155,7 @@ static int bnxt_suspend(struct device *device)
16128
16155
}
16129
16156
bnxt_hwrm_func_drv_unrgtr (bp );
16130
16157
pci_disable_device (bp -> pdev );
16131
- bnxt_free_ctx_mem (bp , true );
16158
+ bnxt_free_ctx_mem (bp , false );
16132
16159
rtnl_unlock ();
16133
16160
return rc ;
16134
16161
}
@@ -16240,7 +16267,7 @@ static pci_ers_result_t bnxt_io_error_detected(struct pci_dev *pdev,
16240
16267
16241
16268
if (pci_is_enabled (pdev ))
16242
16269
pci_disable_device (pdev );
16243
- bnxt_free_ctx_mem (bp , true );
16270
+ bnxt_free_ctx_mem (bp , false );
16244
16271
rtnl_unlock ();
16245
16272
16246
16273
/* Request a slot slot reset. */
0 commit comments