forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
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,21 +22,17 @@
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>
4235 #include <asm/mmu_context.h>
43
-#include <asm/kmap_types.h>
4436 #include <asm/fixmap.h>
4537 #include <asm/tlbflush.h>
4638 #include <asm/sections.h>
....@@ -51,17 +43,14 @@
5143
5244 static void __init zone_sizes_init(void)
5345 {
54
- unsigned long zones_size[MAX_NR_ZONES];
55
-
56
- /* Clear the zone sizes */
57
- memset(zones_size, 0, sizeof(zones_size));
46
+ unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };
5847
5948 /*
6049 * We use only ZONE_NORMAL
6150 */
62
- zones_size[ZONE_NORMAL] = max_low_pfn;
51
+ max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
6352
64
- free_area_init(zones_size);
53
+ free_area_init(max_zone_pfn);
6554 }
6655
6756 extern const char _s_kernel_ro[], _e_kernel_ro[];
....@@ -74,29 +63,32 @@
7463 */
7564 static void __init map_ram(void)
7665 {
66
+ phys_addr_t start, end;
7767 unsigned long v, p, e;
7868 pgprot_t prot;
7969 pgd_t *pge;
70
+ p4d_t *p4e;
8071 pud_t *pue;
8172 pmd_t *pme;
8273 pte_t *pte;
74
+ u64 i;
8375 /* These mark extents of read-only kernel pages...
8476 * ...from vmlinux.lds.S
8577 */
86
- struct memblock_region *region;
8778
8879 v = PAGE_OFFSET;
8980
90
- for_each_memblock(memory, region) {
91
- p = (u32) region->base & PAGE_MASK;
92
- e = p + (u32) region->size;
81
+ for_each_mem_range(i, &start, &end) {
82
+ p = (u32) start & PAGE_MASK;
83
+ e = (u32) end;
9384
9485 v = (u32) __va(p);
9586 pge = pgd_offset_k(v);
9687
9788 while (p < e) {
9889 int j;
99
- pue = pud_offset(pge, v);
90
+ p4e = p4d_offset(pge, v);
91
+ pue = pud_offset(p4e, v);
10092 pme = pmd_offset(pue, v);
10193
10294 if ((u32) pue != (u32) pge || (u32) pme != (u32) pge) {
....@@ -106,7 +98,10 @@
10698 }
10799
108100 /* Alloc one page for holding PTE's... */
109
- pte = (pte_t *) __va(memblock_alloc(PAGE_SIZE, PAGE_SIZE));
101
+ pte = memblock_alloc_raw(PAGE_SIZE, PAGE_SIZE);
102
+ if (!pte)
103
+ panic("%s: Failed to allocate page for PTEs\n",
104
+ __func__);
110105 set_pmd(pme, __pmd(_KERNPG_TABLE + __pa(pte)));
111106
112107 /* Fill the newly allocated page with PTE'S */
....@@ -125,7 +120,7 @@
125120 }
126121
127122 printk(KERN_INFO "%s: Memory: 0x%x-0x%x\n", __func__,
128
- region->base, region->base + region->size);
123
+ start, end);
129124 }
130125 }
131126
....@@ -213,23 +208,11 @@
213208 memset((void *)empty_zero_page, 0, PAGE_SIZE);
214209
215210 /* this will put all low memory onto the freelists */
216
- free_all_bootmem();
211
+ memblock_free_all();
217212
218213 mem_init_print_info(NULL);
219214
220215 printk("mem_init_done ...........................................\n");
221216 mem_init_done = 1;
222217 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);
235218 }