powerpc/fadump: register for fadump as early as possible
authorHari Bathini <hbathini@linux.ibm.com>
Tue, 1 Feb 2022 10:53:05 +0000 (16:23 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 1 Mar 2022 12:41:00 +0000 (23:41 +1100)
Crash recovery (fadump) is setup in the userspace by some service. This
service rebuilds initrd with dump capture capability, if it is not
already dump capture capable before proceeding to register for firmware
assisted dump (echo 1 > /sys/kernel/fadump/registered). But arming the
kernel with crash recovery support does not have to wait for userspace
configuration. So, register for fadump while setting it up itself. This
can at worst lead to a scenario, where /proc/vmcore is ready afer crash
but the initrd does not know how/where to offload it, which is always
better than not having a /proc/vmcore at all due to incomplete
configuration in the userspace at the time of crash.

Commit 0823c68b054b ("powerpc/fadump: re-register firmware-assisted dump
if already registered") ensures this change does not break userspace.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
[mpe: Reword comment]
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220201105305.155511-1-hbathini@linux.ibm.com
arch/powerpc/kernel/fadump.c

index d03e488..cf92f3f 100644 (file)
@@ -1637,9 +1637,11 @@ int __init setup_fadump(void)
                if (fw_dump.ops->fadump_process(&fw_dump) < 0)
                        fadump_invalidate_release_mem();
        }
-       /* Initialize the kernel dump memory structure for FAD registration. */
-       else if (fw_dump.reserve_dump_area_size)
+       /* Initialize the kernel dump memory structure and register with f/w */
+       else if (fw_dump.reserve_dump_area_size) {
                fw_dump.ops->fadump_init_mem_struct(&fw_dump);
+               register_fadump();
+       }
 
        /*
         * In case of panic, fadump is triggered via ppc_panic_event()
@@ -1651,7 +1653,12 @@ int __init setup_fadump(void)
 
        return 1;
 }
-subsys_initcall(setup_fadump);
+/*
+ * Use subsys_initcall_sync() here because there is dependency with
+ * crash_save_vmcoreinfo_init(), which mush run first to ensure vmcoreinfo initialization
+ * is done before regisering with f/w.
+ */
+subsys_initcall_sync(setup_fadump);
 #else /* !CONFIG_PRESERVE_FA_DUMP */
 
 /* Scan the Firmware Assisted dump configuration details. */