1 From dhobsong@igel.co.jp Mon Oct 29 00:54:00 2012
2 From: Damian Hobson-Garcia <dhobsong@igel.co.jp>
3 Date: Mon, 29 Oct 2012 16:51:10 +0900
4 Subject: [PATCH v2 53/58] ARM: DMA-Mapping: add function for setting coherent pool size from platform code
5 To: greg@kroah.com, laurent.pinchart@ideasonboard.com, horms@verge.net.au
6 Cc: ltsi-dev@lists.linuxfoundation.org, dhobsong@igel.co.jp
7 Message-ID: <1351497075-32717-54-git-send-email-dhobsong@igel.co.jp>
10 From: Marek Szyprowski <m.szyprowski@samsung.com>
12 Some platforms might require to increase atomic coherent pool to make
13 sure that their device will be able to allocate all their buffers from
14 atomic context. This function can be also used to decrease atomic
15 coherent pool size if coherent allocations are not used for the given
18 Suggested-by: Josh Coombs <josh.coombs@gmail.com>
19 Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
20 (cherry picked from commit 6e5267aa543817015edb4a65c66e15f9809f92bd)
22 Signed-off-by: Damian Hobson-Garcia <dhobsong@igel.co.jp>
24 arch/arm/include/asm/dma-mapping.h | 7 +++++++
25 arch/arm/mm/dma-mapping.c | 19 ++++++++++++++++++-
26 2 files changed, 25 insertions(+), 1 deletions(-)
28 diff --git a/arch/arm/include/asm/dma-mapping.h b/arch/arm/include/asm/dma-mapping.h
29 index a048033..b5745a8 100644
30 --- a/arch/arm/include/asm/dma-mapping.h
31 +++ b/arch/arm/include/asm/dma-mapping.h
32 @@ -203,6 +203,13 @@ static inline void dma_free_writecombine(struct device *dev, size_t size,
36 + * This can be called during early boot to increase the size of the atomic
37 + * coherent DMA pool above the default value of 256KiB. It must be called
38 + * before postcore_initcall.
40 +extern void __init init_dma_coherent_pool_size(unsigned long size);
43 * This can be called during boot to increase the size of the consistent
44 * DMA region above it's default value of 2MB. It must be called before the
45 * memory allocator is initialised, i.e. before any core_initcall.
46 diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
47 index 258da10..3ff2585 100644
48 --- a/arch/arm/mm/dma-mapping.c
49 +++ b/arch/arm/mm/dma-mapping.c
50 @@ -266,6 +266,8 @@ static void __dma_free_remap(void *cpu_addr, size_t size)
54 +#define DEFAULT_DMA_COHERENT_POOL_SIZE SZ_256K
59 @@ -276,7 +278,7 @@ struct dma_pool {
62 static struct dma_pool atomic_pool = {
64 + .size = DEFAULT_DMA_COHERENT_POOL_SIZE,
67 static int __init early_coherent_pool(char *p)
68 @@ -286,6 +288,21 @@ static int __init early_coherent_pool(char *p)
70 early_param("coherent_pool", early_coherent_pool);
72 +void __init init_dma_coherent_pool_size(unsigned long size)
75 + * Catch any attempt to set the pool size too late.
77 + BUG_ON(atomic_pool.vaddr);
80 + * Set architecture specific coherent pool size only if
81 + * it has not been changed by kernel command line parameter.
83 + if (atomic_pool.size == DEFAULT_DMA_COHERENT_POOL_SIZE)
84 + atomic_pool.size = size;
88 * Initialise the coherent pool for atomic allocations.