diff mbox

[v3,2/5,SCSI] ufshcd: UFS UTP Transfer requests handling

Message ID 4F6FF1E3.7080908@toshiba.co.jp
State Not Applicable
Headers show

Commit Message

KOBAYASHI Yoshitake March 26, 2012, 4:34 a.m. UTC
Santosh Y wrote:
> +        ucd_cmd_ptr->exp_data_transfer_len =
> +            cpu_to_be32(lrbp->cmd->transfersize);
> +
> +        memcpy(ucd_cmd_ptr->cdb,
> +               lrbp->cmd->cmnd,
> +               (min_t(unsigned short,
> +                  lrbp->cmd->cmd_len,
> +                  MAX_CDB_SIZE)));

"Exptected Data Transfer Length" field contains a value that
represents the number of bytes that are required to complete the
SCSI command request and the number of bytes that the Initiator
expects to be transferred to/from the Target.
(JEDEC Standard 220 Table7-7)
On the other hand, "transfersize" in a scsi_cmnd struct is trimmed
to the sector size when requested transfer length exceeds it.
You may derive the actual transfer length from SCSI command itself like following.

Comments

Santosh Yaraganavi March 27, 2012, 4:03 a.m. UTC | #1
On Mon, Mar 26, 2012 at 10:04 AM, KOBAYASHI Yoshitake
<yoshitake.kobayashi@toshiba.co.jp> wrote:
> Santosh Y wrote:
>>
>> +        ucd_cmd_ptr->exp_data_transfer_len =
>> +            cpu_to_be32(lrbp->cmd->transfersize);
>> +
>> +        memcpy(ucd_cmd_ptr->cdb,
>> +               lrbp->cmd->cmnd,
>> +               (min_t(unsigned short,
>> +                  lrbp->cmd->cmd_len,
>> +                  MAX_CDB_SIZE)));
>
>
> "Exptected Data Transfer Length" field contains a value that
> represents the number of bytes that are required to complete the
> SCSI command request and the number of bytes that the Initiator
> expects to be transferred to/from the Target.
> (JEDEC Standard 220 Table7-7)
> On the other hand, "transfersize" in a scsi_cmnd struct is trimmed
> to the sector size when requested transfer length exceeds it.
> You may derive the actual transfer length from SCSI command itself like
> following.
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index feffe65..e63fecb 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -647,6 +647,34 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb
> *lrbp)
>                       (min_t(unsigned short,
>                              lrbp->cmd->cmd_len,
>                              MAX_CDB_SIZE)));
> +
> +               /* Overwrite exptected transfer length by using
> TRANSFER_LENGTH in SCSI commands */
> +               switch(ucd_cmd_ptr->cdb[0]) {
> +               case READ_6:
> +               case WRITE_6:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ucd_cmd_ptr->cdb[4]);
> +                       break;
> +               case READ_10:
> +               case WRITE_10:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[7] << 8) |
> +                                            ucd_cmd_ptr->cdb[8]));
> +                       break;
> +               case READ_12:
> +               case WRITE_12:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[10] << 24) |
> +                                            (ucd_cmd_ptr->cdb[11] << 16) |
> +                                            (ucd_cmd_ptr->cdb[12] << 8) |
> +                                            ucd_cmd_ptr->cdb[13]));
> +                       break;
> +               default:
> +                       break;
> +               }
>                break;
>        case UTP_CMD_TYPE_DEV_MANAGE:
>
>                /* For query function implementation */
>

Thanks, will incorporate the changes accordingly.
Santosh Yaraganavi March 27, 2012, 5:52 a.m. UTC | #2
On Mon, Mar 26, 2012 at 10:04 AM, KOBAYASHI Yoshitake
<yoshitake.kobayashi@toshiba.co.jp> wrote:
> Santosh Y wrote:
>>
>> +        ucd_cmd_ptr->exp_data_transfer_len =
>> +            cpu_to_be32(lrbp->cmd->transfersize);
>> +
>> +        memcpy(ucd_cmd_ptr->cdb,
>> +               lrbp->cmd->cmnd,
>> +               (min_t(unsigned short,
>> +                  lrbp->cmd->cmd_len,
>> +                  MAX_CDB_SIZE)));
>
>
> "Exptected Data Transfer Length" field contains a value that
> represents the number of bytes that are required to complete the
> SCSI command request and the number of bytes that the Initiator
> expects to be transferred to/from the Target.
> (JEDEC Standard 220 Table7-7)
> On the other hand, "transfersize" in a scsi_cmnd struct is trimmed
> to the sector size when requested transfer length exceeds it.
> You may derive the actual transfer length from SCSI command itself like
> following.
>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index feffe65..e63fecb 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -647,6 +647,34 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb
> *lrbp)
>                       (min_t(unsigned short,
>                              lrbp->cmd->cmd_len,
>                              MAX_CDB_SIZE)));
> +
> +               /* Overwrite exptected transfer length by using
> TRANSFER_LENGTH in SCSI commands */
> +               switch(ucd_cmd_ptr->cdb[0]) {
> +               case READ_6:
> +               case WRITE_6:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ucd_cmd_ptr->cdb[4]);
> +                       break;
> +               case READ_10:
> +               case WRITE_10:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[7] << 8) |
> +                                            ucd_cmd_ptr->cdb[8]));
> +                       break;
> +               case READ_12:
> +               case WRITE_12:

Just a minor change, this will be READ_16 and WRITE_16.

> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[10] << 24) |
> +                                            (ucd_cmd_ptr->cdb[11] << 16) |
> +                                            (ucd_cmd_ptr->cdb[12] << 8) |
> +                                            ucd_cmd_ptr->cdb[13]));
> +                       break;
> +               default:
> +                       break;
> +               }
>                break;
>        case UTP_CMD_TYPE_DEV_MANAGE:
>
>                /* For query function implementation */
>
KOBAYASHI Yoshitake March 29, 2012, 1:40 a.m. UTC | #3
Santosh Y wrote:
>> +               case READ_12:
>> +               case WRITE_12:
>
> Just a minor change, this will be READ_16 and WRITE_16.

Thanks. Your feedback will be correct.
Venkatraman S April 10, 2012, 11:08 a.m. UTC | #4
On 26 March 2012 10:04, KOBAYASHI Yoshitake
<yoshitake.kobayashi@toshiba.co.jp> wrote:
> Santosh Y wrote:
>>
>> +        ucd_cmd_ptr->exp_data_transfer_len =
>> +            cpu_to_be32(lrbp->cmd->transfersize);
>> +
>> +        memcpy(ucd_cmd_ptr->cdb,
>> +               lrbp->cmd->cmnd,
>> +               (min_t(unsigned short,
>> +                  lrbp->cmd->cmd_len,
>> +                  MAX_CDB_SIZE)));
>
>
> "Exptected Data Transfer Length" field contains a value that
> represents the number of bytes that are required to complete the
> SCSI command request and the number of bytes that the Initiator
> expects to be transferred to/from the Target.
> (JEDEC Standard 220 Table7-7)
> On the other hand, "transfersize" in a scsi_cmnd struct is trimmed
> to the sector size when requested transfer length exceeds it.
> You may derive the actual transfer length from SCSI command itself like
> following.
Hi,
  Can you please send signed-off patches for the two issues that you reported ?
I would like to use them on my development tree.

Thanks and regards,
Venkat.

>
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index feffe65..e63fecb 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -647,6 +647,34 @@ static void ufshcd_compose_upiu(struct ufshcd_lrb
> *lrbp)
>                       (min_t(unsigned short,
>                              lrbp->cmd->cmd_len,
>                              MAX_CDB_SIZE)));
> +
> +               /* Overwrite exptected transfer length by using
> TRANSFER_LENGTH in SCSI commands */
> +               switch(ucd_cmd_ptr->cdb[0]) {
> +               case READ_6:
> +               case WRITE_6:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ucd_cmd_ptr->cdb[4]);
> +                       break;
> +               case READ_10:
> +               case WRITE_10:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[7] << 8) |
> +                                            ucd_cmd_ptr->cdb[8]));
> +                       break;
> +               case READ_12:
> +               case WRITE_12:
> +                       ucd_cmd_ptr->exp_data_transfer_len =
> +                               cpu_to_be32(lrbp->cmd->transfersize *
> +                                           ((ucd_cmd_ptr->cdb[10] << 24) |
> +                                            (ucd_cmd_ptr->cdb[11] << 16) |
> +                                            (ucd_cmd_ptr->cdb[12] << 8) |
> +                                            ucd_cmd_ptr->cdb[13]));
> +                       break;
> +               default:
> +                       break;
> +               }
>                break;
>        case UTP_CMD_TYPE_DEV_MANAGE:
>
>                /* For query function implementation */
>
diff mbox

Patch

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index feffe65..e63fecb 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -647,6 +647,34 @@  static void ufshcd_compose_upiu(struct ufshcd_lrb *lrbp)
                        (min_t(unsigned short,
                               lrbp->cmd->cmd_len,
                               MAX_CDB_SIZE)));
+
+               /* Overwrite exptected transfer length by using TRANSFER_LENGTH in SCSI commands */
+               switch(ucd_cmd_ptr->cdb[0]) {
+               case READ_6:
+               case WRITE_6:
+                       ucd_cmd_ptr->exp_data_transfer_len =
+                               cpu_to_be32(lrbp->cmd->transfersize *
+                                           ucd_cmd_ptr->cdb[4]);
+                       break;
+               case READ_10:
+               case WRITE_10:
+                       ucd_cmd_ptr->exp_data_transfer_len =
+                               cpu_to_be32(lrbp->cmd->transfersize *
+                                           ((ucd_cmd_ptr->cdb[7] << 8) |
+                                            ucd_cmd_ptr->cdb[8]));
+                       break;
+               case READ_12:
+               case WRITE_12:
+                       ucd_cmd_ptr->exp_data_transfer_len =
+                               cpu_to_be32(lrbp->cmd->transfersize *
+                                           ((ucd_cmd_ptr->cdb[10] << 24) |
+                                            (ucd_cmd_ptr->cdb[11] << 16) |
+                                            (ucd_cmd_ptr->cdb[12] << 8) |
+                                            ucd_cmd_ptr->cdb[13]));
+                       break;
+               default:
+                       break;
+               }
                 break;
         case UTP_CMD_TYPE_DEV_MANAGE:
                 /* For query function implementation */