From patchwork Thu Mar 8 11:03:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alim Akhtar X-Patchwork-Id: 10267679 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2269F60211 for ; Thu, 8 Mar 2018 11:14:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 13A3A2989C for ; Thu, 8 Mar 2018 11:14:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07257298A5; Thu, 8 Mar 2018 11:14:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2A082989C for ; Thu, 8 Mar 2018 11:14:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935793AbeCHLOW (ORCPT ); Thu, 8 Mar 2018 06:14:22 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:31198 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934456AbeCHLOT (ORCPT ); Thu, 8 Mar 2018 06:14:19 -0500 Received: from epcas1p2.samsung.com (unknown [182.195.41.46]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180308111417epoutp047003777572260d73cf460aae67631834~Z7ah57KEM1374613746epoutp04c; Thu, 8 Mar 2018 11:14:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180308111417epoutp047003777572260d73cf460aae67631834~Z7ah57KEM1374613746epoutp04c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1520507657; bh=9/8vaql11Quz0mSNh0ThWI6EwkABIcYhcSClHKE7dvM=; h=From:To:Cc:Subject:Date:References:From; b=QV60kjBWlTbAwciIuGjkeU8PH13d29OXuY2PNtiTFrlkhMFic+z0IKq+SvbtBVHtP orAU8+9spKglgtjVlPUd0+fxZwesdF4KEM3ZIkZ6zTp/w3BWlZbyQG1a+am0KMwToX CcR5Sp5TOXxHjWZys2W1Qg65qNdoI/T7m7cMbJSc= Received: from epsmges1p1.samsung.com (unknown [182.195.42.53]) by epcas1p3.samsung.com (KnoxPortal) with ESMTP id 20180308111416epcas1p3fa337f6480c65b3f6bc7c601a5ed0d1b~Z7ahoE-FF1596415964epcas1p3B; Thu, 8 Mar 2018 11:14:16 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 0D.31.04145.80B11AA5; Thu, 8 Mar 2018 20:14:16 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180308111416epcas1p4f9f1dbb36e8567121c6236ac0e9b4e03~Z7ahSrPSF1483514835epcas1p4P; Thu, 8 Mar 2018 11:14:16 +0000 (GMT) X-AuditID: b6c32a35-891ff70000001031-df-5aa11b08f9e0 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 98.69.03826.80B11AA5; Thu, 8 Mar 2018 20:14:16 +0900 (KST) Received: from localhost.localdomain ([107.108.73.28]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P5900E78R7HPF90@mmp2.samsung.com>; Thu, 08 Mar 2018 20:14:16 +0900 (KST) From: Alim Akhtar To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: jejb@linux.vnet.ibm.com, martin.petersen@oracle.com, vinholikatti@gmail.com, subhashj@codeaurora.org, devicetree@vger.kernel.org, shaik.ameer@samsung.com Subject: [RFC PATCH V2] scsi: ufs: Add specific callback for setting DMA mask Date: Thu, 08 Mar 2018 16:33:33 +0530 Message-id: <1520507013-2410-1-git-send-email-alim.akhtar@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrHIsWRmVeSWpSXmKPExsWy7bCmri6H9MIog78PtS3mHznHarFqYp7F 5V1z2Cy6r+9gs1h+/B+TxZGHu9ktbizeyWaxY2GVA4fH5b5eJo+ds+6yezw4tJnF4+PTWywe fVtWMXp83iQXwBbFZZOSmpNZllqkb5fAlXH34VHWgnVCFQvOzWZtYOzk72Lk5JAQMJGY+GYz UxcjF4eQwA5Gifd7frFCON8ZJbafaGeHqZo+oZUNIrGBUeLxy8nsEM4PRolZJ/tYQKrYBLQl 7k7fwgRiiwjYSJy/+QBsLrPAQkaJPbdOAHVwcAgL+Esc7kgHqWERUJXYsGALM4jNK+AmsX7W FVaIbXISN891MoP0Sgj8ZZV4dWUzI0TCRWLS3J9sELawxKvjW8BmSghIS1w6agsRzpb4cPwk M4RdIzHrYi9Uub3EgStzwO5kFuCTePe1hxWilVeio00IosRD4tzbL0wQtqPE82//wM4REoiV WHvpBesERskFjAyrGMVSC4pz01OLDQsM9YoTc4tL89L1kvNzNzGCY1HLdAfjlHM+hxgFOBiV eHgl/syPEmJNLCuuzD3EKMHBrCTCy7VsQZQQb0piZVVqUX58UWlOavEhRmkOFiVx3oAAlygh gfTEktTs1NSC1CKYLBMHp1QD4/GyRzFnZ3QLmqctatVbcInF+9rD2xsf8GiET793ij1rwr5H LUybX7rP/PPkgKroliSemLMOlq2OOavt5a/L9sxRybnyvdL9x5vFDzdw2ghmf3AsK0hekndn p8XqfQoh9SECgbMcud2m+Jd3SXT82iR/q/mApkP7beZd83WzVsX3XMpazf5jhRJLcUaioRZz UXEiABewK0LBAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrLJMWRmVeSWpSXmKPExsVy+t9jQV0O6YVRBqt/C1nMP3KO1WLVxDyL y7vmsFl0X9/BZrH8+D8miyMPd7Nb3Fi8k81ix8IqBw6Py329TB47Z91l93hwaDOLx8ent1g8 +rasYvT4vEkugC2KyyYlNSezLLVI3y6BK+Puw6OsBeuEKhacm83awNjJ38XIySEhYCIxfUIr WxcjF4eQwDpGiVd/+5kgnB+MEqt23WMBqWIT0Ja4O30LE4gtImAjcf7mA7AiZoGFjBInu7Yy giSEBXwl1h1qB7NZBFQlNizYwgxi8wq4SayfdYUVYp2cxM1zncwTGLkWMDKsYpRMLSjOTc8t NiowzEst1ytOzC0uzUvXS87P3cQIDJRth7X6djDeXxJ/iFGAg1GJh1fiz/woIdbEsuLK3EOM EhzMSiK8XMsWRAnxpiRWVqUW5ccXleakFh9ilOZgURLnvZ13LFJIID2xJDU7NbUgtQgmy8TB KdXAuO5i7hq5TQlzt5h0na4zvPEjLZHjqNOpSf7mPMw3DVz0jnWVygvxLvg39Y+gUzdzzR6O z+G1a/R3f85nCD1fdrXk+AxDpcg5m74c31LBlGAsuFPfUGeiidkkH1a/J9ITPjlkpOf+NKte Ux758+XN2KLMGcosaczzr7Tqd9s1pa2o+bvxaMl0JZbijERDLeai4kQAOxFd2BACAAA= X-CMS-MailID: 20180308111416epcas1p4f9f1dbb36e8567121c6236ac0e9b4e03 X-Msg-Generator: CA CMS-TYPE: 101P X-CMS-RootMailID: 20180308111416epcas1p4f9f1dbb36e8567121c6236ac0e9b4e03 X-RootMTR: 20180308111416epcas1p4f9f1dbb36e8567121c6236ac0e9b4e03 References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently DMA mask for UFS HCI is set by reading CAP register's [64AS] bit. Some HCI controller like Exynos support 36-bit bus address. This works perfectly fine with DMA mask set as 64 in case there is no IOMMU attached to HCI. In case if HCI is behind an IOMMU, setting DMA mask as 64 bit won't work as HCI has only 36bit addressing and SMMU has created mapping of 64 bit and as the device truncates the address, its mapping will not be found by iommu. To resolve such issues, let the variant driver sets its own DMA mask. Signed-off-by: Alim Akhtar --- drivers/scsi/ufs/ufshcd.c | 3 +++ drivers/scsi/ufs/ufshcd.h | 2 ++ 2 files changed, 5 insertions(+) I am not sure if there are other ways available to handle such cases. The IOMMU I am talking about is arm-smmu and it DT binding does not give much idea about handling such cases. Have tested this patch with HCI controller with IOMMU attached. Changes Since V1: - Fixed build issue as reported by Kbuild test robot. diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index a355d98..9a1374e 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -7781,6 +7781,9 @@ EXPORT_SYMBOL_GPL(ufshcd_dealloc_host); */ static int ufshcd_set_dma_mask(struct ufs_hba *hba) { + if (hba->vops && hba->vops->set_dma_mask) + return hba->vops->set_dma_mask(hba); + if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) { if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64))) return 0; diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h index 1332e54..89c6dae 100644 --- a/drivers/scsi/ufs/ufshcd.h +++ b/drivers/scsi/ufs/ufshcd.h @@ -297,6 +297,7 @@ struct ufs_pwr_mode_info { * @resume: called during host controller PM callback * @dbg_register_dump: used to dump controller debug information * @phy_initialization: used to initialize phys + * @set_dma_mask: used to set variant specific DMA mask */ struct ufs_hba_variant_ops { const char *name; @@ -325,6 +326,7 @@ struct ufs_hba_variant_ops { int (*resume)(struct ufs_hba *, enum ufs_pm_op); void (*dbg_register_dump)(struct ufs_hba *hba); int (*phy_initialization)(struct ufs_hba *); + int (*set_dma_mask)(struct ufs_hba *hba); }; /* clock gating state */