Skip to content

Commit d46c69a

Browse files
abattersbymartinkpetersen
authored andcommitted
scsi: qla2xxx: Clear cmds after chip reset
Commit aefed3e ("scsi: qla2xxx: target: Fix offline port handling and host reset handling") caused two problems: 1. Commands sent to FW, after chip reset got stuck and never freed as FW is not going to respond to them anymore. 2. BUG_ON(cmd->sg_mapped) in qlt_free_cmd(). Commit 26f9ce5 ("scsi: qla2xxx: Fix missed DMA unmap for aborted commands") attempted to fix this, but introduced another bug under different circumstances when two different CPUs were racing to call qlt_unmap_sg() at the same time: BUG_ON(!valid_dma_direction(dir)) in dma_unmap_sg_attrs(). So revert "scsi: qla2xxx: Fix missed DMA unmap for aborted commands" and partially revert "scsi: qla2xxx: target: Fix offline port handling and host reset handling" at __qla2x00_abort_all_cmds. Fixes: aefed3e ("scsi: qla2xxx: target: Fix offline port handling and host reset handling") Fixes: 26f9ce5 ("scsi: qla2xxx: Fix missed DMA unmap for aborted commands") Co-developed-by: Dmitry Bogdanov <d.bogdanov@yadro.com> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com> Signed-off-by: Tony Battersby <tonyb@cybernetics.com> Link: https://patch.msgid.link/0e7e5d26-e7a0-42d1-8235-40eeb27f3e98@cybernetics.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent ed382b9 commit d46c69a

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

drivers/scsi/qla2xxx/qla_os.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,10 +1875,26 @@ __qla2x00_abort_all_cmds(struct qla_qpair *qp, int res)
18751875
continue;
18761876
}
18771877
cmd = (struct qla_tgt_cmd *)sp;
1878-
cmd->aborted = 1;
1878+
1879+
if (cmd->sg_mapped)
1880+
qlt_unmap_sg(vha, cmd);
1881+
1882+
if (cmd->state == QLA_TGT_STATE_NEED_DATA) {
1883+
cmd->aborted = 1;
1884+
cmd->write_data_transferred = 0;
1885+
cmd->state = QLA_TGT_STATE_DATA_IN;
1886+
ha->tgt.tgt_ops->handle_data(cmd);
1887+
} else {
1888+
ha->tgt.tgt_ops->free_cmd(cmd);
1889+
}
18791890
break;
18801891
case TYPE_TGT_TMCMD:
1881-
/* Skip task management functions. */
1892+
/*
1893+
* Currently, only ABTS response gets on the
1894+
* outstanding_cmds[]
1895+
*/
1896+
ha->tgt.tgt_ops->free_mcmd(
1897+
(struct qla_tgt_mgmt_cmd *) sp);
18821898
break;
18831899
default:
18841900
break;

drivers/scsi/qla2xxx/qla_target.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,7 +2447,7 @@ static int qlt_pci_map_calc_cnt(struct qla_tgt_prm *prm)
24472447
return -1;
24482448
}
24492449

2450-
static void qlt_unmap_sg(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd)
2450+
void qlt_unmap_sg(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd)
24512451
{
24522452
struct qla_hw_data *ha;
24532453
struct qla_qpair *qpair;
@@ -3795,9 +3795,6 @@ int qlt_abort_cmd(struct qla_tgt_cmd *cmd)
37953795

37963796
spin_lock_irqsave(&cmd->cmd_lock, flags);
37973797
if (cmd->aborted) {
3798-
if (cmd->sg_mapped)
3799-
qlt_unmap_sg(vha, cmd);
3800-
38013798
spin_unlock_irqrestore(&cmd->cmd_lock, flags);
38023799
/*
38033800
* It's normal to see 2 calls in this path:

drivers/scsi/qla2xxx/qla_target.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,7 @@ extern int qlt_abort_cmd(struct qla_tgt_cmd *);
10581058
extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
10591059
extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
10601060
extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
1061+
extern void qlt_unmap_sg(struct scsi_qla_host *vha, struct qla_tgt_cmd *cmd);
10611062
extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *);
10621063
extern void qlt_enable_vha(struct scsi_qla_host *);
10631064
extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *);

0 commit comments

Comments
 (0)