提交 37b09006 编写于 作者: Y Youling Tang 提交者: Hongchen Zhang

LoongArch: Integrate initrd operation

LoongArch inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I736HO

--------------------------------

Integrate initrd operations to avoid reserving initrd space
multiple times during kexec/kdump.
Signed-off-by: NYouling Tang <tangyouling@loongson.cn>
Change-Id: Idb8a10c2143e7ff4682328f620de8d5b3e35b105
上级 28fc51d6
......@@ -303,79 +303,9 @@ int setup_legacy_IRQ(void)
* Manage initrd
*/
#ifdef CONFIG_BLK_DEV_INITRD
static unsigned long init_initrd(unsigned long ps, unsigned long z)
{
static int initalized;
if (!ps || !z)
return 0;
initrd_start = (unsigned long)__va(ps);
initrd_end = initrd_start + z;
/*
* Board specific code or command line parser should have
* already set up initrd_start and initrd_end. In these cases
* perfom sanity checks and use them if all looks good.
*/
if (initrd_start < PAGE_OFFSET || initrd_end <= initrd_start) {
pr_err("initrd start load address error!");
goto disable;
}
if (initrd_start & ~PAGE_MASK) {
pr_err("initrd start must be page aligned\n");
goto disable;
}
memblock_reserve(__pa(initrd_start), z);
initrd_below_start_ok = 1;
if (!initalized)
pr_info("Initial ramdisk at: 0x%lx (%lu bytes)\n",
initrd_start, z);
initalized = 1;
return 0;
disable:
printk(KERN_CONT " - disabling initrd\n");
initrd_start = 0;
initrd_end = 0;
return 0;
}
static int early_initrd(char *p)
{
unsigned long start, size;
char *endp;
if (!efi_bp)
return 0;
start = memparse(p, &endp);
if (*endp == ',')
size = memparse(endp + 1, NULL);
if (start + size > PFN_PHYS(max_low_pfn)) {
pr_err(KERN_INFO "Initrd physical address is out of memory!");
return 0;
}
init_initrd(start, size);
return 0;
}
early_param("initrd", early_initrd);
static int rd_start_early(char *p)
{
unsigned long start;
if (!efi_bp)
return 0;
start = memparse(p, &p);
initrd_start = start;
initrd_end += start;
init_initrd(__pa(start), initrd_end - start);
phys_initrd_start = __pa(memparse(p, &p));
return 0;
}
......@@ -383,24 +313,21 @@ early_param("rd_start", rd_start_early);
static int rd_size_early(char *p)
{
unsigned long size;
phys_initrd_size = memparse(p, &p);
if (!efi_bp)
return 0;
size = memparse(p, &p);
initrd_end += size;
init_initrd(__pa(initrd_start), size);
return 0;
}
early_param("rd_size", rd_size_early);
#endif
#else /* !CONFIG_BLK_DEV_INITRD */
static unsigned long init_initrd(void)
void __init loongarch_reserve_initrd_mem(void)
{
return 0;
/* The small fdt method should be skipped directly to avoid two reserved operations. */
if (!fw_arg2)
return;
reserve_initrd_mem();
}
#endif
void fw_init_cmdline(unsigned long argc, unsigned long cmdp)
{
......
......@@ -87,4 +87,6 @@ extern int __init
pch_msi_parse_madt(union acpi_subtable_headers *header,
const unsigned long end);
extern struct irq_domain *get_pchpic_irq_domain(void);
extern void __init loongarch_reserve_initrd_mem(void);
#endif
......@@ -461,7 +461,7 @@ void __init setup_arch(char **cmdline_p)
memblock_init();
pagetable_init();
parse_early_param();
reserve_initrd_mem();
loongarch_reserve_initrd_mem();
platform_init();
arch_mem_init(cmdline_p);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册