From patchwork Fri Aug 21 09:27:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 7050861 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2F2609F358 for ; Fri, 21 Aug 2015 09:40:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BBEC202FE for ; Fri, 21 Aug 2015 09:40:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5A1E5205FA for ; Fri, 21 Aug 2015 09:40:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbbHUJha (ORCPT ); Fri, 21 Aug 2015 05:37:30 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:38059 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753063AbbHUJh0 (ORCPT ); Fri, 21 Aug 2015 05:37:26 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NTF00VQBEQDVEB0@mailout4.samsung.com>; Fri, 21 Aug 2015 18:37:25 +0900 (KST) Received: from epcpsbgm2new.samsung.com ( [172.20.52.123]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id 12.93.20564.451F6D55; Fri, 21 Aug 2015 18:37:25 +0900 (KST) X-AuditID: cbfee690-f796f6d000005054-af-55d6f154f7ef Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id A4.EA.07062.451F6D55; Fri, 21 Aug 2015 18:37:24 +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 <0NTF008WKEOTM680@mmp1.samsung.com>; Fri, 21 Aug 2015 18:37:24 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: vinholikatti@gmail.com, JBottomley@odin.com, Seungwon Jeon Subject: [PATCH 02/10] scsi: ufs: add quirk to contain unconformable utrd field Date: Fri, 21 Aug 2015 14:57:53 +0530 Message-id: <1440149281-26336-3-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 1.7.10.4 In-reply-to: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> References: <1440149281-26336-1-git-send-email-alim.akhtar@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsWyRsSkWjf047VQgyedbBb/199msbi8aw6b Rff1HWwWH+5fZLbYsbDKgdVj56y77B6Hf/xg9ujbsorR4/MmuQCWKC6blNSczLLUIn27BK6M r51qBdOlKzrvrWFqYNwp1sXIwSEhYCLxsbW8i5ETyBSTuHBvPVsXIxeHkMAKRollHWtYIRIm Ej++7GaGSCxllNj04z9YQkjgJ6PEh4s8IDabgLbE3elbmEBsEQEbifM3H4DZzALhEtc2zGYH sYUF/CXWd0H0sgioSszv7mAGOYJXwF3ix404iF2KEt3PJrCB2JwCHhJ3m+axQKxyl7h8+RjU Pc3sEpMfcUCMEZD4NvkQC8QvshKbDjBDlEhKHFxxg2UCo/ACRoZVjKKpBckFxUnpRSZ6xYm5 xaV56XrJ+bmbGIHhe/rfswk7GO8dsD7EKMDBqMTDOzPyWqgQa2JZcWXuIUZToA0TmaVEk/OB UZJXEm9obGZkYWpiamxkbmmmJM77WupnsJBAemJJanZqakFqUXxRaU5q8SFGJg5OqQbG1Zd+ aEte2GkS7H9sZdnsGRdXbCtdJlS1jKmbYfOmz0FWXpzlss6J7xdr82qkscrtLC90/s7ce+uQ 96VrPz0vmNpMkbAy2TL7zeZ8Df488R8f/Xbn3/vZ4rTI/djr4F2W2kb9y+NaGl46unyxsJ9Z fC2veknMFHObm81fJ3prekXsSUqVOlGsxFKckWioxVxUnAgARl4MkVoCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGIsWRmVeSWpSXmKPExsVy+t9jAd2Qj9dCDab+t7L4v/42i8XlXXPY LLqv72Cz+HD/IrPFjoVVDqweO2fdZfc4/OMHs0ffllWMHp83yQWwRDUw2mSkJqakFimk5iXn p2TmpdsqeQfHO8ebmhkY6hpaWpgrKeQl5qbaKrn4BOi6ZeYA7VVSKEvMKQUKBSQWFyvp22Ga EBripmsB0xih6xsSBNdjZIAGEtYwZnztVCuYLl3ReW8NUwPjTrEuRk4OCQETiR9fdjND2GIS F+6tZ+ti5OIQEljKKLHpx39WkISQwE9GiQ8XeUBsNgFtibvTtzCB2CICNhLnbz4As5kFwiWu bZjNDmILC/hLrO+C6GURUJWY390BtICDg1fAXeLHjTiIXYoS3c8msIHYnAIeEneb5rFArHKX uHz5GOsERt4FjAyrGCVSC5ILipPSc43yUsv1ihNzi0vz0vWS83M3MYLj5Jn0DsbDu9wPMQpw MCrx8M6IvBYqxJpYVlyZe4hRgoNZSYTX+gVQiDclsbIqtSg/vqg0J7X4EKMp0F0TmaVEk/OB MZxXEm9obGJuamxqaWJhYmapJM6rb7IpVEggPbEkNTs1tSC1CKaPiYNTqoEx4/N10el1Nmcc hHpt0y5vm905zXqhio7w9HO9avWZf43ym1vjuK1clp7gYL3S3/Hs5czHr3KXOoR2tL7XF3+Z vtFJT+nd4g12WjNYa3M2/eldojZl7uu97vMVhZZ8eWmcfDbj7IGYiOJ/X5aHX796vjNaX1n2 5g/56ok3u1k5PkRp2Tl1+HUqsRRnJBpqMRcVJwIAl2Yg/qkCAAA= 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.7 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 b0ade73..f882bf0 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_BROKEN_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); @@ -2035,12 +2040,21 @@ static void ufshcd_host_memory_configure(struct ufs_hba *hba) cpu_to_le32(upper_32_bits(cmd_desc_element_addr)); /* Response upiu and prdt offset should be in double words */ - utrdlp[i].response_upiu_offset = + if (hba->quirks & UFSHCI_QUIRK_BROKEN_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 { + 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 c40a0e7..1fa5ac1 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -459,6 +459,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_BROKEN_UTRD UFS_BIT(6) + unsigned int quirks; /* Deviations from standard UFSHCI spec. */ wait_queue_head_t tm_wq;