Skip to content

Commit 526fbae

Browse files
zongboxpalmer-dabbelt
authored andcommitted
riscv: Register System RAM as iomem resources
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]>
1 parent a2693fe commit 526fbae

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

arch/riscv/mm/init.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,40 @@ void mark_rodata_ro(void)
517517
}
518518
#endif
519519

520+
void __init resource_init(void)
521+
{
522+
struct memblock_region *region;
523+
524+
for_each_memblock(memory, region) {
525+
struct resource *res;
526+
527+
res = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
528+
if (!res)
529+
panic("%s: Failed to allocate %zu bytes\n", __func__,
530+
sizeof(struct resource));
531+
532+
if (memblock_is_nomap(region)) {
533+
res->name = "reserved";
534+
res->flags = IORESOURCE_MEM;
535+
} else {
536+
res->name = "System RAM";
537+
res->flags = IORESOURCE_SYSTEM_RAM | IORESOURCE_BUSY;
538+
}
539+
res->start = __pfn_to_phys(memblock_region_memory_base_pfn(region));
540+
res->end = __pfn_to_phys(memblock_region_memory_end_pfn(region)) - 1;
541+
542+
request_resource(&iomem_resource, res);
543+
}
544+
}
545+
520546
void __init paging_init(void)
521547
{
522548
setup_vm_final();
523549
memblocks_present();
524550
sparse_init();
525551
setup_zero_page();
526552
zone_sizes_init();
553+
resource_init();
527554
}
528555

529556
#ifdef CONFIG_SPARSEMEM_VMEMMAP

0 commit comments

Comments
 (0)