[PATCH 2/6] ARM: xen: Register with kernel restart handler

2019-10-15 Thread Thierry Reding
From: Guenter Roeck 

Register with kernel restart handler instead of setting arm_pm_restart
directly.

Select a high priority of 192 to ensure that default restart handlers
are replaced if Xen is running.

Acked-by: Arnd Bergmann 
Reviewed-by: Wolfram Sang 
Reviewed-by: Stefano Stabellini 
Signed-off-by: Guenter Roeck 
Signed-off-by: Thierry Reding 
---
 arch/arm/xen/enlighten.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 1e57692552d9..eb0a0edb9909 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -181,11 +182,18 @@ void xen_reboot(int reason)
BUG_ON(rc);
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+  void *data)
 {
xen_reboot(SHUTDOWN_reboot);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+   .notifier_call = xen_restart,
+   .priority = 192,
+};
 
 static void xen_power_off(void)
 {
@@ -406,7 +414,7 @@ static int __init xen_pm_init(void)
return -ENODEV;
 
pm_power_off = xen_power_off;
-   arm_pm_restart = xen_restart;
+   register_restart_handler(_restart_nb);
if (!xen_initial_domain()) {
struct timespec64 ts;
xen_read_wallclock();
-- 
2.23.0



[PATCH 2/6] ARM: xen: Register with kernel restart handler

2017-01-30 Thread Thierry Reding
From: Guenter Roeck 

Register with kernel restart handler instead of setting arm_pm_restart
directly.

Select a high priority of 192 to ensure that default restart handlers
are replaced if Xen is running.

Acked-by: Arnd Bergmann 
Reviewed-by: Wolfram Sang 
Reviewed-by: Stefano Stabellini 
Signed-off-by: Guenter Roeck 
Signed-off-by: Thierry Reding 
---
 arch/arm/xen/enlighten.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 11d9f2898b16..85d678e1d826 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -191,14 +192,22 @@ static int xen_dying_cpu(unsigned int cpu)
return 0;
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+  void *data)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
int rc;
rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
BUG_ON(rc);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+   .notifier_call = xen_restart,
+   .priority = 192,
+};
+
 static void xen_power_off(void)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
@@ -423,7 +432,7 @@ static int __init xen_pm_init(void)
return -ENODEV;
 
pm_power_off = xen_power_off;
-   arm_pm_restart = xen_restart;
+   register_restart_handler(_restart_nb);
if (!xen_initial_domain()) {
struct timespec64 ts;
xen_read_wallclock();
-- 
2.11.0



[PATCH 2/6] ARM: xen: Register with kernel restart handler

2017-01-30 Thread Thierry Reding
From: Guenter Roeck 

Register with kernel restart handler instead of setting arm_pm_restart
directly.

Select a high priority of 192 to ensure that default restart handlers
are replaced if Xen is running.

Acked-by: Arnd Bergmann 
Reviewed-by: Wolfram Sang 
Reviewed-by: Stefano Stabellini 
Signed-off-by: Guenter Roeck 
Signed-off-by: Thierry Reding 
---
 arch/arm/xen/enlighten.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 11d9f2898b16..85d678e1d826 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -191,14 +192,22 @@ static int xen_dying_cpu(unsigned int cpu)
return 0;
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+  void *data)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
int rc;
rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
BUG_ON(rc);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+   .notifier_call = xen_restart,
+   .priority = 192,
+};
+
 static void xen_power_off(void)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
@@ -423,7 +432,7 @@ static int __init xen_pm_init(void)
return -ENODEV;
 
pm_power_off = xen_power_off;
-   arm_pm_restart = xen_restart;
+   register_restart_handler(_restart_nb);
if (!xen_initial_domain()) {
struct timespec64 ts;
xen_read_wallclock();
-- 
2.11.0



Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-09 Thread Stefano Stabellini
On Sat, 9 Apr 2016, Stefano Stabellini wrote:
> On Fri, 8 Apr 2016, Guenter Roeck wrote:
> > Register with kernel restart handler instead of setting arm_pm_restart
> > directly.
> > 
> > Select a high priority of 192 to ensure that default restart handlers
> > are replaced if Xen is running.
> > 
> > Signed-off-by: Guenter Roeck 
> 
> Reviewed-by: Stefano Stabellini 

and queued for 4.7


> 
> >  arch/arm/xen/enlighten.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > index 75cd7345c654..76a1d12fd27e 100644
> > --- a/arch/arm/xen/enlighten.c
> > +++ b/arch/arm/xen/enlighten.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -193,14 +194,22 @@ after_register_vcpu_info:
> > put_cpu();
> >  }
> >  
> > -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> > +static int xen_restart(struct notifier_block *nb, unsigned long action,
> > +  void *data)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
> > int rc;
> > rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
> > BUG_ON(rc);
> > +
> > +   return NOTIFY_DONE;
> >  }
> >  
> > +static struct notifier_block xen_restart_nb = {
> > +   .notifier_call = xen_restart,
> > +   .priority = 192,
> > +};
> > +
> >  static void xen_power_off(void)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> > @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
> > return -ENODEV;
> >  
> > pm_power_off = xen_power_off;
> > -   arm_pm_restart = xen_restart;
> > +   register_restart_handler(_restart_nb);
> > if (!xen_initial_domain()) {
> > struct timespec64 ts;
> > xen_read_wallclock();
> > -- 
> > 2.5.0
> > 
> 


Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-09 Thread Stefano Stabellini
On Sat, 9 Apr 2016, Stefano Stabellini wrote:
> On Fri, 8 Apr 2016, Guenter Roeck wrote:
> > Register with kernel restart handler instead of setting arm_pm_restart
> > directly.
> > 
> > Select a high priority of 192 to ensure that default restart handlers
> > are replaced if Xen is running.
> > 
> > Signed-off-by: Guenter Roeck 
> 
> Reviewed-by: Stefano Stabellini 

and queued for 4.7


> 
> >  arch/arm/xen/enlighten.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > index 75cd7345c654..76a1d12fd27e 100644
> > --- a/arch/arm/xen/enlighten.c
> > +++ b/arch/arm/xen/enlighten.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -193,14 +194,22 @@ after_register_vcpu_info:
> > put_cpu();
> >  }
> >  
> > -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> > +static int xen_restart(struct notifier_block *nb, unsigned long action,
> > +  void *data)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
> > int rc;
> > rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
> > BUG_ON(rc);
> > +
> > +   return NOTIFY_DONE;
> >  }
> >  
> > +static struct notifier_block xen_restart_nb = {
> > +   .notifier_call = xen_restart,
> > +   .priority = 192,
> > +};
> > +
> >  static void xen_power_off(void)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> > @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
> > return -ENODEV;
> >  
> > pm_power_off = xen_power_off;
> > -   arm_pm_restart = xen_restart;
> > +   register_restart_handler(_restart_nb);
> > if (!xen_initial_domain()) {
> > struct timespec64 ts;
> > xen_read_wallclock();
> > -- 
> > 2.5.0
> > 
> 


Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-09 Thread Stefano Stabellini
On Fri, 8 Apr 2016, Guenter Roeck wrote:
> Register with kernel restart handler instead of setting arm_pm_restart
> directly.
> 
> Select a high priority of 192 to ensure that default restart handlers
> are replaced if Xen is running.
> 
> Signed-off-by: Guenter Roeck 

Reviewed-by: Stefano Stabellini 


>  arch/arm/xen/enlighten.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 75cd7345c654..76a1d12fd27e 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -193,14 +194,22 @@ after_register_vcpu_info:
>   put_cpu();
>  }
>  
> -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> +static int xen_restart(struct notifier_block *nb, unsigned long action,
> +void *data)
>  {
>   struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
>   int rc;
>   rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
>   BUG_ON(rc);
> +
> + return NOTIFY_DONE;
>  }
>  
> +static struct notifier_block xen_restart_nb = {
> + .notifier_call = xen_restart,
> + .priority = 192,
> +};
> +
>  static void xen_power_off(void)
>  {
>   struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
>   return -ENODEV;
>  
>   pm_power_off = xen_power_off;
> - arm_pm_restart = xen_restart;
> + register_restart_handler(_restart_nb);
>   if (!xen_initial_domain()) {
>   struct timespec64 ts;
>   xen_read_wallclock();
> -- 
> 2.5.0
> 


Re: [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-09 Thread Stefano Stabellini
On Fri, 8 Apr 2016, Guenter Roeck wrote:
> Register with kernel restart handler instead of setting arm_pm_restart
> directly.
> 
> Select a high priority of 192 to ensure that default restart handlers
> are replaced if Xen is running.
> 
> Signed-off-by: Guenter Roeck 

Reviewed-by: Stefano Stabellini 


>  arch/arm/xen/enlighten.c | 13 +++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 75cd7345c654..76a1d12fd27e 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -193,14 +194,22 @@ after_register_vcpu_info:
>   put_cpu();
>  }
>  
> -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> +static int xen_restart(struct notifier_block *nb, unsigned long action,
> +void *data)
>  {
>   struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
>   int rc;
>   rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
>   BUG_ON(rc);
> +
> + return NOTIFY_DONE;
>  }
>  
> +static struct notifier_block xen_restart_nb = {
> + .notifier_call = xen_restart,
> + .priority = 192,
> +};
> +
>  static void xen_power_off(void)
>  {
>   struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
>   return -ENODEV;
>  
>   pm_power_off = xen_power_off;
> - arm_pm_restart = xen_restart;
> + register_restart_handler(_restart_nb);
>   if (!xen_initial_domain()) {
>   struct timespec64 ts;
>   xen_read_wallclock();
> -- 
> 2.5.0
> 


Re: [Xen-devel] [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-08 Thread Guenter Roeck
On Fri, Apr 08, 2016 at 11:22:57AM -0400, Konrad Rzeszutek Wilk wrote:
> On Fri, Apr 08, 2016 at 05:53:55AM -0700, Guenter Roeck wrote:
> > Register with kernel restart handler instead of setting arm_pm_restart
> > directly.
> > 
> > Select a high priority of 192 to ensure that default restart handlers
> 
> Is there some macro for that magic value?
> 
No, only guidelines in kernel/reboot.c.

Guenter

> > are replaced if Xen is running.
> > 
> > Signed-off-by: Guenter Roeck 
> > ---
> >  arch/arm/xen/enlighten.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > index 75cd7345c654..76a1d12fd27e 100644
> > --- a/arch/arm/xen/enlighten.c
> > +++ b/arch/arm/xen/enlighten.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -193,14 +194,22 @@ after_register_vcpu_info:
> > put_cpu();
> >  }
> >  
> > -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> > +static int xen_restart(struct notifier_block *nb, unsigned long action,
> > +  void *data)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
> > int rc;
> > rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
> > BUG_ON(rc);
> > +
> > +   return NOTIFY_DONE;
> >  }
> >  
> > +static struct notifier_block xen_restart_nb = {
> > +   .notifier_call = xen_restart,
> > +   .priority = 192,
> > +};
> > +
> >  static void xen_power_off(void)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> > @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
> > return -ENODEV;
> >  
> > pm_power_off = xen_power_off;
> > -   arm_pm_restart = xen_restart;
> > +   register_restart_handler(_restart_nb);
> > if (!xen_initial_domain()) {
> > struct timespec64 ts;
> > xen_read_wallclock();
> > -- 
> > 2.5.0
> > 
> > 
> > ___
> > Xen-devel mailing list
> > xen-de...@lists.xen.org
> > http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-08 Thread Guenter Roeck
On Fri, Apr 08, 2016 at 11:22:57AM -0400, Konrad Rzeszutek Wilk wrote:
> On Fri, Apr 08, 2016 at 05:53:55AM -0700, Guenter Roeck wrote:
> > Register with kernel restart handler instead of setting arm_pm_restart
> > directly.
> > 
> > Select a high priority of 192 to ensure that default restart handlers
> 
> Is there some macro for that magic value?
> 
No, only guidelines in kernel/reboot.c.

Guenter

> > are replaced if Xen is running.
> > 
> > Signed-off-by: Guenter Roeck 
> > ---
> >  arch/arm/xen/enlighten.c | 13 +++--
> >  1 file changed, 11 insertions(+), 2 deletions(-)
> > 
> > diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> > index 75cd7345c654..76a1d12fd27e 100644
> > --- a/arch/arm/xen/enlighten.c
> > +++ b/arch/arm/xen/enlighten.c
> > @@ -27,6 +27,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -193,14 +194,22 @@ after_register_vcpu_info:
> > put_cpu();
> >  }
> >  
> > -static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
> > +static int xen_restart(struct notifier_block *nb, unsigned long action,
> > +  void *data)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
> > int rc;
> > rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
> > BUG_ON(rc);
> > +
> > +   return NOTIFY_DONE;
> >  }
> >  
> > +static struct notifier_block xen_restart_nb = {
> > +   .notifier_call = xen_restart,
> > +   .priority = 192,
> > +};
> > +
> >  static void xen_power_off(void)
> >  {
> > struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
> > @@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
> > return -ENODEV;
> >  
> > pm_power_off = xen_power_off;
> > -   arm_pm_restart = xen_restart;
> > +   register_restart_handler(_restart_nb);
> > if (!xen_initial_domain()) {
> > struct timespec64 ts;
> > xen_read_wallclock();
> > -- 
> > 2.5.0
> > 
> > 
> > ___
> > Xen-devel mailing list
> > xen-de...@lists.xen.org
> > http://lists.xen.org/xen-devel


[PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-08 Thread Guenter Roeck
Register with kernel restart handler instead of setting arm_pm_restart
directly.

Select a high priority of 192 to ensure that default restart handlers
are replaced if Xen is running.

Signed-off-by: Guenter Roeck 
---
 arch/arm/xen/enlighten.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 75cd7345c654..76a1d12fd27e 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -193,14 +194,22 @@ after_register_vcpu_info:
put_cpu();
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+  void *data)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
int rc;
rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
BUG_ON(rc);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+   .notifier_call = xen_restart,
+   .priority = 192,
+};
+
 static void xen_power_off(void)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
@@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
return -ENODEV;
 
pm_power_off = xen_power_off;
-   arm_pm_restart = xen_restart;
+   register_restart_handler(_restart_nb);
if (!xen_initial_domain()) {
struct timespec64 ts;
xen_read_wallclock();
-- 
2.5.0



[PATCH 2/6] ARM: xen: Register with kernel restart handler

2016-04-08 Thread Guenter Roeck
Register with kernel restart handler instead of setting arm_pm_restart
directly.

Select a high priority of 192 to ensure that default restart handlers
are replaced if Xen is running.

Signed-off-by: Guenter Roeck 
---
 arch/arm/xen/enlighten.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 75cd7345c654..76a1d12fd27e 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -193,14 +194,22 @@ after_register_vcpu_info:
put_cpu();
 }
 
-static void xen_restart(enum reboot_mode reboot_mode, const char *cmd)
+static int xen_restart(struct notifier_block *nb, unsigned long action,
+  void *data)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_reboot };
int rc;
rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, );
BUG_ON(rc);
+
+   return NOTIFY_DONE;
 }
 
+static struct notifier_block xen_restart_nb = {
+   .notifier_call = xen_restart,
+   .priority = 192,
+};
+
 static void xen_power_off(void)
 {
struct sched_shutdown r = { .reason = SHUTDOWN_poweroff };
@@ -370,7 +379,7 @@ static int __init xen_pm_init(void)
return -ENODEV;
 
pm_power_off = xen_power_off;
-   arm_pm_restart = xen_restart;
+   register_restart_handler(_restart_nb);
if (!xen_initial_domain()) {
struct timespec64 ts;
xen_read_wallclock();
-- 
2.5.0