From: Pingfan Liu <kernelfans@gmail.com>
To: kexec@lists.infradead.org
Cc: Pingfan Liu <piliu@redhat.com>, Jiri Bohac <jbohac@suse.cz>,
Michal Hocko <mhocko@suse.com>, Philipp Rudo <prudo@redhat.com>,
Baoquan He <bhe@redhat.com>, Dave Young <dyoung@redhat.com>
Subject: [RFC 3/3] of: fdt: Parse properties of reusing CMA in kdump
Date: Mon, 18 Dec 2023 13:23:25 +0800 [thread overview]
Message-ID: <20231218052325.20982-4-kernelfans@gmail.com> (raw)
In-Reply-To: <20231218052325.20982-1-kernelfans@gmail.com>
From: Pingfan Liu <piliu@redhat.com>
Signed-off-by: Pingfan Liu <piliu@redhat.com>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Philipp Rudo <prudo@redhat.com>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
To: kexec@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
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2023-12-18 5:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-18 5:23 [RFC 0/3] kdump: Check mem_map of CMA area in kdump Pingfan Liu
2023-12-18 5:23 ` [RFC 1/3] crash_dump: Parse the CMA's mem_map " Pingfan Liu
2023-12-18 5:23 ` [RFC 2/3] of: kexec: Set up properties for reusing CMA " Pingfan Liu
2023-12-18 5:23 ` Pingfan Liu [this message]
2023-12-18 15:19 ` [RFC 0/3] kdump: Check mem_map of CMA area " Michal Hocko
2023-12-19 15:20 ` Philipp Rudo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231218052325.20982-4-kernelfans@gmail.com \
--to=kernelfans@gmail.com \
--cc=bhe@redhat.com \
--cc=dyoung@redhat.com \
--cc=jbohac@suse.cz \
--cc=kexec@lists.infradead.org \
--cc=mhocko@suse.com \
--cc=piliu@redhat.com \
--cc=prudo@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox