Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ wit the following convention:
	(linux,contiguous-region);
	(linux,default-contiguous-region);
	(linux,reserve-region);
	(linux,memory-limit);
        label = (unique_name);
};

@@ -52,6 +53,11 @@ linux,default-contiguous-region: property indicating that the region
linux,reserve-region: property indicating that the contiguous memory will
		not be given back to the system allocator. The memory be
		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
		cma region with a given device. The label is optional;
		if the label is not given the client is responsible for
+8 −3
Original line number Diff line number Diff line
@@ -222,6 +222,7 @@ int __init cma_fdt_scan(unsigned long node, const char *uname,
	bool in_system;
	unsigned long size_cells = dt_root_size_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))
		return 0;
@@ -245,9 +246,13 @@ int __init cma_fdt_scan(unsigned long node, const char *uname,
	in_system =
		of_get_flat_dt_prop(node, "linux,reserve-region", NULL) ? 0 : 1;

	pr_info("Found %s, memory base %lx, size %ld MiB\n", uname,
		(unsigned long)base, (unsigned long)size / SZ_1M);
	dma_contiguous_reserve_area(size, &base, MEMBLOCK_ALLOC_ANYWHERE, name,
	prop = of_get_flat_dt_prop(node, "linux,memory-limit", NULL);
	if (prop)
		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);

	return 0;