Skip to contentSkip to conversation

scsi: ufs: Fix and simplify setup_xfer_req vop and request's completion timestamp

PATCH Applied Stanley Chu 4 participants 7 messages Jul 6, 2020 – Jul 14, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover scsi: ufs: Fix and simplify setup_xfer_req vop and request's completion timestamp

Hi,
This small series fixes and simplifies setup_xfer_req vop and request's completion timestamp.

Stanley Chu (2):
scsi: ufs: Simplify completion timestamp for SCSI and query commands
scsi: ufs: Fix and simplify setup_xfer_req variant operation

 drivers/scsi/ufs/ufshcd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/2 scsi: ufs: Simplify completion timestamp for SCSI and query commands

Simplify recording command completion time in __ufshcd_transfer_req_compl() by assigning lrbp->compl_time_stamp in an unified location.

---
 drivers/scsi/ufs/ufshcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -2
index 18da2d64f9fa..71e8d7c782bd 100644
@@ -4881,6 +4881,7 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
 
 	for_each_set_bit(index, &completed_reqs, hba->nutrs) {
 		lrbp = &hba->lrb[index];
+		lrbp->compl_time_stamp = ktime_get();
 		cmd = lrbp->cmd;
 		if (cmd) {
 			ufshcd_add_command_trace(hba, index, "complete");
@@ -4889,13 +4890,11 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
 			cmd->result = result;
 			/* Mark completed command as NULL in LRB */
 			lrbp->cmd = NULL;
-			lrbp->compl_time_stamp = ktime_get();
 			/* Do not touch lrbp after scsi done */
 			cmd->scsi_done(cmd);
 			__ufshcd_release(hba);
 		} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
 			lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
-			lrbp->compl_time_stamp = ktime_get();
 			if (hba->dev_cmd.complete) {
 				ufshcd_add_command_trace(hba, index,
 						"dev_complete");
Signature · 1 line
2.18.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH v1 1/2] scsi: ufs: Simplify completion timestamp for SCSI and query commands

Quoted 5 lines · Stanley Chu

Simplify recording command completion time in __ufshcd_transfer_req_compl() by assigning lrbp->compl_time_stamp in an unified location.

Quoted 31 lines
---
 drivers/scsi/ufs/ufshcd.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +1 -0
index 18da2d64f9fa..71e8d7c782bd 100644
@@ -4881,6 +4881,7 @@ static void __ufshcd_transfer_req_compl(struct
 ufs_hba *hba,
 
 	for_each_set_bit(index, &completed_reqs, hba->nutrs) {
 		lrbp = &hba->lrb[index];
+		lrbp->compl_time_stamp = ktime_get();
 		cmd = lrbp->cmd;
 		if (cmd) {
drivers/scsi/ufs/ufshcd.c +0 -2
 			ufshcd_add_command_trace(hba, index, "complete");
@@ -4889,13 +4890,11 @@ static void __ufshcd_transfer_req_compl(struct
 ufs_hba *hba,
 			cmd->result = result;
 			/* Mark completed command as NULL in LRB */
 			lrbp->cmd = NULL;
-			lrbp->compl_time_stamp = ktime_get();
 			/* Do not touch lrbp after scsi done */
 			cmd->scsi_done(cmd);
 			__ufshcd_release(hba);
 		} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE ||
 			lrbp->command_type == UTP_CMD_TYPE_UFS_STORAGE) {
-			lrbp->compl_time_stamp = ktime_get();
 			if (hba->dev_cmd.complete) {
 				ufshcd_add_command_trace(hba, index,
Quoted 1 line

"dev_complete");

_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek

#3 lore raw

PATCH 2/2 scsi: ufs: Fix and simplify setup_xfer_req variant operation

In reply to Stanley Chu

Add missing "setup_xfer_req" call in ufshcd_issue_devman_upiu_cmd() by ufs-bsg path, and collect all "setup_xfer_req" calls to an unified place, i.e., ufshcd_send_command(), to simplify the driver.

---
 drivers/scsi/ufs/ufshcd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/ufs/ufshcd.c +5 -4
index 71e8d7c782bd..8603b07045a6 100644
@@ -1925,8 +1925,11 @@ static void ufshcd_clk_scaling_update_busy(struct ufs_hba *hba)
 static inline
 void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
 {
-	hba->lrb[task_tag].issue_time_stamp = ktime_get();
-	hba->lrb[task_tag].compl_time_stamp = ktime_set(0, 0);
+	struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
+
+	lrbp->issue_time_stamp = ktime_get();
+	lrbp->compl_time_stamp = ktime_set(0, 0);
+	ufshcd_vops_setup_xfer_req(hba, task_tag, (lrbp->cmd ? true : false));
 	ufshcd_add_command_trace(hba, task_tag, "send");
 	ufshcd_clk_scaling_start_busy(hba);
 	__set_bit(task_tag, &hba->outstanding_reqs);
@@ -2544,7 +2547,6 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd)
 
 	/* issue command to the controller */
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_vops_setup_xfer_req(hba, tag, true);
 	ufshcd_send_command(hba, tag);
 out_unlock:
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -2731,7 +2733,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba *hba,
 	/* Make sure descriptors are ready before ringing the doorbell */
 	wmb();
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_vops_setup_xfer_req(hba, tag, false);
 	ufshcd_send_command(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
 
Signature · 1 line
2.18.0
Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH v1 2/2] scsi: ufs: Fix and simplify setup_xfer_req variant operation

Quoted 5 lines · Stanley Chu

Add missing "setup_xfer_req" call in ufshcd_issue_devman_upiu_cmd() by ufs-bsg path, and collect all "setup_xfer_req" calls to an unified place, i.e., ufshcd_send_command(), to simplify the driver.

Quoted 41 lines
---
 drivers/scsi/ufs/ufshcd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/ufs/ufshcd.c +5 -2
index 71e8d7c782bd..8603b07045a6 100644
@@ -1925,8 +1925,11 @@ static void
 ufshcd_clk_scaling_update_busy(struct ufs_hba *hba)
 static inline
 void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag)
 {
-	hba->lrb[task_tag].issue_time_stamp = ktime_get();
-	hba->lrb[task_tag].compl_time_stamp = ktime_set(0, 0);
+	struct ufshcd_lrb *lrbp = &hba->lrb[task_tag];
+
+	lrbp->issue_time_stamp = ktime_get();
+	lrbp->compl_time_stamp = ktime_set(0, 0);
+	ufshcd_vops_setup_xfer_req(hba, task_tag, (lrbp->cmd ? true : 
 false));
 	ufshcd_add_command_trace(hba, task_tag, "send");
drivers/scsi/ufs/ufshcd.c +0 -1
 	ufshcd_clk_scaling_start_busy(hba);
 	__set_bit(task_tag, &hba->outstanding_reqs);
@@ -2544,7 +2547,6 @@ static int ufshcd_queuecommand(struct Scsi_Host
 *host, struct scsi_cmnd *cmd)
 
 	/* issue command to the controller */
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_vops_setup_xfer_req(hba, tag, true);
 	ufshcd_send_command(hba, tag);
 out_unlock:
drivers/scsi/ufs/ufshcd.c +0 -1
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
@@ -2731,7 +2733,6 @@ static int ufshcd_exec_dev_cmd(struct ufs_hba 
 *hba,
 	/* Make sure descriptors are ready before ringing the doorbell */
 	wmb();
 	spin_lock_irqsave(hba->host->host_lock, flags);
-	ufshcd_vops_setup_xfer_req(hba, tag, false);
 	ufshcd_send_command(hba, tag);
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
#5 lore raw
In reply to Stanley Chu

Looks good to me.
Thanks,
Avri

Quoted 14 lines

Hi,
This small series fixes and simplifies setup_xfer_req vop and request's completion timestamp.

Stanley Chu (2):
scsi: ufs: Simplify completion timestamp for SCSI and query commands
scsi: ufs: Fix and simplify setup_xfer_req variant operation

 drivers/scsi/ufs/ufshcd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--
2.18.0

#6 lore raw
In reply to Stanley Chu
Quoted 8 lines · Stanley Chu

This small series fixes and simplifies setup_xfer_req vop and request's completion timestamp.

Stanley Chu (2):
scsi: ufs: Simplify completion timestamp for SCSI and query commands
scsi: ufs: Fix and simplify setup_xfer_req variant operation

 drivers/scsi/ufs/ufshcd.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Applied to 5.9/scsi-queue, thanks!

[1/2] scsi: ufs: Simplify completion timestamp for SCSI and query commands

      https://git.kernel.org/mkp/scsi/c/a3170376f7db
[2/2] scsi: ufs: Fix and simplify setup_xfer_req variant operation
      https://git.kernel.org/mkp/scsi/c/6edfdcfe285e
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering