xref: /linux/arch/arm64/mm/init.c (revision 86c8b27a01cf6c16fc159ade223cb2ccc70dc4b5)
1c1cc1552SCatalin Marinas /*
2c1cc1552SCatalin Marinas  * Based on arch/arm/mm/init.c
3c1cc1552SCatalin Marinas  *
4c1cc1552SCatalin Marinas  * Copyright (C) 1995-2005 Russell King
5c1cc1552SCatalin Marinas  * Copyright (C) 2012 ARM Ltd.
6c1cc1552SCatalin Marinas  *
7c1cc1552SCatalin Marinas  * This program is free software; you can redistribute it and/or modify
8c1cc1552SCatalin Marinas  * it under the terms of the GNU General Public License version 2 as
9c1cc1552SCatalin Marinas  * published by the Free Software Foundation.
10c1cc1552SCatalin Marinas  *
11c1cc1552SCatalin Marinas  * This program is distributed in the hope that it will be useful,
12c1cc1552SCatalin Marinas  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c1cc1552SCatalin Marinas  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14c1cc1552SCatalin Marinas  * GNU General Public License for more details.
15c1cc1552SCatalin Marinas  *
16c1cc1552SCatalin Marinas  * You should have received a copy of the GNU General Public License
17c1cc1552SCatalin Marinas  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18c1cc1552SCatalin Marinas  */
19c1cc1552SCatalin Marinas 
20c1cc1552SCatalin Marinas #include <linux/kernel.h>
21c1cc1552SCatalin Marinas #include <linux/export.h>
22c1cc1552SCatalin Marinas #include <linux/errno.h>
23c1cc1552SCatalin Marinas #include <linux/swap.h>
24c1cc1552SCatalin Marinas #include <linux/init.h>
25c1cc1552SCatalin Marinas #include <linux/bootmem.h>
26c1cc1552SCatalin Marinas #include <linux/mman.h>
27c1cc1552SCatalin Marinas #include <linux/nodemask.h>
28c1cc1552SCatalin Marinas #include <linux/initrd.h>
29c1cc1552SCatalin Marinas #include <linux/gfp.h>
30c1cc1552SCatalin Marinas #include <linux/memblock.h>
31c1cc1552SCatalin Marinas #include <linux/sort.h>
32c1cc1552SCatalin Marinas #include <linux/of_fdt.h>
3319e7640dSCatalin Marinas #include <linux/dma-mapping.h>
346ac2104dSLaura Abbott #include <linux/dma-contiguous.h>
35*86c8b27aSLeif Lindholm #include <linux/efi.h>
36c1cc1552SCatalin Marinas 
3708375198SCatalin Marinas #include <asm/fixmap.h>
38c1cc1552SCatalin Marinas #include <asm/sections.h>
39c1cc1552SCatalin Marinas #include <asm/setup.h>
40c1cc1552SCatalin Marinas #include <asm/sizes.h>
41c1cc1552SCatalin Marinas #include <asm/tlb.h>
42c1cc1552SCatalin Marinas 
43c1cc1552SCatalin Marinas #include "mm.h"
44c1cc1552SCatalin Marinas 
45c1cc1552SCatalin Marinas phys_addr_t memstart_addr __read_mostly = 0;
46c1cc1552SCatalin Marinas 
47ec2eaa73SRob Herring #ifdef CONFIG_BLK_DEV_INITRD
48c1cc1552SCatalin Marinas static int __init early_initrd(char *p)
49c1cc1552SCatalin Marinas {
50c1cc1552SCatalin Marinas 	unsigned long start, size;
51c1cc1552SCatalin Marinas 	char *endp;
52c1cc1552SCatalin Marinas 
53c1cc1552SCatalin Marinas 	start = memparse(p, &endp);
54c1cc1552SCatalin Marinas 	if (*endp == ',') {
55c1cc1552SCatalin Marinas 		size = memparse(endp + 1, NULL);
56c1cc1552SCatalin Marinas 
57ec2eaa73SRob Herring 		initrd_start = (unsigned long)__va(start);
58ec2eaa73SRob Herring 		initrd_end = (unsigned long)__va(start + size);
59c1cc1552SCatalin Marinas 	}
60c1cc1552SCatalin Marinas 	return 0;
61c1cc1552SCatalin Marinas }
62c1cc1552SCatalin Marinas early_param("initrd", early_initrd);
63ec2eaa73SRob Herring #endif
64c1cc1552SCatalin Marinas 
65d50314a6SCatalin Marinas /*
66d50314a6SCatalin Marinas  * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It
67d50314a6SCatalin Marinas  * currently assumes that for memory starting above 4G, 32-bit devices will
68d50314a6SCatalin Marinas  * use a DMA offset.
69d50314a6SCatalin Marinas  */
70d50314a6SCatalin Marinas static phys_addr_t max_zone_dma_phys(void)
71d50314a6SCatalin Marinas {
72d50314a6SCatalin Marinas 	phys_addr_t offset = memblock_start_of_DRAM() & GENMASK_ULL(63, 32);
73d50314a6SCatalin Marinas 	return min(offset + (1ULL << 32), memblock_end_of_DRAM());
74d50314a6SCatalin Marinas }
75d50314a6SCatalin Marinas 
76c1cc1552SCatalin Marinas static void __init zone_sizes_init(unsigned long min, unsigned long max)
77c1cc1552SCatalin Marinas {
78c1cc1552SCatalin Marinas 	struct memblock_region *reg;
79c1cc1552SCatalin Marinas 	unsigned long zone_size[MAX_NR_ZONES], zhole_size[MAX_NR_ZONES];
8019e7640dSCatalin Marinas 	unsigned long max_dma = min;
81c1cc1552SCatalin Marinas 
82c1cc1552SCatalin Marinas 	memset(zone_size, 0, sizeof(zone_size));
83c1cc1552SCatalin Marinas 
84c1cc1552SCatalin Marinas 	/* 4GB maximum for 32-bit only capable devices */
8519e7640dSCatalin Marinas 	if (IS_ENABLED(CONFIG_ZONE_DMA)) {
86d50314a6SCatalin Marinas 		max_dma = PFN_DOWN(max_zone_dma_phys());
8719e7640dSCatalin Marinas 		zone_size[ZONE_DMA] = max_dma - min;
8819e7640dSCatalin Marinas 	}
8919e7640dSCatalin Marinas 	zone_size[ZONE_NORMAL] = max - max_dma;
90c1cc1552SCatalin Marinas 
91c1cc1552SCatalin Marinas 	memcpy(zhole_size, zone_size, sizeof(zhole_size));
92c1cc1552SCatalin Marinas 
93c1cc1552SCatalin Marinas 	for_each_memblock(memory, reg) {
94c1cc1552SCatalin Marinas 		unsigned long start = memblock_region_memory_base_pfn(reg);
95c1cc1552SCatalin Marinas 		unsigned long end = memblock_region_memory_end_pfn(reg);
96c1cc1552SCatalin Marinas 
97c1cc1552SCatalin Marinas 		if (start >= max)
98c1cc1552SCatalin Marinas 			continue;
9919e7640dSCatalin Marinas 
10019e7640dSCatalin Marinas 		if (IS_ENABLED(CONFIG_ZONE_DMA) && start < max_dma) {
10119e7640dSCatalin Marinas 			unsigned long dma_end = min(end, max_dma);
10219e7640dSCatalin Marinas 			zhole_size[ZONE_DMA] -= dma_end - start;
103c1cc1552SCatalin Marinas 		}
10419e7640dSCatalin Marinas 
10519e7640dSCatalin Marinas 		if (end > max_dma) {
106c1cc1552SCatalin Marinas 			unsigned long normal_end = min(end, max);
10719e7640dSCatalin Marinas 			unsigned long normal_start = max(start, max_dma);
108c1cc1552SCatalin Marinas 			zhole_size[ZONE_NORMAL] -= normal_end - normal_start;
109c1cc1552SCatalin Marinas 		}
110c1cc1552SCatalin Marinas 	}
111c1cc1552SCatalin Marinas 
112c1cc1552SCatalin Marinas 	free_area_init_node(0, zone_size, min, zhole_size);
113c1cc1552SCatalin Marinas }
114c1cc1552SCatalin Marinas 
115c1cc1552SCatalin Marinas #ifdef CONFIG_HAVE_ARCH_PFN_VALID
116c1cc1552SCatalin Marinas int pfn_valid(unsigned long pfn)
117c1cc1552SCatalin Marinas {
118c1cc1552SCatalin Marinas 	return memblock_is_memory(pfn << PAGE_SHIFT);
119c1cc1552SCatalin Marinas }
120c1cc1552SCatalin Marinas EXPORT_SYMBOL(pfn_valid);
121c1cc1552SCatalin Marinas #endif
122c1cc1552SCatalin Marinas 
123c1cc1552SCatalin Marinas #ifndef CONFIG_SPARSEMEM
124c1cc1552SCatalin Marinas static void arm64_memory_present(void)
125c1cc1552SCatalin Marinas {
126c1cc1552SCatalin Marinas }
127c1cc1552SCatalin Marinas #else
128c1cc1552SCatalin Marinas static void arm64_memory_present(void)
129c1cc1552SCatalin Marinas {
130c1cc1552SCatalin Marinas 	struct memblock_region *reg;
131c1cc1552SCatalin Marinas 
132c1cc1552SCatalin Marinas 	for_each_memblock(memory, reg)
133c1cc1552SCatalin Marinas 		memory_present(0, memblock_region_memory_base_pfn(reg),
134c1cc1552SCatalin Marinas 			       memblock_region_memory_end_pfn(reg));
135c1cc1552SCatalin Marinas }
136c1cc1552SCatalin Marinas #endif
137c1cc1552SCatalin Marinas 
138c1cc1552SCatalin Marinas void __init arm64_memblock_init(void)
139c1cc1552SCatalin Marinas {
1402d5a5612SCatalin Marinas 	phys_addr_t dma_phys_limit = 0;
1412d5a5612SCatalin Marinas 
142bd00cd5fSMark Rutland 	/*
143bd00cd5fSMark Rutland 	 * Register the kernel text, kernel data, initrd, and initial
144bd00cd5fSMark Rutland 	 * pagetables with memblock.
145bd00cd5fSMark Rutland 	 */
146c1cc1552SCatalin Marinas 	memblock_reserve(__pa(_text), _end - _text);
147c1cc1552SCatalin Marinas #ifdef CONFIG_BLK_DEV_INITRD
148ec2eaa73SRob Herring 	if (initrd_start)
149ec2eaa73SRob Herring 		memblock_reserve(__virt_to_phys(initrd_start), initrd_end - initrd_start);
150c1cc1552SCatalin Marinas #endif
151c1cc1552SCatalin Marinas 
152*86c8b27aSLeif Lindholm 	if (!efi_enabled(EFI_MEMMAP))
1539bf14b7cSMarek Szyprowski 		early_init_fdt_scan_reserved_mem();
1542d5a5612SCatalin Marinas 
1552d5a5612SCatalin Marinas 	/* 4GB maximum for 32-bit only capable devices */
1562d5a5612SCatalin Marinas 	if (IS_ENABLED(CONFIG_ZONE_DMA))
157d50314a6SCatalin Marinas 		dma_phys_limit = max_zone_dma_phys();
1582d5a5612SCatalin Marinas 	dma_contiguous_reserve(dma_phys_limit);
1596ac2104dSLaura Abbott 
160c1cc1552SCatalin Marinas 	memblock_allow_resize();
161c1cc1552SCatalin Marinas 	memblock_dump_all();
162c1cc1552SCatalin Marinas }
163c1cc1552SCatalin Marinas 
164c1cc1552SCatalin Marinas void __init bootmem_init(void)
165c1cc1552SCatalin Marinas {
166c1cc1552SCatalin Marinas 	unsigned long min, max;
167c1cc1552SCatalin Marinas 
168c1cc1552SCatalin Marinas 	min = PFN_UP(memblock_start_of_DRAM());
169c1cc1552SCatalin Marinas 	max = PFN_DOWN(memblock_end_of_DRAM());
170c1cc1552SCatalin Marinas 
171c1cc1552SCatalin Marinas 	/*
172c1cc1552SCatalin Marinas 	 * Sparsemem tries to allocate bootmem in memory_present(), so must be
173c1cc1552SCatalin Marinas 	 * done after the fixed reservations.
174c1cc1552SCatalin Marinas 	 */
175c1cc1552SCatalin Marinas 	arm64_memory_present();
176c1cc1552SCatalin Marinas 
177c1cc1552SCatalin Marinas 	sparse_init();
178c1cc1552SCatalin Marinas 	zone_sizes_init(min, max);
179c1cc1552SCatalin Marinas 
180c1cc1552SCatalin Marinas 	high_memory = __va((max << PAGE_SHIFT) - 1) + 1;
181c1cc1552SCatalin Marinas 	max_pfn = max_low_pfn = max;
182c1cc1552SCatalin Marinas }
183c1cc1552SCatalin Marinas 
184c1cc1552SCatalin Marinas #ifndef CONFIG_SPARSEMEM_VMEMMAP
185c1cc1552SCatalin Marinas static inline void free_memmap(unsigned long start_pfn, unsigned long end_pfn)
186c1cc1552SCatalin Marinas {
187c1cc1552SCatalin Marinas 	struct page *start_pg, *end_pg;
188c1cc1552SCatalin Marinas 	unsigned long pg, pgend;
189c1cc1552SCatalin Marinas 
190c1cc1552SCatalin Marinas 	/*
191c1cc1552SCatalin Marinas 	 * Convert start_pfn/end_pfn to a struct page pointer.
192c1cc1552SCatalin Marinas 	 */
193c1cc1552SCatalin Marinas 	start_pg = pfn_to_page(start_pfn - 1) + 1;
194c1cc1552SCatalin Marinas 	end_pg = pfn_to_page(end_pfn - 1) + 1;
195c1cc1552SCatalin Marinas 
196c1cc1552SCatalin Marinas 	/*
197c1cc1552SCatalin Marinas 	 * Convert to physical addresses, and round start upwards and end
198c1cc1552SCatalin Marinas 	 * downwards.
199c1cc1552SCatalin Marinas 	 */
200c1cc1552SCatalin Marinas 	pg = (unsigned long)PAGE_ALIGN(__pa(start_pg));
201c1cc1552SCatalin Marinas 	pgend = (unsigned long)__pa(end_pg) & PAGE_MASK;
202c1cc1552SCatalin Marinas 
203c1cc1552SCatalin Marinas 	/*
204c1cc1552SCatalin Marinas 	 * If there are free pages between these, free the section of the
205c1cc1552SCatalin Marinas 	 * memmap array.
206c1cc1552SCatalin Marinas 	 */
207c1cc1552SCatalin Marinas 	if (pg < pgend)
208c1cc1552SCatalin Marinas 		free_bootmem(pg, pgend - pg);
209c1cc1552SCatalin Marinas }
210c1cc1552SCatalin Marinas 
211c1cc1552SCatalin Marinas /*
212c1cc1552SCatalin Marinas  * The mem_map array can get very big. Free the unused area of the memory map.
213c1cc1552SCatalin Marinas  */
214c1cc1552SCatalin Marinas static void __init free_unused_memmap(void)
215c1cc1552SCatalin Marinas {
216c1cc1552SCatalin Marinas 	unsigned long start, prev_end = 0;
217c1cc1552SCatalin Marinas 	struct memblock_region *reg;
218c1cc1552SCatalin Marinas 
219c1cc1552SCatalin Marinas 	for_each_memblock(memory, reg) {
220c1cc1552SCatalin Marinas 		start = __phys_to_pfn(reg->base);
221c1cc1552SCatalin Marinas 
222c1cc1552SCatalin Marinas #ifdef CONFIG_SPARSEMEM
223c1cc1552SCatalin Marinas 		/*
224c1cc1552SCatalin Marinas 		 * Take care not to free memmap entries that don't exist due
225c1cc1552SCatalin Marinas 		 * to SPARSEMEM sections which aren't present.
226c1cc1552SCatalin Marinas 		 */
227c1cc1552SCatalin Marinas 		start = min(start, ALIGN(prev_end, PAGES_PER_SECTION));
228c1cc1552SCatalin Marinas #endif
229c1cc1552SCatalin Marinas 		/*
230c1cc1552SCatalin Marinas 		 * If we had a previous bank, and there is a space between the
231c1cc1552SCatalin Marinas 		 * current bank and the previous, free it.
232c1cc1552SCatalin Marinas 		 */
233c1cc1552SCatalin Marinas 		if (prev_end && prev_end < start)
234c1cc1552SCatalin Marinas 			free_memmap(prev_end, start);
235c1cc1552SCatalin Marinas 
236c1cc1552SCatalin Marinas 		/*
237c1cc1552SCatalin Marinas 		 * Align up here since the VM subsystem insists that the
238c1cc1552SCatalin Marinas 		 * memmap entries are valid from the bank end aligned to
239c1cc1552SCatalin Marinas 		 * MAX_ORDER_NR_PAGES.
240c1cc1552SCatalin Marinas 		 */
241c1cc1552SCatalin Marinas 		prev_end = ALIGN(start + __phys_to_pfn(reg->size),
242c1cc1552SCatalin Marinas 				 MAX_ORDER_NR_PAGES);
243c1cc1552SCatalin Marinas 	}
244c1cc1552SCatalin Marinas 
245c1cc1552SCatalin Marinas #ifdef CONFIG_SPARSEMEM
246c1cc1552SCatalin Marinas 	if (!IS_ALIGNED(prev_end, PAGES_PER_SECTION))
247c1cc1552SCatalin Marinas 		free_memmap(prev_end, ALIGN(prev_end, PAGES_PER_SECTION));
248c1cc1552SCatalin Marinas #endif
249c1cc1552SCatalin Marinas }
250c1cc1552SCatalin Marinas #endif	/* !CONFIG_SPARSEMEM_VMEMMAP */
251c1cc1552SCatalin Marinas 
252c1cc1552SCatalin Marinas /*
253c1cc1552SCatalin Marinas  * mem_init() marks the free areas in the mem_map and tells us how much memory
254c1cc1552SCatalin Marinas  * is free.  This is done after various parts of the system have claimed their
255c1cc1552SCatalin Marinas  * memory after the kernel image.
256c1cc1552SCatalin Marinas  */
257c1cc1552SCatalin Marinas void __init mem_init(void)
258c1cc1552SCatalin Marinas {
259c1cc1552SCatalin Marinas 	max_mapnr   = pfn_to_page(max_pfn + PHYS_PFN_OFFSET) - mem_map;
260c1cc1552SCatalin Marinas 
261c1cc1552SCatalin Marinas #ifndef CONFIG_SPARSEMEM_VMEMMAP
262c1cc1552SCatalin Marinas 	free_unused_memmap();
263c1cc1552SCatalin Marinas #endif
264bee4ebd1SJiang Liu 	/* this will put all unused low memory onto the freelists */
2650c988534SJiang Liu 	free_all_bootmem();
266c1cc1552SCatalin Marinas 
2676879ea83SJiang Liu 	mem_init_print_info(NULL);
268c1cc1552SCatalin Marinas 
269c1cc1552SCatalin Marinas #define MLK(b, t) b, t, ((t) - (b)) >> 10
270c1cc1552SCatalin Marinas #define MLM(b, t) b, t, ((t) - (b)) >> 20
27108375198SCatalin Marinas #define MLG(b, t) b, t, ((t) - (b)) >> 30
272c1cc1552SCatalin Marinas #define MLK_ROUNDUP(b, t) b, t, DIV_ROUND_UP(((t) - (b)), SZ_1K)
273c1cc1552SCatalin Marinas 
274c1cc1552SCatalin Marinas 	pr_notice("Virtual kernel memory layout:\n"
27508375198SCatalin Marinas 		  "    vmalloc : 0x%16lx - 0x%16lx   (%6ld GB)\n"
276c1cc1552SCatalin Marinas #ifdef CONFIG_SPARSEMEM_VMEMMAP
27708375198SCatalin Marinas 		  "    vmemmap : 0x%16lx - 0x%16lx   (%6ld GB maximum)\n"
27808375198SCatalin Marinas 		  "              0x%16lx - 0x%16lx   (%6ld MB actual)\n"
279c1cc1552SCatalin Marinas #endif
28008375198SCatalin Marinas 		  "    PCI I/O : 0x%16lx - 0x%16lx   (%6ld MB)\n"
28108375198SCatalin Marinas 		  "    fixed   : 0x%16lx - 0x%16lx   (%6ld KB)\n"
282c1cc1552SCatalin Marinas 		  "    modules : 0x%16lx - 0x%16lx   (%6ld MB)\n"
283c1cc1552SCatalin Marinas 		  "    memory  : 0x%16lx - 0x%16lx   (%6ld MB)\n"
28408375198SCatalin Marinas 		  "      .init : 0x%p" " - 0x%p" "   (%6ld KB)\n"
28508375198SCatalin Marinas 		  "      .text : 0x%p" " - 0x%p" "   (%6ld KB)\n"
28608375198SCatalin Marinas 		  "      .data : 0x%p" " - 0x%p" "   (%6ld KB)\n",
28708375198SCatalin Marinas 		  MLG(VMALLOC_START, VMALLOC_END),
288c1cc1552SCatalin Marinas #ifdef CONFIG_SPARSEMEM_VMEMMAP
28908375198SCatalin Marinas 		  MLG((unsigned long)vmemmap,
29008375198SCatalin Marinas 		      (unsigned long)vmemmap + VMEMMAP_SIZE),
291c1cc1552SCatalin Marinas 		  MLM((unsigned long)virt_to_page(PAGE_OFFSET),
292c1cc1552SCatalin Marinas 		      (unsigned long)virt_to_page(high_memory)),
293c1cc1552SCatalin Marinas #endif
29408375198SCatalin Marinas 		  MLM((unsigned long)PCI_IOBASE, (unsigned long)PCI_IOBASE + SZ_16M),
29508375198SCatalin Marinas 		  MLK(FIXADDR_START, FIXADDR_TOP),
296c1cc1552SCatalin Marinas 		  MLM(MODULES_VADDR, MODULES_END),
297c1cc1552SCatalin Marinas 		  MLM(PAGE_OFFSET, (unsigned long)high_memory),
298c1cc1552SCatalin Marinas 		  MLK_ROUNDUP(__init_begin, __init_end),
299c1cc1552SCatalin Marinas 		  MLK_ROUNDUP(_text, _etext),
300c1cc1552SCatalin Marinas 		  MLK_ROUNDUP(_sdata, _edata));
301c1cc1552SCatalin Marinas 
302c1cc1552SCatalin Marinas #undef MLK
303c1cc1552SCatalin Marinas #undef MLM
304c1cc1552SCatalin Marinas #undef MLK_ROUNDUP
305c1cc1552SCatalin Marinas 
306c1cc1552SCatalin Marinas 	/*
307c1cc1552SCatalin Marinas 	 * Check boundaries twice: Some fundamental inconsistencies can be
308c1cc1552SCatalin Marinas 	 * detected at build time already.
309c1cc1552SCatalin Marinas 	 */
310c1cc1552SCatalin Marinas #ifdef CONFIG_COMPAT
311c1cc1552SCatalin Marinas 	BUILD_BUG_ON(TASK_SIZE_32			> TASK_SIZE_64);
312c1cc1552SCatalin Marinas #endif
313c1cc1552SCatalin Marinas 	BUILD_BUG_ON(TASK_SIZE_64			> MODULES_VADDR);
314c1cc1552SCatalin Marinas 	BUG_ON(TASK_SIZE_64				> MODULES_VADDR);
315c1cc1552SCatalin Marinas 
316bee4ebd1SJiang Liu 	if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {
317c1cc1552SCatalin Marinas 		extern int sysctl_overcommit_memory;
318c1cc1552SCatalin Marinas 		/*
319c1cc1552SCatalin Marinas 		 * On a machine this small we won't get anywhere without
320c1cc1552SCatalin Marinas 		 * overcommit, so turn it on by default.
321c1cc1552SCatalin Marinas 		 */
322c1cc1552SCatalin Marinas 		sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
323c1cc1552SCatalin Marinas 	}
324c1cc1552SCatalin Marinas }
325c1cc1552SCatalin Marinas 
326c1cc1552SCatalin Marinas void free_initmem(void)
327c1cc1552SCatalin Marinas {
3289af5b807SJiang Liu 	free_initmem_default(0);
329c1cc1552SCatalin Marinas }
330c1cc1552SCatalin Marinas 
331c1cc1552SCatalin Marinas #ifdef CONFIG_BLK_DEV_INITRD
332c1cc1552SCatalin Marinas 
333c1cc1552SCatalin Marinas static int keep_initrd;
334c1cc1552SCatalin Marinas 
335c1cc1552SCatalin Marinas void free_initrd_mem(unsigned long start, unsigned long end)
336c1cc1552SCatalin Marinas {
3379af5b807SJiang Liu 	if (!keep_initrd)
3389af5b807SJiang Liu 		free_reserved_area((void *)start, (void *)end, 0, "initrd");
339c1cc1552SCatalin Marinas }
340c1cc1552SCatalin Marinas 
341c1cc1552SCatalin Marinas static int __init keepinitrd_setup(char *__unused)
342c1cc1552SCatalin Marinas {
343c1cc1552SCatalin Marinas 	keep_initrd = 1;
344c1cc1552SCatalin Marinas 	return 1;
345c1cc1552SCatalin Marinas }
346c1cc1552SCatalin Marinas 
347c1cc1552SCatalin Marinas __setup("keepinitrd", keepinitrd_setup);
348c1cc1552SCatalin Marinas #endif
349