Re: [PATCH v2 1/2] scsi: ufs: Fix residual handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 24/07/23 23:08, Bart Van Assche wrote:
> Only call scsi_set_resid() in case of an underflow. Do not call
> scsi_set_resid() in case of an overflow.
> 
> Cc: Avri Altman <avri.altman@xxxxxxx>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Fixes: cb38845d90fc ("scsi: ufs: core: Set the residual byte count")
> Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx>

Reviewed-by: Adrian Hunter <adrian.hunter@xxxxxxxxx>

> ---
>  drivers/ufs/core/ufshcd.c | 12 ++++++++++--
>  include/ufs/ufs.h         |  6 ++++++
>  2 files changed, 16 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index c394dc50504a..27e1a4914837 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -5222,9 +5222,17 @@ ufshcd_transfer_rsp_status(struct ufs_hba *hba, struct ufshcd_lrb *lrbp,
>  	int result = 0;
>  	int scsi_status;
>  	enum utp_ocs ocs;
> +	u8 upiu_flags;
> +	u32 resid;
>  
> -	scsi_set_resid(lrbp->cmd,
> -		be32_to_cpu(lrbp->ucd_rsp_ptr->sr.residual_transfer_count));
> +	upiu_flags = be32_to_cpu(lrbp->ucd_rsp_ptr->header.dword_0) >> 16;
> +	resid = be32_to_cpu(lrbp->ucd_rsp_ptr->sr.residual_transfer_count);
> +	/*
> +	 * Test !overflow instead of underflow to support UFS devices that do
> +	 * not set either flag.
> +	 */
> +	if (resid && !(upiu_flags & UPIU_RSP_FLAG_OVERFLOW))
> +		scsi_set_resid(lrbp->cmd, resid);
>  
>  	/* overall command status of utrd */
>  	ocs = ufshcd_get_tr_ocs(lrbp, cqe);
> diff --git a/include/ufs/ufs.h b/include/ufs/ufs.h
> index 0dd546a20503..c789252b5fad 100644
> --- a/include/ufs/ufs.h
> +++ b/include/ufs/ufs.h
> @@ -104,6 +104,12 @@ enum {
>  	UPIU_CMD_FLAGS_READ	= 0x40,
>  };
>  
> +/* UPIU response flags */
> +enum {
> +	UPIU_RSP_FLAG_UNDERFLOW	= 0x20,
> +	UPIU_RSP_FLAG_OVERFLOW	= 0x40,
> +};
> +
>  /* UPIU Task Attributes */
>  enum {
>  	UPIU_TASK_ATTR_SIMPLE	= 0x00,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux