Skip to contentSkip to conversation

xtensa: xtfpga: Try software restart before simulating CPU reset

RFC PATCH New Guenter Roeck 1 participant 1 message Aug 1, 2021 Tensilica Xtensa port (xtensa)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 xtensa: xtfpga: Try software restart before simulating CPU reset

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.

---
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(-)
arch/xtensa/platforms/xtfpga/setup.c +6 -2
index 4f7d6142d41f..9b1e36b06530 100644
@@ -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 */
 }
Signature · 1 line
2.25.1