linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] openrisc: restart: Call common handlers before hanging
@ 2020-12-27  9:14 Joel Stanley
  2021-01-01  6:11 ` Stafford Horne
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Stanley @ 2020-12-27  9:14 UTC (permalink / raw)
  To: Jonas Bonn, Stefan Kristiansson, Stafford Horne, Geert Uytterhoeven
  Cc: openrisc, linux-kernel

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>
---
Geert has a patch[1] for the litex soc code that adds a restart hander.
Openrisc doesn't hit that code path, this patch fixes that.

[1] https://github.com/geertu/linux/commit/7d09dc0797a8208a11eb7c0c2156c1a4c120180f

 arch/openrisc/kernel/process.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 3c98728cce24..181448f74316 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -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>
@@ -49,10 +50,16 @@
  */
 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);
 }
 
 /*
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] openrisc: restart: Call common handlers before hanging
  2020-12-27  9:14 [PATCH] openrisc: restart: Call common handlers before hanging Joel Stanley
@ 2021-01-01  6:11 ` Stafford Horne
  2021-01-02 13:10   ` Geert Uytterhoeven
  0 siblings, 1 reply; 3+ messages in thread
From: Stafford Horne @ 2021-01-01  6:11 UTC (permalink / raw)
  To: Joel Stanley
  Cc: Jonas Bonn, Stefan Kristiansson, Geert Uytterhoeven, openrisc,
	linux-kernel

On Sun, Dec 27, 2020 at 07:44:46PM +1030, Joel Stanley wrote:
> 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>
> ---
> Geert has a patch[1] for the litex soc code that adds a restart hander.
> Openrisc doesn't hit that code path, this patch fixes that.
> 
> [1] https://github.com/geertu/linux/commit/7d09dc0797a8208a11eb7c0c2156c1a4c120180f
> 
>  arch/openrisc/kernel/process.c | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
> index 3c98728cce24..181448f74316 100644
> --- a/arch/openrisc/kernel/process.c
> +++ b/arch/openrisc/kernel/process.c
> @@ -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>
> @@ -49,10 +50,16 @@
>   */
>  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");
Just a note, this nop with argument 1, is used by the simulators to shutdown.  I
am happy to get rid of this though.  The simulator should be simulating how real
hardware is shut down not doing these tricks.

> +	do_kernel_restart(cmd);
As you mentioned this depends on Geert's patch.  Does he plan to submit it soon?

Geert is CCed.

> +
> +	/* 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);
>  }
>  
>  /*
> -- 
> 2.29.2

I am queing this for 5.11 anyway is it hurt's nothing without Geert's patch.

-Stafford


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] openrisc: restart: Call common handlers before hanging
  2021-01-01  6:11 ` Stafford Horne
@ 2021-01-02 13:10   ` Geert Uytterhoeven
  0 siblings, 0 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2021-01-02 13:10 UTC (permalink / raw)
  To: Stafford Horne
  Cc: Joel Stanley, Jonas Bonn, Stefan Kristiansson, Openrisc,
	Linux Kernel Mailing List

Hi Stafford,

On Fri, Jan 1, 2021 at 7:11 AM Stafford Horne <shorne@gmail.com> wrote:
> On Sun, Dec 27, 2020 at 07:44:46PM +1030, Joel Stanley wrote:
> > 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>
> > ---
> > Geert has a patch[1] for the litex soc code that adds a restart hander.
> > Openrisc doesn't hit that code path, this patch fixes that.
> >
> > [1] https://github.com/geertu/linux/commit/7d09dc0797a8208a11eb7c0c2156c1a4c120180f

> > +     do_kernel_restart(cmd);
> As you mentioned this depends on Geert's patch.  Does he plan to submit it soon?

Will do, once I have managed to escape from Xmas-and-NY mode ;-)

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-02 13:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-27  9:14 [PATCH] openrisc: restart: Call common handlers before hanging Joel Stanley
2021-01-01  6:11 ` Stafford Horne
2021-01-02 13:10   ` Geert Uytterhoeven

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).