diff --git a/drivers/soc/apple/clpc.c b/drivers/soc/apple/clpc.c index f8d5fbbabf8a9..061d23a5d62da 100644 --- a/drivers/soc/apple/clpc.c +++ b/drivers/soc/apple/clpc.c @@ -573,6 +573,7 @@ static const struct of_device_id apple_clpc_ane_providers[] = { { .compatible = "apple,t6041-clpc" }, { .compatible = "apple,t8140-clpc" }, { .compatible = "apple,t8142-clpc" }, + { .compatible = "apple,t8152-clpc" }, {} }; @@ -2889,6 +2890,7 @@ static void apple_clpc_t6041_policy_test(struct kunit *test) apple_clpc_gpu_put(gpu); } +static const struct apple_clpc_hw apple_clpc_hw_t8152; static const struct apple_clpc_hw apple_clpc_hw_t6050; static void apple_clpc_ane_demand_hold_test(struct kunit *test) @@ -2959,6 +2961,20 @@ static void apple_clpc_ane_demand_hold_test(struct kunit *test) apple_clpc_ane_set_active(&ane, false); memset(demand, 0, sizeof(demand)); KUNIT_EXPECT_FALSE(test, apple_clpc_ane_input_demand(clpc, demand)); + /* T8152 holds DCS 7 and fabric 4 while ANE work is in flight. */ + KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8152.ane[APPLE_CLPC_DCS], 7); + KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8152.ane[APPLE_CLPC_SOC], 4); + clpc->hw = &apple_clpc_hw_t8152; + 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], 4u); + apple_clpc_ane_set_active(&ane, false); + memset(demand, 0, sizeof(demand)); + KUNIT_EXPECT_FALSE(test, apple_clpc_ane_input_demand(clpc, demand)); } static void apple_clpc_ane_cluster_test(struct kunit *test) @@ -2981,6 +2997,7 @@ static void apple_clpc_ane_cluster_test(struct kunit *test) KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8142.ane_cluster, 1u); KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8142.ane_cluster_khz, 4176000u); KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8140.ane_cluster_khz, 0u); + KUNIT_EXPECT_EQ(test, apple_clpc_hw_t8152.ane_cluster_khz, 0u); } static void apple_clpc_ane_states_test(struct kunit *test) @@ -3640,6 +3657,15 @@ static const struct apple_clpc_hw apple_clpc_hw_t8152 = { [APPLE_CLPC_SOC] = { 1, 2, 3, 4 }, }, .gpu_input = true, + /* + * ANE demand (J873g, H18G; other T8152 boards sharing the compatible + * are untested): DCS 7 and fabric 4, the top states this table already + * uses for CPU and G18 GPU demand. On J873g with CPUs pinned at + * minimum frequency, raising the PMC floor from (0, 0) to (7, 3) cut + * 256x256 FP16 matvec median kernel time 2.2x (643.0 to 290.1 us on + * ane0, 285.7 us on ane1). + */ + .ane = { [APPLE_CLPC_DCS] = 7, [APPLE_CLPC_SOC] = 4 }, }; /* diff --git a/tools/asahi/clpc-gpu-demand-tests.py b/tools/asahi/clpc-gpu-demand-tests.py index ddd233902d569..80cfa665caadd 100644 --- a/tools/asahi/clpc-gpu-demand-tests.py +++ b/tools/asahi/clpc-gpu-demand-tests.py @@ -299,8 +299,9 @@ def main(): 'struct apple_clpc_hw {', 'struct apple_clpc_vote {']) tables = '\n'.join(item(source, 'static const struct apple_clpc_hw ' + n + ' =') + ';' for n in ['apple_clpc_hw_t8132', 'apple_clpc_hw_t8140', - 'apple_clpc_hw_t8142', 'apple_clpc_hw_t6040', - 'apple_clpc_hw_t6041', 'apple_clpc_hw_t6050']) + 'apple_clpc_hw_t8142', 'apple_clpc_hw_t8152', + 'apple_clpc_hw_t6040', 'apple_clpc_hw_t6041', + 'apple_clpc_hw_t6050']) # When t6041.dtsi supplies the GPU busy-share properties, parse and test them directly; # otherwise exercise the DT parsers and ladder against the reference values. @@ -700,6 +701,24 @@ def main(): jiffies=3040; apple_clpc_sample(&c); assert(published==0 && c.last_reason==0 && queued_idle); } +// T8152 ANE work holds DCS 7 and fabric 4 while it runs, sees a sub-sample +// request once, and releases after HOLD_MS. +static void check_t8152_ane(void) { + struct apple_clpc_ane ane={0}; + struct apple_clpc c={.hw=&apple_clpc_hw_t8152,.has_pmc=true,.agent=1,.mask=3,.ane=&ane}; + c.ane_states[APPLE_CLPC_DCS]=c.hw->ane[APPLE_CLPC_DCS]; + c.ane_states[APPLE_CLPC_SOC]=c.hw->ane[APPLE_CLPC_SOC]; + assert(c.hw->ane[APPLE_CLPC_DCS]==7 && c.hw->ane[APPLE_CLPC_SOC]==4 && !c.hw->ane_cluster_khz); + read_error=vote_error=0; pmgr_status=0; pmp_floor=0; jiffies=4000; published=~0u; + apple_clpc_sample(&c); assert(published==0 && c.last_reason==0); + ane.active=true; jiffies=4004; apple_clpc_sample(&c); + assert(published==0x47 && c.last_reason==32); + ane.active=false; ane.pending=true; jiffies=4008; apple_clpc_sample(&c); + assert(published==0x47 && c.last_reason==32 && !ane.pending); + jiffies=4039; apple_clpc_sample(&c); assert(published==0x47 && c.last_reason==16); + jiffies=4040; apple_clpc_sample(&c); assert(published==0 && c.last_reason==0 && queued_idle); +} + // T6040 ANE work also holds the second P cluster at its qualified frequency, // added on first use, for the vote hold after the last request, then drops it. static void check_t6040_ane(void) { @@ -1081,6 +1100,7 @@ def main(): check_t8140_dense(); check_t8140_ane(); check_t6050_ane(); + check_t8152_ane(); check_low_power(); check_t6040_ane(); puts("PASS: T6040, T6041 and T8132 host demand; DT GPU busy share and down-step hold; T8140/T604x ANE, streaming, dense work, read errors and PMP backoff; idle release");