From eb346c1a25d813a1411a34fafc7d4bdee418e0d4 Mon Sep 17 00:00:00 2001 From: Haoxiang Li Date: Fri, 3 Jul 2026 14:20:49 +0800 Subject: [PATCH 01/14] cpufreq: apple-soc: Fix OPP table cleanup commit d87cb889dc7ab1f2deecadf2a5e9023184bd7900 upstream. apple_soc_cpufreq_init() adds OPP tables from firmware, but some failure paths do not remove them. The driver also uses dev_pm_opp_remove_all_dynamic(), which is not the right cleanup helper for OPP tables loaded from firmware. Use the cpumask OPP helper after the policy CPU mask has been populated. Pair it with the matching cpumask remove helper on failure paths and in apple_soc_cpufreq_exit(). This also removes the separate dev_pm_opp_set_sharing_cpus() call, as the cpumask helper loads the DT OPP tables for all CPUs in the policy. Fixes: 6286bbb40576 ("cpufreq: apple-soc: Add new driver to control Apple SoC CPU P-states") Cc: stable@vger.kernel.org Signed-off-by: Haoxiang Li Signed-off-by: Viresh Kumar Signed-off-by: Ryan Murray --- drivers/cpufreq/apple-soc-cpufreq.c | 36 +++++++++++------------------ 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c index 60935032919d2..d416088bf28a5 100644 --- a/drivers/cpufreq/apple-soc-cpufreq.c +++ b/drivers/cpufreq/apple-soc-cpufreq.c @@ -251,21 +251,19 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) return -ENODEV; } - ret = dev_pm_opp_of_add_table(cpu_dev); - if (ret < 0) { - dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret); - return ret; - } + priv = kzalloc_obj(*priv); + if (!priv) + return -ENOMEM; ret = apple_soc_cpufreq_find_cluster(policy, ®_base, &info); if (ret) { dev_err(cpu_dev, "%s: failed to get cluster info: %d\n", __func__, ret); - return ret; + goto out_free_priv; } - ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus); - if (ret) { - dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", __func__, ret); + ret = dev_pm_opp_of_cpumask_add_table(policy->cpus); + if (ret < 0) { + dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret); goto out_iounmap; } @@ -273,19 +271,13 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) if (ret <= 0) { dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n"); ret = -EPROBE_DEFER; - goto out_free_opp; - } - - priv = kzalloc_obj(*priv); - if (!priv) { - ret = -ENOMEM; - goto out_free_opp; + goto out_free_table; } ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); if (ret) { dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret); - goto out_free_priv; + goto out_free_table; } /* Get OPP levels (p-state indexes) and stash them in driver_data */ @@ -320,12 +312,12 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) out_free_cpufreq_table: dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table); -out_free_priv: - kfree(priv); -out_free_opp: - dev_pm_opp_remove_all_dynamic(cpu_dev); +out_free_table: + dev_pm_opp_of_cpumask_remove_table(policy->cpus); out_iounmap: iounmap(reg_base); +out_free_priv: + kfree(priv); return ret; } @@ -334,7 +326,7 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy) struct apple_cpu_priv *priv = policy->driver_data; dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); - dev_pm_opp_remove_all_dynamic(priv->cpu_dev); + dev_pm_opp_of_cpumask_remove_table(policy->cpus); iounmap(priv->reg_base); kfree(priv); } From 6559da7d50ab10da722b3719f447836b12427159 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:00:04 +1000 Subject: [PATCH 02/14] cpufreq: apple-soc: Use related_cpus when removing OPP tables at exit apple_soc_cpufreq_exit() drops the static OPP tables with dev_pm_opp_of_cpumask_remove_table(policy->cpus), but policy->cpus is always empty by then. __cpufreq_offline() clears the outgoing CPU from the mask first and calls ->exit() only once the last CPU of the policy has gone, and unbinding the driver takes the same path. The call removes nothing, so every time a cluster goes fully offline and comes back, or the driver is rebound, the OPP table of each of its CPUs is left with one more reference and is never freed. Remove the tables of policy->related_cpus instead, which still lists every CPU the policy covered, as qcom-cpufreq-hw does. The error path of apple_soc_cpufreq_init() keeps using policy->cpus, because the core fills in related_cpus only after ->init() has succeeded. Fixes: d87cb889dc7a ("cpufreq: apple-soc: Fix OPP table cleanup") Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 Signed-off-by: Ryan Murray --- drivers/cpufreq/apple-soc-cpufreq.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c index d416088bf28a5..873f5fc5243d3 100644 --- a/drivers/cpufreq/apple-soc-cpufreq.c +++ b/drivers/cpufreq/apple-soc-cpufreq.c @@ -326,7 +326,11 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy) struct apple_cpu_priv *priv = policy->driver_data; dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); - dev_pm_opp_of_cpumask_remove_table(policy->cpus); + /* + * The core clears the last CPU from policy->cpus before calling + * ->exit(), so remove the tables of every CPU the policy covered. + */ + dev_pm_opp_of_cpumask_remove_table(policy->related_cpus); iounmap(priv->reg_base); kfree(priv); } From 891f609b47be6a57905816ab2e422fa5e1b25bbc Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:00:34 +1000 Subject: [PATCH 03/14] hwmon: (macsmc-hwmon) Reject NaN/Inf and decode subnormal floats macsmc_hwmon_read_f32_scaled() decodes the IEEE-754 single-precision values that the SMC returns for most sensor keys, and it mishandles the special encodings: - An exponent field of 0xff (infinity or NaN) is decoded as a huge finite number and saturated, so a sensor without a valid reading is reported as LONG_MAX or LONG_MIN millidegrees, millivolts, milliamps or microwatts. The chip registers HWMON_C_REGISTER_TZ, so a thermal zone built on such a sensor would see an absurd temperature. - The implicit leading one is also added when the exponent field is 0, so zero and subnormal inputs are decoded with the wrong mantissa and exponent. With the scales the driver uses (1000 and 1000000) the result still truncates to 0, so no reported value changes; the decoder now follows IEEE-754 for every exponent. - A negative value whose magnitude is exactly LONG_MAX + 1 was negated after the conversion to long, which is signed overflow. Return -ENODATA for NaN and infinity so that such readings show up as unavailable rather than as extreme values, decode exponent field 0 without the implicit bit and with the minimum exponent, and produce LONG_MIN without negating it. A scaled value that does not fit in a long is now reported as -ERANGE instead of being clamped to LONG_MAX or LONG_MIN: nothing the SMC measures gets anywhere near 9.2e15 degrees, volts or amps, so such a value is a decoding or transport problem, and a clamped number would only hide it from the thermal core and from userspace. Ordinary readings are unchanged and still truncate towards zero. Eryk Wieliczko wrote this change for Aurora's tree (2026-09-08, under the file's GPL-2.0-only OR MIT licence) and verified it against 9045 exact-integer oracle cases under UBSan and on a J700. It is carried here unchanged, without its host-side Python test; his Signed-off-by is outstanding. Fixes: 785205fd8139 ("hwmon: Add Apple Silicon SMC hwmon driver") Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- drivers/hwmon/macsmc-hwmon.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c index 1500ec2cc9f83..13e38b25c75fb 100644 --- a/drivers/hwmon/macsmc-hwmon.c +++ b/drivers/hwmon/macsmc-hwmon.c @@ -151,31 +151,42 @@ static int macsmc_hwmon_read_f32_scaled(struct apple_smc *smc, smc_key key, if (ret < 0) return ret; - val = ((u64)((fval & FLT_MANT_MASK) | BIT(23))); - exp = ((fval >> 23) & 0xff) - FLT_EXP_BIAS - FLT_MANT_BIAS; + exp = FIELD_GET(FLT_EXP_MASK, fval); + /* NaN and infinity are unavailable readings, not extreme temperatures. */ + if (exp == 0xff) + return -ENODATA; + + val = fval & FLT_MANT_MASK; + if (exp) + val |= BIT(23); + else + exp = 1; /* Zero and subnormal values have no implicit leading one. */ + exp -= FLT_EXP_BIAS + FLT_MANT_BIAS; /* We never have negatively scaled SMC floats */ val *= scale; if (exp > 63) - val = U64_MAX; + return -ERANGE; else if (exp < -63) val = 0; else if (exp < 0) val >>= -exp; else if (exp != 0 && (val & ~((1ULL << (64 - exp)) - 1))) /* overflow */ - val = U64_MAX; + return -ERANGE; else val <<= exp; if (fval & FLT_SIGN_MASK) { if (val > (u64)LONG_MAX + 1) + return -ERANGE; + if (val == (u64)LONG_MAX + 1) *p = LONG_MIN; else *p = -(long)val; } else { if (val > (u64)LONG_MAX) - *p = LONG_MAX; + return -ERANGE; else *p = (long)val; } From 5543c692a184eb7c61f587149559302e2a4b6f36 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:01:20 +1000 Subject: [PATCH 04/14] arm64: cputype: Add T8140 core MIDRs Add the MIDR part numbers of the two core types in the Apple T8140 (A18 Pro) SoC, as read from MIDR_EL1 on a J700: 0x060 for the efficiency cores and 0x061 for the performance cores. The T8140 WFI workaround in the idle code matches on them. These cores have no generational codename, so name them after the SoC codename and the core type, as the "apple,tahiti-e" and "apple,tahiti-p" CPU compatibles for this SoC do. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- arch/arm64/include/asm/cputype.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h index 1b9f0cda1336d..d44795ef73e4c 100644 --- a/arch/arm64/include/asm/cputype.h +++ b/arch/arm64/include/asm/cputype.h @@ -153,6 +153,8 @@ #define APPLE_CPU_PART_M2_AVALANCHE_PRO 0x035 #define APPLE_CPU_PART_M2_BLIZZARD_MAX 0x038 #define APPLE_CPU_PART_M2_AVALANCHE_MAX 0x039 +#define APPLE_CPU_PART_TAHITI_E 0x060 +#define APPLE_CPU_PART_TAHITI_P 0x061 #define AMPERE_CPU_PART_AMPERE1 0xAC3 #define AMPERE_CPU_PART_AMPERE1A 0xAC4 @@ -246,6 +248,8 @@ #define MIDR_APPLE_M2_AVALANCHE_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO) #define MIDR_APPLE_M2_BLIZZARD_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX) #define MIDR_APPLE_M2_AVALANCHE_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX) +#define MIDR_APPLE_TAHITI_E MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_TAHITI_E) +#define MIDR_APPLE_TAHITI_P MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_TAHITI_P) #define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1) #define MIDR_AMPERE1A MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1A) #define MIDR_MICROSOFT_AZURE_COBALT_100 MIDR_CPU_MODEL(ARM_CPU_IMP_MICROSOFT, MICROSOFT_CPU_PART_AZURE_COBALT_100) From c407e1097ba74b464982c66483ba507a50ed927a Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:01:44 +1000 Subject: [PATCH 05/14] arm64: idle: Preserve architectural state across WFI on T8140 On the Apple T8140 (A18 Pro) in the J700, the secondary CPUs can come back from WFI with their general-purpose registers cleared and their FP/SIMD registers lost; SP and memory survive. cpu_do_idle() is C code that expects its callee-saved registers back, so the default idle=wfi corrupts whatever the idle path keeps in them. Until now the only stable setting on J700 was idle=nop, which leaves every core spinning at full clock: measured on J700 at the same load average, the die idled at 85-92 C (peaks of 106.7 C) with idle=nop and at 43.4 C with WFI and this change. On those CPUs, cpu_do_idle() now enters WFI through apple_cpu_wfi(), which stores x18-x30 (the AAPCS64 callee-saved registers, the frame pointer, the link register, and x18, which may hold the shadow call stack pointer) on the stack, issues DSB SY and WFI, and restores them after an ISB. Being an ordinary function call, it already tells the compiler that x0-x17 and the flags are clobbered. Beforehand, fpsimd_save_and_flush_cpu_state() saves any live user FP/SIMD state and drops this CPU's ownership of it, so the next return to userspace reloads the registers even when the same task resumes here. The workaround is chosen once at boot: an early initcall matches the boot CPU's MIDR against the T8140 E and P core IDs and enables a static key. Every other CPU pays one patched-out branch per idle entry, and kernels without CONFIG_ARCH_APPLE compile the path out. The key is set before the secondaries are brought up; the boot CPU idles with plain WFI until then, and only the secondaries are known to be affected. apple_cpu_wfi() lives in .cpuidle.text like the rest of the idle path. The root cause is not known. Other Apple SoCs keep this state across WFI unless the OS asks for a deep state: cpuidle-apple sets bits 25:24 of s3_5_c15_c5_0 (CYC_OVRD) for its power-down state and brackets that state with cpu_pm_enter()/cpu_pm_exit(). The T8140 secondaries may be left by the boot chain with a WFI mode that does not retain state. Until that is understood, this stays a downstream workaround. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 Signed-off-by: Ryan Murray --- arch/arm64/include/asm/apple-idle.h | 8 +++++ arch/arm64/kernel/Makefile | 2 ++ arch/arm64/kernel/idle-apple.S | 45 ++++++++++++++++++++++++ arch/arm64/kernel/idle.c | 54 +++++++++++++++++++++++++++-- 4 files changed, 107 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/include/asm/apple-idle.h create mode 100644 arch/arm64/kernel/idle-apple.S diff --git a/arch/arm64/include/asm/apple-idle.h b/arch/arm64/include/asm/apple-idle.h new file mode 100644 index 0000000000000..3a0a2660877f5 --- /dev/null +++ b/arch/arm64/include/asm/apple-idle.h @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_APPLE_IDLE_H +#define __ASM_APPLE_IDLE_H + +/* WFI that preserves x18-x30 on cores that lose them (Apple T8140). */ +void apple_cpu_wfi(void); + +#endif diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 81df89483ba9d..2db39f6e1b007 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -37,6 +37,8 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ cpufeature_impdef.o \ rsi.o jump_label.o +obj-$(CONFIG_ARCH_APPLE) += idle-apple.o + obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o obj-$(CONFIG_COMPAT) += sigreturn32.o diff --git a/arch/arm64/kernel/idle-apple.S b/arch/arm64/kernel/idle-apple.S new file mode 100644 index 0000000000000..02c3e4f6402ca --- /dev/null +++ b/arch/arm64/kernel/idle-apple.S @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include +#include + +/* + * T8140 secondaries can resume from WFI with cleared general registers. + * SP and stack memory survive. Preserve the AAPCS64 callee-saved registers + * and x18 (which may hold the shadow call stack), including the return PC. + * This follows the stateless-wait approach used during m1n1 M5 Windows + * bring-up. It does not configure an Apple deep-sleep state or DVFS policy. + * + * IRQ masking/context management remains with cpu_do_idle(). The direct + * function call tells its compiler that x0-x17 and flags are clobbered. + */ + .macro apple_wait_save + stp x29, x30, [sp, #-112]! + mov x29, sp + stp x19, x20, [sp, #16] + stp x21, x22, [sp, #32] + stp x23, x24, [sp, #48] + stp x25, x26, [sp, #64] + stp x27, x28, [sp, #80] + str x18, [sp, #96] + dsb sy + .endm + + .macro apple_wait_restore + isb + ldr x18, [sp, #96] + ldp x19, x20, [sp, #16] + ldp x21, x22, [sp, #32] + ldp x23, x24, [sp, #48] + ldp x25, x26, [sp, #64] + ldp x27, x28, [sp, #80] + ldp x29, x30, [sp], #112 + ret + .endm + + .pushsection .cpuidle.text, "ax" +SYM_FUNC_START(apple_cpu_wfi) + apple_wait_save + wfi + apple_wait_restore +SYM_FUNC_END(apple_cpu_wfi) + .popsection diff --git a/arch/arm64/kernel/idle.c b/arch/arm64/kernel/idle.c index 42c5543f9589c..45bc79f128543 100644 --- a/arch/arm64/kernel/idle.c +++ b/arch/arm64/kernel/idle.c @@ -4,11 +4,16 @@ */ #include +#include #include +#include +#include #include #include #include +#include +#include #include enum { @@ -34,6 +39,41 @@ static int __init setup_idle(char *arg) } early_param("idle", setup_idle); +#ifdef CONFIG_ARCH_APPLE +/* + * Apple T8140 (A18 Pro) secondary CPUs can return from WFI with their + * general-purpose and FP/SIMD registers cleared. The key is enabled once + * at boot on those parts; everywhere else the check is a patched-out branch. + */ +static DEFINE_STATIC_KEY_FALSE(apple_wfi_loses_regs); + +static const struct midr_range apple_wfi_loses_regs_cpus[] __initconst = { + MIDR_ALL_VERSIONS(MIDR_APPLE_TAHITI_E), + MIDR_ALL_VERSIONS(MIDR_APPLE_TAHITI_P), + {} +}; + +static int __init apple_wfi_quirk_init(void) +{ + if (is_midr_in_range_list(apple_wfi_loses_regs_cpus)) { + static_branch_enable(&apple_wfi_loses_regs); + pr_info("Apple T8140: preserving registers across WFI\n"); + } + return 0; +} +early_initcall(apple_wfi_quirk_init); + +static __always_inline bool apple_wfi_needs_save(void) +{ + return static_branch_unlikely(&apple_wfi_loses_regs); +} +#else +static __always_inline bool apple_wfi_needs_save(void) +{ + return false; +} +#endif + /* * cpu_do_idle() * @@ -50,8 +90,18 @@ void __cpuidle cpu_do_idle(void) arm_cpuidle_save_irq_context(&context); if (likely(idle == ARM64_IDLE_WFI)) { - dsb(sy); - wfi(); + if (apple_wfi_needs_save()) { + /* + * The FP/SIMD registers do not survive either: drop the + * lazy ownership so the next return to userspace reloads + * them, even when the same task resumes on this CPU. + */ + fpsimd_save_and_flush_cpu_state(); + apple_cpu_wfi(); + } else { + dsb(sy); + wfi(); + } } else if (idle == ARM64_IDLE_YIELD) { dsb(sy); asm volatile("yield" ::: "memory"); From 568b9d23cb310dfcbe04fe60b05589093bcba21e Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:03:18 +1000 Subject: [PATCH 06/14] dt-bindings: cpufreq: apple,cluster-cpufreq: Add T8140 compatible The CPU clusters of the Apple T8140 (A18 Pro) use the same command register layout as T8112, with a 5-bit state field, but Linux has to drive them differently: every transition must be verified, the state left by the bootloader must be adopted rather than overwritten, and states above 2 may only be used under a thermal policy. Add the compatible without the generic "apple,cluster-cpufreq" fallback. A kernel that only knows the fallback must not program these clusters: it would drive them without verifying any transition and expose the whole ladder without thermal coupling. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- .../devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml b/Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml index b51913a817917..8e87c0f6d3d45 100644 --- a/Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml +++ b/Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml @@ -35,6 +35,7 @@ properties: - const: apple,t7000-cluster-cpufreq - const: apple,s5l8960x-cluster-cpufreq - const: apple,s5l8960x-cluster-cpufreq + - const: apple,t8140-cluster-cpufreq - items: - const: apple,t6020-cluster-cpufreq - const: apple,t8112-cluster-cpufreq From 31ce0bec7173eb3fbc1067e6dba46c2ca2f4dc8e Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:14:55 +1000 Subject: [PATCH 07/14] cpufreq: apple-soc: Add T8140 support The Apple T8140 (A18 Pro) clusters take P-state requests through the same command register layout as T8112, but this driver cannot assume that it owns them from the start: the bootloader leaves a state of its own choosing, and nothing guarantees that no other agent writes the register later. Add them with a per-SoC verify_transition mode: - At init, wait for the controller to be idle, read the state left in the command register and adopt it as policy->cur. A state that is not in the OPP table fails init with -ERANGE rather than being replaced by one whose effect is unknown. - Before each request, check that the register still holds the state this driver last set or adopted; anything else means another agent has changed it. After writing, poll until the controller is idle and reports the requested state. A request for the current state is skipped. - A busy timeout, an unexpected state or a completion timeout latches the cluster as failed. The driver logs the command register once and then returns -EIO for every later request without touching the hardware, so the cluster stays wherever the controller stopped and no governor, user limit or thermal cap can move it until the policy is torn down and initialised again. The driver deliberately does not guess a rollback after an unexplained failure. - Fast switching is disabled, because a verified request can busy-wait for up to twice APPLE_DVFS_TRANSITION_TIMEOUT, and that doubled bound is the transition latency the policy advertises when the DT gives none. - T8140 state IDs start at 1, so the info data gains min_pstate. Its DVFS_STATUS layout is not known, so ->get() uses the existing command-register fallback and reports the last accepted request, not a measured frequency. The T8140 ladders go up to P17 (4.044 GHz) on the P cluster and E6 (2.424 GHz) on the E cluster. States above 2 need a thermal policy that can cap them; until one is coupled to this driver, a T8140 OPP table containing them is refused. Three changes apply to every SoC the driver handles: - OPP levels outside [min_pstate, max_pstate] fail init, and apple_soc_cpufreq_set_target() rejects them. The old "fallback" clamp compared the table index rather than the level and ran after the level had been read, so an out-of-range level was shifted unmasked into the command register, over the neighbouring bits. No in-tree Apple DT has such a level. - A cluster node with status = "disabled" is left alone. - The cluster node reference is dropped after of_iomap() instead of before it. All SoCs keep sharing one cpufreq_driver; the match data alone selects the T8140 behaviour. As on the other SoCs, T8140 clusters are set to their lowest state for system suspend. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 Signed-off-by: Ryan Murray --- drivers/cpufreq/apple-soc-cpufreq.c | 119 ++++++++++++++++++++++++++-- 1 file changed, 112 insertions(+), 7 deletions(-) diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c index 873f5fc5243d3..790d05d415785 100644 --- a/drivers/cpufreq/apple-soc-cpufreq.c +++ b/drivers/cpufreq/apple-soc-cpufreq.c @@ -62,6 +62,8 @@ struct apple_soc_cpufreq_info { bool has_ps2; + bool verify_transition; + u64 min_pstate; u64 max_pstate; u64 cur_pstate_mask; u64 cur_pstate_shift; @@ -73,6 +75,8 @@ struct apple_cpu_priv { struct device *cpu_dev; void __iomem *reg_base; const struct apple_soc_cpufreq_info *info; + bool transition_failed; + unsigned int expected_pstate; }; static struct cpufreq_driver apple_soc_cpufreq_driver; @@ -104,6 +108,20 @@ static const struct apple_soc_cpufreq_info soc_t8112_info = { .ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT, }; +/* + * T8140 uses 5-bit PS1 state IDs starting at 1. The command register reads + * back the last accepted request, not a measured frequency; every transition + * is verified, see apple_soc_cpufreq_set_target(). Voltage, PLL and firmware + * throttling configuration are left as the bootloader set them. + */ +static const struct apple_soc_cpufreq_info soc_t8140_info = { + .verify_transition = true, + .min_pstate = 1, + .max_pstate = 31, + .ps1_mask = APPLE_DVFS_CMD_PS1, + .ps1_shift = APPLE_DVFS_CMD_PS1_SHIFT, +}; + static const struct apple_soc_cpufreq_info soc_default_info = { .has_ps2 = false, .max_pstate = 15, @@ -129,6 +147,10 @@ static const struct of_device_id apple_soc_cpufreq_of_match[] __maybe_unused = { .compatible = "apple,cluster-cpufreq", .data = &soc_default_info, }, + { + .compatible = "apple,t8140-cluster-cpufreq", + .data = &soc_t8140_info, + }, {} }; @@ -175,16 +197,37 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy, unsigned int pstate = policy->freq_table[index].driver_data; u64 reg; - /* Fallback for newer SoCs */ - if (index > priv->info->max_pstate) - index = priv->info->max_pstate; + /* OPP level is a hardware ID, not the frequency-table array index. */ + if (pstate < priv->info->min_pstate || pstate > priv->info->max_pstate) + return -EINVAL; + if (priv->transition_failed) + return -EIO; if (readq_poll_timeout_atomic(priv->reg_base + APPLE_DVFS_CMD, reg, !(reg & APPLE_DVFS_CMD_BUSY), 2, APPLE_DVFS_TRANSITION_TIMEOUT)) { + if (priv->info->verify_transition) { + priv->transition_failed = true; + dev_err(priv->cpu_dev, + "DVFS busy timeout, command=%#llx; stopping requests\n", reg); + } return -EIO; } + if (priv->info->verify_transition) { + unsigned int previous = FIELD_GET(APPLE_DVFS_CMD_PS1, reg); + + /* Do not fight an unexpected retained policy owner. */ + if (previous != priv->expected_pstate) { + priv->transition_failed = true; + dev_err(priv->cpu_dev, "unexpected DVFS state %u (expected %u); stopping requests\n", + previous, priv->expected_pstate); + return -EIO; + } + if (previous == pstate) + return 0; + } + reg &= ~priv->info->ps1_mask; reg |= pstate << priv->info->ps1_shift; if (priv->info->has_ps2) { @@ -195,6 +238,20 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy, writeq_relaxed(reg, priv->reg_base + APPLE_DVFS_CMD); + if (priv->info->verify_transition && + readq_poll_timeout_atomic(priv->reg_base + APPLE_DVFS_CMD, reg, + !(reg & APPLE_DVFS_CMD_BUSY) && + FIELD_GET(APPLE_DVFS_CMD_PS1, reg) == pstate, + 2, APPLE_DVFS_TRANSITION_TIMEOUT)) { + /* Do not issue another request or guess a rollback after failure. */ + priv->transition_failed = true; + dev_err(priv->cpu_dev, + "DVFS completion timeout, command=%#llx; stopping requests\n", reg); + return -ETIMEDOUT; + } + if (priv->info->verify_transition) + priv->expected_pstate = pstate; + return 0; } @@ -222,13 +279,15 @@ static int apple_soc_cpufreq_find_cluster(struct cpufreq_policy *policy, return ret; match = of_match_node(apple_soc_cpufreq_of_match, args.np); - of_node_put(args.np); - if (!match) + if (!match || !of_device_is_available(args.np)) { + of_node_put(args.np); return -ENODEV; + } *info = match->data; *reg_base = of_iomap(args.np, 0); + of_node_put(args.np); if (!*reg_base) return -ENOMEM; @@ -237,6 +296,7 @@ static int apple_soc_cpufreq_find_cluster(struct cpufreq_policy *policy, static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) { + struct cpufreq_frequency_table *p; int ret, i; unsigned int transition_latency; void __iomem *reg_base; @@ -291,6 +351,33 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) } freq_table[i].driver_data = dev_pm_opp_get_level(opp); dev_pm_opp_put(opp); + if (freq_table[i].driver_data < info->min_pstate || + freq_table[i].driver_data > info->max_pstate) { + ret = -EINVAL; + goto out_free_cpufreq_table; + } + } + + if (info->verify_transition) { + u64 cmd; + unsigned int state; + + /* Registration must not silently reset an unknown inherited state. */ + ret = readq_poll_timeout_atomic(reg_base + APPLE_DVFS_CMD, cmd, + !(cmd & APPLE_DVFS_CMD_BUSY), 2, + APPLE_DVFS_TRANSITION_TIMEOUT); + if (ret) + goto out_free_cpufreq_table; + state = FIELD_GET(APPLE_DVFS_CMD_PS1, cmd); + for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) + if (freq_table[i].driver_data == state) + break; + if (freq_table[i].frequency == CPUFREQ_TABLE_END) { + ret = -ERANGE; + goto out_free_cpufreq_table; + } + policy->cur = freq_table[i].frequency; + priv->expected_pstate = state; } priv->cpu_dev = cpu_dev; @@ -300,13 +387,31 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) policy->freq_table = freq_table; transition_latency = dev_pm_opp_get_max_transition_latency(cpu_dev); - if (!transition_latency) + if (!transition_latency) { + /* Conservative transaction bound, not a measured transition time. */ transition_latency = APPLE_DVFS_TRANSITION_TIMEOUT * NSEC_PER_USEC; + if (info->verify_transition) + transition_latency *= 2; + } policy->cpuinfo.transition_latency = transition_latency; policy->dvfs_possible_from_any_cpu = true; - policy->fast_switch_possible = true; + policy->fast_switch_possible = !info->verify_transition; policy->suspend_freq = freq_table[0].frequency; + if (info->verify_transition) { + /* + * P-states above 2 need a thermal policy that can cap them; + * refuse such a table rather than run it unthrottled. + */ + cpufreq_for_each_valid_entry(p, policy->freq_table) { + if (p->driver_data > 2) { + dev_err(cpu_dev, "P-state %u requires a CPU thermal policy\n", + p->driver_data); + ret = -ENODEV; + goto out_free_cpufreq_table; + } + } + } return 0; From 1a5f8adfb4fdd3c6bf197d90e46ff4bbfda579b2 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:15:29 +1000 Subject: [PATCH 08/14] dt-bindings: hwmon: apple,smc-hwmon: Add apple,cpu-thermal-policy The SMC in the J700 (T8140) reports six CPU die temperatures: Te05 and Te0S for the E cluster and Tp01, Tp05, Tp09 and Tp0D for the P cluster. Add a boolean property that makes the SMC hwmon node the telemetry source of the J700 CPU thermal policy. When it is present, the first six temperature channels must be exactly those keys, further channels only report to userspace, and the CPU frequency is held at its minimum while the six readings are unavailable. This describes operating-system policy rather than hardware. The standard description of a thermal sensor is #thermal-sensor-cells on this node plus thermal-zones and cooling-maps in the board DT; the J700 policy does not use that yet because it also holds a minimum-frequency cap while the readings are stale, which DT thermal zones cannot express. The property is a downstream binding and goes away when the J700 CPU thermal policy moves to DT thermal zones. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- .../devicetree/bindings/hwmon/apple,smc-hwmon.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml index 2eec317bc4b3e..f3751b5af1720 100644 --- a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml +++ b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml @@ -40,6 +40,14 @@ properties: compatible: const: apple,smc-hwmon + apple,cpu-thermal-policy: + type: boolean + description: + Enable the J700 CPU thermal provider over the first six temperature + channels, which must contain Te05, Te0S, Tp01, Tp05, Tp09 and Tp0D. + Further temperature channels are reporting-only. The provider holds + CPU frequency constraints while these readings are unavailable. + patternProperties: "^current-[A-Za-z0-9]{4}$": $ref: "#/$defs/sensor" From ae37f03d4163df8143b2144e742916b91bf90654 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:17:39 +1000 Subject: [PATCH 09/14] thermal: apple-smc-cpu: Add the J700 CPU thermal policy Add the CPU thermal policy that the J700 (T8140) needs before apple-soc-cpufreq may use P-states above 2, and couple the cpufreq driver to it. The policy follows the hottest of six SMC CPU die sensors, read every 25 ms through a callback registered with devm_apple_smc_thermal_register() (the SMC hwmon driver provides it). It has two controls: - A thermal zone, "apple-smc-selected", with one passive trip at 95 C and 10 C of hysteresis. Its binding sets both the lower and the upper limit to the maximum state of the two cpufreq cooling devices, so step_wise sends both clusters straight to their lowest frequency when the trip is crossed instead of stepping down the table. - A FREQ_QOS_MAX request per cluster, added at the lowest frequency when cpufreq attaches the cluster. It is released only while the zone is registered and enabled and the last three samples were read within 200 ms, and it is applied again from 103 C until the die is back below 98 C, after any read error or stale sample, when the zone is disabled, when a whole cluster goes offline, and after cpufreq reports a DVFS fault. A 25 ms watchdog re-evaluates it in case sampling stalls. Until a provider registers, both clusters stay at their lowest frequency. apple-soc-cpufreq attaches a T8140 cluster when its OPP table has states above 2 or the SMC hwmon node carries apple,cpu-thermal-policy, registers the cooling device from ->ready(), reports latched DVFS failures, and detaches in ->exit(). This replaces the outright refusal of such tables. If the policy cannot attach, the cluster is not registered. A latched cluster cannot act on the minimum request, but the other cluster is still capped. The thresholds are Linux operating policy, not Apple or silicon limits. The trip was first set at 80 C with a 70 C release, but with the spinning idle loop the J700 needed at the time the die idled at 70-77 C, inside that band, so the throttle never released and the P cluster was held between 1.26 and 2.20 GHz of its 4.044 GHz. The band now sits above the idle temperature, which is around 43 C with WFI idle. SMC readings can lag by about a second under load, so the 25 ms sampling does not bound the sensor age; the 200 ms limit only bounds the host transaction. This is a narrow, J700-only arrangement and not how thermal limits are meant to be described. It bypasses DT thermal zones even though macsmc-hwmon already registers its channels as thermal sensors and apple-soc-cpufreq is a cooling device; it hard-codes two clusters, runs three 25 ms timers (sampling, watchdog and zone polling) and only acts on "apple,j700" machines. DT thermal zones are the intended replacement: this driver, the provider hooks in macsmc-hwmon and apple,cpu-thermal-policy go away once the J700 device tree describes its CPU thermal zones and the stale-reading cap has an equivalent there. The driver is built in only, since it keeps global state and has no unload path. Its entry points are exported so that apple-soc-cpufreq and macsmc-hwmon can still be built as modules. The policy, its cpufreq coupling and the provider interface are Eryk Wieliczko's J700 SMC thermal mitigation for Aurora's tree (2026-09-08, GPL-2.0-only OR MIT), with the thresholds re-tuned as described above and without the auxiliary-zone and boot-cap adaptations that coupled it to the PMP coprocessor policy; those stay on the parked PMP branch. His Signed-off-by is outstanding. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 Signed-off-by: Ryan Murray --- drivers/cpufreq/apple-soc-cpufreq.c | 38 ++- drivers/thermal/Kconfig | 20 ++ drivers/thermal/Makefile | 1 + drivers/thermal/apple-smc-cpu-thermal.c | 370 ++++++++++++++++++++++++ include/linux/soc/apple/smc-thermal.h | 37 +++ 5 files changed, 457 insertions(+), 9 deletions(-) create mode 100644 drivers/thermal/apple-smc-cpu-thermal.c create mode 100644 include/linux/soc/apple/smc-thermal.h diff --git a/drivers/cpufreq/apple-soc-cpufreq.c b/drivers/cpufreq/apple-soc-cpufreq.c index 790d05d415785..c37fb272ada73 100644 --- a/drivers/cpufreq/apple-soc-cpufreq.c +++ b/drivers/cpufreq/apple-soc-cpufreq.c @@ -21,6 +21,7 @@ #include #include #include +#include #define APPLE_DVFS_CMD 0x20 #define APPLE_DVFS_CMD_BUSY BIT(31) @@ -77,6 +78,7 @@ struct apple_cpu_priv { const struct apple_soc_cpufreq_info *info; bool transition_failed; unsigned int expected_pstate; + struct apple_smc_thermal_cpu *thermal; }; static struct cpufreq_driver apple_soc_cpufreq_driver; @@ -208,6 +210,7 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy, APPLE_DVFS_TRANSITION_TIMEOUT)) { if (priv->info->verify_transition) { priv->transition_failed = true; + apple_smc_thermal_cpu_fault(priv->thermal); dev_err(priv->cpu_dev, "DVFS busy timeout, command=%#llx; stopping requests\n", reg); } @@ -220,6 +223,7 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy, /* Do not fight an unexpected retained policy owner. */ if (previous != priv->expected_pstate) { priv->transition_failed = true; + apple_smc_thermal_cpu_fault(priv->thermal); dev_err(priv->cpu_dev, "unexpected DVFS state %u (expected %u); stopping requests\n", previous, priv->expected_pstate); return -EIO; @@ -245,6 +249,7 @@ static int apple_soc_cpufreq_set_target(struct cpufreq_policy *policy, 2, APPLE_DVFS_TRANSITION_TIMEOUT)) { /* Do not issue another request or guess a rollback after failure. */ priv->transition_failed = true; + apple_smc_thermal_cpu_fault(priv->thermal); dev_err(priv->cpu_dev, "DVFS completion timeout, command=%#llx; stopping requests\n", reg); return -ETIMEDOUT; @@ -399,15 +404,21 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) policy->fast_switch_possible = !info->verify_transition; policy->suspend_freq = freq_table[0].frequency; if (info->verify_transition) { - /* - * P-states above 2 need a thermal policy that can cap them; - * refuse such a table rather than run it unthrottled. - */ - cpufreq_for_each_valid_entry(p, policy->freq_table) { - if (p->driver_data > 2) { - dev_err(cpu_dev, "P-state %u requires a CPU thermal policy\n", - p->driver_data); - ret = -ENODEV; + struct device_node *hwmon; + bool higher = false; + bool thermal; + + /* P-states above 2 are only allowed under the SMC thermal policy. */ + cpufreq_for_each_valid_entry(p, policy->freq_table) + if (p->driver_data > 2) + higher = true; + hwmon = of_find_compatible_node(NULL, NULL, "apple,smc-hwmon"); + thermal = hwmon && of_property_read_bool(hwmon, "apple,cpu-thermal-policy"); + of_node_put(hwmon); + if (higher || thermal) { + priv->thermal = apple_smc_thermal_cpu_add(policy); + if (IS_ERR(priv->thermal)) { + ret = PTR_ERR(priv->thermal); goto out_free_cpufreq_table; } } @@ -430,6 +441,7 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy) { struct apple_cpu_priv *priv = policy->driver_data; + apple_smc_thermal_cpu_remove(priv->thermal); dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table); /* * The core clears the last CPU from policy->cpus before calling @@ -440,6 +452,13 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy) kfree(priv); } +static void apple_soc_cpufreq_ready(struct cpufreq_policy *policy) +{ + struct apple_cpu_priv *priv = policy->driver_data; + + apple_smc_thermal_cpu_ready(priv->thermal); +} + static struct cpufreq_driver apple_soc_cpufreq_driver = { .name = "apple-cpufreq", .flags = CPUFREQ_HAVE_GOVERNOR_PER_POLICY | @@ -453,6 +472,7 @@ static struct cpufreq_driver apple_soc_cpufreq_driver = { .register_em = cpufreq_register_em_with_opp, .set_boost = cpufreq_boost_set_sw, .suspend = cpufreq_generic_suspend, + .ready = apple_soc_cpufreq_ready, }; static int __init apple_soc_cpufreq_module_init(void) diff --git a/drivers/thermal/Kconfig b/drivers/thermal/Kconfig index b10080d618604..15fc1d56d9540 100644 --- a/drivers/thermal/Kconfig +++ b/drivers/thermal/Kconfig @@ -527,4 +527,24 @@ config LOONGSON2_THERMAL is higher than the high temperature threshold or lower than the low temperature threshold, the interrupt will occur. +config APPLE_SMC_CPU_THERMAL + bool "Apple J700 SMC CPU thermal policy" + depends on ARCH_APPLE || COMPILE_TEST + depends on ARM_APPLE_SOC_CPUFREQ && SENSORS_MACSMC_HWMON + depends on CPU_FREQ_THERMAL + select THERMAL_GOV_STEP_WISE + help + CPU thermal policy for the Apple J700 (T8140). It follows the + hottest of six SMC CPU die sensors, sends both CPU clusters to + their lowest frequency through cpufreq cooling devices above a + passive trip, and holds them there through a frequency QoS + request while the readings are missing, stale or failing, while + the zone is disabled, or above a second, hard threshold. + + apple-soc-cpufreq only allows T8140 P-states above 2 when this + policy is present. The thresholds are Linux operating policy, not + Apple or silicon limits. + + Say Y for J700 kernels. + endif diff --git a/drivers/thermal/Makefile b/drivers/thermal/Makefile index bb21e7ea7fc6b..e88a682c75851 100644 --- a/drivers/thermal/Makefile +++ b/drivers/thermal/Makefile @@ -68,4 +68,5 @@ obj-$(CONFIG_AMLOGIC_THERMAL) += amlogic_thermal.o obj-$(CONFIG_SPRD_THERMAL) += sprd_thermal.o obj-$(CONFIG_KHADAS_MCU_FAN_THERMAL) += khadas_mcu_fan.o obj-$(CONFIG_LOONGSON2_THERMAL) += loongson2_thermal.o +obj-$(CONFIG_APPLE_SMC_CPU_THERMAL) += apple-smc-cpu-thermal.o obj-$(CONFIG_THERMAL_CORE_TESTING) += testing/ diff --git a/drivers/thermal/apple-smc-cpu-thermal.c b/drivers/thermal/apple-smc-cpu-thermal.c new file mode 100644 index 0000000000000..8ad053205f13e --- /dev/null +++ b/drivers/thermal/apple-smc-cpu-thermal.c @@ -0,0 +1,370 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * Apple J700 CPU thermal policy over selected SMC telemetry + * + * Copyright (C) 2026 Eryk Wieliczko + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Two controls act on the hottest of the six selected sensors: a passive + * trip bound to maximum cpufreq cooling (95 C, released below 85 C), and a + * hard tier that pins both clusters to their minimum frequency through a + * frequency-QoS guard (from 103 C, released below 98 C). The guard also + * holds the minimum while readings are missing, stale or failing, while the + * zone is disabled, and after a cpufreq DVFS fault. + * + * The band sits above the idle temperature: the original 80 C trip with a + * 70 C release latched the throttle permanently while the die idled at + * 70-77 C with the spinning idle loop, because step_wise never saw it drop + * below the release point. + * + * The thresholds are Linux operating policy, not Apple or silicon limits. + * SMC readings can lag a successful read by about a second under load, so + * faster host polling does not bound the sensor age; the 200 ms limit only + * bounds the host transaction. + */ +#define SMC_TRIP_MC 95000 +#define SMC_RELEASE_MC 85000 +#define SMC_HOT_MC 103000 +#define SMC_HOT_RELEASE_MC 98000 +#define SMC_SAMPLE_MS 25 +#define SMC_MAX_AGE_MS APPLE_SMC_THERMAL_MAX_AGE_MS +#define SMC_WATCH_MS 25 + +struct apple_smc_thermal_cpu { + struct cpufreq_policy *policy; + struct freq_qos_request guard; + struct thermal_cooling_device *cdev; + unsigned int min_freq; + bool failed; +}; + +static DEFINE_MUTEX(smc_lock); +/* Only sampling/removal take this lock: a stuck SMC read cannot block guards. */ +static DEFINE_MUTEX(smc_provider_lock); +static struct apple_smc_thermal_cpu *smc_cpus[2]; +static struct thermal_zone_device *smc_zone; +static int (*smc_read)(void *, int *); +static void *smc_ctx; +static unsigned long smc_sample_time; +static unsigned int smc_good; +static int smc_value, smc_error = -ENODATA; +static bool smc_enabled, smc_hot; +static void smc_sample_work(struct work_struct *work); +static void smc_watch_work(struct work_struct *work); +static DECLARE_DELAYED_WORK(smc_sample, smc_sample_work); +static DECLARE_DELAYED_WORK(smc_watch, smc_watch_work); + +static bool smc_fresh(void) +{ + return !smc_error && time_before(jiffies, + smc_sample_time + msecs_to_jiffies(SMC_MAX_AGE_MS)); +} + +/* smc_lock held. QoS is independent of user limits and the thermal governor. */ +static void smc_update_guards(void) +{ + bool healthy = smc_zone && smc_enabled && smc_fresh() && smc_good >= 3; + bool clamp = !healthy || smc_hot; + bool error = false; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (smc_cpus[i] && READ_ONCE(smc_cpus[i]->failed)) + clamp = true; + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) { + struct apple_smc_thermal_cpu *cpu = smc_cpus[i]; + int ret; + + if (!cpu) + continue; + ret = freq_qos_update_request(&cpu->guard, clamp || READ_ONCE(cpu->failed) ? + cpu->min_freq : FREQ_QOS_MAX_DEFAULT_VALUE); + if (ret < 0) { + error = true; + WRITE_ONCE(cpu->failed, true); + freq_qos_update_request(&cpu->guard, cpu->min_freq); + pr_err_ratelimited("apple-smc-thermal: CPU%u guard update failed: %d\n", + cpu->policy->cpu, ret); + } + } + if (error) + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (smc_cpus[i]) + freq_qos_update_request(&smc_cpus[i]->guard, smc_cpus[i]->min_freq); +} + +static int smc_zone_temp(struct thermal_zone_device *zone, int *temp) +{ + guard(mutex)(&smc_lock); + if (!smc_fresh()) + return smc_error ?: -ETIMEDOUT; + *temp = smc_value; + return 0; +} + +static int smc_zone_mode(struct thermal_zone_device *zone, enum thermal_device_mode mode) +{ + guard(mutex)(&smc_lock); + smc_enabled = mode == THERMAL_DEVICE_ENABLED; + smc_good = 0; + smc_update_guards(); + return 0; +} + +static bool smc_zone_bind(struct thermal_zone_device *zone, const struct thermal_trip *trip, + struct thermal_cooling_device *cdev, struct cooling_spec *spec) +{ + unsigned int i; + + guard(mutex)(&smc_lock); + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (smc_cpus[i] && smc_cpus[i]->cdev == cdev) { + spec->lower = cdev->max_state; + spec->upper = cdev->max_state; + return true; + } + return false; +} + +static const struct thermal_zone_device_ops smc_zone_ops = { + .get_temp = smc_zone_temp, + .change_mode = smc_zone_mode, + .should_bind = smc_zone_bind, +}; + +static const struct thermal_trip smc_trips[] = { + { .temperature = SMC_TRIP_MC, .hysteresis = SMC_TRIP_MC - SMC_RELEASE_MC, + .type = THERMAL_TRIP_PASSIVE }, +}; + +static const struct thermal_zone_params smc_params = { + .governor_name = "step_wise", + .no_hwmon = true, +}; + +static int smc_check_binding(struct thermal_trip *trip, void *data) +{ + struct thermal_zone_device *zone = data; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (!thermal_trip_is_bound_to_cdev(zone, trip, smc_cpus[i]->cdev)) + return -ENODEV; + return 0; +} + +/* provider_lock held; never register/update a zone while holding smc_lock. */ +static void smc_start_zone(void) +{ + struct thermal_zone_device *zone; + int ret; + + if (smc_zone || !smc_read || !smc_cpus[0] || !smc_cpus[1] || + !smc_cpus[0]->cdev || !smc_cpus[1]->cdev) + return; + zone = thermal_zone_device_register_with_trips("apple-smc-selected", + smc_trips, + ARRAY_SIZE(smc_trips), + NULL, &smc_zone_ops, + &smc_params, + SMC_SAMPLE_MS, + SMC_SAMPLE_MS); + if (IS_ERR(zone)) { + pr_err("apple-smc-thermal: zone registration failed: %ld\n", PTR_ERR(zone)); + return; + } + ret = for_each_thermal_trip(zone, smc_check_binding, zone); + if (ret) { + thermal_zone_device_unregister(zone); + pr_err("apple-smc-thermal: missing CPU cooling binding\n"); + return; + } + mutex_lock(&smc_lock); + smc_zone = zone; + mutex_unlock(&smc_lock); + ret = thermal_zone_device_enable(zone); + if (ret) + pr_err("apple-smc-thermal: zone enable failed: %d; retaining minimum caps\n", ret); +} + +static void smc_sample_work(struct work_struct *work) +{ + unsigned long start = jiffies; + int value = 0, ret; + + guard(mutex)(&smc_provider_lock); + if (!smc_read) + return; + ret = smc_read(smc_ctx, &value); + if (!ret && time_after_eq(jiffies, start + msecs_to_jiffies(SMC_MAX_AGE_MS))) + ret = -ETIMEDOUT; + mutex_lock(&smc_lock); + smc_error = ret; + if (ret) { + smc_good = 0; + } else { + smc_value = value; + smc_sample_time = start; /* Bound the age of the oldest read in the round. */ + if (smc_good < 3) + smc_good++; + if (value >= SMC_HOT_MC) + smc_hot = true; + else if (value < SMC_HOT_RELEASE_MC) + smc_hot = false; + } + smc_update_guards(); + mutex_unlock(&smc_lock); + if (smc_zone) + thermal_zone_device_update(smc_zone, THERMAL_EVENT_UNSPECIFIED); + queue_delayed_work(system_unbound_wq, &smc_sample, msecs_to_jiffies(SMC_SAMPLE_MS)); +} + +static void smc_watch_work(struct work_struct *work) +{ + guard(mutex)(&smc_lock); + if (!smc_fresh()) + smc_good = 0; + smc_update_guards(); + if (smc_cpus[0] || smc_cpus[1]) + queue_delayed_work(system_unbound_wq, &smc_watch, msecs_to_jiffies(SMC_WATCH_MS)); +} + +struct apple_smc_thermal_cpu *apple_smc_thermal_cpu_add(struct cpufreq_policy *policy) +{ + struct apple_smc_thermal_cpu *cpu; + unsigned int i; + int ret; + + if (!of_machine_is_compatible("apple,j700")) + return ERR_PTR(-ENODEV); + cpu = kzalloc_obj(*cpu); + if (!cpu) + return ERR_PTR(-ENOMEM); + cpu->policy = policy; + cpu->min_freq = policy->freq_table[0].frequency; + ret = freq_qos_add_request(&policy->constraints, &cpu->guard, FREQ_QOS_MAX, + policy->freq_table[0].frequency); + if (ret < 0) { + kfree(cpu); + return ERR_PTR(ret); + } + mutex_lock(&smc_provider_lock); + mutex_lock(&smc_lock); + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (!smc_cpus[i]) { + smc_cpus[i] = cpu; + break; + } + mutex_unlock(&smc_lock); + mutex_unlock(&smc_provider_lock); + if (i == ARRAY_SIZE(smc_cpus)) { + freq_qos_remove_request(&cpu->guard); + kfree(cpu); + return ERR_PTR(-EBUSY); + } + queue_delayed_work(system_unbound_wq, &smc_watch, 0); + return cpu; +} +EXPORT_SYMBOL_GPL(apple_smc_thermal_cpu_add); + +void apple_smc_thermal_cpu_ready(struct apple_smc_thermal_cpu *cpu) +{ + if (!cpu) + return; + guard(mutex)(&smc_provider_lock); + cpu->cdev = cpufreq_cooling_register(cpu->policy); + if (IS_ERR(cpu->cdev)) { + pr_err("apple-smc-thermal: cooling registration failed: %ld\n", PTR_ERR(cpu->cdev)); + cpu->cdev = NULL; + return; + } + smc_start_zone(); +} +EXPORT_SYMBOL_GPL(apple_smc_thermal_cpu_ready); + +void apple_smc_thermal_cpu_fault(struct apple_smc_thermal_cpu *cpu) +{ + if (!cpu) + return; + /* Called inside target_index: do not recursively take the policy lock. */ + WRITE_ONCE(cpu->failed, true); + mod_delayed_work(system_unbound_wq, &smc_watch, 0); +} +EXPORT_SYMBOL_GPL(apple_smc_thermal_cpu_fault); + +void apple_smc_thermal_cpu_remove(struct apple_smc_thermal_cpu *cpu) +{ + struct thermal_zone_device *zone; + unsigned int i; + + if (!cpu) + return; + guard(mutex)(&smc_provider_lock); + mutex_lock(&smc_lock); + zone = smc_zone; + smc_zone = NULL; + smc_enabled = false; + smc_good = 0; + smc_update_guards(); + mutex_unlock(&smc_lock); + if (zone) + thermal_zone_device_unregister(zone); + cpufreq_cooling_unregister(cpu->cdev); + mutex_lock(&smc_lock); + for (i = 0; i < ARRAY_SIZE(smc_cpus); i++) + if (smc_cpus[i] == cpu) + smc_cpus[i] = NULL; + freq_qos_remove_request(&cpu->guard); + mutex_unlock(&smc_lock); + kfree(cpu); +} +EXPORT_SYMBOL_GPL(apple_smc_thermal_cpu_remove); + +static void smc_provider_remove(void *unused) +{ + mutex_lock(&smc_provider_lock); + smc_read = NULL; + smc_ctx = NULL; + mutex_lock(&smc_lock); + smc_error = -ENODEV; + smc_good = 0; + smc_update_guards(); + mutex_unlock(&smc_lock); + mutex_unlock(&smc_provider_lock); + cancel_delayed_work_sync(&smc_sample); +} + +int devm_apple_smc_thermal_register(struct device *dev, int (*read)(void *, int *), void *ctx) +{ + int ret; + + if (!of_machine_is_compatible("apple,j700")) + return -ENODEV; + mutex_lock(&smc_provider_lock); + if (smc_read) { + mutex_unlock(&smc_provider_lock); + return -EBUSY; + } + smc_ctx = ctx; + smc_read = read; + smc_start_zone(); + mutex_unlock(&smc_provider_lock); + ret = devm_add_action_or_reset(dev, smc_provider_remove, NULL); + if (!ret) + queue_delayed_work(system_unbound_wq, &smc_sample, 0); + return ret; +} +EXPORT_SYMBOL_GPL(devm_apple_smc_thermal_register); diff --git a/include/linux/soc/apple/smc-thermal.h b/include/linux/soc/apple/smc-thermal.h new file mode 100644 index 0000000000000..9cd5788e55cc8 --- /dev/null +++ b/include/linux/soc/apple/smc-thermal.h @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ +/* + * Apple J700 CPU thermal policy: cpufreq and telemetry provider interface + * + * Copyright (C) 2026 Eryk Wieliczko + */ +#ifndef _APPLE_SMC_THERMAL_H +#define _APPLE_SMC_THERMAL_H + +#include +#include +#include + +struct cpufreq_policy; +struct device; +struct apple_smc_thermal_cpu; + +/* Maximum host transaction/cache age, NOT a firmware sensor-age guarantee. */ +#define APPLE_SMC_THERMAL_MAX_AGE_MS 200 + +#if IS_REACHABLE(CONFIG_APPLE_SMC_CPU_THERMAL) +struct apple_smc_thermal_cpu *apple_smc_thermal_cpu_add(struct cpufreq_policy *policy); +void apple_smc_thermal_cpu_ready(struct apple_smc_thermal_cpu *cpu); +void apple_smc_thermal_cpu_remove(struct apple_smc_thermal_cpu *cpu); +void apple_smc_thermal_cpu_fault(struct apple_smc_thermal_cpu *cpu); +int devm_apple_smc_thermal_register(struct device *dev, int (*read)(void *, int *), void *ctx); +#else +static inline struct apple_smc_thermal_cpu * +apple_smc_thermal_cpu_add(struct cpufreq_policy *policy) { return ERR_PTR(-ENODEV); } +static inline void apple_smc_thermal_cpu_ready(struct apple_smc_thermal_cpu *cpu) {} +static inline void apple_smc_thermal_cpu_remove(struct apple_smc_thermal_cpu *cpu) {} +static inline void apple_smc_thermal_cpu_fault(struct apple_smc_thermal_cpu *cpu) {} +static inline int devm_apple_smc_thermal_register(struct device *dev, + int (*read)(void *, int *), void *ctx) +{ return -ENODEV; } +#endif +#endif From cbbb86645f96bd12eac83bb6628c8c0f22378df5 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:17:52 +1000 Subject: [PATCH 10/14] hwmon: (macsmc-hwmon) Expose the CPU sensors to the SMC thermal policy When the SMC hwmon node carries apple,cpu-thermal-policy (J700 only), supply the CPU die temperatures to the SMC CPU thermal policy: - At probe, check that the first six temperature channels are exactly Te05, Te0S, Tp01, Tp05, Tp09 and Tp0D, each a readable 4-byte "flt " key that is not a function key, and register a sampling callback with devm_apple_smc_thermal_register(). A mismatch, a machine other than the J700 or a failed registration fails the probe. That includes -ENODEV when the thermal policy is not built, in which case the SMC sensors are missing from hwmon altogether. - The callback reads the six keys and returns the highest value in millidegrees. A read error (a NaN reading is now -ENODATA), a value outside the range of an int (-ERANGE) or a round that took 200 ms or more (-ETIMEDOUT) fails the sample. - Each successful round is cached, and reads of temp1 to temp6 are answered from the cache: userspace sees the values the policy acts on and adds no SMC traffic of its own. Those reads return the last sampling error, or -ETIMEDOUT once the cache is older than 200 ms. Channels after the sixth are read from the SMC as before. The channels are identified by position, so the board DT must list the six policy sensors first. Like the property, this is a J700-specific arrangement that goes away when the CPU thermal limits move to DT thermal zones. The provider is part of Eryk Wieliczko's J700 SMC thermal mitigation for Aurora's tree (2026-09-08, GPL-2.0-only OR MIT); the reporting-only channels after the sixth were added to it later in that tree. His Signed-off-by is outstanding. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- drivers/hwmon/macsmc-hwmon.c | 93 ++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c index 13e38b25c75fb..b41f8813d4165 100644 --- a/drivers/hwmon/macsmc-hwmon.c +++ b/drivers/hwmon/macsmc-hwmon.c @@ -22,17 +22,26 @@ #include #include +#include #include #include #include #include #include +#include #define MAX_LABEL_LENGTH 32 /* Temperature, voltage, current, power, fan(s) */ #define NUM_SENSOR_TYPES 5 +/* + * The J700 CPU thermal policy samples a fixed set of die temperatures, which + * must therefore be the first temperature channels; any further channels are + * only reported to userspace and never feed the policy. + */ +#define APPLE_SMC_CPU_POLICY_SENSORS 6 + #define FLT_EXP_BIAS 127 #define FLT_EXP_MASK GENMASK(30, 23) #define FLT_MANT_BIAS 23 @@ -86,6 +95,12 @@ struct macsmc_hwmon { struct macsmc_hwmon_sensors curr; struct macsmc_hwmon_sensors power; struct macsmc_hwmon_fans fan; + bool cpu_thermal_policy; + /* Protects the thermal_cache fields below. */ + struct mutex thermal_cache_lock; + long thermal_cache[APPLE_SMC_CPU_POLICY_SENSORS]; + unsigned long thermal_cache_time; + int thermal_cache_error; }; static int macsmc_hwmon_read_label(struct device *dev, @@ -359,6 +374,17 @@ static int macsmc_hwmon_read(struct device *dev, enum hwmon_sensor_types type, switch (type) { case hwmon_temp: + if (hwmon->cpu_thermal_policy && channel < APPLE_SMC_CPU_POLICY_SENSORS) { + guard(mutex)(&hwmon->thermal_cache_lock); + + if (hwmon->thermal_cache_error) + return hwmon->thermal_cache_error; + if (time_after_eq(jiffies, hwmon->thermal_cache_time + + msecs_to_jiffies(APPLE_SMC_THERMAL_MAX_AGE_MS))) + return -ETIMEDOUT; + *val = hwmon->thermal_cache[channel]; + return 0; + } ret = macsmc_hwmon_read_key(hwmon->smc, &hwmon->temp.sensors[channel], 1000, val); break; @@ -782,6 +808,70 @@ static int macsmc_hwmon_create_infos(struct macsmc_hwmon *hwmon) return 0; } +static int macsmc_hwmon_cpu_sample(void *ctx, int *temp) +{ + struct macsmc_hwmon *hwmon = ctx; + unsigned long start = jiffies; + long values[APPLE_SMC_CPU_POLICY_SENSORS], maximum = LONG_MIN; + unsigned int i; + int ret = 0; + + for (i = 0; i < ARRAY_SIZE(values); i++) { + ret = macsmc_hwmon_read_key(hwmon->smc, &hwmon->temp.sensors[i], 1000, &values[i]); + if (ret) + break; + if (values[i] < INT_MIN || values[i] > INT_MAX) { + ret = -ERANGE; + break; + } + maximum = max(maximum, values[i]); + } + if (!ret && time_after_eq(jiffies, start + msecs_to_jiffies(APPLE_SMC_THERMAL_MAX_AGE_MS))) + ret = -ETIMEDOUT; + guard(mutex)(&hwmon->thermal_cache_lock); + hwmon->thermal_cache_error = ret; + if (!ret) { + memcpy(hwmon->thermal_cache, values, sizeof(values)); + hwmon->thermal_cache_time = start; + *temp = maximum; + } + return ret; +} + +static int macsmc_hwmon_cpu_policy(struct macsmc_hwmon *hwmon) +{ + static const smc_key keys[] = { + SMC_KEY(Te05), SMC_KEY(Te0S), SMC_KEY(Tp01), + SMC_KEY(Tp05), SMC_KEY(Tp09), SMC_KEY(Tp0D), + }; + unsigned int i, j, seen = 0; + + static_assert(ARRAY_SIZE(keys) == APPLE_SMC_CPU_POLICY_SENSORS); + + if (!of_property_read_bool(hwmon->dev->of_node, "apple,cpu-thermal-policy")) + return 0; + if (!of_machine_is_compatible("apple,j700") || hwmon->temp.count < ARRAY_SIZE(keys)) + return -EINVAL; + for (i = 0; i < ARRAY_SIZE(keys); i++) { + struct macsmc_hwmon_sensor *sensor = &hwmon->temp.sensors[i]; + + if (sensor->info.type_code != __SMC_KEY('f', 'l', 't', ' ') || + sensor->info.size != 4 || !(sensor->info.flags & APPLE_SMC_READABLE) || + (sensor->info.flags & APPLE_SMC_FUNCTION)) + return -EINVAL; + for (j = 0; j < ARRAY_SIZE(keys); j++) + if (sensor->macsmc_key == keys[j]) + break; + if (j == ARRAY_SIZE(keys) || seen & BIT(j)) + return -EINVAL; + seen |= BIT(j); + } + mutex_init(&hwmon->thermal_cache_lock); + hwmon->thermal_cache_error = -ENODATA; + hwmon->cpu_thermal_policy = true; + return devm_apple_smc_thermal_register(hwmon->dev, macsmc_hwmon_cpu_sample, hwmon); +} + static int macsmc_hwmon_probe(struct platform_device *pdev) { struct apple_smc *smc = dev_get_drvdata(pdev->dev.parent); @@ -821,6 +911,9 @@ static int macsmc_hwmon_probe(struct platform_device *pdev) ret = macsmc_hwmon_create_infos(hwmon); if (ret) return ret; + ret = macsmc_hwmon_cpu_policy(hwmon); + if (ret) + return dev_err_probe(hwmon->dev, ret, "CPU thermal provider setup failed\n"); hwmon->chip_info.ops = &macsmc_hwmon_ops; hwmon->chip_info.info = From 7965f16c0533f8e60b9d9424517717ff504833ed Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:18:39 +1000 Subject: [PATCH 11/14] dt-bindings: mfd: apple,smc: Add apple,t8140-smc The SMC of the Apple T8140 (A18 Pro) is driven like the T8103 one, through the same mailbox protocol and the same "smc" and "sram" register regions; the J700 device tree describes it as "apple,t8140-smc", "apple,t8103-smc". Add the SoC compatible to the list that falls back to apple,t8103-smc. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- Documentation/devicetree/bindings/mfd/apple,smc.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/mfd/apple,smc.yaml b/Documentation/devicetree/bindings/mfd/apple,smc.yaml index d5d30c0538458..ed6b02086c33c 100644 --- a/Documentation/devicetree/bindings/mfd/apple,smc.yaml +++ b/Documentation/devicetree/bindings/mfd/apple,smc.yaml @@ -20,6 +20,7 @@ properties: - enum: - apple,t6020-smc - apple,t8122-smc + - apple,t8140-smc - const: apple,t8103-smc - items: - enum: From 63f8aafa3f0b9f41131804106fa1fbe91882456f Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:19:44 +1000 Subject: [PATCH 12/14] dt-bindings: spmi: apple,spmi: Add apple,t8140-spmi The SPMI controller of the Apple T8140 (A18 Pro), which connects the J700's Baku PMIC, is register compatible with the T8103 one. Add the SoC compatible with the apple,t8103-spmi fallback so that the J700 device tree can describe it. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- Documentation/devicetree/bindings/spmi/apple,spmi.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/spmi/apple,spmi.yaml b/Documentation/devicetree/bindings/spmi/apple,spmi.yaml index fceed47b2cd17..f0f7d21d031ca 100644 --- a/Documentation/devicetree/bindings/spmi/apple,spmi.yaml +++ b/Documentation/devicetree/bindings/spmi/apple,spmi.yaml @@ -25,6 +25,7 @@ properties: - apple,t8012-spmi - apple,t8015-spmi - apple,t8122-spmi + - apple,t8140-spmi - const: apple,t8103-spmi - items: - enum: From d9cc0564fa537560b30b5d1ba1333a0e4809caac Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:20:30 +1000 Subject: [PATCH 13/14] dt-bindings: nvmem: apple,spmi-nvmem: Add apple,baku-pmic The J700 (T8140) uses a PMIC called Baku. Like the PMICs already listed, it holds the boot-state scratch registers that apple,smc-reboot uses (boot stage, boot error and panic counters, and the shutdown flag) and exposes them over SPMI; on Baku they start at 0xf700. Add its compatible so that it can be described with the apple,spmi-nvmem fallback. Assisted-by: LLM checkpatch sparse Signed-off-by: Ryan Murray --- Documentation/devicetree/bindings/nvmem/apple,spmi-nvmem.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/nvmem/apple,spmi-nvmem.yaml b/Documentation/devicetree/bindings/nvmem/apple,spmi-nvmem.yaml index 4ca75ed07a54f..7a4114c7fbd19 100644 --- a/Documentation/devicetree/bindings/nvmem/apple,spmi-nvmem.yaml +++ b/Documentation/devicetree/bindings/nvmem/apple,spmi-nvmem.yaml @@ -18,6 +18,7 @@ properties: compatible: items: - enum: + - apple,baku-pmic - apple,maverick-pmic - apple,sera-pmic - apple,stowe-pmic From 73adb45383911623ffe356c8c530fc74cd97d278 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Sat, 26 Sep 2026 01:20:31 +1000 Subject: [PATCH 14/14] MAINTAINERS: Add the J700 idle and thermal files to the T8140 entry The T8140 WFI workaround and the J700 CPU thermal policy are Aurora Silicon code rather than Asahi Linux code, so list their files in the Apple T8140 / J700 entry instead of under ARM/APPLE MACHINE SUPPORT. Changes to the shared drivers (apple-soc-cpufreq, macsmc-hwmon) and to the DT bindings stay with their existing entries. Assisted-by: LLM checkpatch sparse Co-authored-by: Claude Fable 5.1 Signed-off-by: Ryan Murray --- MAINTAINERS | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4fd1875a9b93d..e78ba9b5a4b05 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1976,7 +1976,11 @@ F: Documentation/devicetree/bindings/serial/apple,dockchannel-uart.yaml F: Documentation/devicetree/bindings/soc/apple/apple,t8140-aop.yaml F: Documentation/devicetree/bindings/sound/apple,t8140-aop-audio.yaml F: arch/arm64/boot/dts/apple/t8140* +F: arch/arm64/include/asm/apple-idle.h +F: arch/arm64/kernel/idle-apple.S +F: drivers/thermal/apple-smc-cpu-thermal.c F: drivers/tty/serial/apple_dockchannel* +F: include/linux/soc/apple/smc-thermal.h APPLETALK NETWORK LAYER L: netdev@vger.kernel.org