From patchwork Wed Feb 6 02:06:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Seung-Woo Kim X-Patchwork-Id: 2101351 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 81B883FDF1 for ; Wed, 6 Feb 2013 02:09:58 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U2uPL-0006eq-1h; Wed, 06 Feb 2013 02:06:43 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1U2uPF-0006cU-GJ for linux-arm-kernel@lists.infradead.org; Wed, 06 Feb 2013 02:06:39 +0000 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MHS001S70HPBUC0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 06 Feb 2013 11:06:33 +0900 (KST) Received: from epcpsbgm2.samsung.com ( [203.254.230.42]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id B0.18.03880.9AAB1115; Wed, 06 Feb 2013 11:06:33 +0900 (KST) X-AuditID: cbfee61b-b7fb06d000000f28-5e-5111baa9045a Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id EF.08.03880.9AAB1115; Wed, 06 Feb 2013 11:06:33 +0900 (KST) Received: from localhost.localdomain ([10.90.8.56]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MHS004VQ0ITJ4M0@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 06 Feb 2013 11:06:33 +0900 (KST) From: Seung-Woo Kim To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH] ARM: dma-mapping: Add maximum alignment order for dma iommu buffers Date: Wed, 06 Feb 2013 11:06:43 +0900 Message-id: <1360116403-14112-1-git-send-email-sw0312.kim@samsung.com> X-Mailer: git-send-email 1.7.4.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrFLMWRmVeSWpSXmKPExsVy+t8zLd2VuwQDDX69MrLY9PgaqwOjx+Yl 9QGMUVw2Kak5mWWpRfp2CVwZT+Y/YilYLFBxfdIHxgbGft4uRk4OCQETiX+HvrFC2GISF+6t Z+ti5OIQEljGKLH25jQWmKLOVatZIBLTGSWWPb3LDpIQEljDJPFrhxaIzSagI7F/yW+wSSIC HhJPVpxjBrGZBTIlPk1YAVYvLBAmsbGhD8xmEVCV6Hl5HayGV8BN4sr8iVDLFCQW3HsLdoWE wBY2iV977kM1CEh8m3wIqIgDKCErsekAM0S9pMTBFTdYJjAKLmBkWMUomlqQXFCclJ5rpFec mFtcmpeul5yfu4kRElLSOxhXNVgcYhTgYFTi4b2hJxgoxJpYVlyZe4hRgoNZSYR3dytQiDcl sbIqtSg/vqg0J7X4EGMy0PKJzFKiyfnAcM8riTc0NjA2NLQ0NDO1NDUgTVhJnJfx1JMAIYH0 xJLU7NTUgtQimC1MHJxSDYym+2qVOb5sVHBdfEC74lPiVu7j4RufGtbnqL1hWjCv4fXtmp0a +53UXtopXDn3S6v6gsParz0d7+72RM5I0unw3uaQY31J5UsH82ZplU01cZuO6EZrbuEoUTv5 bbrjjy9JvKwPBRbt+OEgwRJZZyff4Vj3drWG36nN8yPb4ns31N/MaP0msU+JpTgj0VCLuag4 EQB9AcedbQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkkeLIzCtJLcpLzFFi42I5/e+xoO7KXYKBBv2/NSw2Pb7G6sDosXlJ fQBjVAOjTUZqYkpqkUJqXnJ+SmZeuq2Sd3C8c7ypmYGhrqGlhbmSQl5ibqqtkotPgK5bZg7Q VCWFssScUqBQQGJxsZK+HaYJoSFuuhYwjRG6viFBcD1GBmggYR1jxpP5j1gKFgtUXJ/0gbGB sZ+3i5GTQ0LARKJz1WoWCFtM4sK99WxdjFwcQgLTGSWWPb3LDpIQEljDJPFrhxaIzSagI7F/ yW9WEFtEwEPiyYpzzCA2s0CmxKcJK8DqhQXCJDY29IHZLAKqEj0vr4PV8Aq4SVyZPxFqmYLE gntv2SYwci9gZFjFKJpakFxQnJSea6RXnJhbXJqXrpecn7uJERywz6R3MK5qsDjEKMDBqMTD e0NPMFCINbGsuDL3EKMEB7OSCO/uVqAQb0piZVVqUX58UWlOavEhxmSg7ROZpUST84HRlFcS b2hsYmZkaWRmbGJubEyasJI4L+OpJwFCAumJJanZqakFqUUwW5g4OKUaGOOfm9b0yLmeDOgS khFIFtPd99RlWjeX/ovK3rCfT+bqs/uzljfyRLiLzGKYl841qfHYjIS9cuEMJboW5/4eKGxd 3VIQnL/Va++UmOyzaqI5PHslcmfOV65bJh1/5/3Td2XH53ObnmfgeSOz4BHrtYYHvx/uv79N vO6OvlttW96v4oDa5tMWSizFGYmGWsxFxYkAgW1LFJwCAAA= DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130205_210637_795107_EDFD03F3 X-CRM114-Status: GOOD ( 12.87 ) X-Spam-Score: -7.5 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.5 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [203.254.224.25 listed in list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 HDRS_LCASE Odd capitalization of message header Cc: sw0312.kim@samsung.com, kyungmin.park@samsung.com, linux@arm.linux.org.uk, m.szyprowski@samsung.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Alignment order for a dma iommu buffer is set by buffer size. For large buffer, it is a waste of iommu address space. So configurable parameter to limit maximum alignment order can reduce the waste. Signed-off-by: Seung-Woo Kim Signed-off-by: Kyungmin.park --- arch/arm/Kconfig | 21 +++++++++++++++++++++ arch/arm/mm/dma-mapping.c | 3 +++ 2 files changed, 24 insertions(+), 0 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 67874b8..4e89112 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -75,6 +75,27 @@ config ARM_DMA_USE_IOMMU select ARM_HAS_SG_CHAIN select NEED_SG_DMA_LENGTH +if ARM_DMA_USE_IOMMU + +config ARM_DMA_IOMMU_ALIGNMENT + int "Maximum PAGE_SIZE order of alignment for DMA IOMMU buffers" + range 4 9 + default 8 + help + DMA mapping framework by default aligns all buffers to the smallest + PAGE_SIZE order which is greater than or equal to the requested buffer + size. This works well for buffers up to a few hundreds kilobytes, but + for larger buffers it just a waste of address space. Drivers which has + relatively small addressing window (like 64Mib) might run out of + virtual space with just a few allocations. + + With this parameter you can specify the maximum PAGE_SIZE order for + DMA IOMMU buffers. Larger buffers will be aligned only to this + specified order. The order is expressed as a power of two multiplied + by the PAGE_SIZE. + +endif + config HAVE_PWM bool diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 076c26d..4cce854 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -1002,6 +1002,9 @@ static inline dma_addr_t __alloc_iova(struct dma_iommu_mapping *mapping, unsigned int count, start; unsigned long flags; + if (order > ARM_DMA_IOMMU_ALIGNMENT) + order = ARM_DMA_IOMMU_ALIGNMENT; + count = ((PAGE_ALIGN(size) >> PAGE_SHIFT) + (1 << mapping->order) - 1) >> mapping->order;