aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-15 20:24:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-15 20:24:12 -0400
commitf0d98d85831bf1a3b1f56f8c14af60797aaca536 (patch)
treeb63abe91e769ef429774e6383c9a552a07a288f6
parentca71b3ba4c78c2c05b44be9b257a4127223f0b0c (diff)
parent4d42680330e1ac6f9aee715311a198038264747f (diff)
Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
Pull SCSI fixes from James Bottomley: "This is a set of minor (and safe changes) that didn't make the initial pull request plus some bug fixes. The status handling code is actually a running regression from the previous merge window which had an incomplete fix (now reverted) and most of the remaining bug fixes are for problems older than the current merge window" [ Side note: this merge also takes the base kernel git repository to 6+ million objects for the first time. Technically we hit it a couple of merges ago already if you count all the tag objects, but now it reaches 6M+ objects reachable from HEAD. I was joking around that that's when I should switch to 5.0, because 3.0 happened at the 2M mark, and 4.0 happened at 4M objects. But probably not, even if numerology is about as good a reason as any. - Linus ] * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: scsi: devinfo: Add Microsoft iSCSI target to 1024 sector blacklist scsi: cxgb4i: silence overflow warning in t4_uld_rx_handler() scsi: dpt_i2o: Use after free in I2ORESETCMD ioctl scsi: core: Make scsi_result_to_blk_status() recognize CONDITION MET scsi: core: Rename __scsi_error_from_host_byte() into scsi_result_to_blk_status() Revert "scsi: core: return BLK_STS_OK for DID_OK in __scsi_error_from_host_byte()" scsi: aacraid: Insure command thread is not recursively stopped scsi: qla2xxx: Correct setting of SAM_STAT_CHECK_CONDITION scsi: qla2xxx: correctly shift host byte scsi: qla2xxx: Fix race condition between iocb timeout and initialisation scsi: qla2xxx: Avoid double completion of abort command scsi: qla2xxx: Fix small memory leak in qla2x00_probe_one on probe failure scsi: scsi_dh: Don't look for NULL devices handlers by name scsi: core: remove redundant assignment to shost->use_blk_mq
-rw-r--r--drivers/scsi/aacraid/commsup.c4
-rw-r--r--drivers/scsi/aacraid/linit.c1
-rw-r--r--drivers/scsi/cxgbi/cxgb4i/cxgb4i.c8
-rw-r--r--drivers/scsi/dpt_i2o.c13
-rw-r--r--drivers/scsi/hosts.c1
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c12
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c41
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h2
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_mbx.c8
-rw-r--r--drivers/scsi/qla2xxx/qla_mid.c2
-rw-r--r--drivers/scsi/qla2xxx/qla_mr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c44
-rw-r--r--drivers/scsi/qla2xxx/qla_target.c2
-rw-r--r--drivers/scsi/scsi_devinfo.c2
-rw-r--r--drivers/scsi/scsi_dh.c3
-rw-r--r--drivers/scsi/scsi_lib.c27
18 files changed, 109 insertions, 82 deletions
diff --git a/drivers/scsi/aacraid/commsup.c b/drivers/scsi/aacraid/commsup.c
index 84858d5c8257..0156c9623c35 100644
--- a/drivers/scsi/aacraid/commsup.c
+++ b/drivers/scsi/aacraid/commsup.c
@@ -1502,9 +1502,10 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
1502 host = aac->scsi_host_ptr; 1502 host = aac->scsi_host_ptr;
1503 scsi_block_requests(host); 1503 scsi_block_requests(host);
1504 aac_adapter_disable_int(aac); 1504 aac_adapter_disable_int(aac);
1505 if (aac->thread->pid != current->pid) { 1505 if (aac->thread && aac->thread->pid != current->pid) {
1506 spin_unlock_irq(host->host_lock); 1506 spin_unlock_irq(host->host_lock);
1507 kthread_stop(aac->thread); 1507 kthread_stop(aac->thread);
1508 aac->thread = NULL;
1508 jafo = 1; 1509 jafo = 1;
1509 } 1510 }
1510 1511
@@ -1591,6 +1592,7 @@ static int _aac_reset_adapter(struct aac_dev *aac, int forced, u8 reset_type)
1591 aac->name); 1592 aac->name);
1592 if (IS_ERR(aac->thread)) { 1593 if (IS_ERR(aac->thread)) {
1593 retval = PTR_ERR(aac->thread); 1594 retval = PTR_ERR(aac->thread);
1595 aac->thread = NULL;
1594 goto out; 1596 goto out;
1595 } 1597 }
1596 } 1598 }
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 2664ea0df35f..f24fb942065d 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1562,6 +1562,7 @@ static void __aac_shutdown(struct aac_dev * aac)
1562 up(&fib->event_wait); 1562 up(&fib->event_wait);
1563 } 1563 }
1564 kthread_stop(aac->thread); 1564 kthread_stop(aac->thread);
1565 aac->thread = NULL;
1565 } 1566 }
1566 1567
1567 aac_send_shutdown(aac); 1568 aac_send_shutdown(aac);
diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
index 406e94312d4e..211da1d5a869 100644
--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c
@@ -2108,12 +2108,12 @@ static int t4_uld_rx_handler(void *handle, const __be64 *rsp,
2108 log_debug(1 << CXGBI_DBG_TOE, 2108 log_debug(1 << CXGBI_DBG_TOE,
2109 "cdev %p, opcode 0x%x(0x%x,0x%x), skb %p.\n", 2109 "cdev %p, opcode 0x%x(0x%x,0x%x), skb %p.\n",
2110 cdev, opc, rpl->ot.opcode_tid, ntohl(rpl->ot.opcode_tid), skb); 2110 cdev, opc, rpl->ot.opcode_tid, ntohl(rpl->ot.opcode_tid), skb);
2111 if (cxgb4i_cplhandlers[opc]) 2111 if (opc >= ARRAY_SIZE(cxgb4i_cplhandlers) || !cxgb4i_cplhandlers[opc]) {
2112 cxgb4i_cplhandlers[opc](cdev, skb);
2113 else {
2114 pr_err("No handler for opcode 0x%x.\n", opc); 2112 pr_err("No handler for opcode 0x%x.\n", opc);
2115 __kfree_skb(skb); 2113 __kfree_skb(skb);
2116 } 2114 } else
2115 cxgb4i_cplhandlers[opc](cdev, skb);
2116
2117 return 0; 2117 return 0;
2118nomem: 2118nomem:
2119 log_debug(1 << CXGBI_DBG_TOE, "OOM bailing out.\n"); 2119 log_debug(1 << CXGBI_DBG_TOE, "OOM bailing out.\n");
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 6866975b25f3..5ceea8da7bb6 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -2051,13 +2051,16 @@ static int adpt_ioctl(struct inode *inode, struct file *file, uint cmd, ulong ar
2051 } 2051 }
2052 break; 2052 break;
2053 } 2053 }
2054 case I2ORESETCMD: 2054 case I2ORESETCMD: {
2055 if(pHba->host) 2055 struct Scsi_Host *shost = pHba->host;
2056 spin_lock_irqsave(pHba->host->host_lock, flags); 2056
2057 if (shost)
2058 spin_lock_irqsave(shost->host_lock, flags);
2057 adpt_hba_reset(pHba); 2059 adpt_hba_reset(pHba);
2058 if(pHba->host) 2060 if (shost)
2059 spin_unlock_irqrestore(pHba->host->host_lock, flags); 2061 spin_unlock_irqrestore(shost->host_lock, flags);
2060 break; 2062 break;
2063 }
2061 case I2ORESCANCMD: 2064 case I2ORESCANCMD:
2062 adpt_rescan(pHba); 2065 adpt_rescan(pHba);
2063 break; 2066 break;
diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
index 7649d63a1b8d..3771e59a9fae 100644
--- a/drivers/scsi/hosts.c
+++ b/drivers/scsi/hosts.c
@@ -472,7 +472,6 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
472 else 472 else
473 shost->dma_boundary = 0xffffffff; 473 shost->dma_boundary = 0xffffffff;
474 474
475 shost->use_blk_mq = scsi_use_blk_mq;
476 shost->use_blk_mq = scsi_use_blk_mq || shost->hostt->force_blk_mq; 475 shost->use_blk_mq = scsi_use_blk_mq || shost->hostt->force_blk_mq;
477 476
478 device_initialize(&shost->shost_gendev); 477 device_initialize(&shost->shost_gendev);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 2288757b5c9e..9e914f9c3ffb 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -3794,6 +3794,7 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport)
3794 sp->gen1 = fcport->rscn_gen; 3794 sp->gen1 = fcport->rscn_gen;
3795 sp->gen2 = fcport->login_gen; 3795 sp->gen2 = fcport->login_gen;
3796 3796
3797 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
3797 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 3798 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
3798 3799
3799 /* CT_IU preamble */ 3800 /* CT_IU preamble */
@@ -3812,7 +3813,6 @@ int qla24xx_async_gffid(scsi_qla_host_t *vha, fc_port_t *fcport)
3812 sp->u.iocb_cmd.u.ctarg.rsp_size = GFF_ID_RSP_SIZE; 3813 sp->u.iocb_cmd.u.ctarg.rsp_size = GFF_ID_RSP_SIZE;
3813 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; 3814 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS;
3814 3815
3815 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
3816 sp->done = qla24xx_async_gffid_sp_done; 3816 sp->done = qla24xx_async_gffid_sp_done;
3817 3817
3818 rval = qla2x00_start_sp(sp); 3818 rval = qla2x00_start_sp(sp);
@@ -4230,6 +4230,8 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp,
4230 sp->name = "gnnft"; 4230 sp->name = "gnnft";
4231 sp->gen1 = vha->hw->base_qpair->chip_reset; 4231 sp->gen1 = vha->hw->base_qpair->chip_reset;
4232 sp->gen2 = fc4_type; 4232 sp->gen2 = fc4_type;
4233
4234 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4233 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 4235 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
4234 4236
4235 memset(sp->u.iocb_cmd.u.ctarg.rsp, 0, sp->u.iocb_cmd.u.ctarg.rsp_size); 4237 memset(sp->u.iocb_cmd.u.ctarg.rsp, 0, sp->u.iocb_cmd.u.ctarg.rsp_size);
@@ -4246,7 +4248,6 @@ static int qla24xx_async_gnnft(scsi_qla_host_t *vha, struct srb *sp,
4246 sp->u.iocb_cmd.u.ctarg.req_size = GNN_FT_REQ_SIZE; 4248 sp->u.iocb_cmd.u.ctarg.req_size = GNN_FT_REQ_SIZE;
4247 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; 4249 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS;
4248 4250
4249 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4250 sp->done = qla2x00_async_gpnft_gnnft_sp_done; 4251 sp->done = qla2x00_async_gpnft_gnnft_sp_done;
4251 4252
4252 rval = qla2x00_start_sp(sp); 4253 rval = qla2x00_start_sp(sp);
@@ -4370,6 +4371,8 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
4370 sp->name = "gpnft"; 4371 sp->name = "gpnft";
4371 sp->gen1 = vha->hw->base_qpair->chip_reset; 4372 sp->gen1 = vha->hw->base_qpair->chip_reset;
4372 sp->gen2 = fc4_type; 4373 sp->gen2 = fc4_type;
4374
4375 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4373 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 4376 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
4374 4377
4375 rspsz = sizeof(struct ct_sns_gpnft_rsp) + 4378 rspsz = sizeof(struct ct_sns_gpnft_rsp) +
@@ -4385,7 +4388,6 @@ int qla24xx_async_gpnft(scsi_qla_host_t *vha, u8 fc4_type, srb_t *sp)
4385 4388
4386 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; 4389 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS;
4387 4390
4388 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4389 sp->done = qla2x00_async_gpnft_gnnft_sp_done; 4391 sp->done = qla2x00_async_gpnft_gnnft_sp_done;
4390 4392
4391 rval = qla2x00_start_sp(sp); 4393 rval = qla2x00_start_sp(sp);
@@ -4495,6 +4497,7 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport)
4495 sp->gen1 = fcport->rscn_gen; 4497 sp->gen1 = fcport->rscn_gen;
4496 sp->gen2 = fcport->login_gen; 4498 sp->gen2 = fcport->login_gen;
4497 4499
4500 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4498 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 4501 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
4499 4502
4500 /* CT_IU preamble */ 4503 /* CT_IU preamble */
@@ -4516,7 +4519,6 @@ int qla24xx_async_gnnid(scsi_qla_host_t *vha, fc_port_t *fcport)
4516 sp->u.iocb_cmd.u.ctarg.rsp_size = GNN_ID_RSP_SIZE; 4519 sp->u.iocb_cmd.u.ctarg.rsp_size = GNN_ID_RSP_SIZE;
4517 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; 4520 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS;
4518 4521
4519 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4520 sp->done = qla2x00_async_gnnid_sp_done; 4522 sp->done = qla2x00_async_gnnid_sp_done;
4521 4523
4522 rval = qla2x00_start_sp(sp); 4524 rval = qla2x00_start_sp(sp);
@@ -4632,6 +4634,7 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport)
4632 sp->gen1 = fcport->rscn_gen; 4634 sp->gen1 = fcport->rscn_gen;
4633 sp->gen2 = fcport->login_gen; 4635 sp->gen2 = fcport->login_gen;
4634 4636
4637 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4635 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 4638 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
4636 4639
4637 /* CT_IU preamble */ 4640 /* CT_IU preamble */
@@ -4653,7 +4656,6 @@ int qla24xx_async_gfpnid(scsi_qla_host_t *vha, fc_port_t *fcport)
4653 sp->u.iocb_cmd.u.ctarg.rsp_size = GFPN_ID_RSP_SIZE; 4656 sp->u.iocb_cmd.u.ctarg.rsp_size = GFPN_ID_RSP_SIZE;
4654 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS; 4657 sp->u.iocb_cmd.u.ctarg.nport_handle = NPH_SNS;
4655 4658
4656 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
4657 sp->done = qla2x00_async_gfpnid_sp_done; 4659 sp->done = qla2x00_async_gfpnid_sp_done;
4658 4660
4659 rval = qla2x00_start_sp(sp); 4661 rval = qla2x00_start_sp(sp);
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 8aeb0ed524a1..8f55dd44adae 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -183,10 +183,11 @@ qla2x00_async_login(struct scsi_qla_host *vha, fc_port_t *fcport,
183 sp->name = "login"; 183 sp->name = "login";
184 sp->gen1 = fcport->rscn_gen; 184 sp->gen1 = fcport->rscn_gen;
185 sp->gen2 = fcport->login_gen; 185 sp->gen2 = fcport->login_gen;
186 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
187 186
188 lio = &sp->u.iocb_cmd; 187 lio = &sp->u.iocb_cmd;
189 lio->timeout = qla2x00_async_iocb_timeout; 188 lio->timeout = qla2x00_async_iocb_timeout;
189 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
190
190 sp->done = qla2x00_async_login_sp_done; 191 sp->done = qla2x00_async_login_sp_done;
191 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI; 192 lio->u.logio.flags |= SRB_LOGIN_COND_PLOGI;
192 193
@@ -245,10 +246,11 @@ qla2x00_async_logout(struct scsi_qla_host *vha, fc_port_t *fcport)
245 246
246 sp->type = SRB_LOGOUT_CMD; 247 sp->type = SRB_LOGOUT_CMD;
247 sp->name = "logout"; 248 sp->name = "logout";
248 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
249 249
250 lio = &sp->u.iocb_cmd; 250 lio = &sp->u.iocb_cmd;
251 lio->timeout = qla2x00_async_iocb_timeout; 251 lio->timeout = qla2x00_async_iocb_timeout;
252 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
253
252 sp->done = qla2x00_async_logout_sp_done; 254 sp->done = qla2x00_async_logout_sp_done;
253 rval = qla2x00_start_sp(sp); 255 rval = qla2x00_start_sp(sp);
254 if (rval != QLA_SUCCESS) 256 if (rval != QLA_SUCCESS)
@@ -307,10 +309,11 @@ qla2x00_async_prlo(struct scsi_qla_host *vha, fc_port_t *fcport)
307 309
308 sp->type = SRB_PRLO_CMD; 310 sp->type = SRB_PRLO_CMD;
309 sp->name = "prlo"; 311 sp->name = "prlo";
310 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
311 312
312 lio = &sp->u.iocb_cmd; 313 lio = &sp->u.iocb_cmd;
313 lio->timeout = qla2x00_async_iocb_timeout; 314 lio->timeout = qla2x00_async_iocb_timeout;
315 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
316
314 sp->done = qla2x00_async_prlo_sp_done; 317 sp->done = qla2x00_async_prlo_sp_done;
315 rval = qla2x00_start_sp(sp); 318 rval = qla2x00_start_sp(sp);
316 if (rval != QLA_SUCCESS) 319 if (rval != QLA_SUCCESS)
@@ -412,10 +415,11 @@ qla2x00_async_adisc(struct scsi_qla_host *vha, fc_port_t *fcport,
412 415
413 sp->type = SRB_ADISC_CMD; 416 sp->type = SRB_ADISC_CMD;
414 sp->name = "adisc"; 417 sp->name = "adisc";
415 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
416 418
417 lio = &sp->u.iocb_cmd; 419 lio = &sp->u.iocb_cmd;
418 lio->timeout = qla2x00_async_iocb_timeout; 420 lio->timeout = qla2x00_async_iocb_timeout;
421 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
422
419 sp->done = qla2x00_async_adisc_sp_done; 423 sp->done = qla2x00_async_adisc_sp_done;
420 if (data[1] & QLA_LOGIO_LOGIN_RETRIED) 424 if (data[1] & QLA_LOGIO_LOGIN_RETRIED)
421 lio->u.logio.flags |= SRB_LOGIN_RETRIED; 425 lio->u.logio.flags |= SRB_LOGIN_RETRIED;
@@ -745,6 +749,8 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
745 sp->gen1 = fcport->rscn_gen; 749 sp->gen1 = fcport->rscn_gen;
746 sp->gen2 = fcport->login_gen; 750 sp->gen2 = fcport->login_gen;
747 751
752 mbx = &sp->u.iocb_cmd;
753 mbx->timeout = qla2x00_async_iocb_timeout;
748 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2); 754 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2);
749 755
750 mb = sp->u.iocb_cmd.u.mbx.out_mb; 756 mb = sp->u.iocb_cmd.u.mbx.out_mb;
@@ -757,9 +763,6 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
757 mb[8] = vha->gnl.size; 763 mb[8] = vha->gnl.size;
758 mb[9] = vha->vp_idx; 764 mb[9] = vha->vp_idx;
759 765
760 mbx = &sp->u.iocb_cmd;
761 mbx->timeout = qla2x00_async_iocb_timeout;
762
763 sp->done = qla24xx_async_gnl_sp_done; 766 sp->done = qla24xx_async_gnl_sp_done;
764 767
765 rval = qla2x00_start_sp(sp); 768 rval = qla2x00_start_sp(sp);
@@ -887,10 +890,11 @@ qla24xx_async_prli(struct scsi_qla_host *vha, fc_port_t *fcport)
887 890
888 sp->type = SRB_PRLI_CMD; 891 sp->type = SRB_PRLI_CMD;
889 sp->name = "prli"; 892 sp->name = "prli";
890 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
891 893
892 lio = &sp->u.iocb_cmd; 894 lio = &sp->u.iocb_cmd;
893 lio->timeout = qla2x00_async_iocb_timeout; 895 lio->timeout = qla2x00_async_iocb_timeout;
896 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
897
894 sp->done = qla2x00_async_prli_sp_done; 898 sp->done = qla2x00_async_prli_sp_done;
895 lio->u.logio.flags = 0; 899 lio->u.logio.flags = 0;
896 900
@@ -955,6 +959,9 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
955 sp->name = "gpdb"; 959 sp->name = "gpdb";
956 sp->gen1 = fcport->rscn_gen; 960 sp->gen1 = fcport->rscn_gen;
957 sp->gen2 = fcport->login_gen; 961 sp->gen2 = fcport->login_gen;
962
963 mbx = &sp->u.iocb_cmd;
964 mbx->timeout = qla2x00_async_iocb_timeout;
958 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2); 965 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
959 966
960 pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma); 967 pd = dma_pool_zalloc(ha->s_dma_pool, GFP_KERNEL, &pd_dma);
@@ -974,8 +981,6 @@ int qla24xx_async_gpdb(struct scsi_qla_host *vha, fc_port_t *fcport, u8 opt)
974 mb[9] = vha->vp_idx; 981 mb[9] = vha->vp_idx;
975 mb[10] = opt; 982 mb[10] = opt;
976 983
977 mbx = &sp->u.iocb_cmd;
978 mbx->timeout = qla2x00_async_iocb_timeout;
979 mbx->u.mbx.in = (void *)pd; 984 mbx->u.mbx.in = (void *)pd;
980 mbx->u.mbx.in_dma = pd_dma; 985 mbx->u.mbx.in_dma = pd_dma;
981 986
@@ -1490,13 +1495,15 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint32_t lun,
1490 tm_iocb = &sp->u.iocb_cmd; 1495 tm_iocb = &sp->u.iocb_cmd;
1491 sp->type = SRB_TM_CMD; 1496 sp->type = SRB_TM_CMD;
1492 sp->name = "tmf"; 1497 sp->name = "tmf";
1498
1499 tm_iocb->timeout = qla2x00_tmf_iocb_timeout;
1500 init_completion(&tm_iocb->u.tmf.comp);
1493 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)); 1501 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha));
1502
1494 tm_iocb->u.tmf.flags = flags; 1503 tm_iocb->u.tmf.flags = flags;
1495 tm_iocb->u.tmf.lun = lun; 1504 tm_iocb->u.tmf.lun = lun;
1496 tm_iocb->u.tmf.data = tag; 1505 tm_iocb->u.tmf.data = tag;
1497 sp->done = qla2x00_tmf_sp_done; 1506 sp->done = qla2x00_tmf_sp_done;
1498 tm_iocb->timeout = qla2x00_tmf_iocb_timeout;
1499 init_completion(&tm_iocb->u.tmf.comp);
1500 1507
1501 rval = qla2x00_start_sp(sp); 1508 rval = qla2x00_start_sp(sp);
1502 if (rval != QLA_SUCCESS) 1509 if (rval != QLA_SUCCESS)
@@ -1550,8 +1557,8 @@ qla24xx_abort_sp_done(void *ptr, int res)
1550 srb_t *sp = ptr; 1557 srb_t *sp = ptr;
1551 struct srb_iocb *abt = &sp->u.iocb_cmd; 1558 struct srb_iocb *abt = &sp->u.iocb_cmd;
1552 1559
1553 del_timer(&sp->u.iocb_cmd.timer); 1560 if (del_timer(&sp->u.iocb_cmd.timer))
1554 complete(&abt->u.abt.comp); 1561 complete(&abt->u.abt.comp);
1555} 1562}
1556 1563
1557int 1564int
@@ -1570,7 +1577,11 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp)
1570 abt_iocb = &sp->u.iocb_cmd; 1577 abt_iocb = &sp->u.iocb_cmd;
1571 sp->type = SRB_ABT_CMD; 1578 sp->type = SRB_ABT_CMD;
1572 sp->name = "abort"; 1579 sp->name = "abort";
1580
1581 abt_iocb->timeout = qla24xx_abort_iocb_timeout;
1582 init_completion(&abt_iocb->u.abt.comp);
1573 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)); 1583 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha));
1584
1574 abt_iocb->u.abt.cmd_hndl = cmd_sp->handle; 1585 abt_iocb->u.abt.cmd_hndl = cmd_sp->handle;
1575 1586
1576 if (vha->flags.qpairs_available && cmd_sp->qpair) 1587 if (vha->flags.qpairs_available && cmd_sp->qpair)
@@ -1580,8 +1591,6 @@ qla24xx_async_abort_cmd(srb_t *cmd_sp)
1580 abt_iocb->u.abt.req_que_no = cpu_to_le16(vha->req->id); 1591 abt_iocb->u.abt.req_que_no = cpu_to_le16(vha->req->id);
1581 1592
1582 sp->done = qla24xx_abort_sp_done; 1593 sp->done = qla24xx_abort_sp_done;
1583 abt_iocb->timeout = qla24xx_abort_iocb_timeout;
1584 init_completion(&abt_iocb->u.abt.comp);
1585 1594
1586 rval = qla2x00_start_sp(sp); 1595 rval = qla2x00_start_sp(sp);
1587 if (rval != QLA_SUCCESS) 1596 if (rval != QLA_SUCCESS)
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index b7a05aebf065..37ae0f6d8ae5 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -272,13 +272,13 @@ qla2x00_init_timer(srb_t *sp, unsigned long tmo)
272{ 272{
273 timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0); 273 timer_setup(&sp->u.iocb_cmd.timer, qla2x00_sp_timeout, 0);
274 sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ; 274 sp->u.iocb_cmd.timer.expires = jiffies + tmo * HZ;
275 add_timer(&sp->u.iocb_cmd.timer);
276 sp->free = qla2x00_sp_free; 275 sp->free = qla2x00_sp_free;
277 init_completion(&sp->comp); 276 init_completion(&sp->comp);
278 if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD)) 277 if (IS_QLAFX00(sp->vha->hw) && (sp->type == SRB_FXIOCB_DCMD))
279 init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp); 278 init_completion(&sp->u.iocb_cmd.u.fxiocb.fxiocb_comp);
280 if (sp->type == SRB_ELS_DCMD) 279 if (sp->type == SRB_ELS_DCMD)
281 init_completion(&sp->u.iocb_cmd.u.els_logo.comp); 280 init_completion(&sp->u.iocb_cmd.u.els_logo.comp);
281 add_timer(&sp->u.iocb_cmd.timer);
282} 282}
283 283
284static inline int 284static inline int
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index f74ff7b550b6..a91cca52b5d5 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -2460,8 +2460,8 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
2460 sp->type = SRB_ELS_DCMD; 2460 sp->type = SRB_ELS_DCMD;
2461 sp->name = "ELS_DCMD"; 2461 sp->name = "ELS_DCMD";
2462 sp->fcport = fcport; 2462 sp->fcport = fcport;
2463 qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT);
2464 elsio->timeout = qla2x00_els_dcmd_iocb_timeout; 2463 elsio->timeout = qla2x00_els_dcmd_iocb_timeout;
2464 qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT);
2465 sp->done = qla2x00_els_dcmd_sp_done; 2465 sp->done = qla2x00_els_dcmd_sp_done;
2466 sp->free = qla2x00_els_dcmd_sp_free; 2466 sp->free = qla2x00_els_dcmd_sp_free;
2467 2467
@@ -2658,8 +2658,11 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
2658 sp->type = SRB_ELS_DCMD; 2658 sp->type = SRB_ELS_DCMD;
2659 sp->name = "ELS_DCMD"; 2659 sp->name = "ELS_DCMD";
2660 sp->fcport = fcport; 2660 sp->fcport = fcport;
2661 qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT); 2661
2662 elsio->timeout = qla2x00_els_dcmd2_iocb_timeout; 2662 elsio->timeout = qla2x00_els_dcmd2_iocb_timeout;
2663 init_completion(&elsio->u.els_plogi.comp);
2664 qla2x00_init_timer(sp, ELS_DCMD_TIMEOUT);
2665
2663 sp->done = qla2x00_els_dcmd2_sp_done; 2666 sp->done = qla2x00_els_dcmd2_sp_done;
2664 sp->free = qla2x00_els_dcmd2_sp_free; 2667 sp->free = qla2x00_els_dcmd2_sp_free;
2665 2668
@@ -2696,7 +2699,6 @@ qla24xx_els_dcmd2_iocb(scsi_qla_host_t *vha, int els_opcode,
2696 ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x0109, 2699 ql_dump_buffer(ql_dbg_io + ql_dbg_buffer, vha, 0x0109,
2697 (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, 0x70); 2700 (uint8_t *)elsio->u.els_plogi.els_plogi_pyld, 0x70);
2698 2701
2699 init_completion(&elsio->u.els_plogi.comp);
2700 rval = qla2x00_start_sp(sp); 2702 rval = qla2x00_start_sp(sp);
2701 if (rval != QLA_SUCCESS) { 2703 if (rval != QLA_SUCCESS) {
2702 rval = QLA_FUNCTION_FAILED; 2704 rval = QLA_FUNCTION_FAILED;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index 7cacdc3408fa..a3dc83f9444d 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -2174,7 +2174,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
2174 0x10, 0x1); 2174 0x10, 0x1);
2175 set_driver_byte(cmd, DRIVER_SENSE); 2175 set_driver_byte(cmd, DRIVER_SENSE);
2176 set_host_byte(cmd, DID_ABORT); 2176 set_host_byte(cmd, DID_ABORT);
2177 cmd->result |= SAM_STAT_CHECK_CONDITION << 1; 2177 cmd->result |= SAM_STAT_CHECK_CONDITION;
2178 return 1; 2178 return 1;
2179 } 2179 }
2180 2180
@@ -2184,7 +2184,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
2184 0x10, 0x3); 2184 0x10, 0x3);
2185 set_driver_byte(cmd, DRIVER_SENSE); 2185 set_driver_byte(cmd, DRIVER_SENSE);
2186 set_host_byte(cmd, DID_ABORT); 2186 set_host_byte(cmd, DID_ABORT);
2187 cmd->result |= SAM_STAT_CHECK_CONDITION << 1; 2187 cmd->result |= SAM_STAT_CHECK_CONDITION;
2188 return 1; 2188 return 1;
2189 } 2189 }
2190 2190
@@ -2194,7 +2194,7 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)
2194 0x10, 0x2); 2194 0x10, 0x2);
2195 set_driver_byte(cmd, DRIVER_SENSE); 2195 set_driver_byte(cmd, DRIVER_SENSE);
2196 set_host_byte(cmd, DID_ABORT); 2196 set_host_byte(cmd, DID_ABORT);
2197 cmd->result |= SAM_STAT_CHECK_CONDITION << 1; 2197 cmd->result |= SAM_STAT_CHECK_CONDITION;
2198 return 1; 2198 return 1;
2199 } 2199 }
2200 2200
@@ -2347,7 +2347,7 @@ done:
2347 bsg_job->reply_len = sizeof(struct fc_bsg_reply); 2347 bsg_job->reply_len = sizeof(struct fc_bsg_reply);
2348 /* Always return DID_OK, bsg will send the vendor specific response 2348 /* Always return DID_OK, bsg will send the vendor specific response
2349 * in this case only */ 2349 * in this case only */
2350 sp->done(sp, DID_OK << 6); 2350 sp->done(sp, DID_OK << 16);
2351 2351
2352} 2352}
2353 2353
diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c
index 5db0262d5c94..d8a36c13aeda 100644
--- a/drivers/scsi/qla2xxx/qla_mbx.c
+++ b/drivers/scsi/qla2xxx/qla_mbx.c
@@ -6023,14 +6023,14 @@ int qla24xx_send_mb_cmd(struct scsi_qla_host *vha, mbx_cmd_t *mcp)
6023 sp->type = SRB_MB_IOCB; 6023 sp->type = SRB_MB_IOCB;
6024 sp->name = mb_to_str(mcp->mb[0]); 6024 sp->name = mb_to_str(mcp->mb[0]);
6025 6025
6026 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
6027
6028 memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG);
6029
6030 c = &sp->u.iocb_cmd; 6026 c = &sp->u.iocb_cmd;
6031 c->timeout = qla2x00_async_iocb_timeout; 6027 c->timeout = qla2x00_async_iocb_timeout;
6032 init_completion(&c->u.mbx.comp); 6028 init_completion(&c->u.mbx.comp);
6033 6029
6030 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
6031
6032 memcpy(sp->u.iocb_cmd.u.mbx.out_mb, mcp->mb, SIZEOF_IOCB_MB_REG);
6033
6034 sp->done = qla2x00_async_mb_sp_done; 6034 sp->done = qla2x00_async_mb_sp_done;
6035 6035
6036 rval = qla2x00_start_sp(sp); 6036 rval = qla2x00_start_sp(sp);
diff --git a/drivers/scsi/qla2xxx/qla_mid.c b/drivers/scsi/qla2xxx/qla_mid.c
index da85cd89639f..f6f0a759a7c2 100644
--- a/drivers/scsi/qla2xxx/qla_mid.c
+++ b/drivers/scsi/qla2xxx/qla_mid.c
@@ -929,8 +929,8 @@ int qla24xx_control_vp(scsi_qla_host_t *vha, int cmd)
929 sp->type = SRB_CTRL_VP; 929 sp->type = SRB_CTRL_VP;
930 sp->name = "ctrl_vp"; 930 sp->name = "ctrl_vp";
931 sp->done = qla_ctrlvp_sp_done; 931 sp->done = qla_ctrlvp_sp_done;
932 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
933 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout; 932 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
933 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha) + 2);
934 sp->u.iocb_cmd.u.ctrlvp.cmd = cmd; 934 sp->u.iocb_cmd.u.ctrlvp.cmd = cmd;
935 sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index; 935 sp->u.iocb_cmd.u.ctrlvp.vp_index = vp_index;
936 936
diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 7113acf42ff3..521a51370554 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -1821,9 +1821,11 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type)
1821 1821
1822 sp->type = SRB_FXIOCB_DCMD; 1822 sp->type = SRB_FXIOCB_DCMD;
1823 sp->name = "fxdisc"; 1823 sp->name = "fxdisc";
1824 qla2x00_init_timer(sp, FXDISC_TIMEOUT);
1825 1824
1826 fdisc = &sp->u.iocb_cmd; 1825 fdisc = &sp->u.iocb_cmd;
1826 fdisc->timeout = qla2x00_fxdisc_iocb_timeout;
1827 qla2x00_init_timer(sp, FXDISC_TIMEOUT);
1828
1827 switch (fx_type) { 1829 switch (fx_type) {
1828 case FXDISC_GET_CONFIG_INFO: 1830 case FXDISC_GET_CONFIG_INFO:
1829 fdisc->u.fxiocb.flags = 1831 fdisc->u.fxiocb.flags =
@@ -1924,7 +1926,6 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type)
1924 goto done_unmap_req; 1926 goto done_unmap_req;
1925 } 1927 }
1926 1928
1927 fdisc->timeout = qla2x00_fxdisc_iocb_timeout;
1928 fdisc->u.fxiocb.req_func_type = cpu_to_le16(fx_type); 1929 fdisc->u.fxiocb.req_func_type = cpu_to_le16(fx_type);
1929 sp->done = qla2x00_fxdisc_sp_done; 1930 sp->done = qla2x00_fxdisc_sp_done;
1930 1931
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 2bbf0bff0da0..15eaa6dded04 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -470,9 +470,6 @@ fail_req_map:
470 470
471static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req) 471static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
472{ 472{
473 if (!ha->req_q_map)
474 return;
475
476 if (IS_QLAFX00(ha)) { 473 if (IS_QLAFX00(ha)) {
477 if (req && req->ring_fx00) 474 if (req && req->ring_fx00)
478 dma_free_coherent(&ha->pdev->dev, 475 dma_free_coherent(&ha->pdev->dev,
@@ -483,17 +480,14 @@ static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
483 (req->length + 1) * sizeof(request_t), 480 (req->length + 1) * sizeof(request_t),
484 req->ring, req->dma); 481 req->ring, req->dma);
485 482
486 if (req) { 483 if (req)
487 kfree(req->outstanding_cmds); 484 kfree(req->outstanding_cmds);
488 kfree(req); 485
489 } 486 kfree(req);
490} 487}
491 488
492static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) 489static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
493{ 490{
494 if (!ha->rsp_q_map)
495 return;
496
497 if (IS_QLAFX00(ha)) { 491 if (IS_QLAFX00(ha)) {
498 if (rsp && rsp->ring_fx00) 492 if (rsp && rsp->ring_fx00)
499 dma_free_coherent(&ha->pdev->dev, 493 dma_free_coherent(&ha->pdev->dev,
@@ -504,8 +498,7 @@ static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
504 (rsp->length + 1) * sizeof(response_t), 498 (rsp->length + 1) * sizeof(response_t),
505 rsp->ring, rsp->dma); 499 rsp->ring, rsp->dma);
506 } 500 }
507 if (rsp) 501 kfree(rsp);
508 kfree(rsp);
509} 502}
510 503
511static void qla2x00_free_queues(struct qla_hw_data *ha) 504static void qla2x00_free_queues(struct qla_hw_data *ha)
@@ -3106,7 +3099,8 @@ qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
3106 goto probe_failed; 3099 goto probe_failed;
3107 3100
3108 /* Alloc arrays of request and response ring ptrs */ 3101 /* Alloc arrays of request and response ring ptrs */
3109 if (qla2x00_alloc_queues(ha, req, rsp)) { 3102 ret = qla2x00_alloc_queues(ha, req, rsp);
3103 if (ret) {
3110 ql_log(ql_log_fatal, base_vha, 0x003d, 3104 ql_log(ql_log_fatal, base_vha, 0x003d,
3111 "Failed to allocate memory for queue pointers..." 3105 "Failed to allocate memory for queue pointers..."
3112 "aborting.\n"); 3106 "aborting.\n");
@@ -3407,8 +3401,15 @@ probe_failed:
3407 } 3401 }
3408 3402
3409 qla2x00_free_device(base_vha); 3403 qla2x00_free_device(base_vha);
3410
3411 scsi_host_put(base_vha->host); 3404 scsi_host_put(base_vha->host);
3405 /*
3406 * Need to NULL out local req/rsp after
3407 * qla2x00_free_device => qla2x00_free_queues frees
3408 * what these are pointing to. Or else we'll
3409 * fall over below in qla2x00_free_req/rsp_que.
3410 */
3411 req = NULL;
3412 rsp = NULL;
3412 3413
3413probe_hw_failed: 3414probe_hw_failed:
3414 qla2x00_mem_free(ha); 3415 qla2x00_mem_free(ha);
@@ -4114,6 +4115,7 @@ fail_npiv_info:
4114 (*rsp)->dma = 0; 4115 (*rsp)->dma = 0;
4115fail_rsp_ring: 4116fail_rsp_ring:
4116 kfree(*rsp); 4117 kfree(*rsp);
4118 *rsp = NULL;
4117fail_rsp: 4119fail_rsp:
4118 dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * 4120 dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) *
4119 sizeof(request_t), (*req)->ring, (*req)->dma); 4121 sizeof(request_t), (*req)->ring, (*req)->dma);
@@ -4121,6 +4123,7 @@ fail_rsp:
4121 (*req)->dma = 0; 4123 (*req)->dma = 0;
4122fail_req_ring: 4124fail_req_ring:
4123 kfree(*req); 4125 kfree(*req);
4126 *req = NULL;
4124fail_req: 4127fail_req:
4125 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), 4128 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
4126 ha->ct_sns, ha->ct_sns_dma); 4129 ha->ct_sns, ha->ct_sns_dma);
@@ -4508,16 +4511,11 @@ qla2x00_mem_free(struct qla_hw_data *ha)
4508 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, 4511 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
4509 ha->init_cb, ha->init_cb_dma); 4512 ha->init_cb, ha->init_cb_dma);
4510 4513
4511 if (ha->optrom_buffer) 4514 vfree(ha->optrom_buffer);
4512 vfree(ha->optrom_buffer); 4515 kfree(ha->nvram);
4513 if (ha->nvram) 4516 kfree(ha->npiv_info);
4514 kfree(ha->nvram); 4517 kfree(ha->swl);
4515 if (ha->npiv_info) 4518 kfree(ha->loop_id_map);
4516 kfree(ha->npiv_info);
4517 if (ha->swl)
4518 kfree(ha->swl);
4519 if (ha->loop_id_map)
4520 kfree(ha->loop_id_map);
4521 4519
4522 ha->srb_mempool = NULL; 4520 ha->srb_mempool = NULL;
4523 ha->ctx_mempool = NULL; 4521 ha->ctx_mempool = NULL;
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 5546ac9c3d9d..025dc2d3f3de 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -664,10 +664,10 @@ int qla24xx_async_notify_ack(scsi_qla_host_t *vha, fc_port_t *fcport,
664 sp->type = type; 664 sp->type = type;
665 sp->name = "nack"; 665 sp->name = "nack";
666 666
667 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
667 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2); 668 qla2x00_init_timer(sp, qla2x00_get_async_timeout(vha)+2);
668 669
669 sp->u.iocb_cmd.u.nack.ntfy = ntfy; 670 sp->u.iocb_cmd.u.nack.ntfy = ntfy;
670 sp->u.iocb_cmd.timeout = qla2x00_async_iocb_timeout;
671 sp->done = qla2x00_async_nack_sp_done; 671 sp->done = qla2x00_async_nack_sp_done;
672 672
673 rval = qla2x00_start_sp(sp); 673 rval = qla2x00_start_sp(sp);
diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c
index e5370d718058..dd107dc4db0e 100644
--- a/drivers/scsi/scsi_devinfo.c
+++ b/drivers/scsi/scsi_devinfo.c
@@ -202,7 +202,7 @@ static struct {
202 {"Medion", "Flash XL MMC/SD", "2.6D", BLIST_FORCELUN}, 202 {"Medion", "Flash XL MMC/SD", "2.6D", BLIST_FORCELUN},
203 {"MegaRAID", "LD", NULL, BLIST_FORCELUN}, 203 {"MegaRAID", "LD", NULL, BLIST_FORCELUN},
204 {"MICROP", "4110", NULL, BLIST_NOTQ}, 204 {"MICROP", "4110", NULL, BLIST_NOTQ},
205 {"MSFT", "Virtual HD", NULL, BLIST_NO_RSOC}, 205 {"MSFT", "Virtual HD", NULL, BLIST_MAX_1024 | BLIST_NO_RSOC},
206 {"MYLEX", "DACARMRB", "*", BLIST_REPORTLUN2}, 206 {"MYLEX", "DACARMRB", "*", BLIST_REPORTLUN2},
207 {"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN}, 207 {"nCipher", "Fastness Crypto", NULL, BLIST_FORCELUN},
208 {"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN}, 208 {"NAKAMICH", "MJ-4.8S", NULL, BLIST_FORCELUN | BLIST_SINGLELUN},
diff --git a/drivers/scsi/scsi_dh.c b/drivers/scsi/scsi_dh.c
index b88b5dbbc444..188f30572aa1 100644
--- a/drivers/scsi/scsi_dh.c
+++ b/drivers/scsi/scsi_dh.c
@@ -112,6 +112,9 @@ static struct scsi_device_handler *scsi_dh_lookup(const char *name)
112{ 112{
113 struct scsi_device_handler *dh; 113 struct scsi_device_handler *dh;
114 114
115 if (!name || strlen(name) == 0)
116 return NULL;
117
115 dh = __scsi_dh_lookup(name); 118 dh = __scsi_dh_lookup(name);
116 if (!dh) { 119 if (!dh) {
117 request_module("scsi_dh_%s", name); 120 request_module("scsi_dh_%s", name);
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 0dfec0dedd5e..e9b4f279d29c 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -723,18 +723,25 @@ static bool scsi_end_request(struct request *req, blk_status_t error,
723} 723}
724 724
725/** 725/**
726 * __scsi_error_from_host_byte - translate SCSI error code into errno 726 * scsi_result_to_blk_status - translate a SCSI result code into blk_status_t
727 * @cmd: SCSI command (unused) 727 * @cmd: SCSI command
728 * @result: scsi error code 728 * @result: scsi error code
729 * 729 *
730 * Translate SCSI error code into block errors. 730 * Translate a SCSI result code into a blk_status_t value. May reset the host
731 * byte of @cmd->result.
731 */ 732 */
732static blk_status_t __scsi_error_from_host_byte(struct scsi_cmnd *cmd, 733static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)
733 int result)
734{ 734{
735 switch (host_byte(result)) { 735 switch (host_byte(result)) {
736 case DID_OK: 736 case DID_OK:
737 return BLK_STS_OK; 737 /*
738 * Also check the other bytes than the status byte in result
739 * to handle the case when a SCSI LLD sets result to
740 * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION.
741 */
742 if (scsi_status_is_good(result) && (result & ~0xff) == 0)
743 return BLK_STS_OK;
744 return BLK_STS_IOERR;
738 case DID_TRANSPORT_FAILFAST: 745 case DID_TRANSPORT_FAILFAST:
739 return BLK_STS_TRANSPORT; 746 return BLK_STS_TRANSPORT;
740 case DID_TARGET_FAILURE: 747 case DID_TARGET_FAILURE:
@@ -812,10 +819,10 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
812 SCSI_SENSE_BUFFERSIZE); 819 SCSI_SENSE_BUFFERSIZE);
813 } 820 }
814 if (!sense_deferred) 821 if (!sense_deferred)
815 error = __scsi_error_from_host_byte(cmd, result); 822 error = scsi_result_to_blk_status(cmd, result);
816 } 823 }
817 /* 824 /*
818 * __scsi_error_from_host_byte may have reset the host_byte 825 * scsi_result_to_blk_status may have reset the host_byte
819 */ 826 */
820 scsi_req(req)->result = cmd->result; 827 scsi_req(req)->result = cmd->result;
821 scsi_req(req)->resid_len = scsi_get_resid(cmd); 828 scsi_req(req)->resid_len = scsi_get_resid(cmd);
@@ -837,7 +844,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
837 * good_bytes != blk_rq_bytes(req) as the signal for an error. 844 * good_bytes != blk_rq_bytes(req) as the signal for an error.
838 * This sets the error explicitly for the problem case. 845 * This sets the error explicitly for the problem case.
839 */ 846 */
840 error = __scsi_error_from_host_byte(cmd, result); 847 error = scsi_result_to_blk_status(cmd, result);
841 } 848 }
842 849
843 /* no bidi support for !blk_rq_is_passthrough yet */ 850 /* no bidi support for !blk_rq_is_passthrough yet */
@@ -907,7 +914,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
907 if (result == 0) 914 if (result == 0)
908 goto requeue; 915 goto requeue;
909 916
910 error = __scsi_error_from_host_byte(cmd, result); 917 error = scsi_result_to_blk_status(cmd, result);
911 918
912 if (host_byte(result) == DID_RESET) { 919 if (host_byte(result) == DID_RESET) {
913 /* Third party bus reset or reset for error recovery 920 /* Third party bus reset or reset for error recovery