of: Support more than one crash kernel regions for kexec -s
authorZhen Lei <thunder.leizhen@huawei.com>
Fri, 6 May 2022 11:44:01 +0000 (19:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 9 Jun 2022 08:22:36 +0000 (10:22 +0200)
[ Upstream commit 8af6b91f58341325bf74ecb0389ddc0039091d84 ]

When "crashkernel=X,high" is used, there may be two crash regions:
high=crashk_res and low=crashk_low_res. But now the syscall
kexec_file_load() only add crashk_res into "linux,usable-memory-range",
this may cause the second kernel to have no available dma memory.

Fix it like kexec-tools does for option -c, add both 'high' and 'low'
regions into the dtb.

Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
Acked-by: Rob Herring <robh@kernel.org>
Acked-by: Baoquan He <bhe@redhat.com>
Link: https://lore.kernel.org/r/20220506114402.365-6-thunder.leizhen@huawei.com
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/of/kexec.c

index 761fd870d1db277f79ff199c49729c6450e6d7fe..72c790a3c910c9b6fa8df790fb50b07c4d328d09 100644 (file)
@@ -386,6 +386,15 @@ void *of_kexec_alloc_and_setup_fdt(const struct kimage *image,
                                crashk_res.end - crashk_res.start + 1);
                if (ret)
                        goto out;
+
+               if (crashk_low_res.end) {
+                       ret = fdt_appendprop_addrrange(fdt, 0, chosen_node,
+                                       "linux,usable-memory-range",
+                                       crashk_low_res.start,
+                                       crashk_low_res.end - crashk_low_res.start + 1);
+                       if (ret)
+                               goto out;
+               }
        }
 
        /* add bootargs */