Repository navigation
pmdomain: apple: pmgr-pwrstate: power gate a domain left clock gated - #3668
Conversation
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at cef3aeb8a42a.
The new probe-time predicate accepts every nonzero target when active is false. For example, an ordinary domain with actual state clock-gated, target active, and auto-PM disabled is classified inactive by apple_pmgr_ps_is_active(). The new branch can then replace that pending power-up with a power-gate request. It can also take the branch while the register reports a transition.
Please limit probe-time gating to the settled clock-gated state shown in the J413 receipt. Add a control that leaves an active target or a busy transition untouched. Keep the J413 evidence and verify the corrected change on current main and a second generation before landing.
There was a problem hiding this comment.
Probe can power gate any inactive non-ALWAYS_ON domain with a non-gated target. That does not establish that firmware or a consumer outside the Linux genpd graph no longer needs it. Skip firmware-owned and retained domains and require an explicit hardware or firmware ownership contract before gating an otherwise unclaimed boot-left domain. Keep peer-SoC boot and wake coverage.
cef3aeb to
104fc07
Compare
|
Review fix: gate only a domain settled at clock gated (target and actual both clock gated, BUSY clear). A domain whose target is already on but whose actual state still reads clock gated, or one mid-transition, is left alone. The J413 domains from the earlier row all read Old head |
There was a problem hiding this comment.
The settled target/actual and BUSY checks avoid interrupting an active transition. A settled clock-gated state still does not establish firmware ownership. The new guard can still power-gate a firmware-owned or retained domain. Please require an explicit ownership contract or opt-in for probe-time gating.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
The deep-sleep result is in the PR body (this patch on the sleep series). |
|
host-tests fix: the probe host test ( Old head |
There was a problem hiding this comment.
Verdict: HOLD at 0b0e7d2af1cd
Blockers:
- Hosted CI at
0b0e7d2af1cdis still queued (host-tests,kunit,pr-text,readinessqueued/cancelled;apple-buildnot yet green at head). - Multi-generation hardware verification is still pending (as noted in
Not yetand prior review):pmgr-pwrstate.cprobes on every Mac family, and only J413 (M2 Air) has been verified so far; boot/wake regression rows on at least one second SoC family (e.g., M1 Pro / M3 / M4 / M5) are needed to confirm no bootloader-left0x44domain without a DT consumer regresses when power-gated at probe. - The open
CHANGES_REQUESTEDreview from104fc07bon probe-time ownership semantics for unclaimed boot-left domains still needs to be resolved before merge.
Checked:
0b0e7d2a(tools/testing/selftests/drivers/apple/pmgr-inherited.py): verifieddev_warn()stub fixes thehost-testsbuild break, TAP plan updates cleanly (1..5->1..6), and case 5 verifies both gating of settled0x44(TARGET=4, ACTUAL=4, !BUSY) and leaving0x4f(rising),0x00(already gated),0x40/0x04(mid-transition), and0x44 | APPLE_PMGR_BUSYuntouched.104fc07b(drivers/pmdomain/apple/pmgr-pwrstate.c): verifiedps->firmware_owned,ps->inherited_on,ps->auto_managed, andapple,always-ondomains cannot reachif (!active && !(ps->genpd.flags & GENPD_FLAG_ALWAYS_ON))at probe (firmware_ownedandinherited_onsetactive = trueandGENPD_FLAG_ALWAYS_ON;auto_managedexits-EIO/-ENODEVwhen!active;always_onsetsGENPD_FLAG_ALWAYS_ON), andAPPLE_PMGR_PS_MINonly bounds hardware auto-PM rather than explicit softwareTARGET=0.- Verified J413 exact-head boot row (
104fc07b, kernel code unchanged at0b0e7d2a: 0 clock-gated genpd-off domains, 0 gate warnings, GPU render PASS) and earlier J413 deep-sleep drain improvement (0.51 W->< 0.034 W), humanSigned-off-byon both commits,MERGEABLEonmain, and no Apple material or AI attribution.
Evidence
- Head:
0b0e7d2af1cddee9cf2a231cf1d5f95c5db6cc0f(base: main,MERGEABLE,+36/-3, 2 files, 2 commits). - Non-blocking nits:
- The
Detailssection of the PR body still describes the pre-104fc07bpredicate ("whose target is above power gated") rather than the settled clock-gated check (TARGET == CLKGATE && ACTUAL == CLKGATE && !BUSY). - If
apple_pmgr_ps_set(&ps->genpd, APPLE_PMGR_PS_PWRGATE, false)fails,TARGEThas already been written to0(PWRGATE), so the warning text"left as it is"is slightly imprecise (though harmless for an already-inactive domain).
- The
genpd registers a domain that is not on as off, and it never powers off a domain it already holds off. A boot loader can leave a domain clock gated: not on, so genpd holds it off, but still powered. With no consumer to raise it, nothing ever gates it, and it stays powered through system sleep. On a J413 (M2 Air) ten domains are left that way, among them four MCA clusters with no stream, and they are most of what is still on when the system sleeps. At probe, gate a domain genpd will hold off that has settled clock gated: target and actual state both clock gated, no transition pending. A domain still on its way to another state is left alone. Its consumers raise it as before. Signed-off-by: Satya Benson <[email protected]>
The pmgr probe host test builds the driver's probe, which now gates a domain the boot loader left clock gated and warns when it cannot. Stub dev_warn() so it compiles, and check that only a domain settled at clock gated (target and actual both clock gated, not busy) is gated: one on its way on, already power gated, mid-transition or busy is left alone. Signed-off-by: Satya Benson <[email protected]>
0b0e7d2 to
2d28628
Compare
|
Rebased onto current Old head |
There was a problem hiding this comment.
Verdict: FINISH at 2d286282.
The rebase preserves the settled clock-gated check and its host regression. I verified that domains explicitly marked firmware-owned, inherited-on or always-on skip this branch. The remaining gap is an unmarked domain retained for a firmware or non-genpd user. The probe has no positive release or ownership signal and does not inspect consumer use. Please require a documented handoff or opt-in and cover the case where an otherwise identical clock-gated domain lacks that permission. Keep the J413 result, hosted checks and peer-family validation.
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 2d286282. Re-check of my review at cef3aeb8.
- Gate only a settled clock-gated domain: fixed in
104fc07b. Target and actual must both be clock gated with BUSY clear, so a pending power-up or a transition is left alone. - A host control for those cases: added in
0b0e7d2a. The test case fails against the old unbounded condition. - J413 on current main: done at
104fc07b, which has the same patch-id as this head. Every domain genpd holds off reads power gated, and there are no gate failures. - Still missing: a boot row on a second generation.
pmgr-pwrstateprobes on every Mac. A domain left clock gated with no DT consumer but used by a coprocessor or firmware would now lose power at probe, and only another SoC can show whether one exists. Any one of the M1 Pro, M3 Air, M4 Air, M4 Pro or Neo boot rows you listed closes this. Report whether any domain was gated at probe, and that the devices with firmware owners still work: audio, input, Wi-Fi, display.
|
Holding this after the J773g failure: the handoff went out, but the machine never reached the network. Here's an offline analysis to check against the hypervisor log. What the change does on T8132. At each domain's own probe it power gates the domain if target and actual both read clock gated, nothing is pending, and the domain isn't always-on. Which T8132 domains can be hit. 124 of the 145 domains in
Which of these actually read Proposed narrowing (no chip gate). Move the gate from probe to the provider's
A consumer that adopts the boot loader's state (PCIe, DCPEXT, NVMe) raises its domain when it attaches, before this runs. A domain whose consumer never probes is left clock gated, as on I'll rework the commit along these lines, then re-run it on J413, where the probe-time version passed. If the log shows a domain that has a consumer and is still lost, I'll look at that domain specifically. |
…c_state Power gating a domain the boot loader left clock gated at its own probe runs before any consumer has attached, and before the domains registered after it exist. A consumer that takes over state the boot loader left in its domain then finds it lost. A J773g (T8132) boot with the probe-time gate never reached the network, while main booted fine. Note the domain at probe instead, and power gate it from the driver's sync_state, which fw_devlink calls once every consumer the devicetree names for it has probed. It is gated only if genpd still holds it off, no subdomain is on, and the hardware still reads it settled clock gated. A consumer that took the domain over raised it first. A domain whose consumer never probes stays as the boot loader left it, as before this series. The driver now has its own sync_state, so it calls of_genpd_sync_state() itself. Signed-off-by: Satya Benson <[email protected]>
|
Pushed Tested: host test Not yet tested on hardware: a J413 row at this head is next. Dj's J773g log will show whether any domain the probe-time version gated has a consumer, which is the case this change guards against. Staying draft until both are in. |
There was a problem hiding this comment.
Moving gating to sync_state addresses the early-probe race for DT consumers. The new checks also preserve a domain raised by a consumer or an active subdomain. The remaining case is a boot-left clock-gated domain used by firmware without a DT consumer link. A genpd-off state and zero active subdomains do not establish that firmware released it. Please document an ownership guarantee that rules that case out or require a positive handoff signal, with a regression test for a domain without it. The current sync_state implementation also needs a current-head boot/wake result and a second SoC family.
There was a problem hiding this comment.
Please recheck the observed J773g boot failure on the current sync_state implementation and report the J413 run for the claimed gating behavior. The earlier probe-time version failed to reach the network on J773g. A new ownership flag is unnecessary unless the recheck demonstrates that the sync_state change still gates a domain with a live user.
|
Row at
That's the same result as the probe-time version on this machine. The question the rework answers, a domain with a consumer being gated before that consumer attaches, only showed on J773g, so this stays draft until a J773g boot at this head (and ideally Dj's hypervisor log) is in. |
|
J773g (M4 Mac mini, T8132):
|
|
Both current-head rows at |
|
Boot rows at Kernel
The only errors are the two DWC3 |
|
J713 (M4 Air, T8132) at M1 Pro (J316s, T6000): FAIL to investigate. The same kernel family (fleet92 = main |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Reviewed ffe20ff. Probe records the settled state without writing it. The sync_state callback takes the genpd lock and rechecks domain state, active subdomains, and the hardware target, actual state and busy bit before gating. The current J413, J773g, J615 and J616s rows cover boot and wake across the affected families. The PMGR KUnit and host checks passed.
What: genpd registers a power domain that is not on as off and never powers it off, so a domain the boot loader left clock gated (still powered) with no consumer stays powered, through system sleep too. Note such domains at probe and power gate them at
sync_state, once fw_devlink confirms every DT consumer has probed, only if genpd still holds the domain off, no subdomain is on, and hardware still reads it settled clock gated.Tested: Exact head
ffe20ff768258445e1734f84354f7d40d89393c3:2d286282) — both lab and stock default graphical boots reached the network with 0 failed units, display connected, GPU smoke CRCb022fbafmatch, 0 GPU faults/WARNs;power-controller@250ransync_statecleanly once the GPU probed, andpower-controller@308stayed pending due to unbound421094000.iommu(leaving its domains untouched).tools/testing/selftests/drivers/apple/pmgr-inherited.pyandPMGR power state KUnitPASS, covering probe-only noting, singlesync_stategating, and leaving raised/subdomain-active/moved/mid-transition domains untouched.Risk: two-way door · all Macs (shared
pmgr-pwrstatedriver). Gating now waits untilsync_state(after every DT consumer has probed) and skips any domain raised by a consumer, with an active subdomain, or not still settled clock gated; only a firmware-used domain with no DT consumer link and still settled clock gated would be gated.Not yet: additional SoC families beyond T8112 and T8132 (M1 Pro, M3 Air, M4 Pro, Neo).
Details
apple_pmgr_ps_is_active()treats only an actually-on domain (or one auto-managed toward on) as active, so genpd starts any other as off. genpd never callspower_offfor a domain it already holds off. A domain the boot loader left at clock gated (target 4) with no consumer raising it is therefore never gated: on J413 that is ten domains (four MCA clusters without a stream,aft0,fpwm2,spi5,uart8,isp_set4andsoc_spmi0) that otherwise stay powered through deep sleep.Power gating at probe ran before consumers attached and broke boot on J773g (
2d286282). Instead, probe recordsboot_clkgatedfor domains that are not active, not always-on, and settled clock gated (target 4, actual 4, not busy). Inapple_pmgr_ps_sync_state(), after callingof_genpd_sync_state(), the driver checks undergenpd.slockthatgenpd.status == GENPD_STATE_OFF,sd_count == 0, and hardware still reads settled clock gated before callingapple_pmgr_ps_set(PWRGATE). A domain whose consumer never probes never reachessync_stateand stays as the boot loader left it.Evidence
Earlier J413 (M2 Air, firmware 27.2) deep-sleep drain check with GPU and desktop live, battery
energy_now(steps of about 11.4 mWh):