linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart
@ 2016-04-15  2:42 Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 1/6] ARM: prima2: Register with kernel restart handler Guenter Roeck
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck

This is the final push to replace arm_pm_restart with the kernel restart
handler. Finally drop arm_pm_restart after it is no longer used.

---
v2: Rebased to v4.6-rc3
    Added Reviewed-by/Acked/by/Tested-by tags
    Variable name change in patch 3/6.

----------------------------------------------------------------
Guenter Roeck (6):
      ARM: prima2: Register with kernel restart handler
      ARM: xen: Register with kernel restart handler
      ARM: PSCI: Register with kernel restart handler
      ARM: Register with kernel restart handler
      ARM64: Remove arm_pm_restart
      ARM: Remove arm_pm_restart

 arch/arm/include/asm/system_misc.h   |  1 -
 arch/arm/kernel/reboot.c             |  6 +-----
 arch/arm/kernel/setup.c              | 20 ++++++++++++++++++--
 arch/arm/mach-prima2/rstc.c          | 11 +++++++++--
 arch/arm/xen/enlighten.c             | 13 +++++++++++--
 arch/arm64/include/asm/system_misc.h |  2 --
 arch/arm64/kernel/process.c          |  7 +------
 drivers/firmware/psci.c              | 11 +++++++++--
 8 files changed, 49 insertions(+), 22 deletions(-)

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

* [PATCH v2 1/6] ARM: prima2: Register with kernel restart handler
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 2/6] ARM: xen: " Guenter Roeck
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck, Barry Song

Register with kernel restart handler instead of setting arm_pm_restart
directly. By doing this, the prima2 reset handler can be prioritized
among other restart methods available on a particular board.

Select a high priority of 192 since the original code overwrites the
default arm restart handler.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags

 arch/arm/mach-prima2/rstc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-prima2/rstc.c b/arch/arm/mach-prima2/rstc.c
index 7c251eb11d01..1639997c5b49 100644
--- a/arch/arm/mach-prima2/rstc.c
+++ b/arch/arm/mach-prima2/rstc.c
@@ -65,11 +65,18 @@ static struct reset_controller_dev sirfsoc_reset_controller = {
 
 #define SIRFSOC_SYS_RST_BIT  BIT(31)
 
-static void sirfsoc_restart(enum reboot_mode mode, const char *cmd)
+static int sirfsoc_restart(struct notifier_block *nb, unsigned long action,
+			   void *data)
 {
 	writel(SIRFSOC_SYS_RST_BIT, sirfsoc_rstc_base);
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block sirfsoc_restart_nb = {
+	.notifier_call  = sirfsoc_restart,
+	.priority       = 192,
+};
+
 static int sirfsoc_rstc_probe(struct platform_device *pdev)
 {
 	struct device_node *np = pdev->dev.of_node;
@@ -80,7 +87,7 @@ static int sirfsoc_rstc_probe(struct platform_device *pdev)
 	}
 
 	sirfsoc_reset_controller.of_node = np;
-	arm_pm_restart = sirfsoc_restart;
+	register_restart_handler(&sirfsoc_restart_nb);
 
 	if (IS_ENABLED(CONFIG_RESET_CONTROLLER))
 		reset_controller_register(&sirfsoc_reset_controller);
-- 
2.5.0

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

* [PATCH v2 2/6] ARM: xen: Register with kernel restart handler
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 1/6] ARM: prima2: Register with kernel restart handler Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  2016-04-15 18:22   ` Stefano Stabellini
  2016-04-15  2:42 ` [PATCH v2 3/6] ARM: PSCI: " Guenter Roeck
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck, Stefano Stabellini, xen-devel

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 <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags

 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 <linux/cpu.h>
 #include <linux/console.h>
 #include <linux/pvclock_gtod.h>
+#include <linux/reboot.h>
 #include <linux/time64.h>
 #include <linux/timekeeping.h>
 #include <linux/timekeeper_internal.h>
@@ -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, &r);
 	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(&xen_restart_nb);
 	if (!xen_initial_domain()) {
 		struct timespec64 ts;
 		xen_read_wallclock(&ts);
-- 
2.5.0

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

* [PATCH v2 3/6] ARM: PSCI: Register with kernel restart handler
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 1/6] ARM: prima2: Register with kernel restart handler Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 2/6] ARM: xen: " Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  2016-04-19 15:47   ` Lorenzo Pieralisi
  2016-04-15  2:42 ` [PATCH v2 4/6] ARM: " Guenter Roeck
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck, Lorenzo Pieralisi, Mark Rutland

Register with kernel restart handler instead of setting arm_pm_restart
directly. This enables support for replacing the PSCI restart handler
with a different handler if necessary for a specific board.

Select a priority of 129 to indicate a higher than default priority, but
keep it as low as possible since PSCI reset is known to fail on some
boards.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by/Tested-by tags
    Variable name change: np -> nb

 drivers/firmware/psci.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
index 11bfee8b79a9..a0f71480f145 100644
--- a/drivers/firmware/psci.c
+++ b/drivers/firmware/psci.c
@@ -231,11 +231,18 @@ static int get_set_conduit_method(struct device_node *np)
 	return 0;
 }
 
-static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
+static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
+			  void *data)
 {
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+	return NOTIFY_DONE;
 }
 
+static struct notifier_block psci_sys_reset_nb = {
+	.notifier_call = psci_sys_reset,
+	.priority = 129,
+};
+
 static void psci_sys_poweroff(void)
 {
 	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
@@ -461,7 +468,7 @@ static void __init psci_0_2_set_functions(void)
 
 	psci_ops.migrate_info_type = psci_migrate_info_type;
 
-	arm_pm_restart = psci_sys_reset;
+	register_restart_handler(&psci_sys_reset_nb);
 
 	pm_power_off = psci_sys_poweroff;
 }
-- 
2.5.0

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

* [PATCH v2 4/6] ARM: Register with kernel restart handler
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
                   ` (2 preceding siblings ...)
  2016-04-15  2:42 ` [PATCH v2 3/6] ARM: PSCI: " Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 5/6] ARM64: Remove arm_pm_restart Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 6/6] ARM: " Guenter Roeck
  5 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck

By making use of the kernel restart handler, board specific restart
handlers can be prioritized amongst available mechanisms for a particular
board or system.

Select the default priority of 128 to indicate that the restart callback
in the machine description is the default restart mechanism.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags

 arch/arm/kernel/setup.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index a28fce0bdbbe..735e6a2ce216 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -1004,6 +1004,20 @@ void __init hyp_mode_check(void)
 #endif
 }
 
+static void (*__arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
+
+static int arm_restart(struct notifier_block *nb, unsigned long action,
+		       void *data)
+{
+	__arm_pm_restart(action, data);
+	return NOTIFY_DONE;
+}
+
+static struct notifier_block arm_restart_nb = {
+	.notifier_call = arm_restart,
+	.priority = 128,
+};
+
 void __init setup_arch(char **cmdline_p)
 {
 	const struct machine_desc *mdesc;
@@ -1046,8 +1060,10 @@ void __init setup_arch(char **cmdline_p)
 	paging_init(mdesc);
 	request_standard_resources(mdesc);
 
-	if (mdesc->restart)
-		arm_pm_restart = mdesc->restart;
+	if (mdesc->restart) {
+		__arm_pm_restart = mdesc->restart;
+		register_restart_handler(&arm_restart_nb);
+	}
 
 	unflatten_device_tree();
 
-- 
2.5.0

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

* [PATCH v2 5/6] ARM64: Remove arm_pm_restart
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
                   ` (3 preceding siblings ...)
  2016-04-15  2:42 ` [PATCH v2 4/6] ARM: " Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  2016-04-15  2:42 ` [PATCH v2 6/6] ARM: " Guenter Roeck
  5 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck, Will Deacon

All users of arm_pm_restart have been converted to use the kernel restart
handler.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by/Tested-by tags

 arch/arm64/include/asm/system_misc.h | 2 --
 arch/arm64/kernel/process.c          | 7 +------
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/arch/arm64/include/asm/system_misc.h b/arch/arm64/include/asm/system_misc.h
index 57f110bea6a8..f1d865b7d38d 100644
--- a/arch/arm64/include/asm/system_misc.h
+++ b/arch/arm64/include/asm/system_misc.h
@@ -43,8 +43,6 @@ struct mm_struct;
 extern void show_pte(struct mm_struct *mm, unsigned long addr);
 extern void __show_regs(struct pt_regs *);
 
-extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
-
 #define show_unhandled_signals_ratelimited()				\
 ({									\
 	static DEFINE_RATELIMIT_STATE(_rs,				\
diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c
index 80624829db61..29c29984eca0 100644
--- a/arch/arm64/kernel/process.c
+++ b/arch/arm64/kernel/process.c
@@ -66,8 +66,6 @@ EXPORT_SYMBOL(__stack_chk_guard);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL_GPL(pm_power_off);
 
-void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
-
 /*
  * This is our default idle handler.
  */
@@ -153,10 +151,7 @@ void machine_restart(char *cmd)
 		efi_reboot(reboot_mode, NULL);
 
 	/* Now call the architecture specific reboot code. */
-	if (arm_pm_restart)
-		arm_pm_restart(reboot_mode, cmd);
-	else
-		do_kernel_restart(cmd);
+	do_kernel_restart(cmd);
 
 	/*
 	 * Whoops - the architecture was unable to reboot.
-- 
2.5.0

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

* [PATCH v2 6/6] ARM: Remove arm_pm_restart
  2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
                   ` (4 preceding siblings ...)
  2016-04-15  2:42 ` [PATCH v2 5/6] ARM64: Remove arm_pm_restart Guenter Roeck
@ 2016-04-15  2:42 ` Guenter Roeck
  5 siblings, 0 replies; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15  2:42 UTC (permalink / raw)
  To: Russell King, Catalin Marinas
  Cc: Wolfram Sang, Geert Uytterhoeven, linux-arm-kernel, linux-kernel,
	Guenter Roeck

All users of arm_pm_restart have been converted to use the kernel restart
handler.

Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags

 arch/arm/include/asm/system_misc.h | 1 -
 arch/arm/kernel/reboot.c           | 6 +-----
 2 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/system_misc.h b/arch/arm/include/asm/system_misc.h
index a3d61ad984af..6c952538f1e8 100644
--- a/arch/arm/include/asm/system_misc.h
+++ b/arch/arm/include/asm/system_misc.h
@@ -11,7 +11,6 @@
 extern void cpu_init(void);
 
 void soft_restart(unsigned long);
-extern void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 extern void (*arm_pm_idle)(void);
 
 #define UDBG_UNDEFINED	(1 << 0)
diff --git a/arch/arm/kernel/reboot.c b/arch/arm/kernel/reboot.c
index 71a2ff9ec490..4785c39ee3eb 100644
--- a/arch/arm/kernel/reboot.c
+++ b/arch/arm/kernel/reboot.c
@@ -20,7 +20,6 @@ typedef void (*phys_reset_t)(unsigned long);
 /*
  * Function pointers to optional machine specific functions
  */
-void (*arm_pm_restart)(enum reboot_mode reboot_mode, const char *cmd);
 void (*pm_power_off)(void);
 EXPORT_SYMBOL(pm_power_off);
 
@@ -140,10 +139,7 @@ void machine_restart(char *cmd)
 	local_irq_disable();
 	smp_send_stop();
 
-	if (arm_pm_restart)
-		arm_pm_restart(reboot_mode, cmd);
-	else
-		do_kernel_restart(cmd);
+	do_kernel_restart(cmd);
 
 	/* Give a grace period for failure to restart of 1s */
 	mdelay(1000);
-- 
2.5.0

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

* Re: [PATCH v2 2/6] ARM: xen: Register with kernel restart handler
  2016-04-15  2:42 ` [PATCH v2 2/6] ARM: xen: " Guenter Roeck
@ 2016-04-15 18:22   ` Stefano Stabellini
  2016-04-15 19:35     ` Guenter Roeck
  0 siblings, 1 reply; 11+ messages in thread
From: Stefano Stabellini @ 2016-04-15 18:22 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Russell King, Catalin Marinas, Wolfram Sang, Geert Uytterhoeven,
	linux-arm-kernel, linux-kernel, Stefano Stabellini, xen-devel

On Thu, 14 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.
> 
> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Thanks. I assume this is going to go in via Russell or Catalin's tree
with the rest of your series?


> v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags
> 
>  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 <linux/cpu.h>
>  #include <linux/console.h>
>  #include <linux/pvclock_gtod.h>
> +#include <linux/reboot.h>
>  #include <linux/time64.h>
>  #include <linux/timekeeping.h>
>  #include <linux/timekeeper_internal.h>
> @@ -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, &r);
>  	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(&xen_restart_nb);
>  	if (!xen_initial_domain()) {
>  		struct timespec64 ts;
>  		xen_read_wallclock(&ts);
> -- 
> 2.5.0
> 

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

* Re: [PATCH v2 2/6] ARM: xen: Register with kernel restart handler
  2016-04-15 18:22   ` Stefano Stabellini
@ 2016-04-15 19:35     ` Guenter Roeck
  2016-04-15 21:10       ` Stefano Stabellini
  0 siblings, 1 reply; 11+ messages in thread
From: Guenter Roeck @ 2016-04-15 19:35 UTC (permalink / raw)
  To: Stefano Stabellini
  Cc: Russell King, Catalin Marinas, Wolfram Sang, Geert Uytterhoeven,
	linux-arm-kernel, linux-kernel, xen-devel

On Fri, Apr 15, 2016 at 11:22:36AM -0700, Stefano Stabellini wrote:
> On Thu, 14 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.
> > 
> > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> 
> Thanks. I assume this is going to go in via Russell or Catalin's tree
> with the rest of your series?
> 
I would suggest Russell, if he is willing to pick it up, since it mostly
affects arm.

Guenter

> 
> > v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags
> > 
> >  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 <linux/cpu.h>
> >  #include <linux/console.h>
> >  #include <linux/pvclock_gtod.h>
> > +#include <linux/reboot.h>
> >  #include <linux/time64.h>
> >  #include <linux/timekeeping.h>
> >  #include <linux/timekeeper_internal.h>
> > @@ -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, &r);
> >  	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(&xen_restart_nb);
> >  	if (!xen_initial_domain()) {
> >  		struct timespec64 ts;
> >  		xen_read_wallclock(&ts);
> > -- 
> > 2.5.0
> > 

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

* Re: [PATCH v2 2/6] ARM: xen: Register with kernel restart handler
  2016-04-15 19:35     ` Guenter Roeck
@ 2016-04-15 21:10       ` Stefano Stabellini
  0 siblings, 0 replies; 11+ messages in thread
From: Stefano Stabellini @ 2016-04-15 21:10 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Stefano Stabellini, Russell King, Catalin Marinas, Wolfram Sang,
	Geert Uytterhoeven, linux-arm-kernel, linux-kernel, xen-devel

On Fri, 15 Apr 2016, Guenter Roeck wrote:
> On Fri, Apr 15, 2016 at 11:22:36AM -0700, Stefano Stabellini wrote:
> > On Thu, 14 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.
> > > 
> > > Acked-by: Arnd Bergmann <arnd@arndb.de>
> > > Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > > Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > > Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> > 
> > Thanks. I assume this is going to go in via Russell or Catalin's tree
> > with the rest of your series?
> > 
> I would suggest Russell, if he is willing to pick it up, since it mostly
> affects arm.

I am happy with that. In that case I'll remove this patch from my queue
not to have duplicates.


> 
> > 
> > > v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by tags
> > > 
> > >  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 <linux/cpu.h>
> > >  #include <linux/console.h>
> > >  #include <linux/pvclock_gtod.h>
> > > +#include <linux/reboot.h>
> > >  #include <linux/time64.h>
> > >  #include <linux/timekeeping.h>
> > >  #include <linux/timekeeper_internal.h>
> > > @@ -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, &r);
> > >  	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(&xen_restart_nb);
> > >  	if (!xen_initial_domain()) {
> > >  		struct timespec64 ts;
> > >  		xen_read_wallclock(&ts);
> > > -- 
> > > 2.5.0
> > > 
> 

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

* Re: [PATCH v2 3/6] ARM: PSCI: Register with kernel restart handler
  2016-04-15  2:42 ` [PATCH v2 3/6] ARM: PSCI: " Guenter Roeck
@ 2016-04-19 15:47   ` Lorenzo Pieralisi
  0 siblings, 0 replies; 11+ messages in thread
From: Lorenzo Pieralisi @ 2016-04-19 15:47 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Russell King, Catalin Marinas, Wolfram Sang, Geert Uytterhoeven,
	linux-arm-kernel, linux-kernel, Mark Rutland

On Thu, Apr 14, 2016 at 07:42:34PM -0700, Guenter Roeck wrote:
> Register with kernel restart handler instead of setting arm_pm_restart
> directly. This enables support for replacing the PSCI restart handler
> with a different handler if necessary for a specific board.
> 
> Select a priority of 129 to indicate a higher than default priority, but
> keep it as low as possible since PSCI reset is known to fail on some
> boards.

I do not think you should play with notifiers priorities to paper over
FW bugs, if PSCI SYSTEM_RESET is broken FW is not PSCI0.2+ compliant
so it should not even be advertised as such in the DT.

This means that this priority kludge must disappear soon, what priority
to assign to the PSCI reset handler remains to be seen.

Are you sending this patch series via arm-soc ? If so:

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>

> Acked-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Tested-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
> v2: Rebased to v4.6-rc3, added Reviewed/by/Acked-by/Tested-by tags
>     Variable name change: np -> nb
> 
>  drivers/firmware/psci.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/firmware/psci.c b/drivers/firmware/psci.c
> index 11bfee8b79a9..a0f71480f145 100644
> --- a/drivers/firmware/psci.c
> +++ b/drivers/firmware/psci.c
> @@ -231,11 +231,18 @@ static int get_set_conduit_method(struct device_node *np)
>  	return 0;
>  }
>  
> -static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
> +static int psci_sys_reset(struct notifier_block *nb, unsigned long action,
> +			  void *data)
>  {
>  	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
> +	return NOTIFY_DONE;
>  }
>  
> +static struct notifier_block psci_sys_reset_nb = {
> +	.notifier_call = psci_sys_reset,
> +	.priority = 129,
> +};
> +
>  static void psci_sys_poweroff(void)
>  {
>  	invoke_psci_fn(PSCI_0_2_FN_SYSTEM_OFF, 0, 0, 0);
> @@ -461,7 +468,7 @@ static void __init psci_0_2_set_functions(void)
>  
>  	psci_ops.migrate_info_type = psci_migrate_info_type;
>  
> -	arm_pm_restart = psci_sys_reset;
> +	register_restart_handler(&psci_sys_reset_nb);
>  
>  	pm_power_off = psci_sys_poweroff;
>  }
> -- 
> 2.5.0
> 

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

end of thread, other threads:[~2016-04-19 15:47 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-15  2:42 [PATCH v2 0/6] ARM/ARM64: Drop arm_pm_restart Guenter Roeck
2016-04-15  2:42 ` [PATCH v2 1/6] ARM: prima2: Register with kernel restart handler Guenter Roeck
2016-04-15  2:42 ` [PATCH v2 2/6] ARM: xen: " Guenter Roeck
2016-04-15 18:22   ` Stefano Stabellini
2016-04-15 19:35     ` Guenter Roeck
2016-04-15 21:10       ` Stefano Stabellini
2016-04-15  2:42 ` [PATCH v2 3/6] ARM: PSCI: " Guenter Roeck
2016-04-19 15:47   ` Lorenzo Pieralisi
2016-04-15  2:42 ` [PATCH v2 4/6] ARM: " Guenter Roeck
2016-04-15  2:42 ` [PATCH v2 5/6] ARM64: Remove arm_pm_restart Guenter Roeck
2016-04-15  2:42 ` [PATCH v2 6/6] ARM: " Guenter Roeck

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