From d08f9cf923c5097eec2d9907fb9c740e6f962b63 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Tue, 3 Nov 2026 00:52:00 +1100 Subject: [PATCH 1/2] pmdomain: apple: pmc: allow a floor on the DCS rail A rail floor could not sit on the DCS rail, since the AP agent's DCS vote carries the DCS limit. Let a DCS floor share that vote instead: without a limit the AP votes the higher of its inherited vote and the floors held, and with a limit the higher of the other agents' demand and the floors, capped by the limit as before. The thermal limit therefore still wins over any floor. KUnit: a DCS floor above the inherited vote, under a limit, and its release back to the inherited vote. Assisted-by: LLM Signed-off-by: Ryan Murray --- .../devicetree/bindings/power/apple,pmc.yaml | 3 +- drivers/pmdomain/apple/pmc-test.c | 32 +++++++++++++++++++ drivers/pmdomain/apple/pmc.c | 25 +++++++++++---- 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/power/apple,pmc.yaml b/Documentation/devicetree/bindings/power/apple,pmc.yaml index f4dae18decef7..4c1d9aefc2519 100644 --- a/Documentation/devicetree/bindings/power/apple,pmc.yaml +++ b/Documentation/devicetree/bindings/power/apple,pmc.yaml @@ -124,7 +124,8 @@ patternProperties: A rail floor, provided as a power domain. While the domain is powered, the AP's voter agent holds the rail at least at the given performance state. Floors on the same rail combine to the highest powered one. The - AP agent must be a static voter, and the DCS rail cannot have a floor. + AP agent must be a static voter. A floor on the DCS rail shares the AP + agent's DCS vote with the DCS limit, which caps it. additionalProperties: false properties: diff --git a/drivers/pmdomain/apple/pmc-test.c b/drivers/pmdomain/apple/pmc-test.c index 9428e3c4317d2..7cf8a43e8b085 100644 --- a/drivers/pmdomain/apple/pmc-test.c +++ b/drivers/pmdomain/apple/pmc-test.c @@ -250,7 +250,39 @@ static void apple_pmc_test_floor_pending_timeout(struct kunit *test) KUNIT_EXPECT_FALSE(test, dom->on); } +/* + * A DCS floor raises the AP's DCS vote above its inherited vote while held, + * yields to the DCS limit, and gives the inherited vote back when released. + */ +static void apple_pmc_test_dcs_floor(struct kunit *test) +{ + struct apple_pmc *pmc = apple_pmc_test_alloc(test); + const struct apple_pmc_hw *hw = pmc->hw; + struct apple_pmc_domain *dom; + + INIT_LIST_HEAD(&pmc->domains); + apple_pmc_test_set_dcs_vote(pmc, hw->ap_agent, 1); + pmc->ap_dcs_vote = apple_pmc_ap_dcs_read(pmc); + pmc->enable[hw->dcs_rail] = BIT(1) | BIT(hw->ap_agent); + dom = apple_pmc_test_floor(test, pmc, hw->dcs_rail, hw->dcs_max); + + KUNIT_ASSERT_EQ(test, apple_pmc_floor_set(dom, true), 0); + KUNIT_EXPECT_EQ(test, apple_pmc_ap_dcs_read(pmc), hw->dcs_max); + /* The limit caps the floor; the other agents ask for nothing. */ + pmc->dcs_state = 3; + apple_pmc_dcs_vote(pmc); + KUNIT_EXPECT_EQ(test, apple_pmc_ap_dcs_read(pmc), hw->dcs_max - 3); + pmc->dcs_state = 0; + apple_pmc_dcs_vote(pmc); + KUNIT_EXPECT_EQ(test, apple_pmc_ap_dcs_read(pmc), hw->dcs_max); + KUNIT_ASSERT_EQ(test, apple_pmc_floor_set(dom, false), 0); + KUNIT_EXPECT_EQ(test, apple_pmc_ap_dcs_read(pmc), 1); + /* Other rails of the AP's floor word are untouched. */ + KUNIT_EXPECT_EQ(test, apple_pmc_test_ap_floor(pmc) & ~APPLE_PMC_RAIL_MASK(hw->dcs_rail), 0U); +} + static struct kunit_case apple_pmc_test_cases[] = { + KUNIT_CASE(apple_pmc_test_dcs_floor), KUNIT_CASE(apple_pmc_test_partial_enable), KUNIT_CASE(apple_pmc_test_release_restores_ap_vote), KUNIT_CASE(apple_pmc_test_pending_floor), diff --git a/drivers/pmdomain/apple/pmc.c b/drivers/pmdomain/apple/pmc.c index 5d07b595d7cce..6b1e4c472e399 100644 --- a/drivers/pmdomain/apple/pmc.c +++ b/drivers/pmdomain/apple/pmc.c @@ -113,6 +113,8 @@ struct apple_pmc { unsigned long dcs_state; /* DCS state the AP's agent voted for before probe, kept without a limit. */ unsigned int ap_dcs_vote; + /* Highest DCS floor held by a floor domain; protected by @lock. */ + unsigned int dcs_floor; /* Power cost of each DCS state in mW, if a model is described. */ u32 dcs_power[APPLE_PMC_MAX_STATES]; struct delayed_work dcs_work; @@ -386,19 +388,20 @@ static unsigned int apple_pmc_ap_dcs_read(struct apple_pmc *pmc) /* * Caller holds pmc->lock. Vote through the AP's agent for what the other - * agents ask for, capped by the limit; without a limit, put back the vote - * the AP's agent had before probe. + * agents ask for and the DCS floors held, capped by the limit; without a + * limit, the vote the AP's agent had before probe or the floors, if higher. */ static void apple_pmc_dcs_vote(struct apple_pmc *pmc) { const struct apple_pmc_hw *hw = pmc->hw; void __iomem *reg = pmc->voters + hw->ap_agent * hw->agent_stride; u32 mask = APPLE_PMC_RAIL_MASK(hw->dcs_rail); - unsigned int state = pmc->ap_dcs_vote; + unsigned int state = max(pmc->ap_dcs_vote, pmc->dcs_floor); u32 old, val; if (pmc->dcs_state) - state = min_t(unsigned int, apple_pmc_dcs_demand(pmc), + state = min_t(unsigned int, + max(apple_pmc_dcs_demand(pmc), pmc->dcs_floor), hw->dcs_max - pmc->dcs_state); old = readl(reg); @@ -618,6 +621,13 @@ static int apple_pmc_floor_apply(struct apple_pmc *pmc, unsigned int rail) if (dom->floor && dom->rail == rail && dom->on) level = max(level, dom->level); + /* The AP's DCS vote also carries the DCS limit; it combines both. */ + if (rail == pmc->hw->dcs_rail) { + pmc->dcs_floor = level; + apple_pmc_dcs_vote(pmc); + return 0; + } + return __apple_pmc_floor_update(pmc, pmc->hw->ap_agent, APPLE_PMC_RAIL_MASK(rail), level << APPLE_PMC_RAIL_SHIFT(rail)); @@ -860,11 +870,12 @@ static int apple_pmc_floor_add(struct apple_pmc *pmc, struct device_node *np) if (of_property_read_u32(np, "apple,rail", &rail) || of_property_read_u32(np, "apple,level", &level)) return dev_err_probe(dev, -EINVAL, "%pOF: missing rail or level\n", np); - /* The DCS rail's AP vote belongs to the DCS limit. */ - if (rail >= hw->rails || rail == hw->dcs_rail || + /* A DCS floor shares the AP's DCS vote with the DCS limit, which caps it. */ + if (rail >= hw->rails || (hw->agent_rails && !(hw->agent_rails & BIT(rail)))) return dev_err_probe(dev, -EINVAL, "%pOF: invalid rail %u\n", np, rail); - if (!level || level >= APPLE_PMC_MAX_STATES) + if (!level || level >= APPLE_PMC_MAX_STATES || + (rail == hw->dcs_rail && level > hw->dcs_max)) return dev_err_probe(dev, -EINVAL, "%pOF: invalid level %u\n", np, level); if (!(pmc->static_agents & BIT(hw->ap_agent))) return dev_err_probe(dev, -EINVAL, From f6ae7c53db50bea0b0c8ffb2e46080f42385b564 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Tue, 3 Nov 2026 00:52:33 +1100 Subject: [PATCH 2/2] arm64: dts: apple: t8140: hold DRAM up while ProRes encodes The PMP takes ProRes VMAX on the SOC rail but votes no DCS state for it, and while an encode keeps the CPUs mostly idle the CLPC lowers its DCS vote to state 0. On the Neo, 4K ProRes 422 HQ ran at 355-371 fps with the CPUs idle and at 430 fps with any one CPU busy (CLPC DCS vote 4), 4444 at 239-242 and 287 fps; 1080p 422 HQ at 1511 and 1683 fps. macOS does 425 and 282 fps at 4K. Give the ProRes performance request a second parent, a DCS floor at the highest state, so DRAM follows the engine instead of the CPUs. Assisted-by: LLM Signed-off-by: Ryan Murray --- arch/arm64/boot/dts/apple/t8140.dtsi | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/apple/t8140.dtsi b/arch/arm64/boot/dts/apple/t8140.dtsi index bbffbc0e05963..32a817a0ad3c5 100644 --- a/arch/arm64/boot/dts/apple/t8140.dtsi +++ b/arch/arm64/boot/dts/apple/t8140.dtsi @@ -587,14 +587,17 @@ /* * ProRes is soc-device record 14, DVFS ordinal 7. Its VMAX * request votes the SOC rail through the PMP's static agent, - * like AVD; it has no cluster-agent bit. + * like AVD; it has no cluster-agent bit. The PMP votes no DCS + * state for it, and with the CPUs idle the CLPC drops DCS to + * state 0 during an encode: the DCS floor holds DRAM up while + * frames are in the engine. */ pmp_report_prores: report@e { compatible = "apple,t8140-pmp-v2-report-entry"; reg = <0xe>; label = "pmp-prores"; #power-domain-cells = <0>; - power-domains = <&ps_prores>; + power-domains = <&ps_prores>, <&pmc_dcs_max>; apple,dvfs = <0x197 2>; }; @@ -1367,6 +1370,17 @@ apple,static-voters = <0 1 3>; status = "disabled"; + /* + * DCS (DRAM) at its highest state, through the AP's agent. + * The DCS limit still caps it. + */ + pmc_dcs_max: floor-dcs-max { + label = "dcs-max"; + #power-domain-cells = <0>; + apple,rail = <0>; + apple,level = <4>; + }; + /* VENC-CLSTR-V: the video encoder cluster, bit 3. */ pmc_venc_cluster: cluster-venc { label = "venc-cluster";