diff mbox series

[07/24] scsi: ufs: core: Only call ufshcd_add_command_trace() for SCSI commands

Message ID 20250403211937.2225615-8-bvanassche@acm.org
State New
Headers show
Series Optimize the hot path in the UFS driver | expand

Commit Message

Bart Van Assche April 3, 2025, 9:17 p.m. UTC
Instead of checking inside ufshcd_add_command_trace() whether 'cmd' points
at a SCSI command, let the caller perform that check. This patch prepares
for removing the lrbp->cmd pointer.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/ufs/core/ufshcd.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

Avri Altman April 9, 2025, 6:24 a.m. UTC | #1
> Instead of checking inside ufshcd_add_command_trace() whether 'cmd' points at
> a SCSI command, let the caller perform that check. This patch prepares for
> removing the lrbp->cmd pointer.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Avri Altman <avri.altman@sandisk.com>

> ---
>  drivers/ufs/core/ufshcd.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index
> 3b470f564313..94cf864ac62b 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -438,9 +438,6 @@ static void ufshcd_add_command_trace(struct ufs_hba
> *hba, unsigned int tag,
>  	struct request *rq = scsi_cmd_to_rq(cmd);
>  	int transfer_len = -1;
> 
> -	if (!cmd)
> -		return;
> -
>  	/* trace UPIU also */
>  	ufshcd_add_cmd_upiu_trace(hba, lrbp, str_t);
>  	if (!trace_ufshcd_command_enabled())
> @@ -2309,9 +2306,10 @@ void ufshcd_send_command(struct ufs_hba *hba,
> unsigned int task_tag,
>  	lrbp->issue_time_stamp_local_clock = local_clock();
>  	lrbp->compl_time_stamp = ktime_set(0, 0);
>  	lrbp->compl_time_stamp_local_clock = 0;
> -	ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND);
> -	if (lrbp->cmd)
> +	if (lrbp->cmd) {
> +		ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND);
>  		ufshcd_clk_scaling_start_busy(hba);
> +	}
>  	if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
>  		ufshcd_start_monitor(hba, lrbp);
>
Peter Wang (王信友) April 14, 2025, 12:47 p.m. UTC | #2
On Thu, 2025-04-03 at 14:17 -0700, Bart Van Assche wrote:
> 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
> 
> 
> Instead of checking inside ufshcd_add_command_trace() whether 'cmd'
> points
> at a SCSI command, let the caller perform that check. This patch
> prepares
> for removing the lrbp->cmd pointer.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Peter Wang <peter.wang@mediatek.com>
diff mbox series

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 3b470f564313..94cf864ac62b 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -438,9 +438,6 @@  static void ufshcd_add_command_trace(struct ufs_hba *hba, unsigned int tag,
 	struct request *rq = scsi_cmd_to_rq(cmd);
 	int transfer_len = -1;
 
-	if (!cmd)
-		return;
-
 	/* trace UPIU also */
 	ufshcd_add_cmd_upiu_trace(hba, lrbp, str_t);
 	if (!trace_ufshcd_command_enabled())
@@ -2309,9 +2306,10 @@  void ufshcd_send_command(struct ufs_hba *hba, unsigned int task_tag,
 	lrbp->issue_time_stamp_local_clock = local_clock();
 	lrbp->compl_time_stamp = ktime_set(0, 0);
 	lrbp->compl_time_stamp_local_clock = 0;
-	ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND);
-	if (lrbp->cmd)
+	if (lrbp->cmd) {
+		ufshcd_add_command_trace(hba, task_tag, UFS_CMD_SEND);
 		ufshcd_clk_scaling_start_busy(hba);
+	}
 	if (unlikely(ufshcd_should_inform_monitor(hba, lrbp)))
 		ufshcd_start_monitor(hba, lrbp);