cxgb4: fix adapter crash due to wrong MC size
Subsystems (3)
PATCH 1/1 cxgb4: fix adapter crash due to wrong MC size
In the absence of MC1, the size calculation function cudbg_mem_region_size() was returing wrong MC size and resulted in adapter crash. This patch adds new argument to cudbg_mem_region_size() which will have actual size and returns error to caller in the absence of MC1.
Fixes a1c69520f785 ("cxgb4: collect MC memory dump")
Signed-off-by Vishal Kulkarni <[email protected]>"
--- .../net/ethernet/chelsio/cxgb4/cudbg_lib.c | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +20 -7
@@ -1049,9 +1049,9 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init, } } -static unsigned long cudbg_mem_region_size (struct cudbg_init *pdbg_init, -struct cudbg_error *cudbg_err, -u8 mem_type) +static int cudbg_mem_region_size (struct cudbg_init *pdbg_init, +struct cudbg_error *cudbg_err, +u8 mem_type,unsigned long *region_size) {struct adapter *padap = pdbg_init->adap;struct cudbg_meminfo mem_info;
@@ -1060,15 +1060,23 @@ static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,memset (&mem_info,0 ,sizeof (struct cudbg_meminfo )); rc =cudbg_fill_meminfo (padap, &mem_info); -if (rc) +if (rc) { + cudbg_err->sys_err = rc;return rc; + }cudbg_t4_fwcache (pdbg_init, cudbg_err); rc =cudbg_meminfo_get_mem_index (padap, &mem_info, mem_type, &mc_idx); -if (rc) +if (rc) { + cudbg_err->sys_err = rc;return rc; + } + +if (region_size) + *region_size = mem_info.avail[mc_idx].limit - + mem_info.avail[mc_idx].base; -return mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base; +return 0 ; } static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
@@ -1076,7 +1084,12 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, struct cudbg_error *cudbg_err, u8 mem_type) { -unsigned long size =cudbg_mem_region_size (pdbg_init, cudbg_err, mem_type); +unsigned long size =0 ; +int rc; + + rc =cudbg_mem_region_size (pdbg_init, cudbg_err, mem_type, &size); +if (rc) +return rc;return cudbg_read_fw_mem (pdbg_init, dbg_buff, mem_type, size, cudbg_err);
Signature · 1 line
2.21.1
David Miller
maintainerFrom: Vishal Kulkarni <[email protected]>
Date: Wed, 22 Apr 2020 21:20:07 +0530
Quoted 8 lines
In the absence of MC1, the size calculation function
cudbg_mem_region_size()was returing wrong MC size and resulted in adapter crash. This patch adds new argument tocudbg_mem_region_size()which will have actual size and returns error to caller in the absence of MC1.Fixes a1c69520f785 ("cxgb4: collect MC memory dump")Signed-off-by Vishal Kulkarni <[email protected]>"
Applied and queued up for -stable, thanks.