From: shawn.guo@linaro.org (Shawn Guo)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: imx: replace imx6q_restart() with mxc_restart()
Date: Sun, 6 Oct 2013 17:06:10 +0800 [thread overview]
Message-ID: <1381050370-3301-1-git-send-email-shawn.guo@linaro.org> (raw)
The imx6q_restart() works fine with normal reboot but will run into
problem with emergency reboot like sysrq-b. In that case, of_iomap()
gets called from interrupt context and hence triggers the BUG_ON in
__get_vm_area_node().
Actually, since commit c1e31d1 (ARM: imx: create
mxc_arch_reset_init_dt() for DT boot), imx6q/dl should try to use
mxc_restart() by calling mxc_arch_reset_init_dt() beforehand, where
things like of_iomap() can be done.
The patch updates mxc_restart() a little bit to get it work for imx6q/dl
and kill imx6q_restart() completely.
Reported-by: Nathan Lynch <nathan_lynch@mentor.com>
Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
---
arch/arm/mach-imx/common.h | 4 ++++
arch/arm/mach-imx/mach-imx6q.c | 35 +++--------------------------------
arch/arm/mach-imx/system.c | 5 +++++
3 files changed, 12 insertions(+), 32 deletions(-)
diff --git a/arch/arm/mach-imx/common.h b/arch/arm/mach-imx/common.h
index 7230cf8..9ebca9e 100644
--- a/arch/arm/mach-imx/common.h
+++ b/arch/arm/mach-imx/common.h
@@ -130,7 +130,11 @@ static inline void imx_smp_prepare(void) {}
static inline void imx_scu_standby_enable(void) {}
#endif
extern void imx_src_init(void);
+#ifdef CONFIG_HAVE_IMX_SRC
extern void imx_src_prepare_restart(void);
+#else
+extern inline void imx_src_prepare_restart(void) {}
+#endif
extern void imx_gpc_init(void);
extern void imx_gpc_pre_suspend(void);
extern void imx_gpc_post_resume(void);
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 398858b..53e70f4 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -15,7 +15,6 @@
#include <linux/clkdev.h>
#include <linux/clocksource.h>
#include <linux/cpu.h>
-#include <linux/delay.h>
#include <linux/export.h>
#include <linux/init.h>
#include <linux/io.h>
@@ -40,36 +39,6 @@
#include "cpuidle.h"
#include "hardware.h"
-static void imx6q_restart(enum reboot_mode mode, const char *cmd)
-{
- struct device_node *np;
- void __iomem *wdog_base;
-
- np = of_find_compatible_node(NULL, NULL, "fsl,imx6q-wdt");
- wdog_base = of_iomap(np, 0);
- if (!wdog_base)
- goto soft;
-
- imx_src_prepare_restart();
-
- /* enable wdog */
- writew_relaxed(1 << 2, wdog_base);
- /* write twice to ensure the request will not get ignored */
- writew_relaxed(1 << 2, wdog_base);
-
- /* wait for reset to assert ... */
- mdelay(500);
-
- pr_err("Watchdog reset failed to assert reset\n");
-
- /* delay to allow the serial port to show the message */
- mdelay(50);
-
-soft:
- /* we'll take a jump through zero as a poor second */
- soft_restart(0);
-}
-
/* For imx6q sabrelite board: set KSZ9021RN RGMII pad skew */
static int ksz9021rn_phy_fixup(struct phy_device *phydev)
{
@@ -166,6 +135,8 @@ static void __init imx6q_init_machine(void)
{
struct device *parent;
+ mxc_arch_reset_init_dt();
+
parent = imx_soc_device_init();
if (parent == NULL)
pr_warn("failed to initialize soc device\n");
@@ -293,5 +264,5 @@ DT_MACHINE_START(IMX6Q, "Freescale i.MX6 Quad/DualLite (Device Tree)")
.init_machine = imx6q_init_machine,
.init_late = imx6q_init_late,
.dt_compat = imx6q_dt_compat,
- .restart = imx6q_restart,
+ .restart = mxc_restart,
MACHINE_END
diff --git a/arch/arm/mach-imx/system.c b/arch/arm/mach-imx/system.c
index 80c177c..e6edcd3 100644
--- a/arch/arm/mach-imx/system.c
+++ b/arch/arm/mach-imx/system.c
@@ -42,6 +42,9 @@ void mxc_restart(enum reboot_mode mode, const char *cmd)
{
unsigned int wcr_enable;
+ if (cpu_is_imx6q() || cpu_is_imx6dl())
+ imx_src_prepare_restart();
+
if (wdog_clk)
clk_enable(wdog_clk);
@@ -52,6 +55,8 @@ void mxc_restart(enum reboot_mode mode, const char *cmd)
/* Assert SRS signal */
__raw_writew(wcr_enable, wdog_base);
+ /* write twice to ensure the request will not get ignored */
+ __raw_writew(wcr_enable, wdog_base);
/* wait for reset to assert... */
mdelay(500);
--
1.7.9.5
next reply other threads:[~2013-10-06 9:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-06 9:06 Shawn Guo [this message]
2013-10-08 15:32 ` [PATCH] ARM: imx: replace imx6q_restart() with mxc_restart() Nathan Lynch
2013-10-08 15:49 ` Shawn Guo
[not found] ` <857E9EDCA6C0904DB3357321AA9123EB62506837@NA-MBX-01.mgc.mentorg.com>
2013-10-21 3:32 ` jiada
2013-10-21 4:59 ` Shawn Guo
[not found] ` <857E9EDCA6C0904DB3357321AA9123EB62506BEA@NA-MBX-01.mgc.mentorg.com>
2013-10-21 6:13 ` jiada
2013-10-21 7:04 ` Shawn Guo
2013-10-28 2:41 ` jiada
2013-10-28 2:52 ` Shawn Guo
2013-10-28 7:45 ` Shawn Guo
2013-10-30 3:13 ` jiada
2013-10-30 17:54 ` Russell King - ARM Linux
2013-10-31 5:23 ` Shawn Guo
2013-10-31 5:31 ` jiada
2013-10-28 5:17 ` Olof Johansson
2013-10-28 8:14 ` Shawn Guo
2013-10-28 17:46 ` Olof Johansson
2013-10-29 2:06 ` Shawn Guo
2013-10-29 8:53 ` Lothar Waßmann
2013-10-29 11:37 ` Russell King - ARM Linux
2013-10-29 13:37 ` Shawn Guo
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=1381050370-3301-1-git-send-email-shawn.guo@linaro.org \
--to=shawn.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.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 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).