qla2x00t: Avoid that an SRR for a command without data triggers a kernel oops

Avoid that the following kernel oops is triggered as the result of
cable pulling:

------------[ cut here ]------------
kernel BUG at /usr/src/linux-3.0.51-0.7.9/include/asm-generic/dma-mapping-common.h:51!
invalid opcode: 0000 [#1] SMP
CPU 0

Pid: 5791, comm: kworker/0:1 Tainted: P           N
3.0.51-0.7.9-default #1 HP ProLiant DL380p Gen8
RIP: 0010:[<ffffffffa03312a7>]  [<ffffffffa03312a7>]
q2t_pci_map_calc_cnt+0x87/0x120 [qla2x00tgt]
RSP: 0018:ffff8807ad879cf0  EFLAGS: 00010202
RAX: ffff880fbfa00960 RBX: 0000000000000009 RCX: ffff880fbfa00960
RDX: 0000000000000000 RSI: 0000000000000009 RDI: ffff880fbfa00960
RBP: ffff8807ad879d40 R08: 0000000000000000 R09: dead000000200200
R10: dead000000100100 R11: ffffffff81020000 R12: ffffffff81a13880
R13: 0000000000000009 R14: ffff88100f172090 R15: ffff880fbfa00840
FS:  0000000000000000(0000) GS:ffff88083fa00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: 00007f74cf266020 CR3: 0000000001a03000 CR4: 00000000000406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Process kworker/0:1 (pid: 5791, threadinfo ffff8807ad878000, task
ffff88074ae801c0)
Stack:
 0000000300000000 ffff88100eb18670 00000000ffffffff ffff88100eb18670
 ffff8807ad879d40 ffff880744b331c8 ffff88080673ca00 ffffffffa03348bc
 0000000000000000 0000000000000000 ffff880744b331c8 ffff88080673ca00
Call Trace:
 [<ffffffffa03348bc>] __q2t_rdy_to_xfer+0x8c/0x1c0 [qla2x00tgt]
 [<ffffffffa033672d>] q2t_handle_srr_work+0x1ed/0x210 [qla2x00tgt]
 [<ffffffff810743cc>] process_one_work+0x16c/0x350
 [<ffffffff81076eba>] worker_thread+0x17a/0x410
 [<ffffffff8107b1e6>] kthread+0x96/0xa0
 [<ffffffff8144db44>] kernel_thread_helper+0x4/0x10
Code: 4d 85 e4 0f 84 a8 00 00 00 45 85 ed 7e 16 4c 89 ff 31 db 90 83
c3 01 e8 58 2b f2 e0 41 39 dd 48 89 c7 7f f0 83 7c 24 04 02 76 04 <0f>
0b eb fe 45 31 c0 8b 4c 24 04 44 89 ea 4c 89 fe 4c 89 f7 41
RIP  [<ffffffffa03312a7>] q2t_pci_map_calc_cnt+0x87/0x120 [qla2x00tgt]
 RSP <ffff8807ad879cf0>
---[ end trace e93624bd6aa42d19 ]---

Signed-off-by: Bart Van Assche <bvanassche@acm.org>



git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4747 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2013-01-25 01:20:37 +00:00
parent f0e65cb9d1
commit 92a296b9e5
+12 -8
View File
@@ -4300,7 +4300,8 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio,
break;
case SRR_IU_DATA_IN:
cmd->bufflen = scst_cmd_get_adjusted_resp_data_len(cmd->scst_cmd);
if (q2t_has_data(cmd)) {
if (q2t_has_data(cmd) &&
(scst_cmd_get_data_direction(cmd->scst_cmd) & SCST_DATA_READ)) {
uint32_t offset;
int xmit_type;
offset = le32_to_cpu(imm->imm.notify_entry24.srr_rel_offs);
@@ -4313,16 +4314,18 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio,
__q24_xmit_response(cmd, xmit_type);
} else {
PRINT_ERROR("qla2x00t(%ld): SRR for in data for cmd "
"without them (tag %d, SCSI status %d), "
"reject", ha->instance, cmd->tag,
scst_cmd_get_status(cmd->scst_cmd));
"without them (tag %d, SCSI status %d, dir %d),"
" reject", ha->instance, cmd->tag,
scst_cmd_get_status(cmd->scst_cmd),
scst_cmd_get_data_direction(cmd->scst_cmd));
goto out_reject;
}
break;
case SRR_IU_DATA_OUT:
cmd->bufflen = scst_cmd_get_write_fields(cmd->scst_cmd,
&cmd->sg, &cmd->sg_cnt);
if (q2t_has_data(cmd)) {
if (q2t_has_data(cmd) &&
(scst_cmd_get_data_direction(cmd->scst_cmd) & SCST_DATA_WRITE)) {
uint32_t offset;
int xmit_type;
offset = le32_to_cpu(imm->imm.notify_entry24.srr_rel_offs);
@@ -4336,9 +4339,10 @@ static void q24_handle_srr(scsi_qla_host_t *ha, struct srr_ctio *sctio,
__q2t_rdy_to_xfer(cmd);
} else {
PRINT_ERROR("qla2x00t(%ld): SRR for out data for cmd "
"without them (tag %d, SCSI status %d), "
"reject", ha->instance, cmd->tag,
scst_cmd_get_status(cmd->scst_cmd));
"without them (tag %d, SCSI status %d, dir %d),"
" reject", ha->instance, cmd->tag,
scst_cmd_get_status(cmd->scst_cmd),
scst_cmd_get_data_direction(cmd->scst_cmd));
goto out_reject;
}
break;