From patchwork Mon Mar 26 04:34:43 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KOBAYASHI Yoshitake X-Patchwork-Id: 7457 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 595CE23E13 for ; Mon, 26 Mar 2012 04:35:08 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id EC93AA18165 for ; Mon, 26 Mar 2012 04:35:07 +0000 (UTC) Received: by iage36 with SMTP id e36so10202753iag.11 for ; Sun, 25 Mar 2012 21:35:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:message-id :date:from:user-agent:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=VPnXiTfY8T3OWdXuWc1BUWTQVkGutNULjFu0c6kFwmc=; b=fKN2P0W6W3CnuoR1M0Xtn4HosFGQesLUpeCoHnrTaf90o02In438jFHrezPqi7bN73 NL5pFeVkhGllrWvRhq6VY8JQYRTaTSofZVbPluPOrTFmjtTfrdTXJq3QZsJBnkV2m7Dp VkUVU+afOYsRMtZ9gh95BB4YWipa3zB6fmGj1gasufaxWW0le29mmT4SljMG8H/gDrfl KAKaY2kS0R/fNUv00IARAXQPsrIEv6WINziDhZKsewAVjoPvsV4kym9eGiSB3qsfZEQu L3A+K/AJhVi2GIHmMBbYkTsX4qfjnRgSiAfp82jIyi7JpqDyoHDyWu8d6ZqeG+Fmm+xT W2Nw== Received: by 10.50.191.233 with SMTP id hb9mr4502124igc.44.1332736507399; Sun, 25 Mar 2012 21:35:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.5.205 with SMTP id 13csp8742ibw; Sun, 25 Mar 2012 21:35:06 -0700 (PDT) Received: by 10.68.230.230 with SMTP id tb6mr50662412pbc.40.1332736506157; Sun, 25 Mar 2012 21:35:06 -0700 (PDT) Received: from imx12.toshiba.co.jp (imx12.toshiba.co.jp. [61.202.160.132]) by mx.google.com with ESMTPS id r4si17142658pbi.95.2012.03.25.21.35.05 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 25 Mar 2012 21:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of yoshitake.kobayashi@toshiba.co.jp designates 61.202.160.132 as permitted sender) client-ip=61.202.160.132; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yoshitake.kobayashi@toshiba.co.jp designates 61.202.160.132 as permitted sender) smtp.mail=yoshitake.kobayashi@toshiba.co.jp Received: from arc11.toshiba.co.jp ([133.199.90.127]) by imx12.toshiba.co.jp with ESMTP id q2Q4Yk2r027114; Mon, 26 Mar 2012 13:34:46 +0900 (JST) Received: (from root@localhost) by arc11.toshiba.co.jp id q2Q4YkqG026113; Mon, 26 Mar 2012 13:34:46 +0900 (JST) Received: from ovp11.toshiba.co.jp [133.199.90.148] by arc11.toshiba.co.jp with ESMTP id PAA26111; Mon, 26 Mar 2012 13:34:45 +0900 Received: from mx.toshiba.co.jp (localhost [127.0.0.1]) by ovp11.toshiba.co.jp with ESMTP id q2Q4Yjkk023865; Mon, 26 Mar 2012 13:34:45 +0900 (JST) Received: from BK2211.rdc.toshiba.co.jp by toshiba.co.jp id q2Q4Yj78011145; Mon, 26 Mar 2012 13:34:45 +0900 (JST) Received: from island.swc.toshiba.co.jp (localhost [127.0.0.1]) by BK2211.rdc.toshiba.co.jp (8.13.8+Sun/8.13.8) with ESMTP id q2Q4YiFq000812; Mon, 26 Mar 2012 13:34:44 +0900 (JST) Received: from [133.196.174.107] (unknown [133.196.174.107]) by island.swc.toshiba.co.jp (Postfix) with ESMTP id D82AB40002; Mon, 26 Mar 2012 13:34:43 +0900 (JST) Message-ID: <4F6FF1E3.7080908@toshiba.co.jp> Date: Mon, 26 Mar 2012 13:34:43 +0900 From: KOBAYASHI Yoshitake User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120312 Thunderbird/11.0 MIME-Version: 1.0 To: Santosh Y Cc: James Bottomley , linux-scsi@vger.kernel.org, patches@linaro.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org, arnd.bergmann@linaro.org, saugata.das@linaro.org, dsaxena@linaro.org, stephen.doel@linaro.org, venkat@linaro.org, ilho215.lee@samsung.com, nala.la@samsung.com, girish.shivananjappa@linaro.org, vishak.g@samsung.com, k.rajesh@samsung.com, yejin.moon@samsung.com, sreekumar.c@samsung.com, vinholikatti@gmail.com, linkinjeon@gmail.com, michaelc@cs.wisc.edu Subject: Re: [PATCH v3 2/5] [SCSI] ufshcd: UFS UTP Transfer requests handling References: <1330497714-26504-3-git-send-email-santoshsy@gmail.com> In-Reply-To: <1330497714-26504-3-git-send-email-santoshsy@gmail.com> X-Gm-Message-State: ALoCoQnyRbFZCd/jsl3net90gubEbZIh7fBQtTLPPmCfCO9uoXFOntpqmCGykfTObon6okB/amx7 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 */