Skip to content

Commit 4895009

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Prevent command send on chip reset
Currently IOCBs are allowed to push through while chip reset could be in progress. During chip reset the outstanding_cmds array is cleared twice. Once when any command on this array is returned as failed and secondly when the array is initialize to zero. If a command is inserted on to the array between these intervals, then the command will be lost. Check for chip reset before sending IOCB. Cc: [email protected] Signed-off-by: Quinn Tran <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 517bcc2 commit 4895009

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,8 +1193,12 @@ int qla24xx_async_gnl(struct scsi_qla_host *vha, fc_port_t *fcport)
11931193
return rval;
11941194

11951195
done_free_sp:
1196-
/* ref: INIT */
1197-
kref_put(&sp->cmd_kref, qla2x00_sp_release);
1196+
/*
1197+
* use qla24xx_async_gnl_sp_done to purge all pending gnl request.
1198+
* kref_put is call behind the scene.
1199+
*/
1200+
sp->u.iocb_cmd.u.mbx.in_mb[0] = MBS_COMMAND_ERROR;
1201+
qla24xx_async_gnl_sp_done(sp, QLA_COMMAND_ERROR);
11981202
fcport->flags &= ~(FCF_ASYNC_SENT);
11991203
done:
12001204
fcport->flags &= ~(FCF_ASYNC_ACTIVE);

drivers/scsi/qla2xxx/qla_iocb.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,6 +2587,33 @@ void
25872587
qla2x00_sp_release(struct kref *kref)
25882588
{
25892589
struct srb *sp = container_of(kref, struct srb, cmd_kref);
2590+
struct scsi_qla_host *vha = sp->vha;
2591+
2592+
switch (sp->type) {
2593+
case SRB_CT_PTHRU_CMD:
2594+
/* GPSC & GFPNID use fcport->ct_desc.ct_sns for both req & rsp */
2595+
if (sp->u.iocb_cmd.u.ctarg.req &&
2596+
(!sp->fcport ||
2597+
sp->u.iocb_cmd.u.ctarg.req != sp->fcport->ct_desc.ct_sns)) {
2598+
dma_free_coherent(&vha->hw->pdev->dev,
2599+
sp->u.iocb_cmd.u.ctarg.req_allocated_size,
2600+
sp->u.iocb_cmd.u.ctarg.req,
2601+
sp->u.iocb_cmd.u.ctarg.req_dma);
2602+
sp->u.iocb_cmd.u.ctarg.req = NULL;
2603+
}
2604+
if (sp->u.iocb_cmd.u.ctarg.rsp &&
2605+
(!sp->fcport ||
2606+
sp->u.iocb_cmd.u.ctarg.rsp != sp->fcport->ct_desc.ct_sns)) {
2607+
dma_free_coherent(&vha->hw->pdev->dev,
2608+
sp->u.iocb_cmd.u.ctarg.rsp_allocated_size,
2609+
sp->u.iocb_cmd.u.ctarg.rsp,
2610+
sp->u.iocb_cmd.u.ctarg.rsp_dma);
2611+
sp->u.iocb_cmd.u.ctarg.rsp = NULL;
2612+
}
2613+
break;
2614+
default:
2615+
break;
2616+
}
25902617

25912618
sp->free(sp);
25922619
}
@@ -2692,7 +2719,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
26922719
*/
26932720
sp = qla2x00_get_sp(vha, fcport, GFP_KERNEL);
26942721
if (!sp) {
2695-
kfree(fcport);
2722+
qla2x00_free_fcport(fcport);
26962723
ql_log(ql_log_info, vha, 0x70e6,
26972724
"SRB allocation failed\n");
26982725
return -ENOMEM;
@@ -2747,6 +2774,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
27472774
if (rval != QLA_SUCCESS) {
27482775
/* ref: INIT */
27492776
kref_put(&sp->cmd_kref, qla2x00_sp_release);
2777+
qla2x00_free_fcport(fcport);
27502778
return QLA_FUNCTION_FAILED;
27512779
}
27522780

@@ -2756,6 +2784,7 @@ qla24xx_els_dcmd_iocb(scsi_qla_host_t *vha, int els_opcode,
27562784
fcport->d_id.b.area, fcport->d_id.b.al_pa);
27572785

27582786
wait_for_completion(&elsio->u.els_logo.comp);
2787+
qla2x00_free_fcport(fcport);
27592788

27602789
/* ref: INIT */
27612790
kref_put(&sp->cmd_kref, qla2x00_sp_release);
@@ -3918,7 +3947,7 @@ qla2x00_start_sp(srb_t *sp)
39183947
return -EAGAIN;
39193948
}
39203949

3921-
pkt = __qla2x00_alloc_iocbs(sp->qpair, sp);
3950+
pkt = qla2x00_alloc_iocbs_ready(sp->qpair, sp);
39223951
if (!pkt) {
39233952
rval = -EAGAIN;
39243953
ql_log(ql_log_warn, vha, 0x700c,

0 commit comments

Comments
 (0)