lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4F6FF1E3.7080908@toshiba.co.jp>
Date:	Mon, 26 Mar 2012 13:34:43 +0900
From:	KOBAYASHI Yoshitake <yoshitake.kobayashi@...hiba.co.jp>
To:	Santosh Y <santoshsy@...il.com>
Cc:	James Bottomley <James.Bottomley@...senPartnership.com>,
	linux-scsi@...r.kernel.org, patches@...aro.org,
	linux-samsung-soc@...r.kernel.org, linux-kernel@...r.kernel.org,
	arnd.bergmann@...aro.org, saugata.das@...aro.org,
	dsaxena@...aro.org, stephen.doel@...aro.org, venkat@...aro.org,
	ilho215.lee@...sung.com, nala.la@...sung.com,
	girish.shivananjappa@...aro.org, vishak.g@...sung.com,
	k.rajesh@...sung.com, yejin.moon@...sung.com,
	sreekumar.c@...sung.com, vinholikatti@...il.com,
	linkinjeon@...il.com, michaelc@...wisc.edu
Subject: Re: [PATCH v3 2/5] [SCSI] ufshcd: UFS UTP Transfer requests handling

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 */

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ