Repository navigation
pmdomain: apple: pmgr-pwrstate: do not gate parent domains at sync_state - #3829
Conversation
fw_devlink invokes sync_state on a parent power domain as soon as its direct consumers (child apple-pmgr-pwrstate devices) finish probing, long before those subdomains' own device consumers probe. At that point a child subdomain is still GENPD_STATE_OFF in genpd (sd_count == 0) but may still be powered/clock-gated in hardware. On T6030 (J516s), ps_atc3_usb_aon is the parent of ps_atc3_usb, whose consumer (atcphy3_xbar) probes later from a module. Power-gating ps_atc3_usb_aon at 0.159 s while ps_atc3_usb is still clock-gated (0x244) hangs boot before rootfs mount. Check list_empty(&ps->genpd.parent_links) before power-gating a boot_clkgated domain in apple_pmgr_ps_sync_state() so only leaf domains are gated there, and add a regression case to pmgr-inherited.py. Fixes: ffe20ff ("pmdomain: apple: pmgr-pwrstate: gate a boot clock-gated domain at sync_state") Signed-off-by: Diljit Singh <hey@djdev.me>
There was a problem hiding this comment.
Verdict: MERGE at eb64ee5
Checked:
genpd.parent_linksis the list of links where this domain is the parent (include/linux/pm_domain.h:207).pm_genpd_add_subdomain()adds to it under the parent's lock, and the parent's lock here isslock(GENPD_FLAG_IRQ_SAFE, pmgr-pwrstate.c:985). So the newlist_empty()test reads the list under the right lock and is true exactly for leaf domains. The driver already walks the same list at :535.- Ran the exact-head
pmgr-inherited.pylocally: 6/6 pass. Negative control: with thelist_empty(&ps->genpd.parent_links) &&line removed, the script fails (rc 1), so the new case 3 catches the #3668 regression. - Behaviour change: a parent domain the boot loader left clock gated is no longer power gated at sync_state, even when all its subdomains end up unused. That's the pre-#3668 behaviour for parents and costs a little idle power, not correctness. Unused leaf domains still get gated, as the J516s row shows (13 leaves to 0x200).
- Exact-head J516s row: boots on the zero-flag cmdline with atc3_usb_aon/atc3_usb active, which matches the reported hang.
Follow-ups (non-blocking): if the idle power matters, a later change can gate a parent once all its subdomains are gated (e.g. from the child's sync_state). A peer smoke row on a T8112/T600x Mac is welcome.
satchlj
left a comment
There was a problem hiding this comment.
Reviewed at eb64ee5.
list_empty(&ps->genpd.parent_links)underps->genpd.slockis the right guard and lock:pm_genpd_add_subdomain()links child subdomains onto the parent'sparent_linksunder the parent's lock (slocksinceGENPD_FLAG_IRQ_SAFEis set), andfw_devlinkdoes not invoke the parent'ssync_stateuntil childapple-pmgr-pwrstatedevices have finished probing and registered their subdomain links.- Restricting
sync_statepower-gating to leaf domains eliminates the premature parent power-gate while keeping unused leaf domain gating intact. - Regression case in
pmgr-inherited.pyexercises the exact off-attached-subdomain scenario.
Building an exact-head J413 (T8112) boot smoke row now and will post the result here once complete.
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
Row: eb64ee5 + J413 (MacBook Air 13" M2, T8112, 27.2 stub) + PASS
|
|
Row: eb64ee5 (+ main cd5cb04 + #3830) + J473 Mac mini M2 (T8112) + PASS: boots, gates no in-use domain, DPMS + s2idle clean. No-regression row off T603x.
|
|
J514s (T6030, ryan-m3pro-binned) — booted on
Kernel: |
|
We carry this PR ( After #3668 landed on Carried so all three Macs stay off that premature parent-domain gating path on |
What: Fix a T6030 (J516s) boot hang introduced by #3668 (
ffe20ff76825).fw_devlinkinvokessync_stateon a parent power domain as soon as its direct consumers (childapple-pmgr-pwrstatedevices) probe, before those subdomains' own device consumers probe. At that time a child subdomain isGENPD_STATE_OFFin genpd (sd_count == 0) while still clock-gated (0x244) in hardware. On J516s,ps_atc3_usb_aon(0x3642800d0) was power-gated at 0.159 s while its childps_atc3_usb(0x3642800f0) was still clock-gated waiting foratcphy3_xbar(mux-apple-display-crossbar) to probe at ~4.2 s, hanging boot before rootfs mount.Check
list_empty(&ps->genpd.parent_links)underps->genpd.slockinapple_pmgr_ps_sync_state()so only leaf domains are power-gated there, and add a regression case totools/testing/selftests/drivers/apple/pmgr-inherited.py.Tested: Exact head
eb64ee5fb02cecfeebe6d296c7c26e3ba1b7f61a(overmaind148fbda6dca):eb64ee5fb02con stock zero-flag RW command line (boot_id=e645e708-34f9-4749-b993-4e2a452e4d1a) — boots cleanly with0failed units;aurora,appledrm,apple_pmp,brcmfmac, andmux_apple_display_crossbarall loaded;atc3_usb_aon(0x3642800d0) andatc3_usb(0x3642800f0) both settle at0x2ff(active); all unused leafboot_clkgateddomains (dwi,pms_fpwm0..4,pmgr_soc_ocla,aft0,fpwm1..2,i2c5,mca2,mca3) power-gate cleanly to0x200(tgt=0 act=0). Plaind148fbda6dcaand1d9a2ac028f2hung before rootfs mount on the same machine, while6773a61129b5booted cleanly.python3 tools/testing/selftests/drivers/apple/pmgr-inherited.pyPASS 6/6, including the new case where aboot_clkgatedparent domain has an attached off subdomain (sd_count == 0, non-emptyparent_links).scripts/checkpatch.pl --strict --git HEAD~1..HEADPASS (0 errors, 0 warnings, 0 checks).Risk: two-way door · all Macs (shared
pmgr-pwrstatedriver). Tightens #3668'sboot_clkgatedgating strictly to leaf domains (list_empty(&ps->genpd.parent_links)), preserving gating of unused leaf domains (such as the 10 leaf domains on J413 and 13 leaf domains on J516s) while preventing premature power-gating of parent domains above unprobed or clock-gated subdomains. Peer smoke on J413 / J773g is still welcome.