LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Chris Zankel <chris@zankel.net>
Cc: Max Filippov <jcmvbkbc@gmail.com>,
	linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org,
	Guenter Roeck <linux@roeck-us.net>
Subject: [RFC PATCH] xtensa: xtfpga: Try software restart before simulating CPU reset
Date: Sun,  1 Aug 2021 10:36:59 -0700	[thread overview]
Message-ID: <20210801173659.2788924-1-linux@roeck-us.net> (raw)

Rebooting xtensa images in qemu does not work. When executing a reboot
command, the qemu session either hangs or experiences an endless sequence
of error messages.

Kernel panic - not syncing: Unrecoverable error in exception handler

Debugging in qemu shows that the code jumps to the CPU restart address,
but Linux can not recover from there.

As it turns out, the FPGA has a means to reset the CPU by writing 0xdead
into a specific FPGA IO address. Use that mechanism to attempt a platform
reset. If it does not work, fall back to the existing mechanism.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
No idea if this is acceptable, but I thought it might be worth a try.

 arch/xtensa/platforms/xtfpga/setup.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/platforms/xtfpga/setup.c b/arch/xtensa/platforms/xtfpga/setup.c
index 4f7d6142d41f..9b1e36b06530 100644
--- a/arch/xtensa/platforms/xtfpga/setup.c
+++ b/arch/xtensa/platforms/xtfpga/setup.c
@@ -51,8 +51,12 @@ void platform_power_off(void)
 
 void platform_restart(void)
 {
-	/* Flush and reset the mmu, simulate a processor reset, and
-	 * jump to the reset vector. */
+	/* Try software reset first. */
+	*((unsigned int *)XTFPGA_SWRST_VADDR) = 0xdead;
+
+	/* If software reset did not work, flush and reset the mmu,
+	 * simulate a processor reset, and jump to the reset vector.
+	 */
 	cpu_reset();
 	/* control never gets here */
 }
-- 
2.25.1


                 reply	other threads:[~2021-08-01 17:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20210801173659.2788924-1-linux@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=chris@zankel.net \
    --cc=jcmvbkbc@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xtensa@linux-xtensa.org \
    --subject='Re: [RFC PATCH] xtensa: xtfpga: Try software restart before simulating CPU reset' \
    /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

This is a public inbox, see mirroring instructions
on how to clone and mirror all data and code used for this inbox