[RFC 3/3] of: fdt: Parse properties of reusing CMA in kdump
Pingfan Liu
kernelfans at gmail.com
Sun Dec 17 21:23:25 PST 2023
From: Pingfan Liu <piliu at redhat.com>
Signed-off-by: Pingfan Liu <piliu at redhat.com>
Cc: Jiri Bohac <jbohac at suse.cz>
Cc: Michal Hocko <mhocko at suse.com>
Cc: Philipp Rudo <prudo at redhat.com>
Cc: Baoquan He <bhe at redhat.com>
Cc: Dave Young <dyoung at redhat.com>
To: kexec at lists.infradead.org
---
drivers/of/fdt.c | 43 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+)
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index bf502ba8da95..09673440f876 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -620,6 +620,19 @@ static void __init fdt_reserve_elfcorehdr(void)
elfcorehdr_size >> 10, elfcorehdr_addr);
}
+static void __init fdt_reserve_kdump_cma(void)
+{
+ if (!IS_ENABLED(CONFIG_CRASH_DUMP))
+ return;
+
+ if (!is_kdump_kernel())
+ return;
+ if (!kdump_cma_pfn || !kdump_cma_pg_cnt || !kdump_cma_pg_paddr)
+ return;
+ memblock_reserve(kdump_cma_pfn << PAGE_SHIFT, kdump_cma_pg_cnt << PAGE_SHIFT);
+ pr_info("Reserving %llu KiB of memory at 0x%llx for kdump cma\n",
+ kdump_cma_pg_cnt >> 10, kdump_cma_pfn << PAGE_SHIFT);
+}
/**
* early_init_fdt_scan_reserved_mem() - create reserved memory regions
*
@@ -637,6 +650,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
fdt_scan_reserved_mem();
fdt_reserve_elfcorehdr();
+ fdt_reserve_kdump_cma();
/* Process header /memreserve/ fields */
for (n = 0; ; n++) {
@@ -1150,6 +1164,34 @@ int __init early_init_dt_scan_memory(void)
return found_memory;
}
+static void __init early_init_dt_check_kdump_cma(unsigned long node)
+{
+ const __be32 *prop;
+ int len;
+
+ if (!IS_ENABLED(CONFIG_CRASH_DUMP))
+ return;
+ if (!is_kdump_kernel())
+ return;
+ pr_debug("Looking for kdump cma property... ");
+
+ prop = of_get_flat_dt_prop(node, "kdump,cma_pfn", &len);
+ if (!prop)
+ return;
+ kdump_cma_pfn = *prop;
+
+ prop = of_get_flat_dt_prop(node, "kdump,cma_pg_cnt", &len);
+ if (!prop)
+ return;
+ kdump_cma_pg_cnt = *prop;
+
+ prop = of_get_flat_dt_prop(node, "kdump,cma_pg_paddr", &len);
+ if (!prop)
+ return;
+ kdump_cma_pg_paddr = *prop;
+
+}
+
int __init early_init_dt_scan_chosen(char *cmdline)
{
int l, node;
@@ -1168,6 +1210,7 @@ int __init early_init_dt_scan_chosen(char *cmdline)
early_init_dt_check_for_initrd(node);
early_init_dt_check_for_elfcorehdr(node);
+ early_init_dt_check_kdump_cma(node);
rng_seed = of_get_flat_dt_prop(node, "rng-seed", &l);
if (rng_seed && l > 0) {
--
2.31.1
More information about the kexec
mailing list