MIPS: replace add_memory_region with memblock

add_memory_region was the old interface for registering memory and
was already changed to used memblock internaly. Replace it by
directly calling memblock functions.

Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
This commit is contained in:
Thomas Bogendoerfer 2020-10-09 14:14:46 +02:00
parent 73826d604b
commit e7ae8d174e
28 changed files with 82 additions and 149 deletions

View file

@ -91,45 +91,6 @@ unsigned long ARCH_PFN_OFFSET;
EXPORT_SYMBOL(ARCH_PFN_OFFSET);
#endif
void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)
{
/*
* Note: This function only exists for historical reason,
* new code should use memblock_add or memblock_add_node instead.
*/
/*
* If the region reaches the top of the physical address space, adjust
* the size slightly so that (start + size) doesn't overflow
*/
if (start + size - 1 == PHYS_ADDR_MAX)
--size;
/* Sanity check */
if (start + size < start) {
pr_warn("Trying to add an invalid memory region, skipped\n");
return;
}
if (start < PHYS_OFFSET)
return;
memblock_add(start, size);
/* Reserve any memory except the ordinary RAM ranges. */
switch (type) {
case BOOT_MEM_RAM:
break;
case BOOT_MEM_NOMAP: /* Discard the range from the system. */
memblock_remove(start, size);
break;
default: /* Reserve the rest of the memory types at boot time */
memblock_reserve(start, size);
break;
}
}
void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_addr_t sz_max)
{
void *dm = &detect_magic;
@ -146,7 +107,7 @@ void __init detect_memory_region(phys_addr_t start, phys_addr_t sz_min, phys_add
((unsigned long long) sz_min) / SZ_1M,
((unsigned long long) sz_max) / SZ_1M);
add_memory_region(start, size, BOOT_MEM_RAM);
memblock_add(start, size);
}
/*
@ -400,7 +361,7 @@ static int __init early_parse_mem(char *p)
if (*p == '@')
start = memparse(p + 1, &p);
add_memory_region(start, size, BOOT_MEM_RAM);
memblock_add(start, size);
return 0;
}
@ -426,13 +387,14 @@ static int __init early_parse_memmap(char *p)
if (*p == '@') {
start_at = memparse(p+1, &p);
add_memory_region(start_at, mem_size, BOOT_MEM_RAM);
memblock_add(start_at, mem_size);
} else if (*p == '#') {
pr_err("\"memmap=nn#ss\" (force ACPI data) invalid on MIPS\n");
return -EINVAL;
} else if (*p == '$') {
start_at = memparse(p+1, &p);
add_memory_region(start_at, mem_size, BOOT_MEM_RESERVED);
memblock_add(start_at, mem_size);
memblock_reserve(start_at, mem_size);
} else {
pr_err("\"memmap\" invalid format!\n");
return -EINVAL;
@ -644,7 +606,7 @@ static void __init bootcmdline_init(void)
* arch_mem_init - initialize memory management subsystem
*
* o plat_mem_setup() detects the memory configuration and will record detected
* memory areas using add_memory_region.
* memory areas using memblock_add.
*
* At this stage the memory configuration of the system is known to the
* kernel but generic memory management system is still entirely uninitialized.