Skip to content

soc: apple: T8140 PMC voters, CLPC DCS/fabric floors and GFX PMP report - #212

Closed
DjDeveloperr wants to merge 5 commits into
aurora-wipfrom
neo-clpc
Closed

DjDeveloperr wants to merge 5 commits into
aurora-wipfrom
neo-clpc

Conversation

@DjDeveloperr

Copy link
Copy Markdown
Contributor

Adds PMC voter enables and CLPC demand floors for DRAM controller (DCS) and SoC fabric performance on T8140, and reports the GPU's power state to the PMP. These are clean, generic versions of the lab modules neo_pmc, neo_pmpdash and neo_clpc. They take their registers from the device tree and build on the existing pmp.rs and pmp-report instead of adding a second PMP driver.

Draft: not tested on hardware yet. See "Testing" below.

What it does

  • PMC voter interface (drivers/pmdomain/apple/pmc.c, apple,t8140-pmc). The PMC only honours a voter agent's perf-state floor on rails where that agent's interface is enabled.
    • Static agents: the PMP, CLPC and AP agents are enabled on every rail while the driver is bound, as macOS's ApplePMC::restorePMC does.
    • Dynamic agents: each one (the GPU) is a power domain, enabled after its parent powers on and disabled before the parent powers off, as ApplePMC::stateChange does.
    • Every enable write is read back. The saved enable words are restored on unbind.
  • CLPC floors (drivers/soc/apple/clpc.c, apple,t8140-clpc, a child of the PMC). Every 4 ms, which is the ADT CLPC sampling interval, it raises the DCS/fabric floor of the CLPC agent from cpufreq load: a busy cluster requests a state indexed by its frequency quartile. Each rail holds its request for 32 ms after demand stops, then drops to 0.
    • The native demand→state mapping is not decoded. The defaults (DCS 1–4 by quartile, no fabric request) are measured policy and can be tuned through module parameters.
    • An optional fixed floor while the GPU is actually powered (gpu_dcs/gpu_soc) is off by default.
    • A debugfs force file holds a rail at a fixed level, for diagnosis only.
  • PMP report entries for T8140. The binding now allows report entries under the T8140 report aperture. The DT adds entry 9 (GFX, an acknowledged type in the ADT).
  • T8140 DT.
    • Adds the PMC node, the PMC's PMGR power state (ps_pmc), the CLPC child and the GFX voter.
    • Moves the GPU onto the chain GPU → pmc_gfx → pmp_report_gfx → ps_gfx. GPU power-on now writes the PMGR state, then reports it to the PMP, then enables its PMC agent; power-off runs in reverse. That is macOS's _enableDeviceGated order.
    • Enables the PMC on J700.

Not included

  • PMP bootargs. The lab PMP owner patched 10 bootargs (BDID, DVID, DCAP, DCHD, PMC_, PMCV, PMCB, PMCX, CVAR, PMCM); pmp.rs patches 3. Whether the PMP votes through the PMC without the PMC* keys is not known yet.
  • Reports for other PMP-tracked devices (ISP, AVD, display, JPG, MSR, PRORES, VENC). They need no acknowledgment natively, but pmp-report fails a power-on after 50 ms without one. They stay out until their acknowledgment behaviour is measured.
  • SLC enable (neo_mcc) and the fast-die module.

Testing

Done:

  • full arm64 build (Image, modules, dtbs) with LLVM;
  • no W=1 warnings in the new files;
  • dt_binding_check passes for both bindings;
  • the J700 DTB checked against them shows no errors from the new nodes;
  • checkpatch is clean apart from the trailer-format warnings and the MAINTAINERS reminder (the new files are covered by ARM/APPLE MACHINE SUPPORT).

Not done: hardware. Neo's DT comes from its m1n1 payload, so these DT changes can't be booted on it as they are. The planned test runs on the current lab boot instead:

  1. Apply the same nodes as a runtime overlay.
  2. Load these drivers as modules built for that kernel.
  3. Check the CLPC floors against CPU load and GPU throughput against the lab neo_clpc.
  4. In a fresh boot before the GPU driver loads, move the GPU onto the report → voter chain. Check the PS-REQ bit 9 acknowledgment, the PMC GFX agent enable, and GPU throughput and power against today's fixed GPU floor.

The PR stays a draft until that passes.

Assisted-by: LLM

The PMP chooses DRAM and fabric performance states partly from the power
state that the host reports for the devices it tracks. On macOS,
ApplePMGR sets a device's bit in the PMP's power-state request word after
it powers the device on, clears it before it powers the device off, and
waits for the PMP to acknowledge the devices that require it.

The pmp-report driver already provides such report entries as power
domains on earlier SoCs. Allow them as children of the T8140 report
aperture, with the device's PMP soc-device index as the unit address.

Assisted-by: LLM
Signed-off-by: Diljit Singh <[email protected]>
The PMC arbitrates the performance states of shared rails, such as the
DRAM controller and the SoC fabric, between voter agents: the PMP, the
host performance controller (CLPC), the GPU and the application
processor. Each agent has a perf-state floor word with one 4-bit state
per rail, and each rail has an interface enable word with one bit per
agent; the PMC ignores the floor of an agent that is not enabled on a
rail.

Describe the voter and rail windows, the static agents, the dynamic
agents as power domains, and the host performance controller's agent.

Assisted-by: LLM
Signed-off-by: Diljit Singh <[email protected]>
The PMC only honours a voter agent's perf-state floor on rails where that
agent's interface is enabled. macOS enables the static agents (PMP, CLPC
and AP) on all their rails when it restores the PMGR
(ApplePMC::restorePMC), and enables a dynamic agent such as the GPU only
while the host keeps the agent's PMGR device powered: after the power-on
state write and before the power-off one (ApplePMC::stateChange). Without
these enables, the PMC ignores those agents' floors.

Enable the static agents listed in the device tree for as long as the
PMC is bound, and restore the saved enable words when it is unbound.
Provide each dynamic agent as a power domain whose parent is its
device's power domain, so that genpd enables the agent after the parent
powers on and disables it before the parent powers off, as macOS does.
Every enable write is read back.

Export the floor words so that a host performance controller can set its
agent's floor.

Assisted-by: LLM
Signed-off-by: Diljit Singh <[email protected]>
On macOS the CLPC raises the DRAM controller (DCS) and SoC fabric floors
of its PMC voter agent while the CPU clusters or the GPU are busy
(AppleT8140CLPC: clpc::memory::DVFManager and clpc::soc::DVFManager, both
ending in the PMC CLPC perf-state floor), and lets them fall at idle.
Linux has no equivalent, so CPU-bound work runs with the DRAM controller
at whatever state the other agents happen to request.

Sample every cpufreq policy every 4 ms, the CLPC sampling interval from
the Apple device tree. A policy whose busiest CPU was busy for at least
half of the period requests a DCS and fabric state from a table indexed
by its frequency quartile. Optionally, while the GPU's PMGR state reports
the GPU as actually powered, request a fixed GPU floor. Each rail keeps
its last request for 32 ms after demand stops, then returns to 0.

The native mapping from CPU and GPU demand to DCS and fabric states is
not decoded. The default tables (DCS 1-4 by quartile, no fabric request,
no GPU floor) are measured policy and can be changed with module
parameters. A debugfs file holds a rail at a fixed state for diagnosis
only.

Assisted-by: LLM
Signed-off-by: Diljit Singh <[email protected]>
Describe the PMC voter interface with the PMP, CLPC and AP agents as
static voters, the GPU's dynamic agent as a power domain, and the host
performance controller's agent. Add the PMC's PMGR power state.

Report the GPU to the PMP through a report entry for PMP soc-device 9,
whose type in the Apple device tree requires an acknowledgment.

The GPU now sits on the PMC GFX agent, which sits on the report entry,
which sits on the GFX PMGR state. Powering the GPU on therefore writes
the PMGR state, then reports it to the PMP, then enables its PMC agent,
and powering it off undoes them in reverse order, as macOS does.

Enable the PMC on J700.

Assisted-by: LLM
Signed-off-by: Diljit Singh <[email protected]>
RyanTheTide added a commit that referenced this pull request Oct 9, 2026
soc: apple: T8140 PMC voters, CLPC floors, GFX PMP report and a DCS thermal limit (supersedes #212)
@DjDeveloperr
DjDeveloperr deleted the neo-clpc branch October 12, 2026 19:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant