Commit f7eea752 authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: qedi: Fix TMF tid allocation

qedi_iscsi_abort_work and qedi_tmf_work both allocate a tid then call
qedi_send_iscsi_tmf which also allocates a tid. This removes the tid
allocation from the callers.

Link: https://lore.kernel.org/r/20210525181821.7617-23-michael.christie@oracle.comReviewed-by: default avatarManish Rangankar <mrangankar@marvell.com>
Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 5b04d050
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "qedi_fw_iscsi.h" #include "qedi_fw_iscsi.h"
#include "qedi_fw_scsi.h" #include "qedi_fw_scsi.h"
static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, static int send_iscsi_tmf(struct qedi_conn *qedi_conn,
struct iscsi_task *mtask); struct iscsi_task *mtask);
void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd) void qedi_iscsi_unmap_sg_list(struct qedi_cmd *cmd)
{ {
...@@ -1348,7 +1348,7 @@ static int qedi_wait_for_cleanup_request(struct qedi_ctx *qedi, ...@@ -1348,7 +1348,7 @@ static int qedi_wait_for_cleanup_request(struct qedi_ctx *qedi,
return 0; return 0;
} }
static void qedi_tmf_work(struct work_struct *work) static void qedi_abort_work(struct work_struct *work)
{ {
struct qedi_cmd *qedi_cmd = struct qedi_cmd *qedi_cmd =
container_of(work, struct qedi_cmd, tmf_work); container_of(work, struct qedi_cmd, tmf_work);
...@@ -1361,7 +1361,6 @@ static void qedi_tmf_work(struct work_struct *work) ...@@ -1361,7 +1361,6 @@ static void qedi_tmf_work(struct work_struct *work)
struct iscsi_task *ctask; struct iscsi_task *ctask;
struct iscsi_tm *tmf_hdr; struct iscsi_tm *tmf_hdr;
s16 rval = 0; s16 rval = 0;
s16 tid = 0;
mtask = qedi_cmd->task; mtask = qedi_cmd->task;
tmf_hdr = (struct iscsi_tm *)mtask->hdr; tmf_hdr = (struct iscsi_tm *)mtask->hdr;
...@@ -1406,6 +1405,7 @@ static void qedi_tmf_work(struct work_struct *work) ...@@ -1406,6 +1405,7 @@ static void qedi_tmf_work(struct work_struct *work)
} }
qedi_cmd->type = TYPEIO; qedi_cmd->type = TYPEIO;
qedi_cmd->state = CLEANUP_WAIT;
list_work->qedi_cmd = qedi_cmd; list_work->qedi_cmd = qedi_cmd;
list_work->rtid = cmd->task_id; list_work->rtid = cmd->task_id;
list_work->state = QEDI_WORK_SCHEDULED; list_work->state = QEDI_WORK_SCHEDULED;
...@@ -1433,15 +1433,7 @@ static void qedi_tmf_work(struct work_struct *work) ...@@ -1433,15 +1433,7 @@ static void qedi_tmf_work(struct work_struct *work)
} }
send_tmf: send_tmf:
tid = qedi_get_task_idx(qedi); send_iscsi_tmf(qedi_conn, qedi_cmd->task);
if (tid == -1) {
QEDI_ERR(&qedi->dbg_ctx, "Invalid tid, cid=0x%x\n",
qedi_conn->iscsi_conn_id);
goto ldel_exit;
}
qedi_cmd->task_id = tid;
qedi_send_iscsi_tmf(qedi_conn, qedi_cmd->task);
clear_cleanup: clear_cleanup:
clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
...@@ -1467,8 +1459,7 @@ static void qedi_tmf_work(struct work_struct *work) ...@@ -1467,8 +1459,7 @@ static void qedi_tmf_work(struct work_struct *work)
clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags); clear_bit(QEDI_CONN_FW_CLEANUP, &qedi_conn->flags);
} }
static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, static int send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask)
struct iscsi_task *mtask)
{ {
struct iscsi_tmf_request_hdr tmf_pdu_header; struct iscsi_tmf_request_hdr tmf_pdu_header;
struct iscsi_task_params task_params; struct iscsi_task_params task_params;
...@@ -1483,7 +1474,6 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, ...@@ -1483,7 +1474,6 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn,
u32 scsi_lun[2]; u32 scsi_lun[2];
s16 tid = 0; s16 tid = 0;
u16 sq_idx = 0; u16 sq_idx = 0;
int rval = 0;
tmf_hdr = (struct iscsi_tm *)mtask->hdr; tmf_hdr = (struct iscsi_tm *)mtask->hdr;
qedi_cmd = (struct qedi_cmd *)mtask->dd_data; qedi_cmd = (struct qedi_cmd *)mtask->dd_data;
...@@ -1547,10 +1537,7 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, ...@@ -1547,10 +1537,7 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn,
task_params.sqe = &ep->sq[sq_idx]; task_params.sqe = &ep->sq[sq_idx];
memset(task_params.sqe, 0, sizeof(struct iscsi_wqe)); memset(task_params.sqe, 0, sizeof(struct iscsi_wqe));
rval = init_initiator_tmf_request_task(&task_params, init_initiator_tmf_request_task(&task_params, &tmf_pdu_header);
&tmf_pdu_header);
if (rval)
return -1;
spin_lock(&qedi_conn->list_lock); spin_lock(&qedi_conn->list_lock);
list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list); list_add_tail(&qedi_cmd->io_cmd, &qedi_conn->active_cmd_list);
...@@ -1562,47 +1549,30 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, ...@@ -1562,47 +1549,30 @@ static int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn,
return 0; return 0;
} }
int qedi_iscsi_abort_work(struct qedi_conn *qedi_conn, int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask)
struct iscsi_task *mtask)
{ {
struct iscsi_tm *tmf_hdr = (struct iscsi_tm *)mtask->hdr;
struct qedi_cmd *qedi_cmd = mtask->dd_data;
struct qedi_ctx *qedi = qedi_conn->qedi; struct qedi_ctx *qedi = qedi_conn->qedi;
struct iscsi_tm *tmf_hdr; int rc = 0;
struct qedi_cmd *qedi_cmd = (struct qedi_cmd *)mtask->dd_data;
s16 tid = 0;
tmf_hdr = (struct iscsi_tm *)mtask->hdr; switch (tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) {
qedi_cmd->task = mtask; case ISCSI_TM_FUNC_ABORT_TASK:
INIT_WORK(&qedi_cmd->tmf_work, qedi_abort_work);
/* If abort task then schedule the work and return */
if ((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) ==
ISCSI_TM_FUNC_ABORT_TASK) {
qedi_cmd->state = CLEANUP_WAIT;
INIT_WORK(&qedi_cmd->tmf_work, qedi_tmf_work);
queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work); queue_work(qedi->tmf_thread, &qedi_cmd->tmf_work);
break;
} else if (((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == case ISCSI_TM_FUNC_LOGICAL_UNIT_RESET:
ISCSI_TM_FUNC_LOGICAL_UNIT_RESET) || case ISCSI_TM_FUNC_TARGET_WARM_RESET:
((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == case ISCSI_TM_FUNC_TARGET_COLD_RESET:
ISCSI_TM_FUNC_TARGET_WARM_RESET) || rc = send_iscsi_tmf(qedi_conn, mtask);
((tmf_hdr->flags & ISCSI_FLAG_TM_FUNC_MASK) == break;
ISCSI_TM_FUNC_TARGET_COLD_RESET)) { default:
tid = qedi_get_task_idx(qedi);
if (tid == -1) {
QEDI_ERR(&qedi->dbg_ctx, "Invalid tid, cid=0x%x\n",
qedi_conn->iscsi_conn_id);
return -1;
}
qedi_cmd->task_id = tid;
qedi_send_iscsi_tmf(qedi_conn, qedi_cmd->task);
} else {
QEDI_ERR(&qedi->dbg_ctx, "Invalid tmf, cid=0x%x\n", QEDI_ERR(&qedi->dbg_ctx, "Invalid tmf, cid=0x%x\n",
qedi_conn->iscsi_conn_id); qedi_conn->iscsi_conn_id);
return -1; return -EINVAL;
} }
return 0; return rc;
} }
int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, int qedi_send_iscsi_text(struct qedi_conn *qedi_conn,
......
...@@ -31,8 +31,7 @@ int qedi_send_iscsi_login(struct qedi_conn *qedi_conn, ...@@ -31,8 +31,7 @@ int qedi_send_iscsi_login(struct qedi_conn *qedi_conn,
struct iscsi_task *task); struct iscsi_task *task);
int qedi_send_iscsi_logout(struct qedi_conn *qedi_conn, int qedi_send_iscsi_logout(struct qedi_conn *qedi_conn,
struct iscsi_task *task); struct iscsi_task *task);
int qedi_iscsi_abort_work(struct qedi_conn *qedi_conn, int qedi_send_iscsi_tmf(struct qedi_conn *qedi_conn, struct iscsi_task *mtask);
struct iscsi_task *mtask);
int qedi_send_iscsi_text(struct qedi_conn *qedi_conn, int qedi_send_iscsi_text(struct qedi_conn *qedi_conn,
struct iscsi_task *task); struct iscsi_task *task);
int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn, int qedi_send_iscsi_nopout(struct qedi_conn *qedi_conn,
......
...@@ -753,7 +753,7 @@ static int qedi_iscsi_send_generic_request(struct iscsi_task *task) ...@@ -753,7 +753,7 @@ static int qedi_iscsi_send_generic_request(struct iscsi_task *task)
rc = qedi_send_iscsi_logout(qedi_conn, task); rc = qedi_send_iscsi_logout(qedi_conn, task);
break; break;
case ISCSI_OP_SCSI_TMFUNC: case ISCSI_OP_SCSI_TMFUNC:
rc = qedi_iscsi_abort_work(qedi_conn, task); rc = qedi_send_iscsi_tmf(qedi_conn, task);
break; break;
case ISCSI_OP_TEXT: case ISCSI_OP_TEXT:
rc = qedi_send_iscsi_text(qedi_conn, task); rc = qedi_send_iscsi_text(qedi_conn, task);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment