Skip to content

Commit 6243146

Browse files
arndbmartinkpetersen
authored andcommitted
scsi: qla2xxx: Avoid stack frame size warning in qla_dfs
The qla2x00_dfs_tgt_port_database_show() function constructs a fake fc_port_t object on the stack, which--depending on the configuration--is large enough to exceed the stack size warning limit: drivers/scsi/qla2xxx/qla_dfs.c:176:1: error: stack frame size (1392) exceeds limit (1280) in 'qla2x00_dfs_tgt_port_database_show' [-Werror,-Wframe-larger-than] Rework this function to no longer need the structure but instead call a custom helper function that just prints the data directly from the port_database_24xx structure. Signed-off-by: Arnd Bergmann <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin K. Petersen <[email protected]>
1 parent ed575d4 commit 6243146

File tree

3 files changed

+55
-14
lines changed

3 files changed

+55
-14
lines changed

drivers/scsi/qla2xxx/qla_dfs.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,9 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
179179
struct qla_hw_data *ha = vha->hw;
180180
struct gid_list_info *gid_list;
181181
dma_addr_t gid_list_dma;
182-
fc_port_t fc_port;
183182
char *id_iter;
184183
int rc, i;
185-
uint16_t entries, loop_id;
184+
uint16_t entries;
186185

187186
seq_printf(s, "%s\n", vha->host_str);
188187
gid_list = dma_alloc_coherent(&ha->pdev->dev,
@@ -205,18 +204,11 @@ qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
205204
seq_puts(s, "Port Name Port ID Loop ID\n");
206205

207206
for (i = 0; i < entries; i++) {
208-
struct gid_list_info *gid =
209-
(struct gid_list_info *)id_iter;
210-
loop_id = le16_to_cpu(gid->loop_id);
211-
memset(&fc_port, 0, sizeof(fc_port_t));
212-
213-
fc_port.loop_id = loop_id;
214-
215-
rc = qla24xx_gpdb_wait(vha, &fc_port, 0);
216-
seq_printf(s, "%8phC %02x%02x%02x %d\n",
217-
fc_port.port_name, fc_port.d_id.b.domain,
218-
fc_port.d_id.b.area, fc_port.d_id.b.al_pa,
219-
fc_port.loop_id);
207+
struct gid_list_info *gid = (struct gid_list_info *)id_iter;
208+
209+
rc = qla24xx_print_fc_port_id(vha, s, le16_to_cpu(gid->loop_id));
210+
if (rc != QLA_SUCCESS)
211+
break;
220212
id_iter += ha->gid_list_info_size;
221213
}
222214
out_free_id_list:

drivers/scsi/qla2xxx/qla_gbl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ qla26xx_dport_diagnostics_v2(scsi_qla_host_t *,
557557

558558
int qla24xx_send_mb_cmd(struct scsi_qla_host *, mbx_cmd_t *);
559559
int qla24xx_gpdb_wait(struct scsi_qla_host *, fc_port_t *, u8);
560+
int qla24xx_print_fc_port_id(struct scsi_qla_host *, struct seq_file *, u16);
560561
int qla24xx_gidlist_wait(struct scsi_qla_host *, void *, dma_addr_t,
561562
uint16_t *);
562563
int __qla24xx_parse_gpdb(struct scsi_qla_host *, fc_port_t *,

drivers/scsi/qla2xxx/qla_mbx.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6597,6 +6597,54 @@ int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp)
65976597
return rval;
65986598
}
65996599

6600+
int qla24xx_print_fc_port_id(struct scsi_qla_host *vha, struct seq_file *s, u16 loop_id)
6601+
{
6602+
int rval = QLA_FUNCTION_FAILED;
6603+
dma_addr_t pd_dma;
6604+
struct port_database_24xx *pd;
6605+
struct qla_hw_data *ha = vha->hw;
6606+
mbx_cmd_t mc;
6607+
6608+
if (!vha->hw->flags.fw_started)
6609+
goto done;
6610+
6611+
pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
6612+
if (pd == NULL) {
6613+
ql_log(ql_log_warn, vha, 0xd047,
6614+
"Failed to allocate port database structure.\n");
6615+
goto done;
6616+
}
6617+
6618+
memset(&mc, 0, sizeof(mc));
6619+
mc.mb[0] = MBC_GET_PORT_DATABASE;
6620+
mc.mb[1] = loop_id;
6621+
mc.mb[2] = MSW(pd_dma);
6622+
mc.mb[3] = LSW(pd_dma);
6623+
mc.mb[6] = MSW(MSD(pd_dma));
6624+
mc.mb[7] = LSW(MSD(pd_dma));
6625+
mc.mb[9] = vha->vp_idx;
6626+
6627+
rval = qla24xx_send_mb_cmd(vha, &mc);
6628+
if (rval != QLA_SUCCESS) {
6629+
ql_dbg(ql_dbg_mbx, vha, 0x1193, "%s: fail\n", __func__);
6630+
goto done_free_sp;
6631+
}
6632+
6633+
ql_dbg(ql_dbg_mbx, vha, 0x1197, "%s: %8phC done\n",
6634+
__func__, pd->port_name);
6635+
6636+
seq_printf(s, "%8phC %02x%02x%02x %d\n",
6637+
pd->port_name, pd->port_id[0],
6638+
pd->port_id[1], pd->port_id[2],
6639+
loop_id);
6640+
6641+
done_free_sp:
6642+
if (pd)
6643+
dma_pool_free(ha->s_dma_pool, pd, pd_dma);
6644+
done:
6645+
return rval;
6646+
}
6647+
66006648
/*
66016649
* qla24xx_gpdb_wait
66026650
* NOTE: Do not call this routine from DPC thread

0 commit comments

Comments
 (0)