From patchwork Mon Nov 9 05:26:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 7580961 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3148EC05C6 for ; Mon, 9 Nov 2015 05:27:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3862C204B0 for ; Mon, 9 Nov 2015 05:27:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2210620453 for ; Mon, 9 Nov 2015 05:27:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751947AbbKIF1l (ORCPT ); Mon, 9 Nov 2015 00:27:41 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:43976 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751600AbbKIF1j (ORCPT ); Mon, 9 Nov 2015 00:27:39 -0500 Received: from epcpsbgr2.samsung.com (u142.gpu120.samsung.co.kr [203.254.230.142]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NXJ02NIR8I1JPA0@mailout2.samsung.com>; Mon, 09 Nov 2015 14:27:37 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.122]) by epcpsbgr2.samsung.com (EPCPMTA) with SMTP id 3D.64.05272.9CE20465; Mon, 9 Nov 2015 14:27:37 +0900 (KST) X-AuditID: cbfee68e-f791c6d000001498-f2-56402ec9f328 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 06.59.18629.9CE20465; Mon, 9 Nov 2015 14:27:37 +0900 (KST) Received: from exypnos.sisodomain.com ([107.108.73.28]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NXJ002ZM8DXYXP0@mmp1.samsung.com>; Mon, 09 Nov 2015 14:27:37 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: JBottomley@odin.com, vinholikatti@gmail.com, gautam.vivek@samsung.com, essuuj@gmail.com, devicetree@vger.kernel.org, kishon@ti.com Subject: [PATCH v5 03/11] scsi: ufs: add quirk to contain unconformable utrd field Date: Mon, 09 Nov 2015 10:56:19 +0530 Message-id: <1447046787-480-4-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1447046787-480-1-git-send-email-alim.akhtar@samsung.com> References: <1447046787-480-1-git-send-email-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRsSkSveknkOYwYRrchbzj5xjtVh+YQmT RduVg+wW/9ffZrG48LSHzeLyrjlsFt3Xd7BZ7FhY5cDhsXPWXXaPwz9+MHv0bVnF6HH8xnYm j8+b5AJYo7hsUlJzMstSi/TtErgyJnzpZiq4KV3x7lgzewPjV7EuRg4OCQETiRn/hbsYOYFM MYkL99azdTFycQgJrGCUmLB4OiNEwkRiy+x7LBCJpYwSK3Z/gKr6ySjx/8FCZpAqNgFtibvT tzCB2CICNhLnbz5gAiliFuhglOg8t4UNJCEsECJx89pFVhCbRUBVYlvzaTaQM3gFXCVOnCiF 2KYo0f1sAlg5p4CbxLmZDWDzhYBKul6fBLtCQmAZu8S7I8vZIeYISHybfIgF4h1ZiU0HmCHm SEocXHGDZQKj8AJGhlWMoqkFyQXFSelFRnrFibnFpXnpesn5uZsYgeF++t+zvh2MNw9YH2IU 4GBU4uGNmGkfJsSaWFZcmXuI0RRow0RmKdHkfGBU5ZXEGxqbGVmYmpg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E4vfGps/VMi0id/M6G27oJTXffzTvRPfszw3d7NvXq5vyKbEUZyQaajEXFScC ABjMDdXAAgAA DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Seungwon Jeon UTRD(UTP Transfer Request Descriptor)'s field such as offset/length, especially response's has DWORD expression. This quirk can be specified for host controller not to conform standard. Signed-off-by: Seungwon Jeon Signed-off-by: Alim Akhtar --- drivers/scsi/ufs/ufshcd.c | 28 +++++++++++++++++++++------- drivers/scsi/ufs/ufshcd.h | 7 +++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 131c72038bf8..587a9c8fbfe9 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -1009,7 +1009,7 @@ ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) * * Returns 0 in case of success, non-zero value in case of failure */ -static int ufshcd_map_sg(struct ufshcd_lrb *lrbp) +static int ufshcd_map_sg(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) { struct ufshcd_sg_entry *prd_table; struct scatterlist *sg; @@ -1023,8 +1023,13 @@ static int ufshcd_map_sg(struct ufshcd_lrb *lrbp) return sg_segments; if (sg_segments) { - lrbp->utr_descriptor_ptr->prd_table_length = - cpu_to_le16((u16) (sg_segments)); + if (hba->quirks & UFSHCI_QUIRK_BYTE_ALIGN_UTRD) + lrbp->utr_descriptor_ptr->prd_table_length = + cpu_to_le16((u16)(sg_segments * + sizeof(struct ufshcd_sg_entry))); + else + lrbp->utr_descriptor_ptr->prd_table_length = + cpu_to_le16((u16) (sg_segments)); prd_table = (struct ufshcd_sg_entry *)lrbp->ucd_prdt_ptr; @@ -1347,7 +1352,7 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) /* form UPIU before issuing the command */ ufshcd_compose_upiu(hba, lrbp); - err = ufshcd_map_sg(lrbp); + err = ufshcd_map_sg(hba, lrbp); if (err) { lrbp->cmd = NULL; clear_bit_unlock(tag, &hba->lrb_in_use); @@ -2034,13 +2039,22 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba) utrdlp[i].command_desc_base_addr_hi = cpu_to_le32(upper_32_bits(cmd_desc_element_addr)); + if (hba->quirks & UFSHCI_QUIRK_BYTE_ALIGN_UTRD) { + utrdlp[i].response_upiu_offset = + cpu_to_le16(response_offset); + utrdlp[i].prd_table_offset = + cpu_to_le16(prdt_offset); + utrdlp[i].response_upiu_length = + cpu_to_le16(ALIGNED_UPIU_SIZE); + } else { /* Response upiu and prdt offset should be in double words */ - utrdlp[i].response_upiu_offset = + utrdlp[i].response_upiu_offset = cpu_to_le16((response_offset >> 2)); - utrdlp[i].prd_table_offset = + utrdlp[i].prd_table_offset = cpu_to_le16((prdt_offset >> 2)); - utrdlp[i].response_upiu_length = + utrdlp[i].response_upiu_length = cpu_to_le16(ALIGNED_UPIU_SIZE >> 2); + } hba->lrb[i].utr_descriptor_ptr = (utrdlp + i); hba->lrb[i].ucd_req_ptr = diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 2570d9477b37..6cd542a803d5 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -467,6 +467,13 @@ struct ufs_hba { */ #define UFSHCD_QUIRK_BROKEN_UFS_HCI_VERSION UFS_BIT(5) + /* + * This quirk needs to be enabled if host controller doesn't conform + * with UTRD. Some fields such as offset/length might not be in double + * word, but in byte. + */ + #define UFSHCI_QUIRK_BYTE_ALIGN_UTRD UFS_BIT(6) + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ wait_queue_head_t tm_wq;