aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/dma-contiguous.c
diff options
context:
space:
mode:
authorVitaly Andrianov <vitalya@ti.com>2012-12-05 09:29:25 -0500
committerMarek Szyprowski <m.szyprowski@samsung.com>2012-12-11 03:28:09 -0500
commit4009793e15d44469da1547a46ab129cc08ffa503 (patch)
tree7d5e89b42669f647278d21284517f3256d051259 /drivers/base/dma-contiguous.c
parent387870f2d6d679746020fa8e25ef786ff338dc98 (diff)
drivers: cma: represent physical addresses as phys_addr_t
This commit changes the CMA early initialization code to use phys_addr_t for representing physical addresses instead of unsigned long. Without this change, among other things, dma_declare_contiguous() simply discards any memory regions whose address is not representable as unsigned long. This is a problem on 32-bit PAE machines where unsigned long is 32-bit but physical address space is larger. Signed-off-by: Vitaly Andrianov <vitalya@ti.com> Signed-off-by: Cyril Chemparathy <cyril@ti.com> Acked-by: Michal Nazarewicz <mina86@mina86.com> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Diffstat (limited to 'drivers/base/dma-contiguous.c')
-rw-r--r--drivers/base/dma-contiguous.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/base/dma-contiguous.c b/drivers/base/dma-contiguous.c
index 612afcc5a938..0ca54421ce97 100644
--- a/drivers/base/dma-contiguous.c
+++ b/drivers/base/dma-contiguous.c
@@ -57,8 +57,8 @@ struct cma *dma_contiguous_default_area;
57 * Users, who want to set the size of global CMA area for their system 57 * Users, who want to set the size of global CMA area for their system
58 * should use cma= kernel parameter. 58 * should use cma= kernel parameter.
59 */ 59 */
60static const unsigned long size_bytes = CMA_SIZE_MBYTES * SZ_1M; 60static const phys_addr_t size_bytes = CMA_SIZE_MBYTES * SZ_1M;
61static long size_cmdline = -1; 61static phys_addr_t size_cmdline = -1;
62 62
63static int __init early_cma(char *p) 63static int __init early_cma(char *p)
64{ 64{
@@ -70,7 +70,7 @@ early_param("cma", early_cma);
70 70
71#ifdef CONFIG_CMA_SIZE_PERCENTAGE 71#ifdef CONFIG_CMA_SIZE_PERCENTAGE
72 72
73static unsigned long __init __maybe_unused cma_early_percent_memory(void) 73static phys_addr_t __init __maybe_unused cma_early_percent_memory(void)
74{ 74{
75 struct memblock_region *reg; 75 struct memblock_region *reg;
76 unsigned long total_pages = 0; 76 unsigned long total_pages = 0;
@@ -88,7 +88,7 @@ static unsigned long __init __maybe_unused cma_early_percent_memory(void)
88 88
89#else 89#else
90 90
91static inline __maybe_unused unsigned long cma_early_percent_memory(void) 91static inline __maybe_unused phys_addr_t cma_early_percent_memory(void)
92{ 92{
93 return 0; 93 return 0;
94} 94}
@@ -106,7 +106,7 @@ static inline __maybe_unused unsigned long cma_early_percent_memory(void)
106 */ 106 */
107void __init dma_contiguous_reserve(phys_addr_t limit) 107void __init dma_contiguous_reserve(phys_addr_t limit)
108{ 108{
109 unsigned long selected_size = 0; 109 phys_addr_t selected_size = 0;
110 110
111 pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit); 111 pr_debug("%s(limit %08lx)\n", __func__, (unsigned long)limit);
112 112
@@ -126,7 +126,7 @@ void __init dma_contiguous_reserve(phys_addr_t limit)
126 126
127 if (selected_size) { 127 if (selected_size) {
128 pr_debug("%s: reserving %ld MiB for global area\n", __func__, 128 pr_debug("%s: reserving %ld MiB for global area\n", __func__,
129 selected_size / SZ_1M); 129 (unsigned long)selected_size / SZ_1M);
130 130
131 dma_declare_contiguous(NULL, selected_size, 0, limit); 131 dma_declare_contiguous(NULL, selected_size, 0, limit);
132 } 132 }
@@ -227,11 +227,11 @@ core_initcall(cma_init_reserved_areas);
227 * called by board specific code when early allocator (memblock or bootmem) 227 * called by board specific code when early allocator (memblock or bootmem)
228 * is still activate. 228 * is still activate.
229 */ 229 */
230int __init dma_declare_contiguous(struct device *dev, unsigned long size, 230int __init dma_declare_contiguous(struct device *dev, phys_addr_t size,
231 phys_addr_t base, phys_addr_t limit) 231 phys_addr_t base, phys_addr_t limit)
232{ 232{
233 struct cma_reserved *r = &cma_reserved[cma_reserved_count]; 233 struct cma_reserved *r = &cma_reserved[cma_reserved_count];
234 unsigned long alignment; 234 phys_addr_t alignment;
235 235
236 pr_debug("%s(size %lx, base %08lx, limit %08lx)\n", __func__, 236 pr_debug("%s(size %lx, base %08lx, limit %08lx)\n", __func__,
237 (unsigned long)size, (unsigned long)base, 237 (unsigned long)size, (unsigned long)base,
@@ -268,10 +268,6 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size,
268 if (!addr) { 268 if (!addr) {
269 base = -ENOMEM; 269 base = -ENOMEM;
270 goto err; 270 goto err;
271 } else if (addr + size > ~(unsigned long)0) {
272 memblock_free(addr, size);
273 base = -EINVAL;
274 goto err;
275 } else { 271 } else {
276 base = addr; 272 base = addr;
277 } 273 }
@@ -285,14 +281,14 @@ int __init dma_declare_contiguous(struct device *dev, unsigned long size,
285 r->size = size; 281 r->size = size;
286 r->dev = dev; 282 r->dev = dev;
287 cma_reserved_count++; 283 cma_reserved_count++;
288 pr_info("CMA: reserved %ld MiB at %08lx\n", size / SZ_1M, 284 pr_info("CMA: reserved %ld MiB at %08lx\n", (unsigned long)size / SZ_1M,
289 (unsigned long)base); 285 (unsigned long)base);
290 286
291 /* Architecture specific contiguous memory fixup. */ 287 /* Architecture specific contiguous memory fixup. */
292 dma_contiguous_early_fixup(base, size); 288 dma_contiguous_early_fixup(base, size);
293 return 0; 289 return 0;
294err: 290err:
295 pr_err("CMA: failed to reserve %ld MiB\n", size / SZ_1M); 291 pr_err("CMA: failed to reserve %ld MiB\n", (unsigned long)size / SZ_1M);
296 return base; 292 return base;
297} 293}
298 294