Commit ce222748 authored by Vishal Kulkarni's avatar Vishal Kulkarni Committed by David S. Miller

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: a1c69520 ("cxgb4: collect MC memory dump")
Signed-off-by: Vishal Kulkarni <vishal@chelsio.com>"
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent da0afd1f
...@@ -1049,9 +1049,9 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init, ...@@ -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, static int cudbg_mem_region_size(struct cudbg_init *pdbg_init,
struct cudbg_error *cudbg_err, struct cudbg_error *cudbg_err,
u8 mem_type) u8 mem_type, unsigned long *region_size)
{ {
struct adapter *padap = pdbg_init->adap; struct adapter *padap = pdbg_init->adap;
struct cudbg_meminfo mem_info; struct cudbg_meminfo mem_info;
...@@ -1060,15 +1060,23 @@ static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init, ...@@ -1060,15 +1060,23 @@ static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init,
memset(&mem_info, 0, sizeof(struct cudbg_meminfo)); memset(&mem_info, 0, sizeof(struct cudbg_meminfo));
rc = cudbg_fill_meminfo(padap, &mem_info); rc = cudbg_fill_meminfo(padap, &mem_info);
if (rc) if (rc) {
cudbg_err->sys_err = rc;
return rc; return rc;
}
cudbg_t4_fwcache(pdbg_init, cudbg_err); cudbg_t4_fwcache(pdbg_init, cudbg_err);
rc = cudbg_meminfo_get_mem_index(padap, &mem_info, mem_type, &mc_idx); rc = cudbg_meminfo_get_mem_index(padap, &mem_info, mem_type, &mc_idx);
if (rc) if (rc) {
cudbg_err->sys_err = rc;
return 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, 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, ...@@ -1076,7 +1084,12 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init,
struct cudbg_error *cudbg_err, struct cudbg_error *cudbg_err,
u8 mem_type) 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, return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size,
cudbg_err); cudbg_err);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment