All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec
@ 2014-08-01  8:00 Chuanxiao Dong
  2014-08-13 15:11 ` Dong, Chuanxiao
  2014-08-18 18:06 ` Santosh Y
  0 siblings, 2 replies; 4+ messages in thread
From: Chuanxiao Dong @ 2014-08-01  8:00 UTC (permalink / raw)
  To: linux-scsi; +Cc: JBottomley, santoshsy, vinholikatti

UFS 2.0 spec defines that the command type in transfer descriptor
is always 0x1 instead of different values as shown in UFSHC1.0/1.1.

This patch will distingwish v1.0/v1.1 UFSHC and later UFSHC when
setting CT

Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
---
 drivers/scsi/ufs/ufshcd.c |   27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index ba27215..8635d5d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -706,16 +706,19 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
 /**
  * ufshcd_prepare_req_desc_hdr() - Fills the requests header
  * descriptor according to request
+ * @hba: per adapter instance
  * @lrbp: pointer to local reference block
  * @upiu_flags: flags required in the header
  * @cmd_dir: requests data direction
  */
-static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
-		u32 *upiu_flags, enum dma_data_direction cmd_dir)
+static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba,
+		struct ufshcd_lrb *lrbp, u32 *upiu_flags,
+		enum dma_data_direction cmd_dir)
 {
 	struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
 	u32 data_direction;
 	u32 dword_0;
+	u8 cmd_type;
 
 	if (cmd_dir == DMA_FROM_DEVICE) {
 		data_direction = UTP_DEVICE_TO_HOST;
@@ -728,8 +731,20 @@ static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
 		*upiu_flags = UPIU_CMD_FLAGS_NONE;
 	}
 
-	dword_0 = data_direction | (lrbp->command_type
-				<< UPIU_COMMAND_TYPE_OFFSET);
+	/*
+	 * Per UFSHCI spec v1.0/v1.1, Command Type in UTP transfer
+	 * request descriptor is not the same as v2.0 spec.
+	 * In v2.0 spec, Command Type is always 1, the other values
+	 * are reserved
+	 */
+	if (hba->ufs_version == UFSHCI_VERSION_10 ||
+			hba->ufs_version == UFSHCI_VERSION_11)
+		cmd_type = lrbp->command_type;
+	else
+		cmd_type = UTP_CMD_TYPE_UFS;
+
+	dword_0 = data_direction | (cmd_type << UPIU_COMMAND_TYPE_OFFSET);
+
 	if (lrbp->intr_cmd)
 		dword_0 |= UTP_REQ_DESC_INT_CMD;
 
@@ -834,7 +849,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 	switch (lrbp->command_type) {
 	case UTP_CMD_TYPE_SCSI:
 		if (likely(lrbp->cmd)) {
-			ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
+			ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
 					lrbp->cmd->sc_data_direction);
 			ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
 		} else {
@@ -842,7 +857,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
 		}
 		break;
 	case UTP_CMD_TYPE_DEV_MANAGE:
-		ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
+		ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE);
 		if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
 			ufshcd_prepare_utp_query_req_upiu(
 					hba, lrbp, upiu_flags);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* RE: [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec
  2014-08-01  8:00 [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec Chuanxiao Dong
@ 2014-08-13 15:11 ` Dong, Chuanxiao
  2014-08-14 13:57   ` Lee Susman
  2014-08-18 18:06 ` Santosh Y
  1 sibling, 1 reply; 4+ messages in thread
From: Dong, Chuanxiao @ 2014-08-13 15:11 UTC (permalink / raw)
  To: linux-scsi; +Cc: JBottomley, santoshsy, vinholikatti

Any comment to this patch?

Thanks
Chuanxiao

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org
> [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Chuanxiao Dong
> Sent: Friday, August 01, 2014 4:01 PM
> To: linux-scsi@vger.kernel.org
> Cc: JBottomley@Parallels.com; santoshsy@gmail.com;
> vinholikatti@gmail.com
> Subject: [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec
> 
> UFS 2.0 spec defines that the command type in transfer descriptor is always
> 0x1 instead of different values as shown in UFSHC1.0/1.1.
> 
> This patch will distingwish v1.0/v1.1 UFSHC and later UFSHC when setting CT
> 
> Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c |   27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index
> ba27215..8635d5d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -706,16 +706,19 @@ static void ufshcd_disable_intr(struct ufs_hba *hba,
> u32 intrs)
>  /**
>   * ufshcd_prepare_req_desc_hdr() - Fills the requests header
>   * descriptor according to request
> + * @hba: per adapter instance
>   * @lrbp: pointer to local reference block
>   * @upiu_flags: flags required in the header
>   * @cmd_dir: requests data direction
>   */
> -static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
> -		u32 *upiu_flags, enum dma_data_direction cmd_dir)
> +static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba,
> +		struct ufshcd_lrb *lrbp, u32 *upiu_flags,
> +		enum dma_data_direction cmd_dir)
>  {
>  	struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
>  	u32 data_direction;
>  	u32 dword_0;
> +	u8 cmd_type;
> 
>  	if (cmd_dir == DMA_FROM_DEVICE) {
>  		data_direction = UTP_DEVICE_TO_HOST;
> @@ -728,8 +731,20 @@ static void ufshcd_prepare_req_desc_hdr(struct
> ufshcd_lrb *lrbp,
>  		*upiu_flags = UPIU_CMD_FLAGS_NONE;
>  	}
> 
> -	dword_0 = data_direction | (lrbp->command_type
> -				<< UPIU_COMMAND_TYPE_OFFSET);
> +	/*
> +	 * Per UFSHCI spec v1.0/v1.1, Command Type in UTP transfer
> +	 * request descriptor is not the same as v2.0 spec.
> +	 * In v2.0 spec, Command Type is always 1, the other values
> +	 * are reserved
> +	 */
> +	if (hba->ufs_version == UFSHCI_VERSION_10 ||
> +			hba->ufs_version == UFSHCI_VERSION_11)
> +		cmd_type = lrbp->command_type;
> +	else
> +		cmd_type = UTP_CMD_TYPE_UFS;
> +
> +	dword_0 = data_direction | (cmd_type <<
> UPIU_COMMAND_TYPE_OFFSET);
> +
>  	if (lrbp->intr_cmd)
>  		dword_0 |= UTP_REQ_DESC_INT_CMD;
> 
> @@ -834,7 +849,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
>  	switch (lrbp->command_type) {
>  	case UTP_CMD_TYPE_SCSI:
>  		if (likely(lrbp->cmd)) {
> -			ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> +			ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
>  					lrbp->cmd->sc_data_direction);
>  			ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
>  		} else {
> @@ -842,7 +857,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba,
> struct ufshcd_lrb *lrbp)
>  		}
>  		break;
>  	case UTP_CMD_TYPE_DEV_MANAGE:
> -		ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
> +		ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE);
>  		if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
>  			ufshcd_prepare_utp_query_req_upiu(
>  					hba, lrbp, upiu_flags);
> --
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body
> of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec
  2014-08-13 15:11 ` Dong, Chuanxiao
@ 2014-08-14 13:57   ` Lee Susman
  0 siblings, 0 replies; 4+ messages in thread
From: Lee Susman @ 2014-08-14 13:57 UTC (permalink / raw)
  To: 'Dong, Chuanxiao', linux-scsi; +Cc: JBottomley, santoshsy, vinholikatti

Hi Chuanxiao,

I have pulled and ran multiple dd runs on a build with your patch (to an
external UFS device). 
Did not see any issues with this patch, adding my reviewed-by and tested-by.

Reviewed-off-by: Lee Susman <lsusman@codeaurora.org>
Tested-off-by: Lee Susman <lsusman@codeaurora.org>

Thanks,
Lee

-----Original Message-----
From: linux-scsi-owner@vger.kernel.org
[mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Dong, Chuanxiao
Sent: Wednesday, August 13, 2014 6:12 PM
To: linux-scsi@vger.kernel.org
Cc: JBottomley@Parallels.com; santoshsy@gmail.com; vinholikatti@gmail.com
Subject: RE: [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0
spec

Any comment to this patch?

Thanks
Chuanxiao

> -----Original Message-----
> From: linux-scsi-owner@vger.kernel.org 
> [mailto:linux-scsi-owner@vger.kernel.org] On Behalf Of Chuanxiao Dong
> Sent: Friday, August 01, 2014 4:01 PM
> To: linux-scsi@vger.kernel.org
> Cc: JBottomley@Parallels.com; santoshsy@gmail.com; 
> vinholikatti@gmail.com
> Subject: [PATCH] scsi: ufs: fix Command Type issue according to UFS 
> 2.0 spec
> 
> UFS 2.0 spec defines that the command type in transfer descriptor is 
> always
> 0x1 instead of different values as shown in UFSHC1.0/1.1.
> 
> This patch will distingwish v1.0/v1.1 UFSHC and later UFSHC when 
> setting CT
> 
> Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c |   27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c 
> index ba27215..8635d5d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -706,16 +706,19 @@ static void ufshcd_disable_intr(struct ufs_hba 
> *hba,
> u32 intrs)
>  /**
>   * ufshcd_prepare_req_desc_hdr() - Fills the requests header
>   * descriptor according to request
> + * @hba: per adapter instance
>   * @lrbp: pointer to local reference block
>   * @upiu_flags: flags required in the header
>   * @cmd_dir: requests data direction
>   */
> -static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
> -		u32 *upiu_flags, enum dma_data_direction cmd_dir)
> +static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba,
> +		struct ufshcd_lrb *lrbp, u32 *upiu_flags,
> +		enum dma_data_direction cmd_dir)
>  {
>  	struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
>  	u32 data_direction;
>  	u32 dword_0;
> +	u8 cmd_type;
> 
>  	if (cmd_dir == DMA_FROM_DEVICE) {
>  		data_direction = UTP_DEVICE_TO_HOST; @@ -728,8 +731,20 @@
static 
> void ufshcd_prepare_req_desc_hdr(struct
> ufshcd_lrb *lrbp,
>  		*upiu_flags = UPIU_CMD_FLAGS_NONE;
>  	}
> 
> -	dword_0 = data_direction | (lrbp->command_type
> -				<< UPIU_COMMAND_TYPE_OFFSET);
> +	/*
> +	 * Per UFSHCI spec v1.0/v1.1, Command Type in UTP transfer
> +	 * request descriptor is not the same as v2.0 spec.
> +	 * In v2.0 spec, Command Type is always 1, the other values
> +	 * are reserved
> +	 */
> +	if (hba->ufs_version == UFSHCI_VERSION_10 ||
> +			hba->ufs_version == UFSHCI_VERSION_11)
> +		cmd_type = lrbp->command_type;
> +	else
> +		cmd_type = UTP_CMD_TYPE_UFS;
> +
> +	dword_0 = data_direction | (cmd_type <<
> UPIU_COMMAND_TYPE_OFFSET);
> +
>  	if (lrbp->intr_cmd)
>  		dword_0 |= UTP_REQ_DESC_INT_CMD;
> 
> @@ -834,7 +849,7 @@ static int ufshcd_compose_upiu(struct ufs_hba 
> *hba, struct ufshcd_lrb *lrbp)
>  	switch (lrbp->command_type) {
>  	case UTP_CMD_TYPE_SCSI:
>  		if (likely(lrbp->cmd)) {
> -			ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> +			ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
>  					lrbp->cmd->sc_data_direction);
>  			ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
>  		} else {
> @@ -842,7 +857,7 @@ static int ufshcd_compose_upiu(struct ufs_hba 
> *hba, struct ufshcd_lrb *lrbp)
>  		}
>  		break;
>  	case UTP_CMD_TYPE_DEV_MANAGE:
> -		ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
> +		ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
DMA_NONE);
>  		if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
>  			ufshcd_prepare_utp_query_req_upiu(
>  					hba, lrbp, upiu_flags);
> --
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" 
> in the body of a message to majordomo@vger.kernel.org More majordomo 
> info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the
body of a message to majordomo@vger.kernel.org More majordomo info at
http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec
  2014-08-01  8:00 [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec Chuanxiao Dong
  2014-08-13 15:11 ` Dong, Chuanxiao
@ 2014-08-18 18:06 ` Santosh Y
  1 sibling, 0 replies; 4+ messages in thread
From: Santosh Y @ 2014-08-18 18:06 UTC (permalink / raw)
  To: Chuanxiao Dong; +Cc: linux-scsi, James E.J. Bottomley, vinayak holikatti

On Fri, Aug 1, 2014 at 1:30 PM, Chuanxiao Dong <chuanxiao.dong@intel.com> wrote:
> UFS 2.0 spec defines that the command type in transfer descriptor
> is always 0x1 instead of different values as shown in UFSHC1.0/1.1.
>
> This patch will distingwish v1.0/v1.1 UFSHC and later UFSHC when
> setting CT
>
> Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.com>
> ---
>  drivers/scsi/ufs/ufshcd.c |   27 +++++++++++++++++++++------
>  1 file changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index ba27215..8635d5d 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -706,16 +706,19 @@ static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs)
>  /**
>   * ufshcd_prepare_req_desc_hdr() - Fills the requests header
>   * descriptor according to request
> + * @hba: per adapter instance
>   * @lrbp: pointer to local reference block
>   * @upiu_flags: flags required in the header
>   * @cmd_dir: requests data direction
>   */
> -static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
> -               u32 *upiu_flags, enum dma_data_direction cmd_dir)
> +static void ufshcd_prepare_req_desc_hdr(struct ufs_hba *hba,
> +               struct ufshcd_lrb *lrbp, u32 *upiu_flags,
> +               enum dma_data_direction cmd_dir)
>  {
>         struct utp_transfer_req_desc *req_desc = lrbp->utr_descriptor_ptr;
>         u32 data_direction;
>         u32 dword_0;
> +       u8 cmd_type;
>
>         if (cmd_dir == DMA_FROM_DEVICE) {
>                 data_direction = UTP_DEVICE_TO_HOST;
> @@ -728,8 +731,20 @@ static void ufshcd_prepare_req_desc_hdr(struct ufshcd_lrb *lrbp,
>                 *upiu_flags = UPIU_CMD_FLAGS_NONE;
>         }
>
> -       dword_0 = data_direction | (lrbp->command_type
> -                               << UPIU_COMMAND_TYPE_OFFSET);
> +       /*
> +        * Per UFSHCI spec v1.0/v1.1, Command Type in UTP transfer
> +        * request descriptor is not the same as v2.0 spec.
> +        * In v2.0 spec, Command Type is always 1, the other values
> +        * are reserved
> +        */
> +       if (hba->ufs_version == UFSHCI_VERSION_10 ||
> +                       hba->ufs_version == UFSHCI_VERSION_11)
> +               cmd_type = lrbp->command_type;
> +       else
> +               cmd_type = UTP_CMD_TYPE_UFS;
> +
> +       dword_0 = data_direction | (cmd_type << UPIU_COMMAND_TYPE_OFFSET);
> +
>         if (lrbp->intr_cmd)
>                 dword_0 |= UTP_REQ_DESC_INT_CMD;
>
> @@ -834,7 +849,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
>         switch (lrbp->command_type) {
>         case UTP_CMD_TYPE_SCSI:
>                 if (likely(lrbp->cmd)) {
> -                       ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags,
> +                       ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags,
>                                         lrbp->cmd->sc_data_direction);
>                         ufshcd_prepare_utp_scsi_cmd_upiu(lrbp, upiu_flags);
>                 } else {
> @@ -842,7 +857,7 @@ static int ufshcd_compose_upiu(struct ufs_hba *hba, struct ufshcd_lrb *lrbp)
>                 }
>                 break;
>         case UTP_CMD_TYPE_DEV_MANAGE:
> -               ufshcd_prepare_req_desc_hdr(lrbp, &upiu_flags, DMA_NONE);
> +               ufshcd_prepare_req_desc_hdr(hba, lrbp, &upiu_flags, DMA_NONE);
>                 if (hba->dev_cmd.type == DEV_CMD_TYPE_QUERY)
>                         ufshcd_prepare_utp_query_req_upiu(
>                                         hba, lrbp, upiu_flags);
> --
> 1.7.10.4
>

Acked-by: Santosh Y <santoshsy@gmail.com>

-- 
~Santosh

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-08-18 18:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-01  8:00 [PATCH] scsi: ufs: fix Command Type issue according to UFS 2.0 spec Chuanxiao Dong
2014-08-13 15:11 ` Dong, Chuanxiao
2014-08-14 13:57   ` Lee Susman
2014-08-18 18:06 ` Santosh Y

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.