From a4c4da52403e390161354524ef9a3a515f73c1d2 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 22:40:58 +1100 Subject: [PATCH 1/2] soc: apple: clpc: link without the SMC driver APPLE_CLPC treats the SMC as optional ("depends on MFD_MACSMC || !MFD_MACSMC"), but the PHPC package-power read and the zETM High Power mode record call apple_smc_read()/apple_smc_write(), which have no stubs. A kernel with APPLE_CLPC=y and MFD_MACSMC unset fails to link: clpc.c: undefined reference to `apple_smc_write' clpc.c: undefined reference to `apple_smc_read' That includes the driver's own clpc.kunitconfig, which does not enable the SMC. Test IS_ENABLED(CONFIG_MFD_MACSMC) before looking the SMC up, so both paths return -ENODEV and the calls drop out at compile time. Probe does not take the apple,smc phandle either in such a kernel, so High Power mode stays off and the performance profile switches like any other (without that, a machine with apple,high-power-mode would fail every write of "performance" with -ENODEV). The low-power profile then has only its frequency ceiling, as it already does when the node has no apple,smc phandle. Kernels with the SMC driver are unchanged. Fixes: f04da7cf87ff ("soc: apple: clpc: J714s: tell the SMC about High Power mode") Fixes: bdd3bc3f17b4 ("soc: apple: clpc: T6050 platform profiles after macOS's power modes") Signed-off-by: Ryan Murray --- drivers/soc/apple/clpc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/soc/apple/clpc.c b/drivers/soc/apple/clpc.c index c3ca54ba859db..f5d5df46e31c6 100644 --- a/drivers/soc/apple/clpc.c +++ b/drivers/soc/apple/clpc.c @@ -796,7 +796,11 @@ static unsigned int apple_clpc_step_khz(struct cpufreq_policy *policy, return best; } -/* The SMC of the apple,smc phandle, once its driver is bound; NULL before. */ +/* + * The SMC of the apple,smc phandle, once its driver is bound; NULL before. + * Callers test IS_ENABLED(CONFIG_MFD_MACSMC) first, so a kernel without the + * SMC driver links without the apple_smc_*() calls. + */ static struct apple_smc *apple_clpc_smc(struct apple_clpc *clpc) { struct platform_device *pdev; @@ -819,7 +823,7 @@ static int apple_clpc_read_power(struct apple_clpc *clpc) u64 mw; u32 f; - if (!apple_clpc_smc(clpc)) + if (!IS_ENABLED(CONFIG_MFD_MACSMC) || !apple_clpc_smc(clpc)) return -ENODEV; ret = apple_smc_read_u32(clpc->smc, SMC_KEY(PHPC), &f); if (ret) @@ -1304,7 +1308,7 @@ static int apple_clpc_send_high_power(struct apple_clpc *clpc, bool on) u8 rec[APPLE_CLPC_ZETM_SIZE] = { APPLE_CLPC_ZETM_TYPE, APPLE_CLPC_ZETM_VERSION }; int ret; - if (!apple_clpc_smc(clpc)) + if (!IS_ENABLED(CONFIG_MFD_MACSMC) || !apple_clpc_smc(clpc)) return -ENODEV; rec[2] = ++clpc->high_power_seq; put_unaligned_le32(on ? APPLE_CLPC_FLOAT_ONE : 0, rec + APPLE_CLPC_ZETM_HIGH_POWER); @@ -1533,8 +1537,13 @@ static int apple_clpc_probe(struct platform_device *pdev) if (!high_power && clpc->hw->high_power_machine) high_power = of_machine_is_compatible(clpc->hw->high_power_machine); if ((clpc->low_power_khz || high_power) && IS_REACHABLE(CONFIG_ACPI_PLATFORM_PROFILE)) { - /* The SMC is optional: without it the low-power profile has only its ceiling. */ - clpc->smc_np = of_parse_phandle(dev->of_node, "apple,smc", 0); + /* + * The SMC is optional: without it (no apple,smc phandle, or a + * kernel without the SMC driver) the low-power profile has only + * its ceiling and there is no High Power mode. + */ + if (IS_ENABLED(CONFIG_MFD_MACSMC)) + clpc->smc_np = of_parse_phandle(dev->of_node, "apple,smc", 0); clpc->high_power = clpc->smc_np && high_power; } /* High Power mode alone needs the SMC; without it there is no profile. */ From 69bc2c322912755ce6d54dbd3437fe702cbba139 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 21 Nov 2026 22:55:18 +1100 Subject: [PATCH 2/2] tools/asahi: clpc-high-power test: model the SMC driver being built apple_clpc_send_high_power() now tests IS_ENABLED(CONFIG_MFD_MACSMC) before it talks to the SMC. The host test compiles the extracted function against its own prelude, which had neither macro, so it stopped building. Define both, with the SMC driver built in, so the test keeps exercising the SMC path it checks. Signed-off-by: Ryan Murray --- tools/asahi/clpc-high-power-cleanup-tests.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/asahi/clpc-high-power-cleanup-tests.py b/tools/asahi/clpc-high-power-cleanup-tests.py index 709aed09ecf4f..c664991024b57 100755 --- a/tools/asahi/clpc-high-power-cleanup-tests.py +++ b/tools/asahi/clpc-high-power-cleanup-tests.py @@ -41,6 +41,9 @@ def function(source, name): #define READ_ONCE(x) (x) #define WRITE_ONCE(x, v) ((x) = (v)) #define SMC_KEY(x) 0x7a45544d +/* Model a kernel built with the SMC driver, so the SMC path runs. */ +#define CONFIG_MFD_MACSMC 1 +#define IS_ENABLED(option) (option) #define dev_warn(...) (warnings++) enum platform_profile_option { PLATFORM_PROFILE_BALANCED, PLATFORM_PROFILE_LOW_POWER, PLATFORM_PROFILE_PERFORMANCE };