From 07effed23425a059f2874f15623a33662a507ead Mon Sep 17 00:00:00 2001 From: Bartosz Nitka Date: Sun, 22 Nov 2026 21:06:21 +0100 Subject: [PATCH] soc: apple: clpc: hold ANE memory/fabric floor on T8142 The H17 ANE driver on T8142 (M5) already requests an ANE CLPC handle via apple_clpc_ane_get() and publishes activity via apple_clpc_ane_set_active(), and the T8142 device trees already declare "apple,t8142-clpc", but drivers/soc/apple/clpc.c neither lists "apple,t8142-clpc" in apple_clpc_ane_providers[] nor configures a floor in apple_clpc_hw_t8142. When the CPUs are idle or lightly loaded, both the DRAM controller (DCS) and SoC fabric stay at low states while ANE inference runs, throttling memory- and fabric-bound workloads. Register "apple,t8142-clpc" as an ANE CLPC provider and set apple_clpc_hw_t8142.ane to DCS 7 (top DCS state) and fabric 3 (a measured policy choice below top fabric state 4). Measured on J813 (MacBook Air 13" M5; J815 and J704 share the compatible and were not tested) via /sys/kernel/debug/ane-h17/.../ execute, CLPC ane_states, and macsmc_hwmon Total System Power: - Cold-SLC denoise-640 firmware time (CPU fixed at 1 GHz, pre-exec floor 0): 20.02 ms at (0, 0) -> 16.02 ms at (7, 0) -> 15.79 ms at (7, 1) -> 11.71 ms at (7, 2) -> 10.37 ms at (7, 3); (7, 4) is 10.36 ms (no gain). - Cold-SLC mm-512x2048 firmware time: 782 us at (0, 0) -> 728 us at (7, 0) -> 560 us at (7, 2) -> 526 us at (7, 3); (7, 4) is 552 us. - Controlled A-B-A sweep (CPU pinned at min freq so ANE owns the floor) across three workload classes shows fabric 3 saturates firmware time while fabric 4 adds 71-121 mW with zero speedup: * denoise-640 (conv UNet): 16.48 ms (0, 0) -> 11.67 ms (7, 2) -> 10.33 ms / 4.284 W (7, 3) vs 10.35 ms / 4.405 W (7, 4) (+121 mW). * unet-320 (conv UNet): 3.94 ms (0, 0) -> 2.79 ms (7, 2) -> 2.46 ms / 3.944 W (7, 3) vs 2.46 ms / 4.035 W (7, 4) (+91 mW). * mm-512x2048 (GEMM): 627 us (0, 0) -> 493 us (7, 2) -> 420 us / 3.948 W (7, 3) vs 420 us / 4.019 W (7, 4) (+71 mW). - Default schedutil (warm SLC, 100 runs) denoise-640 firmware / p50 host latency: 11.60 / 15.43 ms at (0, 0) -> 10.35 / 13.90 ms at (7, 3); (7, 4) adds +95 mW (4.841 vs 4.746 W) with no fw speedup. - Sustained 10.5 min (631 s, 45,164 runs) continuous denoise-640 soak on fanless J813: 4.717 W mean total system power, SoC die plateaued at 31.7 C (21.8 C ambient), 0 CLPC update errors, bit-exact sha256. Closing /dev/accel/accel0 drops the floor to 0x0 within 1 s and returns idle system power to 2.48 W (vs 2.52 W median pre-soak). Under combined ANE + 10-core CPU load, PMP fast-die-effort (lane1) still engages cleanly at 96.7 C and holds die temp <= 99.6 C. - Pinning CPU P-cluster frequency from 1.0 to 4.46 GHz does not change ANE firmware time (10.25 vs 10.24 ms), so no CPU cluster floor is needed. Update the apple-clpc-gpu KUnit suite to assert T8142's DCS 7 / fabric 3 ANE demand instead of expecting no ANE floor on T8142. Signed-off-by: Bartosz Nitka --- drivers/soc/apple/clpc.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/soc/apple/clpc.c b/drivers/soc/apple/clpc.c index c3ca54ba859db..53230b745cb5f 100644 --- a/drivers/soc/apple/clpc.c +++ b/drivers/soc/apple/clpc.c @@ -403,6 +403,7 @@ static const struct of_device_id apple_clpc_ane_providers[] = { { .compatible = "apple,t6041-max-clpc" }, { .compatible = "apple,t6041-clpc" }, { .compatible = "apple,t8140-clpc" }, + { .compatible = "apple,t8142-clpc" }, {} }; @@ -1749,6 +1750,20 @@ static const struct apple_clpc_hw apple_clpc_hw_t8142 = { [APPLE_CLPC_SOC] = { 1, 2, 3, 4 }, }, .gpu_input = true, + /* + * Measured ANE demand (J813, H17; J815/J704 share the compatible and + * are untested): DCS 7 is the top DCS state; fabric 3 is a measured + * policy choice below the top fabric state (4). With the CPU pinned at + * minimum frequency so ANE owns the floor, firmware time drops from + * (0, 0) -> (7, 2) -> (7, 3) across denoise-640 (16.5 -> 11.7 -> 10.3 + * ms; cold SLC 20.0 -> 11.7 -> 10.4 ms), unet-320 conv (3.94 -> 2.79 + * -> 2.46 ms), and mm-512x2048 GEMM (627 -> 493 -> 420 us; cold SLC + * 782 -> 560 -> 526 us). Fabric 4 gives no further speedup on any of + * them and adds 71-121 mW of system power (4.28 -> 4.41 W on + * denoise-640, 3.94 -> 4.04 W on unet-320, 3.95 -> 4.02 W on + * mm-512x2048). + */ + .ane = { [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 3 }, }; #if IS_BUILTIN(CONFIG_KUNIT) && !defined(MODULE) @@ -1989,6 +2004,18 @@ static void apple_clpc_ane_demand_hold_test(struct kunit *test) /* T6040 holds its top qualified DCS and fabric states for the ANE. */ KUNIT_EXPECT_EQ(test, apple_clpc_hw_t6040.ane[APPLE_CLPC_DCS], 5); KUNIT_EXPECT_EQ(test, apple_clpc_hw_t6040.ane[APPLE_CLPC_SOC], 2); + /* T8142 holds DCS 7 and fabric 3 while ANE work is in flight. */ + KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8142.ane[APPLE_CLPC_DCS], 7); + KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8142.ane[APPLE_CLPC_SOC], 3); + clpc->hw = &apple_clpc_hw_t8142; + clpc->ane_states[APPLE_CLPC_DCS] = clpc->hw->ane[APPLE_CLPC_DCS]; + clpc->ane_states[APPLE_CLPC_SOC] = clpc->hw->ane[APPLE_CLPC_SOC]; + memset(demand, 0, sizeof(demand)); + apple_clpc_ane_set_active(&ane, true); + KUNIT_EXPECT_TRUE(test, apple_clpc_ane_input_demand(clpc, demand)); + KUNIT_EXPECT_EQ(test, demand[APPLE_CLPC_DCS], 7u); + KUNIT_EXPECT_EQ(test, demand[APPLE_CLPC_SOC], 3u); + apple_clpc_ane_set_active(&ane, false); } static void apple_clpc_ane_cluster_test(struct kunit *test) @@ -2052,7 +2079,6 @@ static void apple_clpc_ane_no_provider_test(struct kunit *test) KUNIT_EXPECT_EQ(test, demand[APPLE_CLPC_DCS], 0u); KUNIT_EXPECT_EQ(test, demand[APPLE_CLPC_SOC], 0u); KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8132.ane[APPLE_CLPC_DCS], 0); - KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8142.ane[APPLE_CLPC_DCS], 0); } static void apple_clpc_ane_wake_removal_test(struct kunit *test)