Re: [PATCH v7 3/5] firmware: psci: Read and use vendor reset types
From: Stephen Boyd <hidden>
Date: 2024-10-28 18:57:56
Also in:
linux-arm-msm, linux-devicetree, linux-pm, lkml
Quoting Elliot Berman (2024-10-28 11:44:57)
quoted hunk ↗ jump to hunk
diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c index 2328ca58bba6..2d7b6efc8743 100644 --- a/drivers/firmware/psci/psci.c +++ b/drivers/firmware/psci/psci.c@@ -79,6 +79,14 @@ struct psci_0_1_function_ids get_psci_0_1_function_ids(void) static u32 psci_cpu_suspend_feature; static bool psci_system_reset2_supported; +struct psci_reset_param { + const char *mode; + u32 reset_type; + u32 cookie; +}; +static struct psci_reset_param *psci_reset_params; +static size_t num_psci_reset_params;
These two can be __ro_after_init
quoted hunk ↗ jump to hunk
+ static inline bool psci_has_ext_power_state(void) { return psci_cpu_suspend_feature &@@ -305,9 +313,38 @@ static int get_set_conduit_method(const struct device_node *np) return 0; } +static void psci_vendor_system_reset2(unsigned long action, void *data)
Can 'data' simply be 'const char *cmd' instead? And can 'action' be dropped? It isn't used in this function.
+{
+ const char *cmd = data;
+ unsigned long ret;
+ size_t i;
+
+ for (i = 0; i < num_psci_reset_params; i++) {
+ if (!strcmp(psci_reset_params[i].mode, cmd)) {
+ ret = invoke_psci_fn(PSCI_FN_NATIVE(1_1, SYSTEM_RESET2),
+ psci_reset_params[i].reset_type,
+ psci_reset_params[i].cookie, 0);
+ /*
+ * if vendor reset fails, log it and fall back to
+ * architecture reset types
+ */
+ pr_err("failed to perform reset \"%s\": %ld\n", cmd,
+ (long)ret);return? because we're not going to try another one, right?