Skip to content

Commit 1802e5d

Browse files
Quinn Trangregkh
authored andcommitted
scsi: qla2xxx: Fix hang in task management
commit 9ae615c upstream. Task management command hangs where a side band chip reset failed to nudge the TMF from it's current send path. Add additional error check to block TMF from entering during chip reset and along the TMF path to cause it to bail out, skip over abort of marker. 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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 35985b0 commit 1802e5d

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed

drivers/scsi/qla2xxx/qla_def.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5499,4 +5499,8 @@ struct ql_vnd_tgt_stats_resp {
54995499
_fp->disc_state, _fp->scan_state, _fp->loop_id, _fp->deleted, \
55005500
_fp->flags
55015501

5502+
#define TMF_NOT_READY(_fcport) \
5503+
(!_fcport || IS_SESSION_DELETED(_fcport) || atomic_read(&_fcport->state) != FCS_ONLINE || \
5504+
!_fcport->vha->hw->flags.fw_started)
5505+
55025506
#endif

drivers/scsi/qla2xxx/qla_init.c

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,11 @@ qla2x00_tmf_iocb_timeout(void *data)
19971997
int rc, h;
19981998
unsigned long flags;
19991999

2000+
if (sp->type == SRB_MARKER) {
2001+
complete(&tmf->u.tmf.comp);
2002+
return;
2003+
}
2004+
20002005
rc = qla24xx_async_abort_cmd(sp, false);
20012006
if (rc) {
20022007
spin_lock_irqsave(sp->qpair->qp_lock_ptr, flags);
@@ -2024,6 +2029,7 @@ static void qla_marker_sp_done(srb_t *sp, int res)
20242029
sp->handle, sp->fcport->d_id.b24, sp->u.iocb_cmd.u.tmf.flags,
20252030
sp->u.iocb_cmd.u.tmf.lun, sp->qpair->id);
20262031

2032+
sp->u.iocb_cmd.u.tmf.data = res;
20272033
complete(&tmf->u.tmf.comp);
20282034
}
20292035

@@ -2040,6 +2046,11 @@ static void qla_marker_sp_done(srb_t *sp, int res)
20402046
} while (cnt); \
20412047
}
20422048

2049+
/**
2050+
* qla26xx_marker: send marker IOCB and wait for the completion of it.
2051+
* @arg: pointer to argument list.
2052+
* It is assume caller will provide an fcport pointer and modifier
2053+
*/
20432054
static int
20442055
qla26xx_marker(struct tmf_arg *arg)
20452056
{
@@ -2049,6 +2060,14 @@ qla26xx_marker(struct tmf_arg *arg)
20492060
int rval = QLA_FUNCTION_FAILED;
20502061
fc_port_t *fcport = arg->fcport;
20512062

2063+
if (TMF_NOT_READY(arg->fcport)) {
2064+
ql_dbg(ql_dbg_taskm, vha, 0x8039,
2065+
"FC port not ready for marker loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d.\n",
2066+
fcport->loop_id, fcport->d_id.b24,
2067+
arg->modifier, arg->lun, arg->qpair->id);
2068+
return QLA_SUSPENDED;
2069+
}
2070+
20522071
/* ref: INIT */
20532072
sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
20542073
if (!sp)
@@ -2075,11 +2094,19 @@ qla26xx_marker(struct tmf_arg *arg)
20752094

20762095
if (rval != QLA_SUCCESS) {
20772096
ql_log(ql_log_warn, vha, 0x8031,
2078-
"Marker IOCB failed (%x).\n", rval);
2097+
"Marker IOCB send failure (%x).\n", rval);
20792098
goto done_free_sp;
20802099
}
20812100

20822101
wait_for_completion(&tm_iocb->u.tmf.comp);
2102+
rval = tm_iocb->u.tmf.data;
2103+
2104+
if (rval != QLA_SUCCESS) {
2105+
ql_log(ql_log_warn, vha, 0x8019,
2106+
"Marker failed hdl=%x loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d rval %d.\n",
2107+
sp->handle, fcport->loop_id, fcport->d_id.b24,
2108+
arg->modifier, arg->lun, sp->qpair->id, rval);
2109+
}
20832110

20842111
done_free_sp:
20852112
/* ref: INIT */
@@ -2092,6 +2119,8 @@ static void qla2x00_tmf_sp_done(srb_t *sp, int res)
20922119
{
20932120
struct srb_iocb *tmf = &sp->u.iocb_cmd;
20942121

2122+
if (res)
2123+
tmf->u.tmf.data = res;
20952124
complete(&tmf->u.tmf.comp);
20962125
}
20972126

@@ -2105,6 +2134,14 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
21052134

21062135
fc_port_t *fcport = arg->fcport;
21072136

2137+
if (TMF_NOT_READY(arg->fcport)) {
2138+
ql_dbg(ql_dbg_taskm, vha, 0x8032,
2139+
"FC port not ready for TM command loop-id=%x portid=%06x modifier=%x lun=%lld qp=%d.\n",
2140+
fcport->loop_id, fcport->d_id.b24,
2141+
arg->modifier, arg->lun, arg->qpair->id);
2142+
return QLA_SUSPENDED;
2143+
}
2144+
21082145
/* ref: INIT */
21092146
sp = qla2xxx_get_qpair_sp(vha, arg->qpair, fcport, GFP_KERNEL);
21102147
if (!sp)
@@ -2179,7 +2216,9 @@ int qla_get_tmf(fc_port_t *fcport)
21792216
msleep(1);
21802217

21812218
spin_lock_irqsave(&ha->tgt.sess_lock, flags);
2182-
if (fcport->deleted) {
2219+
if (TMF_NOT_READY(fcport)) {
2220+
ql_log(ql_log_warn, vha, 0x802c,
2221+
"Unable to acquire TM resource due to disruption.\n");
21832222
rc = EIO;
21842223
break;
21852224
}
@@ -2205,7 +2244,10 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22052244
struct scsi_qla_host *vha = fcport->vha;
22062245
struct qla_qpair *qpair;
22072246
struct tmf_arg a;
2208-
int i, rval;
2247+
int i, rval = QLA_SUCCESS;
2248+
2249+
if (TMF_NOT_READY(fcport))
2250+
return QLA_SUSPENDED;
22092251

22102252
a.vha = fcport->vha;
22112253
a.fcport = fcport;
@@ -2224,6 +2266,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22242266
qpair = vha->hw->queue_pair_map[i];
22252267
if (!qpair)
22262268
continue;
2269+
2270+
if (TMF_NOT_READY(fcport)) {
2271+
ql_log(ql_log_warn, vha, 0x8026,
2272+
"Unable to send TM due to disruption.\n");
2273+
rval = QLA_SUSPENDED;
2274+
break;
2275+
}
2276+
22272277
a.qpair = qpair;
22282278
a.flags = flags|TCF_NOTMCMD_TO_TARGET;
22292279
rval = __qla2x00_async_tm_cmd(&a);
@@ -2232,10 +2282,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22322282
}
22332283
}
22342284

2285+
if (rval)
2286+
goto bailout;
2287+
22352288
a.qpair = vha->hw->base_qpair;
22362289
a.flags = flags;
22372290
rval = __qla2x00_async_tm_cmd(&a);
22382291

2292+
bailout:
22392293
if (a.modifier == MK_SYNC_ID_LUN)
22402294
qla_put_tmf(fcport);
22412295

0 commit comments

Comments
 (0)