[PATCH 4/6] mach-snapdragon: fixup CPUs with PSCI enable-method
Sam Day
me at samcday.com
Tue Jan 28 00:03:15 CET 2025
If there's no PSCI implementation, then change the enable-method of all
CPUs from "psci" to "spin-table". Later, when spin_table_update_dt runs,
it will further patch the CPU nodes with the necessary cpu-release-addr.
This new fixup is only applied when CONFIG_ARMV8_SPIN_TABLE is enabled,
since that also determines whether spin_table_update_dt runs.
Signed-off-by: Sam Day <me at samcday.com>
---
arch/arm/mach-snapdragon/board.c | 41 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/arch/arm/mach-snapdragon/board.c b/arch/arm/mach-snapdragon/board.c
index 75b9cf1a8a1b3383665eb2d4e6725efe59718de0..396898e270bb744151ffd2f0f4ea319f6018dcd4 100644
--- a/arch/arm/mach-snapdragon/board.c
+++ b/arch/arm/mach-snapdragon/board.c
@@ -181,7 +181,9 @@ static void show_psci_version(void)
static void qcom_psci_fixup(void *fdt)
{
int offset, ret;
+ uint reg;
struct arm_smccc_res res;
+ const char *prop;
arm_smccc_smc(ARM_PSCI_0_2_FN_PSCI_VERSION, 0, 0, 0, 0, 0, 0, 0, &res);
@@ -196,6 +198,45 @@ static void qcom_psci_fixup(void *fdt)
ret = fdt_del_node(fdt, offset);
if (ret)
log_err("Failed to delete /psci node: %d\n", ret);
+
+ if (!CONFIG_IS_ENABLED(ARMV8_SPIN_TABLE))
+ return;
+
+ /* If spin-table support is enabled, make sure any CPU nodes with a
+ * PSCI enable-method are updated to spin-table. Further, any PSCI
+ * power-domains properties are removed.
+ */
+
+ offset = fdt_path_offset(fdt, "/cpus");
+ if (offset < 0)
+ return;
+
+ for (offset = fdt_first_subnode(fdt, offset);
+ offset >= 0;
+ offset = fdt_next_subnode(fdt, offset)) {
+ prop = fdt_getprop(fdt, offset, "device_type", NULL);
+ if (!prop || strcmp(prop, "cpu"))
+ continue;
+
+ prop = fdt_getprop(fdt, offset, "enable-method", NULL);
+ if (!prop || strcmp(prop, "psci"))
+ continue;
+
+ reg = fdtdec_get_uint(fdt, offset, "reg", 0);
+ ret = fdt_setprop_string(fdt, offset,
+ "enable-method", "spin-table");
+ if (ret)
+ log_err("Failed to set CPU%d enable-method to 'spin-table', this CPU will not be available to booted OS! %d\n",
+ reg, ret);
+
+ log_info("Patched CPU%d enable-method to 'spin-table'\n", reg);
+
+ prop = fdt_getprop(fdt, offset, "power-domain-names", NULL);
+ if (prop && !strcmp(prop, "psci")) {
+ fdt_delprop(fdt, offset, "power-domains");
+ fdt_delprop(fdt, offset, "power-domain-names");
+ }
+ }
}
/* We support booting U-Boot with an internal DT when running as a first-stage bootloader
--
2.47.1
More information about the U-Boot
mailing list