Skip to content

Commit 77ddb94

Browse files
himanshu.madhani@cavium.commartinkpetersen
authored andcommitted
scsi: qla2xxx: Only allow operational MBX to proceed during RESET.
This patch is allowing only ROM mailbox command which are necessary to initialize chip after a reset has been issued. In a target environment, there could be a user space daemon which can issue statistics and other management mailbox command which are non-critical. This patch will timeout non critical mailbox commands immediately rather than waiting for timeout, if driver detects that chip reset has been issued or chip reset is in progress. Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Himanshu Madhani <[email protected]> Signed-off-by: Giridhar Malavali <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 7e8a948 commit 77ddb94

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

drivers/scsi/qla2xxx/qla_mbx.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,43 @@
1010
#include <linux/delay.h>
1111
#include <linux/gfp.h>
1212

13+
struct rom_cmd {
14+
uint16_t cmd;
15+
} rom_cmds[] = {
16+
{ MBC_LOAD_RAM },
17+
{ MBC_EXECUTE_FIRMWARE },
18+
{ MBC_READ_RAM_WORD },
19+
{ MBC_MAILBOX_REGISTER_TEST },
20+
{ MBC_VERIFY_CHECKSUM },
21+
{ MBC_GET_FIRMWARE_VERSION },
22+
{ MBC_LOAD_RISC_RAM },
23+
{ MBC_DUMP_RISC_RAM },
24+
{ MBC_LOAD_RISC_RAM_EXTENDED },
25+
{ MBC_DUMP_RISC_RAM_EXTENDED },
26+
{ MBC_WRITE_RAM_WORD_EXTENDED },
27+
{ MBC_READ_RAM_EXTENDED },
28+
{ MBC_GET_RESOURCE_COUNTS },
29+
{ MBC_SET_FIRMWARE_OPTION },
30+
{ MBC_MID_INITIALIZE_FIRMWARE },
31+
{ MBC_GET_FIRMWARE_STATE },
32+
{ MBC_GET_MEM_OFFLOAD_CNTRL_STAT },
33+
{ MBC_GET_RETRY_COUNT },
34+
{ MBC_TRACE_CONTROL },
35+
};
36+
37+
static int is_rom_cmd(uint16_t cmd)
38+
{
39+
int i;
40+
struct rom_cmd *wc;
41+
42+
for (i = 0; i < ARRAY_SIZE(rom_cmds); i++) {
43+
wc = rom_cmds + i;
44+
if (wc->cmd == cmd)
45+
return 1;
46+
}
47+
48+
return 0;
49+
}
1350

1451
/*
1552
* qla2x00_mailbox_command
@@ -92,6 +129,17 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
92129
return QLA_FUNCTION_TIMEOUT;
93130
}
94131

132+
/* check if ISP abort is active and return cmd with timeout */
133+
if ((test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
134+
test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
135+
test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) &&
136+
!is_rom_cmd(mcp->mb[0])) {
137+
ql_log(ql_log_info, vha, 0x1005,
138+
"Cmd 0x%x aborted with timeout since ISP Abort is pending\n",
139+
mcp->mb[0]);
140+
return QLA_FUNCTION_TIMEOUT;
141+
}
142+
95143
/*
96144
* Wait for active mailbox commands to finish by waiting at most tov
97145
* seconds. This is to serialize actual issuing of mailbox cmds during
@@ -178,6 +226,7 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
178226
WRT_REG_WORD(&reg->isp.hccr, HCCR_SET_HOST_INT);
179227
spin_unlock_irqrestore(&ha->hardware_lock, flags);
180228

229+
wait_time = jiffies;
181230
if (!wait_for_completion_timeout(&ha->mbx_intr_comp,
182231
mcp->tov * HZ)) {
183232
ql_dbg(ql_dbg_mbx, vha, 0x117a,
@@ -186,6 +235,9 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
186235
clear_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags);
187236
spin_unlock_irqrestore(&ha->hardware_lock, flags);
188237
}
238+
if (time_after(jiffies, wait_time + 5 * HZ))
239+
ql_log(ql_log_warn, vha, 0x1015, "cmd=0x%x, waited %d msecs\n",
240+
command, jiffies_to_msecs(jiffies - wait_time));
189241
} else {
190242
ql_dbg(ql_dbg_mbx, vha, 0x1011,
191243
"Cmd=%x Polling Mode.\n", command);

0 commit comments

Comments
 (0)