Skip to contentSkip to conversation

drivers: firmware: psci: use kernel restart handler functionality

PATCH In review Stefan Agner 2 participants 3 messages Oct 12, 2019 – Oct 14, 2019 Power state coordination interface (psci)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: firmware: psci: use kernel restart handler functionality

From: Stefan Agner <[email protected]>

Use the kernels restart handler to register the PSCI system reset capability. The restart handler use notifier chains along with priorities. This allows to use restart handlers with higher priority (in case available) while still supporting PSCI.

Since the ARM handler had priority over the kernels restart handler before this patch, use a slightly elevated priority of 160 to make sure PSCI is used before most of the other handlers are called.

---
 drivers/firmware/psci/psci.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/firmware/psci/psci.c +15 -2
index 84f4ff351c62..d8677b54132f 100644
@@ -82,6 +82,7 @@ static u32 psci_function_id[PSCI_FN_MAX];
 
 static u32 psci_cpu_suspend_feature;
 static bool psci_system_reset2_supported;
+static struct notifier_block psci_restart_handler;
 
 static inline bool psci_has_ext_power_state(void)
 {
@@ -250,7 +251,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 *this,
+			    unsigned long reboot_mode, void *cmd)
 {
 	if ((reboot_mode == REBOOT_WARM || reboot_mode == REBOOT_SOFT) &&
 	    psci_system_reset2_supported) {
@@ -263,6 +265,8 @@ 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 void psci_sys_poweroff(void)
@@ -411,6 +415,8 @@ static void __init psci_init_smccc(void)
 
 static void __init psci_0_2_set_functions(void)
 {
+	int ret;
+
 	pr_info("Using standard PSCI v0.2 function IDs\n");
 	psci_ops.get_version = psci_get_version;
 
@@ -431,7 +437,14 @@ static void __init psci_0_2_set_functions(void)
 
 	psci_ops.migrate_info_type = psci_migrate_info_type;
 
-	arm_pm_restart = psci_sys_reset;
+	psci_restart_handler.notifier_call = psci_sys_reset;
+	psci_restart_handler.priority = 160;
+
+	ret = register_restart_handler(&psci_restart_handler);
+	if (ret) {
+		pr_err("Cannot register restart handler, %d\n", ret);
+		return;
+	}
 
 	pm_power_off = psci_sys_poweroff;
 }
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 11 lines · Stefan Agner

From: Stefan Agner <[email protected]>

Use the kernels restart handler to register the PSCI system reset capability. The restart handler use notifier chains along with priorities. This allows to use restart handlers with higher priority (in case available) while still supporting PSCI.

Since the ARM handler had priority over the kernels restart handler before this patch, use a slightly elevated priority of 160 to make sure PSCI is used before most of the other handlers are called.

There's an attempt(rather pull request[1]) to consolidate these into new system power/restart handler.

--
Regards,
Sudeep

[1] https://lore.kernel.org/linux-arm-kernel/[email protected]

#2 lore raw

Hi Sudeep,

Quoted 8 lines · Sudeep Holla
Quoted 7 lines · Stefan Agner

From: Stefan Agner <[email protected]>

Use the kernels restart handler to register the PSCI system reset capability. The restart handler use notifier chains along with priorities. This allows to use restart handlers with higher priority (in case available) while still supporting PSCI.

Quoted 7 lines
Quoted 4 lines

Since the ARM handler had priority over the kernels restart handler before this patch, use a slightly elevated priority of 160 to make sure PSCI is used before most of the other handlers are called.

There's an attempt(rather pull request[1]) to consolidate these into new system power/restart handler.

Oh thanks for the pointer! Interesting timing :-)

--
Stefan

Quoted 7 lines

--
Regards,
Sudeep

[1]
https://lore.kernel.org/linux-arm-kernel/[email protected]