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

Commit 94f79810 authored by Jiacheng Zheng's avatar Jiacheng Zheng
Browse files

drivers: of: Add early param memrsv



We need to do memory hotplug, the most intuitive way is
to change dtsi file. But we cannot do that since dtsi
is shared among all projects. So we add one more early
param to carve out memory for hotplug through command
line. Other projects won't be influenced since they do
not have this param in their command line.

Change-Id: I790a71cb82ecd30302a7d1ba4d2c07fccd5d6d7c
Signed-off-by: default avatarJiacheng Zheng <jiaczhen@codeaurora.org>
parent 1dd9d0a1
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -603,6 +603,52 @@ void *initial_boot_params;

static u32 of_fdt_crc32;

/*
 * Reserve memory via command line if needed.
 */
static int __init early_memory_reserve(char *p)
{
	phys_addr_t base, size;
	int nomap;
	char *endp = p;

	while (1) {
		base = memparse(endp, &endp);
		if (base && (*endp == ',')) {
			size = memparse(endp + 1, &endp);
			if (size && (*endp == ',')) {
				if (memcmp(endp + 1, "nomap", 5) == 0) {
					nomap = 1;
					endp += 6;
				} else if (memcmp(endp + 1, "map", 3) == 0) {
					nomap = 0;
					endp += 4;
				} else
					break;

				if (early_init_dt_reserve_memory_arch(base,
					size, nomap) == 0)
					pr_debug(
					"Early reserved memory: region : base %pa, size %ld MiB\n",
					&base, (unsigned long)size / SZ_1M);
				else
					pr_info(
					"Early reserved memory: failed : base %pa, size %ld MiB\n",
					&base, (unsigned long)size / SZ_1M);

				if (*endp == ';')
					endp++;
				else
					break;
			} else
				break;
		} else
			break;
	}
	return 0;
}
early_param("memrsv", early_memory_reserve);

/**
 * res_mem_reserve_reg() - reserve all memory described in 'reg' property
 */