Skip to content

Commit c449b41

Browse files
Quinn Tranmartinkpetersen
authored andcommitted
scsi: qla2xxx: Use QP lock to search for bsg
On bsg timeout, hardware_lock is used as part of search for the srb. Instead, qpair lock should be used to iterate through different qpair. 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 beafd69 commit c449b41

File tree

1 file changed

+57
-39
lines changed

1 file changed

+57
-39
lines changed

drivers/scsi/qla2xxx/qla_bsg.c

Lines changed: 57 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3059,17 +3059,61 @@ qla24xx_bsg_request(struct bsg_job *bsg_job)
30593059
return ret;
30603060
}
30613061

3062-
int
3063-
qla24xx_bsg_timeout(struct bsg_job *bsg_job)
3062+
static bool qla_bsg_found(struct qla_qpair *qpair, struct bsg_job *bsg_job)
30643063
{
3064+
bool found = false;
30653065
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
30663066
scsi_qla_host_t *vha = shost_priv(fc_bsg_to_shost(bsg_job));
30673067
struct qla_hw_data *ha = vha->hw;
3068-
srb_t *sp;
3069-
int cnt, que;
3068+
srb_t *sp = NULL;
3069+
int cnt;
30703070
unsigned long flags;
30713071
struct req_que *req;
30723072

3073+
spin_lock_irqsave(qpair->qp_lock_ptr, flags);
3074+
req = qpair->req;
3075+
3076+
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
3077+
sp = req->outstanding_cmds[cnt];
3078+
if (sp &&
3079+
(sp->type == SRB_CT_CMD ||
3080+
sp->type == SRB_ELS_CMD_HST ||
3081+
sp->type == SRB_ELS_CMD_HST_NOLOGIN) &&
3082+
sp->u.bsg_job == bsg_job) {
3083+
req->outstanding_cmds[cnt] = NULL;
3084+
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3085+
3086+
if (!ha->flags.eeh_busy && ha->isp_ops->abort_command(sp)) {
3087+
ql_log(ql_log_warn, vha, 0x7089,
3088+
"mbx abort_command failed.\n");
3089+
bsg_reply->result = -EIO;
3090+
} else {
3091+
ql_dbg(ql_dbg_user, vha, 0x708a,
3092+
"mbx abort_command success.\n");
3093+
bsg_reply->result = 0;
3094+
}
3095+
/* ref: INIT */
3096+
kref_put(&sp->cmd_kref, qla2x00_sp_release);
3097+
3098+
found = true;
3099+
goto done;
3100+
}
3101+
}
3102+
spin_unlock_irqrestore(qpair->qp_lock_ptr, flags);
3103+
3104+
done:
3105+
return found;
3106+
}
3107+
3108+
int
3109+
qla24xx_bsg_timeout(struct bsg_job *bsg_job)
3110+
{
3111+
struct fc_bsg_reply *bsg_reply = bsg_job->reply;
3112+
scsi_qla_host_t *vha = shost_priv(fc_bsg_to_shost(bsg_job));
3113+
struct qla_hw_data *ha = vha->hw;
3114+
int i;
3115+
struct qla_qpair *qpair;
3116+
30733117
ql_log(ql_log_info, vha, 0x708b, "%s CMD timeout. bsg ptr %p.\n",
30743118
__func__, bsg_job);
30753119

@@ -3079,48 +3123,22 @@ qla24xx_bsg_timeout(struct bsg_job *bsg_job)
30793123
qla_pci_set_eeh_busy(vha);
30803124
}
30813125

3126+
if (qla_bsg_found(ha->base_qpair, bsg_job))
3127+
goto done;
3128+
30823129
/* find the bsg job from the active list of commands */
3083-
spin_lock_irqsave(&ha->hardware_lock, flags);
3084-
for (que = 0; que < ha->max_req_queues; que++) {
3085-
req = ha->req_q_map[que];
3086-
if (!req)
3130+
for (i = 0; i < ha->max_qpairs; i++) {
3131+
qpair = vha->hw->queue_pair_map[i];
3132+
if (!qpair)
30873133
continue;
3088-
3089-
for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) {
3090-
sp = req->outstanding_cmds[cnt];
3091-
if (sp &&
3092-
(sp->type == SRB_CT_CMD ||
3093-
sp->type == SRB_ELS_CMD_HST ||
3094-
sp->type == SRB_ELS_CMD_HST_NOLOGIN ||
3095-
sp->type == SRB_FXIOCB_BCMD) &&
3096-
sp->u.bsg_job == bsg_job) {
3097-
req->outstanding_cmds[cnt] = NULL;
3098-
spin_unlock_irqrestore(&ha->hardware_lock, flags);
3099-
3100-
if (!ha->flags.eeh_busy && ha->isp_ops->abort_command(sp)) {
3101-
ql_log(ql_log_warn, vha, 0x7089,
3102-
"mbx abort_command failed.\n");
3103-
bsg_reply->result = -EIO;
3104-
} else {
3105-
ql_dbg(ql_dbg_user, vha, 0x708a,
3106-
"mbx abort_command success.\n");
3107-
bsg_reply->result = 0;
3108-
}
3109-
spin_lock_irqsave(&ha->hardware_lock, flags);
3110-
goto done;
3111-
3112-
}
3113-
}
3134+
if (qla_bsg_found(qpair, bsg_job))
3135+
goto done;
31143136
}
3115-
spin_unlock_irqrestore(&ha->hardware_lock, flags);
3137+
31163138
ql_log(ql_log_info, vha, 0x708b, "SRB not found to abort.\n");
31173139
bsg_reply->result = -ENXIO;
3118-
return 0;
31193140

31203141
done:
3121-
spin_unlock_irqrestore(&ha->hardware_lock, flags);
3122-
/* ref: INIT */
3123-
kref_put(&sp->cmd_kref, qla2x00_sp_release);
31243142
return 0;
31253143
}
31263144

0 commit comments

Comments
 (0)