diff mbox

[v6,04/33] tcm_qla2xxx: Move the code for freeing a TMF into tcm_qla2xxx.c

Message ID 20170215002612.14566-5-bart.vanassche@sandisk.com (mailing list archive)
State Superseded
Headers show

Commit Message

Bart Van Assche Feb. 15, 2017, 12:25 a.m. UTC
Move the code for freeingn a TMF from qla_target.c into tcm_qla2xxx.c.
This allows to remove the free_mcmd function pointer from struct
qla_tgt_func_tmpl. Since tcm_qla2xxx_queue_tm_rsp() is called from
thread context, call transport_generic_free_cmd() directly instead
of queueing another work item.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Himanshu Madhani <himanshu.madhani@cavium.com>
Cc: Quinn Tran <quinn.tran@cavium.com>
---
 drivers/scsi/qla2xxx/qla_target.c  | 10 ----------
 drivers/scsi/qla2xxx/qla_target.h  |  1 -
 drivers/scsi/qla2xxx/tcm_qla2xxx.c | 22 ++--------------------
 3 files changed, 2 insertions(+), 31 deletions(-)
diff mbox

Patch

diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index 02d4aee5c422..5a3fd2c63512 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -2030,7 +2030,6 @@  void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd)
 			"RESET-TMR online/active/old-count/new-count = %d/%d/%d/%d.\n",
 			vha->flags.online, qla2x00_reset_active(vha),
 			mcmd->reset_count, ha->chip_reset);
-		ha->tgt.tgt_ops->free_mcmd(mcmd);
 		spin_unlock_irqrestore(&ha->hardware_lock, flags);
 		return;
 	}
@@ -2059,15 +2058,6 @@  void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *mcmd)
 			qlt_24xx_send_task_mgmt_ctio(vha, mcmd,
 			    mcmd->fc_tm_rsp);
 	}
-	/*
-	 * Make the callback for ->free_mcmd() to queue_work() and invoke
-	 * target_put_sess_cmd() to drop cmd_kref to 1.  The final
-	 * target_put_sess_cmd() call will be made from TFO->check_stop_free()
-	 * -> tcm_qla2xxx_check_stop_free() to release the TMR associated se_cmd
-	 * descriptor after TFO->queue_tm_rsp() -> tcm_qla2xxx_queue_tm_rsp() ->
-	 * qlt_xmit_tm_rsp() returns here..
-	 */
-	ha->tgt.tgt_ops->free_mcmd(mcmd);
 	spin_unlock_irqrestore(&ha->hardware_lock, flags);
 }
 EXPORT_SYMBOL(qlt_xmit_tm_rsp);
diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h
index 6aab4b4d5eee..edf548621cb2 100644
--- a/drivers/scsi/qla2xxx/qla_target.h
+++ b/drivers/scsi/qla2xxx/qla_target.h
@@ -671,7 +671,6 @@  struct qla_tgt_func_tmpl {
 	int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint16_t,
 			uint32_t);
 	void (*free_cmd)(struct qla_tgt_cmd *);
-	void (*free_mcmd)(struct qla_tgt_mgmt_cmd *);
 	void (*free_session)(struct fc_port *);
 
 	int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index 752a17dbeb47..061ba85a2168 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -257,25 +257,6 @@  static u32 tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group *se_tpg)
 	return tpg->lport_tpgt;
 }
 
-static void tcm_qla2xxx_complete_mcmd(struct work_struct *work)
-{
-	struct qla_tgt_mgmt_cmd *mcmd = container_of(work,
-			struct qla_tgt_mgmt_cmd, free_work);
-
-	transport_generic_free_cmd(&mcmd->se_cmd, 0);
-}
-
-/*
- * Called from qla_target_template->free_mcmd(), and will call
- * tcm_qla2xxx_release_cmd() via normal struct target_core_fabric_ops
- * release callback.  qla_hw_data->hardware_lock is expected to be held
- */
-static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd)
-{
-	INIT_WORK(&mcmd->free_work, tcm_qla2xxx_complete_mcmd);
-	queue_work(tcm_qla2xxx_free_wq, &mcmd->free_work);
-}
-
 static void tcm_qla2xxx_complete_free(struct work_struct *work)
 {
 	struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
@@ -716,6 +697,8 @@  static void tcm_qla2xxx_queue_tm_rsp(struct se_cmd *se_cmd)
 	 * CTIO response packet.
 	 */
 	qlt_xmit_tm_rsp(mcmd);
+
+	transport_generic_free_cmd(&mcmd->se_cmd, 0);
 }
 
 static void tcm_qla2xxx_aborted_task(struct se_cmd *se_cmd)
@@ -1573,7 +1556,6 @@  static struct qla_tgt_func_tmpl tcm_qla2xxx_template = {
 	.handle_dif_err		= tcm_qla2xxx_handle_dif_err,
 	.handle_tmr		= tcm_qla2xxx_handle_tmr,
 	.free_cmd		= tcm_qla2xxx_free_cmd,
-	.free_mcmd		= tcm_qla2xxx_free_mcmd,
 	.free_session		= tcm_qla2xxx_free_session,
 	.update_sess		= tcm_qla2xxx_update_sess,
 	.check_initiator_node_acl = tcm_qla2xxx_check_initiator_node_acl,