Skip to content

Commit 9b9a59d

Browse files
fancerpaulburton
authored andcommitted
mips: Add reserve-nomap memory type support
It might be necessary to prevent the virtual mapping creation for a requested memory region. For instance there is a "no-map" property indicating exactly this feature. In this case we need to not only reserve the specified region by pretending it doesn't exist in the memory space, but completely remove the range from system just by removing it from memblock. The same way it's done in default early_init_dt_reserve_memory_arch() method. Signed-off-by: Serge Semin <[email protected]> Signed-off-by: Paul Burton <[email protected]> Cc: Ralf Baechle <[email protected]> Cc: James Hogan <[email protected]> Cc: Matt Redfearn <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: Thomas Bogendoerfer <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Stefan Agner <[email protected]> Cc: Stephen Rothwell <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Juergen Gross <[email protected]> Cc: [email protected] Cc: [email protected]
1 parent 4e50a35 commit 9b9a59d

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

arch/mips/include/asm/bootinfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ extern unsigned long mips_machtype;
9292
#define BOOT_MEM_ROM_DATA 2
9393
#define BOOT_MEM_RESERVED 3
9494
#define BOOT_MEM_INIT_RAM 4
95+
#define BOOT_MEM_NOMAP 5
9596

9697
/*
9798
* A memory map that's built upon what was determined

arch/mips/kernel/prom.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ void __init early_init_dt_add_memory_arch(u64 base, u64 size)
4747
int __init early_init_dt_reserve_memory_arch(phys_addr_t base,
4848
phys_addr_t size, bool nomap)
4949
{
50-
add_memory_region(base, size, BOOT_MEM_RESERVED);
50+
add_memory_region(base, size,
51+
nomap ? BOOT_MEM_NOMAP : BOOT_MEM_RESERVED);
52+
5153
return 0;
5254
}
5355

arch/mips/kernel/setup.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static bool __init __maybe_unused memory_region_available(phys_addr_t start,
178178
in_ram = true;
179179
break;
180180
case BOOT_MEM_RESERVED:
181+
case BOOT_MEM_NOMAP:
181182
if ((start >= start_ && start < end_) ||
182183
(start < start_ && start + size >= start_))
183184
free = false;
@@ -213,6 +214,9 @@ static void __init print_memory_map(void)
213214
case BOOT_MEM_RESERVED:
214215
printk(KERN_CONT "(reserved)\n");
215216
break;
217+
case BOOT_MEM_NOMAP:
218+
printk(KERN_CONT "(nomap)\n");
219+
break;
216220
default:
217221
printk(KERN_CONT "type %lu\n", boot_mem_map.map[i].type);
218222
break;
@@ -487,6 +491,9 @@ static void __init bootmem_init(void)
487491
switch (boot_mem_map.map[i].type) {
488492
case BOOT_MEM_RAM:
489493
break;
494+
case BOOT_MEM_NOMAP: /* Discard the range from the system. */
495+
memblock_remove(PFN_PHYS(start), PFN_PHYS(end - start));
496+
continue;
490497
default: /* Reserve the rest of the memory types at boot time */
491498
memblock_reserve(PFN_PHYS(start), PFN_PHYS(end - start));
492499
break;
@@ -861,6 +868,7 @@ static void __init resource_init(void)
861868
res->flags |= IORESOURCE_SYSRAM;
862869
break;
863870
case BOOT_MEM_RESERVED:
871+
case BOOT_MEM_NOMAP:
864872
default:
865873
res->name = "reserved";
866874
}

0 commit comments

Comments
 (0)