linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Sourabh Jain <sourabhjain@linux.ibm.com>
To: linuxppc-dev@ozlabs.org, mpe@ellerman.id.au
Cc: eric.devolder@oracle.com, bhe@redhat.com,
	mahesh@linux.vnet.ibm.com, kexec@lists.infradead.org,
	ldufour@linux.ibm.com, hbathini@linux.ibm.com
Subject: [PATCH v5 4/5] powerpc/crash hp: add crash hotplug support for kexec_load
Date: Mon, 20 Jun 2022 12:31:05 +0530	[thread overview]
Message-ID: <20220620070106.93141-5-sourabhjain@linux.ibm.com> (raw)
In-Reply-To: <20220620070106.93141-1-sourabhjain@linux.ibm.com>

A common crash hotplug handler is used for both kexec_load and
kexec_file_load, which is already implemented in earlier patches while
adding support for kexec_file_load.

To enable the crash hotplug handler to work for kexec_load case the
fdt_index attribute of kimage_arch needs to be populated with index of
FDT segment in kexec segment array.

After loading kexec segments the FDT segment is identified by looping
through all the kexec segments and fdt_index is updated accordingly.

Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
---
 arch/powerpc/kexec/core_64.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/arch/powerpc/kexec/core_64.c b/arch/powerpc/kexec/core_64.c
index 6d448b55dfad..373cb46bcc0e 100644
--- a/arch/powerpc/kexec/core_64.c
+++ b/arch/powerpc/kexec/core_64.c
@@ -74,6 +74,31 @@ int machine_kexec_prepare(struct kimage *image)
 	return 0;
 }
 
+#if defined(CONFIG_HOTPLUG_CPU)
+int machine_kexec_post_load(struct kimage *kimage)
+{
+	int i;
+	void *ptr;
+	unsigned long mem;
+
+	if (kimage->type != KEXEC_TYPE_CRASH)
+		return 0;
+
+	/* Mark fdt_index invalid */
+	kimage->arch.fdt_index = -1;
+
+	for (i = 0; i < kimage->nr_segments; i++) {
+		mem = kimage->segment[i].mem;
+		ptr = __va(mem);
+
+		if (ptr && fdt_magic(ptr) == FDT_MAGIC)
+			kimage->arch.fdt_index = i;
+	}
+
+	return 0;
+}
+#endif
+
 /* Called during kexec sequence with MMU off */
 static notrace void copy_segments(unsigned long ind)
 {
-- 
2.36.1


  parent reply	other threads:[~2022-06-20  7:04 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-20  7:01 [PATCH v5 0/5] In kernel handling of CPU hotplug events for crash kernel Sourabh Jain
2022-06-20  7:01 ` [PATCH v5 1/5] powerpc/kexec: make update_cpus_node non-static Sourabh Jain
2022-06-21  8:59   ` Laurent Dufour
2022-06-22  8:40     ` Sourabh Jain
2022-06-20  7:01 ` [PATCH v5 2/5] powerpc/crash hp: update kimage_arch struct Sourabh Jain
2022-06-20  7:01 ` [PATCH v5 3/5] powerpc/crash hp: add crash hotplug support for kexec_file_load Sourabh Jain
2022-06-22 15:11   ` Laurent Dufour
2022-06-20  7:01 ` Sourabh Jain [this message]
2022-06-22 15:25   ` [PATCH v5 4/5] powerpc/crash hp: add crash hotplug support for kexec_load Laurent Dufour
2022-06-20  7:01 ` [PATCH v5 5/5] powerpc/crash hp: add crash page helper functions Sourabh Jain
2022-06-22 15:33   ` Laurent Dufour

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=20220620070106.93141-5-sourabhjain@linux.ibm.com \
    --to=sourabhjain@linux.ibm.com \
    --cc=bhe@redhat.com \
    --cc=eric.devolder@oracle.com \
    --cc=hbathini@linux.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=ldufour@linux.ibm.com \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mahesh@linux.vnet.ibm.com \
    --cc=mpe@ellerman.id.au \
    /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;
as well as URLs for NNTP newsgroup(s).