Skip to content

Commit c40dd2f

Browse files
antonblanchardozbenh
authored andcommitted
powerpc: Add System RAM to /proc/iomem
We've resisted adding System RAM to /proc/iomem because it is the wrong place for it. Unfortunately we continue to find tools that rely on this behaviour so give up and add it in. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
1 parent 88cf11b commit c40dd2f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

arch/powerpc/mm/mem.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <linux/suspend.h>
3535
#include <linux/memblock.h>
3636
#include <linux/hugetlb.h>
37+
#include <linux/slab.h>
3738

3839
#include <asm/pgalloc.h>
3940
#include <asm/prom.h>
@@ -555,3 +556,32 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address,
555556
book3e_hugetlb_preload(vma->vm_mm, address, *ptep);
556557
#endif
557558
}
559+
560+
/*
561+
* System memory should not be in /proc/iomem but various tools expect it
562+
* (eg kdump).
563+
*/
564+
static int add_system_ram_resources(void)
565+
{
566+
struct memblock_region *reg;
567+
568+
for_each_memblock(memory, reg) {
569+
struct resource *res;
570+
unsigned long base = reg->base;
571+
unsigned long size = reg->size;
572+
573+
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
574+
WARN_ON(!res);
575+
576+
if (res) {
577+
res->name = "System RAM";
578+
res->start = base;
579+
res->end = base + size - 1;
580+
res->flags = IORESOURCE_MEM;
581+
WARN_ON(request_resource(&iomem_resource, res) < 0);
582+
}
583+
}
584+
585+
return 0;
586+
}
587+
subsys_initcall(add_system_ram_resources);

0 commit comments

Comments
 (0)