openrisc: restart: Call common handlers before hanging
authorJoel Stanley <joel@jms.id.au>
Sun, 27 Dec 2020 09:14:46 +0000 (19:44 +1030)
committerStafford Horne <shorne@gmail.com>
Fri, 1 Jan 2021 06:00:08 +0000 (15:00 +0900)
Currently openrisc will print a message and then hang in an infinite
loop when rebooting.

This patch adopts some code from ARM, which calls the common restart
infrastructure and hangs after a small delay if the restart infra
doesn't do anything.

Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Stafford Horne <shorne@gmail.com>
arch/openrisc/kernel/process.c

index 3c98728cce2491c80e586945760b4603e1714c71..181448f743162488a84d3ecd1fca7e4a247997eb 100644 (file)
@@ -34,6 +34,7 @@
 #include <linux/init_task.h>
 #include <linux/mqueue.h>
 #include <linux/fs.h>
+#include <linux/reboot.h>
 
 #include <linux/uaccess.h>
 #include <asm/io.h>
  */
 struct thread_info *current_thread_info_set[NR_CPUS] = { &init_thread_info, };
 
-void machine_restart(void)
+void machine_restart(char *cmd)
 {
-       printk(KERN_INFO "*** MACHINE RESTART ***\n");
-       __asm__("l.nop 1");
+       do_kernel_restart(cmd);
+
+       /* Give a grace period for failure to restart of 1s */
+       mdelay(1000);
+
+       /* Whoops - the platform was unable to reboot. Tell the user! */
+       pr_emerg("Reboot failed -- System halted\n");
+       while (1);
 }
 
 /*