From: Dengcheng Zhu <dzhu@wavecomp.com>
To: pburton@wavecomp.com, ralf@linux-mips.org
Cc: linux-mips@linux-mips.org, rachel.mozes@intel.com,
Dengcheng Zhu <dzhu@wavecomp.com>
Subject: [PATCH v3 6/6] MIPS: kexec: Use prepare method from generic platform as default option
Date: Mon, 23 Jul 2018 07:48:19 -0700 [thread overview]
Message-ID: <1532357299-8063-7-git-send-email-dzhu@wavecomp.com> (raw)
In-Reply-To: <1532357299-8063-1-git-send-email-dzhu@wavecomp.com>
The kexec_prepare method for the generic platform should be applicable to
other platforms. For those otherwise, like Octeon, they will use their own
_machine_kexec_prepare().
Without the default prepare work, platforms other than the generic one will
not be able to automatically set up command line correctly for the new
kernel.
Tested-by: Rachel Mozes <rachel.mozes@intel.com>
Reported-by: Rachel Mozes <rachel.mozes@intel.com>
Signed-off-by: Dengcheng Zhu <dzhu@wavecomp.com>
---
Changes:
* Add LIBFDT to CPU_LOONGSON3 for default_machine_kexec_prepare().
arch/mips/Kconfig | 1 +
arch/mips/generic/Makefile | 1 -
arch/mips/generic/kexec.c | 44 ----------------------------------------
arch/mips/kernel/machine_kexec.c | 34 ++++++++++++++++++++++++++++++-
4 files changed, 34 insertions(+), 46 deletions(-)
delete mode 100644 arch/mips/generic/kexec.c
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 08c10c5..df62764 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -1374,6 +1374,7 @@ config CPU_LOONGSON3
select MIPS_L1_CACHE_SHIFT_6
select GPIOLIB
select SWIOTLB
+ select LIBFDT
help
The Loongson 3 processor implements the MIPS64R2 instruction
set with many extensions.
diff --git a/arch/mips/generic/Makefile b/arch/mips/generic/Makefile
index d03a36f..181aa13 100644
--- a/arch/mips/generic/Makefile
+++ b/arch/mips/generic/Makefile
@@ -15,5 +15,4 @@ obj-y += proc.o
obj-$(CONFIG_YAMON_DT_SHIM) += yamon-dt.o
obj-$(CONFIG_LEGACY_BOARD_SEAD3) += board-sead3.o
obj-$(CONFIG_LEGACY_BOARD_OCELOT) += board-ocelot.o
-obj-$(CONFIG_KEXEC) += kexec.o
obj-$(CONFIG_VIRT_BOARD_RANCHU) += board-ranchu.o
diff --git a/arch/mips/generic/kexec.c b/arch/mips/generic/kexec.c
deleted file mode 100644
index 1ca409f..0000000
--- a/arch/mips/generic/kexec.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2016 Imagination Technologies
- * Author: Marcin Nowakowski <marcin.nowakowski@mips.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#include <linux/kexec.h>
-#include <linux/libfdt.h>
-#include <linux/uaccess.h>
-
-static int generic_kexec_prepare(struct kimage *image)
-{
- int i;
-
- for (i = 0; i < image->nr_segments; i++) {
- struct fdt_header fdt;
-
- if (image->segment[i].memsz <= sizeof(fdt))
- continue;
-
- if (copy_from_user(&fdt, image->segment[i].buf, sizeof(fdt)))
- continue;
-
- if (fdt_check_header(&fdt))
- continue;
-
- kexec_args[0] = -2;
- kexec_args[1] = (unsigned long)
- phys_to_virt((unsigned long)image->segment[i].mem);
- break;
- }
- return 0;
-}
-
-static int __init register_generic_kexec(void)
-{
- _machine_kexec_prepare = generic_kexec_prepare;
- return 0;
-}
-arch_initcall(register_generic_kexec);
diff --git a/arch/mips/kernel/machine_kexec.c b/arch/mips/kernel/machine_kexec.c
index 6e3f7c8..e3efb64 100644
--- a/arch/mips/kernel/machine_kexec.c
+++ b/arch/mips/kernel/machine_kexec.c
@@ -9,6 +9,7 @@
#include <linux/kexec.h>
#include <linux/mm.h>
#include <linux/delay.h>
+#include <linux/libfdt.h>
#include <asm/cacheflush.h>
#include <asm/page.h>
@@ -65,6 +66,36 @@ static void kexec_image_info(const struct kimage *kimage)
}
}
+static int default_machine_kexec_prepare(struct kimage *kimage)
+{
+ int i;
+
+ /*
+ * In case DTB file is not passed to the new kernel, a flat device
+ * tree will be created by kexec tool. It holds modified command
+ * line for the new kernel.
+ */
+ for (i = 0; i < kimage->nr_segments; i++) {
+ struct fdt_header fdt;
+
+ if (kimage->segment[i].memsz <= sizeof(fdt))
+ continue;
+
+ if (copy_from_user(&fdt, kimage->segment[i].buf, sizeof(fdt)))
+ continue;
+
+ if (fdt_check_header(&fdt))
+ continue;
+
+ kexec_args[0] = -2;
+ kexec_args[1] = (unsigned long)
+ phys_to_virt((unsigned long)kimage->segment[i].mem);
+ break;
+ }
+
+ return 0;
+}
+
int
machine_kexec_prepare(struct kimage *kimage)
{
@@ -72,7 +103,8 @@ machine_kexec_prepare(struct kimage *kimage)
if (_machine_kexec_prepare)
return _machine_kexec_prepare(kimage);
- return 0;
+ else
+ return default_machine_kexec_prepare(kimage);
}
void
--
2.7.4
next prev parent reply other threads:[~2018-07-23 14:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-23 14:48 [PATCH v3 0/6] MIPS: kexec/kdump: Fix smp reboot and other issues Dengcheng Zhu
2018-07-23 14:48 ` [PATCH v3 1/6] MIPS: Make play_dead() work for kexec Dengcheng Zhu
2018-07-24 23:23 ` Paul Burton
2018-07-30 18:50 ` Dengcheng Zhu
2018-08-30 23:32 ` Paul Burton
2018-08-31 17:04 ` Dengcheng Zhu
2018-07-23 14:48 ` [PATCH v3 2/6] MIPS: kexec: Let the new kernel handle all CPUs Dengcheng Zhu
2018-07-23 14:48 ` [PATCH v3 3/6] MIPS: kexec: Deprecate (relocated_)kexec_smp_wait Dengcheng Zhu
2018-07-23 14:48 ` [PATCH v3 4/6] MIPS: kexec: Do not flush system wide caches in machine_kexec() Dengcheng Zhu
2018-07-23 14:48 ` [PATCH v3 5/6] MIPS: kexec: Relax memory restriction Dengcheng Zhu
2018-07-23 14:48 ` Dengcheng Zhu [this message]
2018-07-24 23:36 ` [PATCH v3 6/6] MIPS: kexec: Use prepare method from generic platform as default option Paul Burton
2018-07-30 20:57 ` Dengcheng Zhu
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=1532357299-8063-7-git-send-email-dzhu@wavecomp.com \
--to=dzhu@wavecomp.com \
--cc=linux-mips@linux-mips.org \
--cc=pburton@wavecomp.com \
--cc=rachel.mozes@intel.com \
--cc=ralf@linux-mips.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.