Skip to content

pmdomain: apple: pmgr-pwrstate: do not gate parent domains at sync_state - #3829

Merged
DjDeveloperr merged 1 commit into
mainfrom
fix/pmgr-boot-clkgated-parent
Dec 1, 2026
Merged

DjDeveloperr merged 1 commit into
mainfrom
fix/pmgr-boot-clkgated-parent

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What: Fix a T6030 (J516s) boot hang introduced by #3668 (ffe20ff76825). fw_devlink invokes sync_state on a parent power domain as soon as its direct consumers (child apple-pmgr-pwrstate devices) probe, before those subdomains' own device consumers probe. At that time a child subdomain is GENPD_STATE_OFF in 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 child ps_atc3_usb (0x3642800f0) was still clock-gated waiting for atcphy3_xbar (mux-apple-display-crossbar) to probe at ~4.2 s, hanging boot before rootfs mount.

Check list_empty(&ps->genpd.parent_links) under ps->genpd.slock in apple_pmgr_ps_sync_state() so only leaf domains are power-gated there, and add a regression case to tools/testing/selftests/drivers/apple/pmgr-inherited.py.

Tested: Exact head eb64ee5fb02cecfeebe6d296c7c26e3ba1b7f61a (over main d148fbda6dca):

  • J516s (16-inch M3 Pro, T6030): PASS at eb64ee5fb02c on stock zero-flag RW command line (boot_id=e645e708-34f9-4749-b993-4e2a452e4d1a) — boots cleanly with 0 failed units; aurora, appledrm, apple_pmp, brcmfmac, and mux_apple_display_crossbar all loaded; atc3_usb_aon (0x3642800d0) and atc3_usb (0x3642800f0) both settle at 0x2ff (active); all unused leaf boot_clkgated domains (dwi, pms_fpwm0..4, pmgr_soc_ocla, aft0, fpwm1..2, i2c5, mca2, mca3) power-gate cleanly to 0x200 (tgt=0 act=0). Plain d148fbda6dca and 1d9a2ac028f2 hung before rootfs mount on the same machine, while 6773a61129b5 booted cleanly.
  • Host tests: python3 tools/testing/selftests/drivers/apple/pmgr-inherited.py PASS 6/6, including the new case where a boot_clkgated parent domain has an attached off subdomain (sd_count == 0, non-empty parent_links).
  • Style: scripts/checkpatch.pl --strict --git HEAD~1..HEAD PASS (0 errors, 0 warnings, 0 checks).

Risk: two-way door · all Macs (shared pmgr-pwrstate driver). Tightens #3668's boot_clkgated gating 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.

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>
@DjDeveloperr
DjDeveloperr requested review from a team as code owners December 1, 2026 18:46

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at eb64ee5

Checked:

  • genpd.parent_links is 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 is slock (GENPD_FLAG_IRQ_SAFE, pmgr-pwrstate.c:985). So the new list_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.py locally: 6/6 pass. Negative control: with the list_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 satchlj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at eb64ee5.

  • list_empty(&ps->genpd.parent_links) under ps->genpd.slock is the right guard and lock: pm_genpd_add_subdomain() links child subdomains onto the parent's parent_links under the parent's lock (slock since GENPD_FLAG_IRQ_SAFE is set), and fw_devlink does not invoke the parent's sync_state until child apple-pmgr-pwrstate devices have finished probing and registered their subdomain links.
  • Restricting sync_state power-gating to leaf domains eliminates the premature parent power-gate while keeping unused leaf domain gating intact.
  • Regression case in pmgr-inherited.py exercises the exact off-attached-subdomain scenario.

Building an exact-head J413 (T8112) boot smoke row now and will post the result here once complete.

@github-actions github-actions Bot added area:power Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Merge readiness at eb64ee5f: ready to merge

Check Detail
CI at head ok 10 checks passed
Review ok approved by satchlj
Requested changes ok none
Hardware row at head ok in the PR body at eb64ee5f
Conflicts ok none
PR text ok Risk: two-way · all Macs (shared pmgr-pwrstate driver). Tightens #3668's bootclkgated gating strictly to leaf domains (listempty(&ps->genpd.parentlinks)), 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.

Areas: area:power
Merge: gh pr merge 3829 --merge (Owners and Core through the bypass: add --admin).

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Dec 1, 2026
@satchlj

satchlj commented Dec 1, 2026

Copy link
Copy Markdown
Member

Row: eb64ee5 + J413 (MacBook Air 13" M2, T8112, 27.2 stub) + PASS

  • Exact head eb64ee5fb02c booted cleanly on J413 with default Stage 2 and zero-flag PMGR command line (boot_id=e984b323-95d9-4b33-9bfc-2ce756add15a, 0 failed units).
  • greetd, speakerguardd-v2, and NetworkManager active; aurora, appledrm, apple_pmp, brcmfmac, nvme_apple, and apple_soc_edac all loaded cleanly.
  • atc0_usb_aon, atc0_usb, atc1_usb_aon, atc1_usb, atc0_common, atc1_common, atc0_pcie, and atc1_pcie all active (on); 0 PMGR power-gate errors or warnings.

@DjDeveloperr
DjDeveloperr merged commit aaeff89 into main Dec 1, 2026
13 of 14 checks passed
@DjDeveloperr
DjDeveloperr deleted the fix/pmgr-boot-clkgated-parent branch December 1, 2026 19:31
DjDeveloperr added a commit that referenced this pull request Dec 1, 2026
Signed-off-by: Diljit Singh <hey@djdev.me>
@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

  • Kernel 7.3.0-aurora-b1pm3829 = main cd5cb048 + pmdomain: apple: pmgr-pwrstate: do not gate parent domains at sync_state #3829 eb64ee5f + drm/apple: iomfb_v27: skip 8-byte D003 slot metadata on doorbell dashboards #3830 af1d77fc (local merge 02368e37), m2combo30 config, one-shot BLS entry with the production options exactly. Trial Stage 2 = production aura 99b6dd13 + U-Boot + production DTB with the soc: apple: sleep: T8112 (M2) suspend-to-RAM, enabled on J413 #3647 DT delta (chosen/aurora,trial = the trial image).
  • Boot: up in 40 s, Enforcing, 0 failed units, displays, GPU render node, 12 USB, NVMe, Ethernet + gateway ping, 0 oops. Kernel errors = the 3 existing ones (SEP sensor -ENODEV, SEP matching unavailable, DCP audio close -110). genpd: 70 domains on, 80 off after sync_state; 4 always-on domains turned on at boot, as on production.
  • DPMS (Mutter PowerSaveMode 3 then 0): DP-2 + HDMI-A-1 off, then on. 0 DCP crash, 0 D003 bandwidth request is malformed, 0 no reply to set_power_state. HDMI-A-1 read disconnected in the sample 12 s after DPMS on and was connected enabled again at the next check. The J473 has no apple,bw-doorbell (t8112 bw-scratch 0x5d8/0x5e0), so its D003 reply is unchanged by drm/apple: iomfb_v27: skip 8-byte D003 slot metadata on doorbell dashboards #3830.
  • s2idle (rtcwake rtc1, 20 s): rc=0, success +1, fail 0. Both monitors connected + enabled after wake, 0 oops.
  • Then a plain reboot back to saved m2combo30 (48 s), verified: Stage 2 cc5dc744, next_entry empty, no trial files, Enforcing, 0 failed.
  • Evidence: traces/boot/20261202-b1-3829-j473/r1 (lab store).

@joshuaswarren

Copy link
Copy Markdown
Contributor

J514s (T6030, ryan-m3pro-binned) — booted on aaeff89c (main + this PR). Job j1201-203714-397c.

  • boot_id: 8875adf7-1877-468a-a139-cac0712a9165
  • uname -r: 7.3.0-ARCH+ (#2 SMP PREEMPT_DYNAMIC Tue Dec 1 20:30:53 UTC 2026 aarch64)
  • Boot: staged UKI → userspace in 53s; systemd-analyze total 17.677s. No boot hang.
  • Failed units: 1 — speakersafetyd.service (Speaker Protection Daemon). dmesg shows snd-soc-macaudio: no usable amp configuration from the boot loader, disabling speakers; this looks like an amp-config/boot-chain artifact of the hand-built kernel config, not pmgr — noting it for completeness.
  • Modules: appledrm, apple_pmp, brcmfmac, nvme_apple, mux_apple_display_crossbar, aurora loaded; apple_pmgr_pwrstate, apple_pmc, apple_soc_edac absent (built-in / n/a).
  • pm_genpd current_state: atc{0..3}_usb_aon, atc{0..3}_usb, atc{0..3}_common = on; leaf domains all off-0 (atc{0..3}_pcie, dwi, pms_fpwm0..4, pmgr_soc_ocla, aft0, fpwm1, fpwm2, i2c5, mca2, mca3).
  • 0 pmgr/pwrstate power-gate errors in dmesg.

Kernel: aaeff89c built locally (clang 22.1.8, rustc 1.93.1, aurora-bindgen 0.73.2), packed via lab pack. Config based on our M3 Pro config + PCIE_APPLE_T8140_BOOTSTRAP=y, MT7932_FULLMAC=m (required by this Mac's initcpio preset). omarchy-m-test vs 7.2.11 known-good: gpu.driver + gpu.vulkan fixed; 9 regressions (audio.*, camera.frames, display.notch-strip, system.failed-units) consistent with distro-config gaps in the hand-built kernel (e.g. appledrm: unknown parameter 'show_notch').

@erikwb

erikwb commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

We carry this PR (eb64ee5fb02c) in our unified daily kernel across J313 (M1 MacBook Air, T8103), J713 (M4 MacBook Air, T8132), and J716c (16-inch M5 Max, T6050).

After #3668 landed on main, apple_pmgr_ps_sync_state() could prematurely power-gate a parent boot_clkgated domain once its child apple-pmgr-pwrstate devices probed, before the subdomains' own consumers finished probing — risking boot hangs on shared pmgr-pwrstate hardware while still allowing unused leaf domains to gate.

Carried so all three Macs stay off that premature parent-domain gating path on main; all three boot cleanly on eb64ee5fb02c with displays, GPU, Wi-Fi, and NVMe up and no pmgr-pwrstate errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:power Area from CODEOWNERS (bot) blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants