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


Biju Das
 

From: Guenter Roeck <linux@...>

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@...>
Reviewed-by: Wolfram Sang <wsa+renesas@...>
Tested-by: Wolfram Sang <wsa+renesas@...>
Signed-off-by: Guenter Roeck <linux@...>
Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@...>
Signed-off-by: Thierry Reding <treding@...>
Signed-off-by: Lee Jones <lee.jones@...>
Signed-off-by: Russell King <rmk+kernel@...>
Signed-off-by: Biju Das <biju.das.jz@...>
---
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(-)

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;
}
--
2.25.1

Join cip-dev@lists.cip-project.org to automatically receive all group messages.