Skip to content

Commit

Permalink
xtensa: handle memmap kernel option
Browse files Browse the repository at this point in the history
This option is useful for reserving memory regions for secondary cores
in AMP configurations.

Implement the following memmap variants:
- memmap=nn[KMG]@ss[KMG]: force usage of a specific region of memory;
- memmap=nn[KMG]$ss[KMG]: mark specified memory as reserved;
- memmap=nn[KMG]: set end of memory.

Signed-off-by: Max Filippov <[email protected]>
  • Loading branch information
jcmvbkbc committed Apr 1, 2014
1 parent 6232791 commit 06bd282
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions arch/xtensa/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ void __init setup_arch(char **cmdline_p)
__pa(&_Level6InterruptVector_text_end), 0);
#endif

parse_early_param();
bootmem_init();

unflatten_and_copy_device_tree();
Expand Down
50 changes: 50 additions & 0 deletions arch/xtensa/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,53 @@ void free_initmem(void)
{
free_initmem_default(-1);
}

static void __init parse_memmap_one(char *p)
{
char *oldp;
unsigned long start_at, mem_size;

if (!p)
return;

oldp = p;
mem_size = memparse(p, &p);
if (p == oldp)
return;

switch (*p) {
case '@':
start_at = memparse(p + 1, &p);
add_sysmem_bank(start_at, start_at + mem_size);
break;

case '$':
start_at = memparse(p + 1, &p);
mem_reserve(start_at, start_at + mem_size, 0);
break;

case 0:
mem_reserve(mem_size, 0, 0);
break;

default:
pr_warn("Unrecognized memmap syntax: %s\n", p);
break;
}
}

static int __init parse_memmap_opt(char *str)
{
while (str) {
char *k = strchr(str, ',');

if (k)
*k++ = 0;

parse_memmap_one(str);
str = k;
}

return 0;
}
early_param("memmap", parse_memmap_opt);

0 comments on commit 06bd282

Please sign in to comment.