hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/openrisc/mm/init.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * OpenRISC idle.c
34 *
....@@ -8,11 +9,6 @@
89 * Modifications for the OpenRISC architecture:
910 * Copyright (C) 2003 Matjaz Breskvar <phoenix@bsemi.com>
1011 * Copyright (C) 2010-2011 Jonas Bonn <jonas@southpole.se>
11
- *
12
- * This program is free software; you can redistribute it and/or
13
- * modify it under the terms of the GNU General Public License
14
- * as published by the Free Software Foundation; either version
15
- * 2 of the License, or (at your option) any later version.
1612 */
1713
1814 #include <linux/signal.h>
....@@ -26,16 +22,13 @@
2622 #include <linux/mm.h>
2723 #include <linux/swap.h>
2824 #include <linux/smp.h>
29
-#include <linux/bootmem.h>
25
+#include <linux/memblock.h>
3026 #include <linux/init.h>
3127 #include <linux/delay.h>
3228 #include <linux/blkdev.h> /* for initrd_* */
3329 #include <linux/pagemap.h>
34
-#include <linux/memblock.h>
3530
36
-#include <asm/segment.h>
3731 #include <asm/pgalloc.h>
38
-#include <asm/pgtable.h>
3932 #include <asm/dma.h>
4033 #include <asm/io.h>
4134 #include <asm/tlb.h>
....@@ -51,17 +44,14 @@
5144
5245 static void __init zone_sizes_init(void)
5346 {
54
- unsigned long zones_size[MAX_NR_ZONES];
55
-
56
- /* Clear the zone sizes */
57
- memset(zones_size, 0, sizeof(zones_size));
47
+ unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
5848
5949 /*
6050 * We use only ZONE_NORMAL
6151 */
62
- zones_size[ZONE_NORMAL] = max_low_pfn;
52
+ max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
6353
64
- free_area_init(zones_size);
54
+ free_area_init(max_zone_pfn);
6555 }
6656
6757 extern const char _s_kernel_ro[], _e_kernel_ro[];
....@@ -74,29 +64,32 @@
7464 */
7565 static void __init map_ram(void)
7666 {
67
+ phys_addr_t start, end;
7768 unsigned long v, p, e;
7869 pgprot_t prot;
7970 pgd_t *pge;
71
+ p4d_t *p4e;
8072 pud_t *pue;
8173 pmd_t *pme;
8274 pte_t *pte;
75
+ u64 i;
8376 /* These mark extents of read-only kernel pages...
8477 * ...from vmlinux.lds.S
8578 */
86
- struct memblock_region *region;
8779
8880 v = PAGE_OFFSET;
8981
90
- for_each_memblock(memory, region) {
91
- p = (u32) region->base & PAGE_MASK;
92
- e = p + (u32) region->size;
82
+ for_each_mem_range(i, &start, &end) {
83
+ p = (u32) start & PAGE_MASK;
84
+ e = (u32) end;
9385
9486 v = (u32) __va(p);
9587 pge = pgd_offset_k(v);
9688
9789 while (p < e) {
9890 int j;
99
- pue = pud_offset(pge, v);
91
+ p4e = p4d_offset(pge, v);
92
+ pue = pud_offset(p4e, v);
10093 pme = pmd_offset(pue, v);
10194
10295 if ((u32) pue != (u32) pge || (u32) pme != (u32) pge) {
....@@ -106,7 +99,10 @@
10699 }
107100
108101 /* Alloc one page for holding PTE's... */
109
- pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
102
+ pte = memblock_alloc_raw(PAGE_SIZE, PAGE_SIZE);
103
+ if (!pte)
104
+ panic("%s: Failed to allocate page for PTEs\n",
105
+ __func__);
110106 set_pmd(pme, __pmd(_KERNPG_TABLE + __pa(pte)));
111107
112108 /* Fill the newly allocated page with PTE'S */
....@@ -125,7 +121,7 @@
125121 }
126122
127123 printk(KERN_INFO "%s: Memory: 0x%x-0x%x\n", __func__,
128
- region->base, region->base + region->size);
124
+ start, end);
129125 }
130126 }
131127
....@@ -213,23 +209,11 @@
213209 memset((void *)empty_zero_page, 0, PAGE_SIZE);
214210
215211 /* this will put all low memory onto the freelists */
216
- free_all_bootmem();
212
+ memblock_free_all();
217213
218214 mem_init_print_info(NULL);
219215
220216 printk("mem_init_done ...........................................\n");
221217 mem_init_done = 1;
222218 return;
223
-}
224
-
225
-#ifdef CONFIG_BLK_DEV_INITRD
226
-void free_initrd_mem(unsigned long start, unsigned long end)
227
-{
228
- free_reserved_area((void *)start, (void *)end, -1, "initrd");
229
-}
230
-#endif
231
-
232
-void free_initmem(void)
233
-{
234
- free_initmem_default(-1);
235219 }