Skip to content

Commit ce22274

Browse files
vishalsdkdavem330
authored andcommitted
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: a1c6952 ("cxgb4: collect MC memory dump") Signed-off-by: Vishal Kulkarni <[email protected]>" Signed-off-by: David S. Miller <[email protected]>
1 parent da0afd1 commit ce22274

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,9 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init,
10491049
}
10501050
}
10511051

1052-
static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,
1053-
struct cudbg_error *cudbg_err,
1054-
u8 mem_type)
1052+
static int cudbg_mem_region_size(struct cudbg_init *pdbg_init,
1053+
struct cudbg_error *cudbg_err,
1054+
u8 mem_type, unsigned long *region_size)
10551055
{
10561056
struct adapter *padap = pdbg_init->adap;
10571057
struct cudbg_meminfo mem_info;
@@ -1060,23 +1060,36 @@ static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,
10601060

10611061
memset(&mem_info, 0, sizeof(struct cudbg_meminfo));
10621062
rc = cudbg_fill_meminfo(padap, &mem_info);
1063-
if (rc)
1063+
if (rc) {
1064+
cudbg_err->sys_err = rc;
10641065
return rc;
1066+
}
10651067

10661068
cudbg_t4_fwcache(pdbg_init, cudbg_err);
10671069
rc = cudbg_meminfo_get_mem_index(padap, &mem_info, mem_type, &mc_idx);
1068-
if (rc)
1070+
if (rc) {
1071+
cudbg_err->sys_err = rc;
10691072
return rc;
1073+
}
1074+
1075+
if (region_size)
1076+
*region_size = mem_info.avail[mc_idx].limit -
1077+
mem_info.avail[mc_idx].base;
10701078

1071-
return mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base;
1079+
return 0;
10721080
}
10731081

10741082
static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
10751083
struct cudbg_buffer *dbg_buff,
10761084
struct cudbg_error *cudbg_err,
10771085
u8 mem_type)
10781086
{
1079-
unsigned long size = cudbg_mem_region_size(pdbg_init, cudbg_err, mem_type);
1087+
unsigned long size = 0;
1088+
int rc;
1089+
1090+
rc = cudbg_mem_region_size(pdbg_init, cudbg_err, mem_type, &size);
1091+
if (rc)
1092+
return rc;
10801093

10811094
return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size,
10821095
cudbg_err);

0 commit comments

Comments
 (0)