Skip to content

Commit

Permalink
riscv: Register System RAM as iomem resources
Browse files Browse the repository at this point in the history
Add System RAM to /proc/iomem, various tools expect it such as kdump.
It is also needed for page_is_ram API which checks the specified address
whether registered as System RAM in iomem_resource list.

Signed-off-by: Zong Li <[email protected]>
[Palmer: check MEMBLOCK_NOMAP]
Signed-off-by: Palmer Dabbelt <[email protected]>
  • Loading branch information
zongbox authored and palmer-dabbelt committed Jul 9, 2020
1 parent a2693fe commit 526fbae
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions arch/riscv/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,40 @@ void mark_rodata_ro(void)
}
#endif

void __init resource_init(void)
{
struct memblock_region *region;

for_each_memblock(memory, region) {
struct resource *res;

res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
if (!res)
panic("%s: Failed to allocate %zu bytes\n", __func__,
sizeof(struct resource));

if (memblock_is_nomap(region)) {
res->name = "reserved";
res->flags = IORESOURCE_MEM;
} else {
res->name = "System RAM";
res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
}
res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;

request_resource(&iomem_resource, res);
}
}

void __init paging_init(void)
{
setup_vm_final();
memblocks_present();
sparse_init();
setup_zero_page();
zone_sizes_init();
resource_init();
}

#ifdef CONFIG_SPARSEMEM_VMEMMAP
Expand Down

0 comments on commit 526fbae

Please sign in to comment.