Skip to content

Commit 9ae615c

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Fix hang in task management
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]>
1 parent 6a87679 commit 9ae615c

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
@@ -5515,4 +5515,8 @@ struct ql_vnd_tgt_stats_resp {
55155515
_fp->disc_state, _fp->scan_state, _fp->loop_id, _fp->deleted, \
55165516
_fp->flags
55175517

5518+
#define TMF_NOT_READY(_fcport) \
5519+
(!_fcport || IS_SESSION_DELETED(_fcport) || atomic_read(&_fcport->state) != FCS_ONLINE || \
5520+
!_fcport->vha->hw->flags.fw_started)
5521+
55185522
#endif

drivers/scsi/qla2xxx/qla_init.c

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

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

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

@@ -2039,6 +2045,11 @@ static void qla_marker_sp_done(srb_t *sp, int res)
20392045
} while (cnt); \
20402046
}
20412047

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

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

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

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

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

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

@@ -2104,6 +2133,14 @@ __qla2x00_async_tm_cmd(struct tmf_arg *arg)
21042133

21052134
fc_port_t *fcport = arg->fcport;
21062135

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

21802217
spin_lock_irqsave(&ha->tgt.sess_lock, flags);
2181-
if (fcport->deleted) {
2218+
if (TMF_NOT_READY(fcport)) {
2219+
ql_log(ql_log_warn, vha, 0x802c,
2220+
"Unable to acquire TM resource due to disruption.\n");
21822221
rc = EIO;
21832222
break;
21842223
}
@@ -2204,7 +2243,10 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22042243
struct scsi_qla_host *vha = fcport->vha;
22052244
struct qla_qpair *qpair;
22062245
struct tmf_arg a;
2207-
int i, rval;
2246+
int i, rval = QLA_SUCCESS;
2247+
2248+
if (TMF_NOT_READY(fcport))
2249+
return QLA_SUSPENDED;
22082250

22092251
a.vha = fcport->vha;
22102252
a.fcport = fcport;
@@ -2223,6 +2265,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22232265
qpair = vha->hw->queue_pair_map[i];
22242266
if (!qpair)
22252267
continue;
2268+
2269+
if (TMF_NOT_READY(fcport)) {
2270+
ql_log(ql_log_warn, vha, 0x8026,
2271+
"Unable to send TM due to disruption.\n");
2272+
rval = QLA_SUSPENDED;
2273+
break;
2274+
}
2275+
22262276
a.qpair = qpair;
22272277
a.flags = flags|TCF_NOTMCMD_TO_TARGET;
22282278
rval = __qla2x00_async_tm_cmd(&a);
@@ -2231,10 +2281,14 @@ qla2x00_async_tm_cmd(fc_port_t *fcport, uint32_t flags, uint64_t lun,
22312281
}
22322282
}
22332283

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

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

0 commit comments

Comments
 (0)