diff mbox series

[v5.10.y-cip] ARM: 9093/1: drivers: firmwapsci: Register with kernel restart handler

Message ID 20220804142731.569579-1-biju.das.jz@bp.renesas.com (mailing list archive)
State Accepted
Headers show
Series [v5.10.y-cip] ARM: 9093/1: drivers: firmwapsci: Register with kernel restart handler | expand

Commit Message

Biju Das Aug. 4, 2022, 2:27 p.m. UTC
From: Guenter Roeck <linux@roeck-us.net>

commit 2bb565bbdc0358b6042e3076416c4ba32bd56bfc upstream.

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>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
Currently reboot command is taking 60sec(default wdt timeout) to reboot
the system on RZ/{G2L,G2LC} platform, due to [1]

[1] https://elixir.bootlin.com/linux/v5.10.135/source/arch/arm64/kernel/process.c#L203

This patch allows to call watchdog_restart_notifier
and it restart the system immediately.
---
 drivers/firmware/psci/psci.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Nobuhiro Iwamatsu Aug. 9, 2022, 8:50 a.m. UTC | #1
Hi,

> -----Original Message-----
> From: Biju Das <biju.das.jz@bp.renesas.com>
> Sent: Thursday, August 4, 2022 11:28 PM
> To: Pavel Machek <pavel@denx.de>
> Cc: iwamatsu nobuhiro(岩松 信洋 □SWC◯ACT)
> <nobuhiro1.iwamatsu@toshiba.co.jp>; Lad Prabhakar
> <prabhakar.mahadev-lad.rj@bp.renesas.com>; Biju Das
> <biju.das.jz@bp.renesas.com>; cip-dev@lists.cip-project.org
> Subject: [PATCH v5.10.y-cip] ARM: 9093/1: drivers: firmwapsci: Register with
> kernel restart handler
> 
> From: Guenter Roeck <linux@roeck-us.net>
> 
> commit 2bb565bbdc0358b6042e3076416c4ba32bd56bfc upstream.
> 
> 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>
> Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
> Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
> ---
> Currently reboot command is taking 60sec(default wdt timeout) to reboot the
> system on RZ/{G2L,G2LC} platform, due to [1]
> 
> [1]
> https://elixir.bootlin.com/linux/v5.10.135/source/arch/arm64/kernel/process
> .c#L203
> 
> This patch allows to call watchdog_restart_notifier and it restart the system
> immediately.

Applied, thanks.

Best regards,
  Nobuhiro
diff mbox series

Patch

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index 00af99b6f97c..e0427042eb9b 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -259,7 +259,8 @@  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)
 {
 	if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
 	    psci_system_reset2_supported) {
@@ -272,8 +273,15 @@  static void psci_sys_reset(enum reboot_mode reboot_mode, const char *cmd)
 	} else {
 		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);
@@ -440,7 +448,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;
 }