From patchwork Wed May 11 12:15:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kumar X-Patchwork-Id: 12846974 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6CBFDC433FE for ; Thu, 12 May 2022 03:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:Message-Id:Date: Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: List-Owner; bh=yEdVbfEN9/dblYZmOSAR3d6RNgrcM4NoxdNJSnNLJNs=; b=q8b1s7IrNbR4IP YpBA6gAS5LCFda0wT2XSVOsUsQjwXPnByNeJcGbls+CVsDuz5TUuvIBq/INI2fZl+kP3lwn67AtIE oIYnXdV7C2ZT4Wgm9IA/v/wKIGwH5zs/bc7rJmlI0PC2CxwarX6QyRQYoTGqh6NVPRIAeVs+sHlEs 7efDngO7ctEQbqnGWj8gPNiosCNPfr+9CchsZUDndW+jvIfAWpi7Z+itAygozOZOtGIKJ9xo3QSOO Yhq+SP/IXFs1Ncv+7oaIGMl7O0stR7EhRC/fjlkbEpNqInDI4SSAYPStCdPHWXR+ym94+r2tdWWGI +fYngapQ4q/5oklbHPMA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nozfj-009hvY-UL; Thu, 12 May 2022 03:39:28 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nozfe-009hsS-Pr for linux-arm-kernel@lists.infradead.org; Thu, 12 May 2022 03:39:25 +0000 Received: from epcas5p1.samsung.com (unknown [182.195.41.39]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20220512033910epoutp015563bb51af298317596c6c27e9ca7b93~uPmzu2Feq1376613766epoutp01X for ; Thu, 12 May 2022 03:39:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20220512033910epoutp015563bb51af298317596c6c27e9ca7b93~uPmzu2Feq1376613766epoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1652326750; bh=/xvg08mm/FdFaeSMWR962Fm009CzGXkQON5XmH+sZS0=; h=From:To:Cc:Subject:Date:References:From; b=UTkFREidoBKi2WMzp8gfNcka9/FsgsWJJSqZYPKVau9+PyudUtNzyw4vLfpJUkfZf O0VNGPTCXO4xqIGZpIJtt1NxME9EQ1oE3KdDeys5+a9WDXZL7bYNTHlxMBUABepIji V6U/Bz1VtQZ+mjXBz1kPJJc1BTpFtSTBct7Pqdmw= Received: from epsnrtp3.localdomain (unknown [182.195.42.164]) by epcas5p2.samsung.com (KnoxPortal) with ESMTP id 20220512033909epcas5p2e304c55788557dbc1da7cf9df8346359~uPmy6FGiG2890628906epcas5p26; Thu, 12 May 2022 03:39:09 +0000 (GMT) Received: from epsmges5p1new.samsung.com (unknown [182.195.38.181]) by epsnrtp3.localdomain (Postfix) with ESMTP id 4KzHZK3gKWz4x9QC; Thu, 12 May 2022 03:39:05 +0000 (GMT) Received: from epcas5p2.samsung.com ( [182.195.41.40]) by epsmges5p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 3C.51.10063.9518C726; Thu, 12 May 2022 12:39:05 +0900 (KST) Received: from epsmtrp1.samsung.com (unknown [182.195.40.13]) by epcas5p2.samsung.com (KnoxPortal) with ESMTPA id 20220511121425epcas5p256b55554b32dc58566827818a817ac44~uC-YgTXlW1315313153epcas5p2Y; Wed, 11 May 2022 12:14:25 +0000 (GMT) Received: from epsmgms1p1new.samsung.com (unknown [182.195.42.41]) by epsmtrp1.samsung.com (KnoxPortal) with ESMTP id 20220511121425epsmtrp1b2d76ae860b697eecdb90578918f70d9~uC-YfZeFg0052800528epsmtrp1B; Wed, 11 May 2022 12:14:24 +0000 (GMT) X-AuditID: b6c32a49-4b5ff7000000274f-05-627c8159e2e5 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p1new.samsung.com (Symantec Messaging Gateway) with SMTP id D6.0F.11276.0A8AB726; Wed, 11 May 2022 21:14:24 +0900 (KST) Received: from Jaguar.sa.corp.samsungelectronics.net (unknown [107.108.73.139]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20220511121423epsmtip20cb722f047df63de8dd763a9bec56aee~uC-XD16sg0269902699epsmtip2_; Wed, 11 May 2022 12:14:23 +0000 (GMT) From: Ajay Kumar To: linux-arm-kernel@lists.infradead.org, iommu@lists.linux-foundation.org, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com Cc: alim.akhtar@samsung.com, pankaj.dubey@samsung.com, ajaykumar.rs1989@gmail.com, Ajay Kumar Subject: [PATCH V2 0/6] IOMMU-DMA - support DMA_ATTR_LOW_ADDRESS attribute Date: Wed, 11 May 2022 17:45:38 +0530 Message-Id: <20220511121544.5998-1-ajaykumar.rs@samsung.com> X-Mailer: git-send-email 2.17.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEKsWRmVeSWpSXmKPExsWy7bCmhm5kY02SQcdKGYuvJ36zWRx4f5DF 4sG8bWwWC/ZbW3TO3sBusenxNVaLRVu/sFsc/PCE1aLljqkDp8eTg/OYPNbMW8PosXPWXXaP Tas62Tw2L6n3mHxjOaNH35ZVjAHsUdk2GamJKalFCql5yfkpmXnpt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+NgFupnluLIzCtJLcpLzFFi42LZdlhJXnfBiuokg51NJhZfT/xmszjw/iCL xYN529gsFuy3tuicvYHdYtPja6wWi7Z+Ybc4+OEJq0XLHVMHTo8nB+cxeayZt4bRY+esu+we m1Z1snlsXlLvMfnGckaPvi2rGAPYo7hsUlJzMstSi/TtErgyZvRaFqwVrOia/421gfEdbxcj B4eEgIlE+x/LLkYuDiGB3YwS7zsOsXUxcgLFZSSe73jKAmELS6z895wdoqiJSWLm2hNgRWwC 2hLbpt9kAUmICHQxSly9upcVJMEsUCfxdup0RhBbWMBLYs6CacwgNouAqsTzj3MYQTbzCthI 7DodBbFAXmL1hgPMExh5FjAyrGKUTC0ozk3PLTYsMMxLLdcrTswtLs1L10vOz93ECA4zLc0d jNtXfdA7xMjEwXiIUYKDWUmEd39fRZIQb0piZVVqUX58UWlOavEhRmkOFiVx3gtdJ+OFBNIT S1KzU1MLUotgskwcnFINTFN9tpeVbJLV9g6+Pyml8F40+3apb9ZOaUHRr2IvbDduvWVW57p/ rUf4FK2tgp0lV1escts3nT1re8+s172Wq2zXp9ickyi8wCeygu2mieUVBr63t3a9Zj0yY+aW eDbOtke6OtkXFwidCCyx5NyvPUm7sO2nTdz1Cy515uy3fVuN+KTz8+W9PS+Kxe76nJ+1yiAz 1v/vLL2dNadfG82OYvmytTHX4rehq4mV8l33VDOXy6UPQk/++TLxUSrft2fbZpSyNR+e6KkX Z33N4PtEPmntlY/Fdh+r2r+lgu2EfVmcj1YF/wH9ZQ/YNv5/neDN516m9fFV+t4WzWjfDxPv nuNt2CvMfqg4d0HtE8EkJZbijERDLeai4kQAyODziaICAAA= X-CMS-MailID: 20220511121425epcas5p256b55554b32dc58566827818a817ac44 X-Msg-Generator: CA X-Sendblock-Type: REQ_APPROVE CMS-TYPE: 105P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20220511121425epcas5p256b55554b32dc58566827818a817ac44 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220511_203923_259673_58653414 X-CRM114-Status: GOOD ( 18.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This patchset is a rebase of original patches from Marek Szyprowski: https://www.mail-archive.com/linux-kernel@vger.kernel.org/msg2321261.html The patches have been rebased on Joro's IOMMU tree "next" branch: https://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git This patchset is needed to address the IOVA address dependency issue between firmware buffers and other buffers in Samsung s5p-mfc driver. There have been few discussions in the past on how to find a generic soultion for this issue, ranging from adding an entirely new API to choose IOVA window[1], to adding a DMA attribute DMA_ATTR_LOW_ADDRESS which handles buffer allocation from lower address[2]. This is a continuation of initial work from Marek for approach [2]. Patches have been tested with latest version of Samsung s5p-mfc driver. Changes since V1: [PATCH V2 1/6] - Rebase on latest tree. [PATCH V2 2/6] - Rebase on latest tree. Added a missing check for iova_pfn in __iova_rcache_get() Discard changes from drivers/iommu/intel/iommu.c which are not necessary [PATCH V2 3/6] - Rebase on latest tree. [PATCH V2 4/6] - Rebase on latest tree [PATCH V2 5/6] - Rebase on latest tree [PATCH V2 6/6] - Rebase on latest tree. Marek Szyprowski (6): dma-mapping: add DMA_ATTR_LOW_ADDRESS attribute iommu: iova: properly handle 0 as a valid IOVA address iommu: iova: add support for 'first-fit' algorithm iommu: dma-iommu: refactor iommu_dma_alloc_iova() iommu: dma-iommu: add support for DMA_ATTR_LOW_ADDRESS media: platform: s5p-mfc: use DMA_ATTR_LOW_ADDRESS References: [1] https://lore.kernel.org/linux-iommu/20200811054912.GA301@infradead.org/ [2] https://lore.kernel.org/linux-mm/bff57cbe-2247-05e1-9059-d9c66d64c407@arm.com drivers/iommu/dma-iommu.c | 77 +++++++++++----- drivers/iommu/iova.c | 91 ++++++++++++++++++- .../media/platform/samsung/s5p-mfc/s5p_mfc.c | 8 +- include/linux/dma-mapping.h | 6 ++ include/linux/iova.h | 3 + 5 files changed, 156 insertions(+), 29 deletions(-) base-commit: faf93cfaadfaaff2a5c35d6301b45aa2f6e4ddb2