Skip to content
Snippets Groups Projects
Commit 79543b0d authored by Laura Abbott's avatar Laura Abbott
Browse files

cma: Add support for memory limits


Currently, when dynamically placing regions CMA will allow the memory
to be placed anywhere, including highmem. Due to system restrictions,
regions may need to be placed in a smaller range. Add support to
devicetree to allow these regions to have an upper bound on where they
will be placed.

Change-Id: Ib4ae194cbb6389e1091e7e04cfd331e9ab67ad05
Signed-off-by: default avatarLaura Abbott <lauraa@codeaurora.org>
parent 2d472712
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,7 @@ wit the following convention: ...@@ -37,6 +37,7 @@ wit the following convention:
(linux,contiguous-region); (linux,contiguous-region);
(linux,default-contiguous-region); (linux,default-contiguous-region);
(linux,reserve-region); (linux,reserve-region);
(linux,memory-limit);
label = (unique_name); label = (unique_name);
}; };
...@@ -52,6 +53,11 @@ linux,default-contiguous-region: property indicating that the region ...@@ -52,6 +53,11 @@ linux,default-contiguous-region: property indicating that the region
linux,reserve-region: property indicating that the contiguous memory will linux,reserve-region: property indicating that the contiguous memory will
not be given back to the system allocator. The memory be not be given back to the system allocator. The memory be
always be available for contiguous use. always be available for contiguous use.
linux,memory-limit: property specifying an upper bound on the physical address
of the region if the region is placed dynamically. If no limit
is specificed, the region may be placed anywhere in the physical
address space. 0 may be used to specify lowmem (i.e. the region
will be placed in the direct mapped lowmem region)
label: an internal name used for automatically associating the label: an internal name used for automatically associating the
cma region with a given device. The label is optional; cma region with a given device. The label is optional;
if the label is not given the client is responsible for if the label is not given the client is responsible for
......
...@@ -222,6 +222,7 @@ int __init cma_fdt_scan(unsigned long node, const char *uname, ...@@ -222,6 +222,7 @@ int __init cma_fdt_scan(unsigned long node, const char *uname,
bool in_system; bool in_system;
unsigned long size_cells = dt_root_size_cells; unsigned long size_cells = dt_root_size_cells;
unsigned long addr_cells = dt_root_addr_cells; unsigned long addr_cells = dt_root_addr_cells;
phys_addr_t limit = MEMBLOCK_ALLOC_ANYWHERE;
if (!of_get_flat_dt_prop(node, "linux,contiguous-region", NULL)) if (!of_get_flat_dt_prop(node, "linux,contiguous-region", NULL))
return 0; return 0;
...@@ -245,9 +246,13 @@ int __init cma_fdt_scan(unsigned long node, const char *uname, ...@@ -245,9 +246,13 @@ int __init cma_fdt_scan(unsigned long node, const char *uname,
in_system = in_system =
of_get_flat_dt_prop(node, "linux,reserve-region", NULL) ? 0 : 1; of_get_flat_dt_prop(node, "linux,reserve-region", NULL) ? 0 : 1;
pr_info("Found %s, memory base %lx, size %ld MiB\n", uname, prop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
(unsigned long)base, (unsigned long)size / SZ_1M); if (prop)
dma_contiguous_reserve_area(size, &base, MEMBLOCK_ALLOC_ANYWHERE, name, limit = be32_to_cpu(prop[0]);
pr_info("Found %s, memory base %lx, size %ld MiB, limit %pa\n", uname,
(unsigned long)base, (unsigned long)size / SZ_1M, &limit);
dma_contiguous_reserve_area(size, &base, limit, name,
in_system); in_system);
return 0; return 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment