[PATCH 1/2] scsi: ufs: Clear ucd_rsp_ptr for UPIU requests once

Avri Altman posted 2 patches 3 months, 3 weeks ago
[PATCH 1/2] scsi: ufs: Clear ucd_rsp_ptr for UPIU requests once
Posted by Avri Altman 3 months, 3 weeks ago
Previously, the response buffer (ucd_rsp_ptr) was cleared in multiple
UPIU preparation functions. Do it once.

Signed-off-by: Avri Altman <avri.altman@sandisk.com>
---
 drivers/ufs/core/ufshcd.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 0a702356a715..c2048aca09fc 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2826,8 +2826,6 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
 	/* Copy the Descriptor */
 	if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)
 		memcpy(ucd_req_ptr + 1, query->descriptor, len);
-
-	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
 }
 
 static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
@@ -2840,8 +2838,6 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
 		.transaction_code = UPIU_TRANSACTION_NOP_OUT,
 		.task_tag = lrbp->task_tag,
 	};
-
-	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
 }
 
 /**
@@ -2867,6 +2863,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
 	else
 		ret = -EINVAL;
 
+	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
+
 	return ret;
 }
 
-- 
2.25.1
Re: [PATCH 1/2] scsi: ufs: Clear ucd_rsp_ptr for UPIU requests once
Posted by Martin K. Petersen 3 months, 3 weeks ago
Avri,

> Previously, the response buffer (ucd_rsp_ptr) was cleared in multiple
> UPIU preparation functions. Do it once.

Applied to 6.17/scsi-staging, thanks!

-- 
Martin K. Petersen
Re: [PATCH 1/2] scsi: ufs: Clear ucd_rsp_ptr for UPIU requests once
Posted by Bart Van Assche 3 months, 3 weeks ago
On 6/17/25 2:56 AM, Avri Altman wrote:
> Previously, the response buffer (ucd_rsp_ptr) was cleared in multiple
> UPIU preparation functions. Do it once.
> 
> Signed-off-by: Avri Altman <avri.altman@sandisk.com>
> ---
>   drivers/ufs/core/ufshcd.c | 6 ++----
>   1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 0a702356a715..c2048aca09fc 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -2826,8 +2826,6 @@ static void ufshcd_prepare_utp_query_req_upiu(struct ufs_hba *hba,
>   	/* Copy the Descriptor */
>   	if (query->request.upiu_req.opcode == UPIU_QUERY_OPCODE_WRITE_DESC)
>   		memcpy(ucd_req_ptr + 1, query->descriptor, len);
> -
> -	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
>   }
>   
>   static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
> @@ -2840,8 +2838,6 @@ static inline void ufshcd_prepare_utp_nop_upiu(struct ufshcd_lrb *lrbp)
>   		.transaction_code = UPIU_TRANSACTION_NOP_OUT,
>   		.task_tag = lrbp->task_tag,
>   	};
> -
> -	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
>   }
>   
>   /**
> @@ -2867,6 +2863,8 @@ static int ufshcd_compose_devman_upiu(struct ufs_hba *hba,
>   	else
>   		ret = -EINVAL;
>   
> +	memset(lrbp->ucd_rsp_ptr, 0, sizeof(struct utp_upiu_rsp));
> +
>   	return ret;
>   }

Reviewed-by: Bart Van Assche <bvanassche@acm.org>