From patchwork Mon Aug 20 10:47:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 1347981 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 6E00DDFF0F for ; Mon, 20 Aug 2012 10:51:16 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3PWt-0008NF-Ce; Mon, 20 Aug 2012 10:48:19 +0000 Received: from mailout2.samsung.com ([203.254.224.25]) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1T3PWk-0008M7-7H for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2012 10:48:11 +0000 Received: from epcpsbgm1.samsung.com (mailout2.samsung.com [203.254.224.25]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M9100ATSVBV6IR0@mailout2.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2012 19:48:07 +0900 (KST) X-AuditID: cbfee61a-b7fc66d0000043b7-fe-503215e65794 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id 06.FD.17335.6E512305; Mon, 20 Aug 2012 19:48:06 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M91008OAVBT1S40@mmp2.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 20 Aug 2012 19:48:06 +0900 (KST) From: Marek Szyprowski To: linux-arm-kernel@lists.infradead.org, linaro-mm-sig@lists.linaro.org Subject: [PATCH 1/3] ARM: DMA-Mapping: add function for setting coherent pool size from platform code Date: Mon, 20 Aug 2012 12:47:26 +0200 Message-id: <1345459648-24263-2-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1345459648-24263-1-git-send-email-m.szyprowski@samsung.com> References: <1345459648-24263-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQd1nokYBBt8321hsenyN1YHRY/OS +gDGKC6blNSczLLUIn27BK6M7im/GQsWilR8aj/N1MB4SqCLkZNDQsBE4timZnYIW0ziwr31 bF2MXBxCAtMZJdbN/M4O4Wxmkji5+SMzSBWbgKFE19suNhBbRMBD4smKc8wgRcwCh5gkpj7f xQSSEBZIl7jU/JgVxGYRUJVY2rqPEcTmBWqYsbeVGWKdvMTT+31Agzg4OAU8JWasrwYJCwGV rHl8mXUCI+8CRoZVjKKpBckFxUnpuYZ6xYm5xaV56XrJ+bmbGME+fya1g3Flg8UhRgEORiUe 3pPTDQOEWBPLiitzDzFKcDArifBW/wUK8aYkVlalFuXHF5XmpBYfYpTmYFES5+XvA0oJpCeW pGanphakFsFkmTg4pRoY+4p9t25IF3kvxPfVwmrygqVFK/6HHju0ez1ncYj3o79+TfI3xX4J scZzcixclLqvzva07t7I7bx/rks5Pok+/dDydPlF5VUMgb7bclW/zdbkW/983tE3YcusVyed snVtN08z/xiSlCayKvNj9OE5CY6hFXZ7GibrLZsw4cikk8suTjqrnK59Q4mlOCPRUIu5qDgR AG+O5QH1AQAA X-TM-AS-MML: No X-Spam-Note: CRM114 invocation failed X-Spam-Score: -7.1 (-------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-7.1 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.2 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] Cc: Andrew Lunn , Russell King - ARM Linux , Jason Cooper , Arnd Bergmann , Aaro Koskinen , Josh Coombs , Kyungmin Park , Marek Szyprowski 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 Some platforms might require to increase atomic coherent pool to make sure that their device will be able to allocate all their buffers from atomic context. This function can be also used to decrease atomic coherent pool size if coherent allocations are not used for the given sub-platform. Suggested-by: Josh Coombs Signed-off-by: Marek Szyprowski --- arch/arm/include/asm/dma-mapping.h | 7 +++++++ arch/arm/mm/dma-mapping.c | 19 ++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletions(-) diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h index 2ae842d..a53940d 100644 --- a/arch/arm/include/asm/dma-mapping.h +++ b/arch/arm/include/asm/dma-mapping.h @@ -203,6 +203,13 @@ static inline void dma_free_writecombine(struct device *dev, size_t size, } /* + * This can be called during early boot to increase the size of the atomic + * coherent DMA pool above the default value of 256KiB. It must be called + * before postcore_initcall. + */ +extern void __init init_dma_coherent_pool_size(unsigned long size); + +/* * This can be called during boot to increase the size of the consistent * DMA region above it's default value of 2MB. It must be called before the * memory allocator is initialised, i.e. before any core_initcall. diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 4e7d118..d1cc9c1 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -267,6 +267,8 @@ static void __dma_free_remap(void *cpu_addr, size_t size) vunmap(cpu_addr); } +#define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K + struct dma_pool { size_t size; spinlock_t lock; @@ -277,7 +279,7 @@ struct dma_pool { }; static struct dma_pool atomic_pool = { - .size = SZ_256K, + .size = DEFAULT_DMA_COHERENT_POOL_SIZE, }; static int __init early_coherent_pool(char *p) @@ -287,6 +289,21 @@ static int __init early_coherent_pool(char *p) } early_param("coherent_pool", early_coherent_pool); +void __init init_dma_coherent_pool_size(unsigned long size) +{ + /* + * Catch any attempt to set the pool size too late. + */ + BUG_ON(atomic_pool.vaddr); + + /* + * Set architecture specific coherent pool size only if + * it has not been changed by kernel command line parameter. + */ + if (atomic_pool.size == DEFAULT_DMA_COHERENT_POOL_SIZE) + atomic_pool.size = size; +} + /* * Initialise the coherent pool for atomic allocations. */