forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-13 9d77db3c730780c8ef5ccd4b66403ff5675cfe4e
kernel/arch/hexagon/mm/init.c
....@@ -1,26 +1,13 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Memory subsystem initialization for Hexagon
34 *
45 * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved.
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License version 2 and
8
- * only version 2 as published by the Free Software Foundation.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18
- * 02110-1301, USA.
196 */
207
218 #include <linux/init.h>
229 #include <linux/mm.h>
23
-#include <linux/bootmem.h>
10
+#include <linux/memblock.h>
2411 #include <asm/atomic.h>
2512 #include <linux/highmem.h>
2613 #include <asm/tlb.h>
....@@ -67,7 +54,7 @@
6754 void __init mem_init(void)
6855 {
6956 /* No idea where this is actually declared. Seems to evade LXR. */
70
- free_all_bootmem();
57
+ memblock_free_all();
7158 mem_init_print_info(NULL);
7259
7360 /*
....@@ -82,29 +69,6 @@
8269 * kernel segment table's physical address.
8370 */
8471 init_mm.context.ptbase = __pa(init_mm.pgd);
85
-}
86
-
87
-/*
88
- * free_initmem - frees memory used by stuff declared with __init
89
- *
90
- * Todo: free pages between __init_begin and __init_end; possibly
91
- * some devtree related stuff as well.
92
- */
93
-void __ref free_initmem(void)
94
-{
95
-}
96
-
97
-/*
98
- * free_initrd_mem - frees... initrd memory.
99
- * @start - start of init memory
100
- * @end - end of init memory
101
- *
102
- * Apparently has to be passed the address of the initrd memory.
103
- *
104
- * Wrapped by #ifdef CONFIG_BLKDEV_INITRD
105
- */
106
-void free_initrd_mem(unsigned long start, unsigned long end)
107
-{
10872 }
10973
11074 void sync_icache_dcache(pte_t pte)
....@@ -127,7 +91,7 @@
12791 */
12892 void __init paging_init(void)
12993 {
130
- unsigned long zones_sizes[MAX_NR_ZONES] = {0, };
94
+ unsigned long max_zone_pfn[MAX_NR_ZONES] = {0, };
13195
13296 /*
13397 * This is not particularly well documented anywhere, but
....@@ -137,9 +101,9 @@
137101 * adjust accordingly.
138102 */
139103
140
- zones_sizes[ZONE_NORMAL] = max_low_pfn;
104
+ max_zone_pfn[ZONE_NORMAL] = max_low_pfn;
141105
142
- free_area_init(zones_sizes); /* sets up the zonelists and mem_map */
106
+ free_area_init(max_zone_pfn); /* sets up the zonelists and mem_map */
143107
144108 /*
145109 * Start of high memory area. Will probably need something more
....@@ -176,7 +140,6 @@
176140
177141 void __init setup_arch_memory(void)
178142 {
179
- int bootmap_size;
180143 /* XXX Todo: this probably should be cleaned up */
181144 u32 *segtable = (u32 *) &swapper_pg_dir[0];
182145 u32 *segtable_end;
....@@ -195,18 +158,22 @@
195158 bootmem_lastpg = PFN_DOWN((bootmem_lastpg << PAGE_SHIFT) &
196159 ~((BIG_KERNEL_PAGE_SIZE) - 1));
197160
161
+ memblock_add(PHYS_OFFSET,
162
+ (bootmem_lastpg - ARCH_PFN_OFFSET) << PAGE_SHIFT);
163
+
164
+ /* Reserve kernel text/data/bss */
165
+ memblock_reserve(PHYS_OFFSET,
166
+ (bootmem_startpg - ARCH_PFN_OFFSET) << PAGE_SHIFT);
198167 /*
199168 * Reserve the top DMA_RESERVE bytes of RAM for DMA (uncached)
200169 * memory allocation
201170 */
202
-
203171 max_low_pfn = bootmem_lastpg - PFN_DOWN(DMA_RESERVED_BYTES);
204172 min_low_pfn = ARCH_PFN_OFFSET;
205
- bootmap_size = init_bootmem_node(NODE_DATA(0), bootmem_startpg, min_low_pfn, max_low_pfn);
173
+ memblock_reserve(PFN_PHYS(max_low_pfn), DMA_RESERVED_BYTES);
206174
207175 printk(KERN_INFO "bootmem_startpg: 0x%08lx\n", bootmem_startpg);
208176 printk(KERN_INFO "bootmem_lastpg: 0x%08lx\n", bootmem_lastpg);
209
- printk(KERN_INFO "bootmap_size: %d\n", bootmap_size);
210177 printk(KERN_INFO "min_low_pfn: 0x%08lx\n", min_low_pfn);
211178 printk(KERN_INFO "max_low_pfn: 0x%08lx\n", max_low_pfn);
212179
....@@ -255,14 +222,6 @@
255222 __HVM_PDE_S_4KB;
256223 printk(KERN_INFO "*segtable = 0x%08x\n", *segtable);
257224 #endif
258
-
259
- /*
260
- * Free all the memory that wasn't taken up by the bootmap, the DMA
261
- * reserve, or kernel itself.
262
- */
263
- free_bootmem(PFN_PHYS(bootmem_startpg) + bootmap_size,
264
- PFN_PHYS(bootmem_lastpg - bootmem_startpg) - bootmap_size -
265
- DMA_RESERVED_BYTES);
266225
267226 /*
268227 * The bootmem allocator seemingly just lives to feed memory