Skip to content

soc: apple: pmgr-misc: add T8103 idle fabric and single-step DCS scaling - #3222

Closed
erikwb wants to merge 6 commits into
mainfrom
feat/t8103-pmgr-fabric-dcs
Closed

erikwb wants to merge 6 commits into
mainfrom
feat/t8103-pmgr-fabric-dcs

Conversation

@erikwb

@erikwb erikwb commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

What: Add apple,t8103-pmgr-misc with 64-byte single-cache-line single-step fabric (4 -> 1) and DRAM DCS (6 -> 4) idle and s2idle scaling plus GPU activity notification from g14_v27_2, saving ~218 mW automatically under default schedutil on J313 while keeping internal disp0 scanout clean.
Tested: J313 M1 MacBook Air at d9326f973d88 (merged origin/main over verified 97a33f386c50; booted in candidate 7.3.0-j313ener2: 0 failed units, 3x s2idle + deep S2R clean) (default command line, default schedutil): boots cleanly with 0 failed units and visually verified crisp internal eDP-1 display at fab=0x00000111 dcs=0x00000444, rejects dcs=3 with -EINVAL, passes 1x s2idle and 1x deep S2R (boot object resumes 0 -> 1, GPU firmware 27.2 back in 2760 us, suspend_stats success=2 fail=0) returning to fab=0x00000111 dcs=0x00000444 with screen visually intact; arm64 KUnit apple-pmgr-misc 33/33 passed.
Risk: two-way door · T8103 Macs (M1 Air/Pro/mini/iMac); shared apple-pmgr-misc and g14_v27_2 paths on T600x/T602x/T8112.
Not yet: non-J313 T8103 / T600x / T602x / T8112 hardware runs.

Details
  • dt-bindings: add apple,t8103-pmgr-misc to apple,t6000-pmgr-misc.yaml (disallowing interconnect/OPP properties as on t6020).
  • apple-pmgr-misc:
    • Add 64-byte-aligned ARM64 apple_pmgr_perf_step() (40 bytes, zero memory accesses between write and dsb sy) and IRQ-disabled apple_pmgr_step_to() checking initial BUSY, ACTUAL/DESIRED, every intermediate state against valid_mask, and post-step BUSY == 0 && ACTUAL == target.
    • Define DCS_VALID_STATES_T8103 = BIT(4) | BIT(5) | BIT(6) and DCS_DEV_PSTATE_MIN_T8103 = 4. Visual testing on J313 showed fabric=1 with dcs=6, 5, and 4 keeps the 2560x1600 internal panel clean (-118 mW fabric 4->1, -44 mW DCS 6->5, -56 mW DCS 5->4, ~218 mW total), while stepping DCS to 3 starves and latches disp0 blank even after raising DCS back to 4, and 2->1 resets the SoC while DRAM is live.
    • Default-enable idle_fabric_pstate = 1 and idle_dcs_pstate = 4 on T8103 when no PMP node (apple,t6000-pmp-v2 / apple,t8103-pmp) owns the rails and boot DCS is valid, while tracking explicit parameter writes so passing idle_fabric_pstate=0 or idle_dcs_pstate=0 on the kernel command line is preserved.
    • Skip suspend_noirq/resume_noirq stepping on non-s2idle sleeps so the T8103 deep-sleep engine owns DCS stepping undisturbed; verify live active state on deep resume and roll back cleanly on s2idle step failure.
    • Detect parked-idle CPUs (<= 5% busy over >= 50 ms) in apple_pmgr_cpus_at_min() so default schedutil clusters parked at stale high frequencies still allow idle scaling.
    • Export apple_pmgr_gpu_tracking_{start,stop}() and apple_pmgr_gpu_busy_{get,put}() (protected by rwsem for synchronized teardown on module unload).
  • g14_v27_2: notify apple-pmgr-misc via IS_REACHABLE-equivalent #[cfg(any(CONFIG_APPLE_PMGR_MISC = "y", all(CONFIG_APPLE_PMGR_MISC = "m", MODULE)))], raising fabric and DCS before staging/publishing compute or render work and releasing once idle or after firmware stops.
  • t8103.dtsi: add pmgr_misc: power-management@23b058000.
Evidence
  • J313 (M1 MacBook Air, T8103) at 97a33f386c50 (7.3.0-j313pmgrdbg, trial DT m1n1/boot-try-pmgrdbg.bin, default command line):
    • Interactive visual step bisect on J313 internal 2560x1600@60Hz panel (eDP-1): fabric=1 + dcs=6 (good), dcs=5 (good), dcs=4 (good), dcs=3 (latches screen blank, does not recover when raised back to 4).
    • Default command line boot at 97a33f386c50: 0 failed units, echo 3 > idle_dcs_pstate rejected (-EINVAL), 1x s2idle passed (fab=0x00000111 dcs=0x00000444), 1x deep S2R passed (boot object resumes 0 -> 1, GPU firmware 27.2 back in 2760 us, suspend_stats success=2 fail=0, returning to fab=0x00000111 dcs=0x00000444), internal display visually verified clean across boot and both wakes.
  • J313 Screen-ON power deltas (eDP-1 @ 118/420, kbd=0, wifi_ps=off):
    • fabric 4 -> 1: -118 mW PSTR (3.270 W -> 3.152 W), -72 mW PHPC
    • dcs 6 -> 5: -44 mW PSTR (3.152 W -> 3.108 W)
    • dcs 5 -> 4: -56 mW PSTR (3.108 W -> 3.052 W)
    • Total with fabric=1, dcs=4: ~218 mW saved at idle.
  • KUnit at 97a33f386c50:
    • tools/testing/kunit/kunit.py run --arch=arm64 --make_options=LLVM=1 --kunitconfig=drivers/soc/apple/apple-pmgr-misc.kunitconfig: Testing complete. Ran 33 tests: passed: 33.

Document the apple,t8103-pmgr-misc compatible for T8103 fabric-ps and
dcs-ps scaling, keeping interconnect/OPP properties restricted to
T600x.

Signed-off-by: Erik Bourget <[email protected]>
Add support for apple,t8103-pmgr-misc with single-step p-state
transitions executed inside a single 64-byte cache line with IRQs
disabled so memory clock transitions cannot stall their own
instruction fetch.

- Validate initial BUSY, ACTUAL/DESIRED state, and every intermediate
  DCS step against dcs_valid_states (BIT(3..6) on T8103, keeping
  p-state 3 as the safe runtime floor).
- Default-enable idle fabric (p-state 1) and idle DCS (p-state 3) on
  T8103 when no PMP node owns the rails and boot DCS is valid.
- Skip suspend_noirq/resume_noirq stepping on non-s2idle sleeps so the
  T8103 deep-sleep engine owns DCS stepping undisturbed; verify live
  active state on deep resume and roll back cleanly on s2idle error.
- Treat CPUs with <=5% busy utilization over >=50 ms as parked-idle so
  default schedutil clusters parked at stale high frequencies still
  allow idle scaling.
- Export apple_pmgr_gpu_tracking_{start,stop}() and
  apple_pmgr_gpu_busy_{get,put}() so GPU backends whose ASC keeps
  PS_GFX on while idle can report active work and synchronously raise
  fabric and DCS before job publication.
- Add synchronized teardown via rwsem and delayed-work cancellation,
  observational debugfs status, and KUnit coverage (33/33 tests pass).

Signed-off-by: Erik Bourget <[email protected]>
On T8103 with 27.2 GPU firmware, PS_GFX remains active while the ASC
runs even when GPU cores are idle. Register GPU activity tracking with
apple-pmgr-misc so idle fabric/DCS scaling can engage while no GPU
jobs are running, synchronously raising fabric and DCS before staging
and publishing compute or render work and releasing the hold once
in-flight work drains or after firmware stops.

Signed-off-by: Erik Bourget <[email protected]>
Add the pmgr_misc node (fabric-ps at 0x23b058000, dcs-ps at
0x23b05c000) to t8103.dtsi.

Measured on J313 (M1 MacBook Air, T8103) under default schedutil:
saves ~395 mW total (~118 mW fabric 4->1 and ~277 mW DCS 6->3) with
full Borealis compute/render, s2idle, and deep S2R passing.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb requested review from a team and DjDeveloperr as code owners November 26, 2026 09:40
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Merge readiness at d9326f97: not ready yet

Check Detail
CI at head no failing: pr-text / pr-text
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at d9326f97
Conflicts ok none
PR text ok Risk: two-way · T8103 Macs (M1 Air/Pro/mini/iMac); shared apple-pmgr-misc and g14v272 paths on T600x/T602x/T8112.

Areas: area:gpu, area:platform

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

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 26, 2026
@erikwb
erikwb marked this pull request as draft November 26, 2026 20:27
@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Moving back to draft after spotting a visual regression on J313 (M1 MacBook Air, T8103):

With apple-pmgr-misc stepping T8103 idle fabric/DCS down (idle_fabric_pstate=1, idle_dcs_pstate=3), the internal 2560x1600 panel (eDP-1 / disp0) goes visually blank while the backlight remains on and both Hyprland (grim shows normal non-black pixels) and fbcon (tty2) continue running normally underneath. Booting the exact same kernel with initcall_blacklist=apple_pmgr_misc_driver_init restores normal display output immediately.

Likely either the idle_dcs_pstate=3 / idle_fabric_pstate=1 floor is too low for active disp0 scanout bandwidth on T8103, or apple-pmgr-misc needs to account for active display scanout before stepping fabric/DCS down. Will hold in draft until this is diagnosed and verified visually on J313.

@github-actions github-actions Bot removed ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
…xplicit cmdline 0

Visual testing on J313 (M1 MacBook Air, T8103) showed that stepping DRAM DCS to p-state 3 while the internal 2560x1600 panel (disp0) is scanning out latches the display blank (backlight stays on and the screen does not recover when stepping back to p-state 4). Fabric p-state 1 with DCS p-states 5 and 4 keeps the display clean.

Raise DCS_DEV_PSTATE_MIN_T8103 to 4 and narrow DCS_VALID_STATES_T8103 to BIT(4) | BIT(5) | BIT(6), update the T8103 KUnit expectations accordingly (including rejecting p-state 3 with -EINVAL), and track explicit module parameter writes so passing idle_fabric_pstate=0 or idle_dcs_pstate=0 on the kernel command line is not overwritten by hw defaults during probe.

Signed-off-by: Erik Bourget <[email protected]>
@erikwb
erikwb marked this pull request as ready for review November 26, 2026 21:24
@erikwb

erikwb commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Resolved in 97a33f386c50 and marked ready for review:

  • Interactive visual bisect on J313 internal eDP-1 showed fabric=1 with dcs=6, 5, and 4 all keep the display clean, while dcs=3 starves and latches disp0 blank (even after raising DCS back to 4).
  • Raised DCS_DEV_PSTATE_MIN_T8103 to 4 (DCS_VALID_STATES_T8103 = BIT(4..6)), updated KUnit (33/33 pass, including dcs=3 -> -EINVAL), and fixed explicit cmdline =0 overrides so probe does not overwrite them.
  • Verified 97a33f386c50 on J313 default command line across boot, s2idle, and deep S2R (boot object resumes 0 -> 1, settled at fab=0x00000111 dcs=0x00000444, display visually clean throughout).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 26, 2026
@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 27, 2026
…c-dcs

# Conflicts:
#	drivers/gpu/drm/asahi/g14_v27_2.rs
@github-actions github-actions Bot removed the merge-conflict Conflicts with the base branch (bot) label Nov 27, 2026

@RyanTheTide RyanTheTide left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verdict at d9326f9: finish, then merge. The T8103 data is a per-compatible entry (apple,t8103-pmgr-misc), not a code gate, and the J313 rows look careful.

Blockers:

  1. Regression row on a second SoC. The new GPU busy get/put and the tracking start/stop calls in g14_v27_2.rs reach apple_pmgr_raise_fabric() on every SoC that binds pmgr-misc, which includes T600x and T602x (t600x-die0.dtsi, t602x-die0.dtsi). They change when fabric/DCS go up and down under GPU load there, and only the J313 has run them. We will add a T6000 row (M1 Pro: boot, a GPU load, s2idle + deep, fabric/DCS read back) at this head. Please keep the head stable until it is posted.
  2. pr-text is failing at this head. The fix is in the check output (body format); please fix it there.

Questions (answer on the PR):

  • DCS_DEV_PSTATE_MIN_T8103 = 4 comes from a visual bisect: at dcs=3 the internal panel latches blank. Does the J313 ADT describe a DCS floor for display scanout (pmgr perf-state or disp0 bandwidth properties)? If it does, read the floor from there. If it does not, please say so in the commit message so the next SoC knows to measure it.
  • idle_dcs_pstate is a new module parameter. Nothing needs it set (the default comes from the per-compatible data), so it reads as a development knob next to the existing idle_fabric_pstate. Fine if it stays default-off and documented. Otherwise, consider dropping it before merge.

Checked:

  • apple_pmgr_find_pmp_node() only adds apple,t8103-pmp next to apple,t6000-pmp-v2 (a block compatible).
  • On SoCs without pmgr-misc (T8112), the new exports only count atomically and return 0.
  • Single-step deep sleep is left to the sleep engine: no lowering in suspend_noirq on a non-s2idle target. The rollback on a partial set_pstate failure restores both devices.
  • KUnit: 33/33 on the author's arm64 run, which covers the rejection of DCS 1-3.

@RyanTheTide

Copy link
Copy Markdown
Contributor

d9326f973d88 J316s (M1 Pro, T6000 shared apple-pmgr-misc regression Mac): PASS

  • Boot & health: exact-head guarded one-shot (7.3.0-aurora-pr3222+) on the default cmdline (Enforcing, 0 failed units). Note: J316s is headless (no internal panel).
  • apple-pmgr-misc (28e20c000.power-management): PMP manages fabric and DCS p-states (pmp_owned=1 voters_ok=1 holds=0 dcs_bw_active=0 gpu_tracked=0 gpu_busy=0, fabric_active=7 fabric_now=7 dcs_active=9 dcs_now=9). Live hardware p-states under GPU load (deqp-vk pipeline.monolithic.depth.*): fabric_ps=0x00000bbb, dcs_ps=0x00000777 -> settled post-load idle: fabric_ps=0x00000333, dcs_ps=0x00000666 -> post-sleep: fabric_ps=0x00000333, dcs_ps=0x00000666 (matching saved 7.3.0-aurora-fleet89 baseline).
  • Sleep & GPU smoke: s2idle 2/2 PASS (15 s RTC via /dev/rtc1, suspend_stats/success 0 -> 2; mem_sleep=[s2idle], deep not exposed on T6000); Vulkan dEQP-VK.api.smoke.* 8/8 PASS pre-sleep and 8/8 PASS post-sleep.
  • Kernel log diff vs 7.3.0-aurora-fleet89: 0 new pmgr-misc or GPU warnings/errors (2x bpf-restrict-fs errors are from building the trial kernel with CONFIG_DEBUG_INFO_BTF=n; transient dwc3-apple genpd_prepare returns -11 during s2idle did not impede 2/2 wakeups).
  • Restore: cleanly restored & removed back to 7.3.0-aurora-fleet89 (Enforcing, 0 failed units, next_entry empty).

@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #3468 (feat/pmgr-fabric-dcs, clean 4-commit DCO-signed branch on main).

Key changes in #3468 addressing the review feedback here:

  • Moved both T8103 idle floors (apple,fabric-min-pstate, apple,dcs-min-pstate) to board-level DT properties with no hardcoded driver defaults; omitting either floor keeps that rail at its boot p-state.
  • Dropped the idle_dcs_pstate module parameter.
  • Hardened single-step state validation, live-clock confirmation across probe/resume/rollback, .prepare error propagation, and probe/parameter serialization, with 34 KUnit cases passing and exact-head J313 + J716c smoke runs.

Leaving this PR untouched at d9326f973d88 to preserve the existing review history and J316s test record.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for #3468; it takes all three review points (DT floors, no module parameter, hardening). Since #3468 carries this work, could you close this PR with a pointer to it? The review history and the J316s row stay readable on a closed PR. We have asked for a T6000 (M1 Pro) row at #3468 head 6588024 with SELinux enforcing and a failed-unit capture, the regression run its Not yet names.

@erikwb

erikwb commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #3468 (clean DCO-signed history on main with DT-driven fabric/DCS floors).

@erikwb erikwb closed this Nov 28, 2026
erikwb added a commit that referenced this pull request Nov 28, 2026
Merge #3468 (6588024, superseding closed #3222) into the tiered
active fabric/DCS scaling branch:

- Adopt #3468's board-level DT floors (apple,fabric-min-pstate and
  apple,dcs-min-pstate), dropping hardcoded default_idle_fabric,
  default_idle_dcs, DCS_DEV_PSTATE_MIN_T8103, and the idle_dcs_pstate
  module parameter. When DT omits floors, both rails stay at boot clocks.
- Preserve apple_pmgr_inst_sem locking, apple_pmgr_verify_active()
  unknown-rail tracking (U32_MAX), .prepare() error propagation, and
  -EAGAIN deferral in apple_pmgr_gpu_busy_get() while sleeping (via
  apple_pmgr_gpu_sleep_set()).
- Step DCS back to active in apple_pmgr_raise_dcs() whenever dcs_now is
  already known-lowered, even if idle_dcs_pstate was cleared.
- Combine #3468's KUnit coverage (including pf_dt_floors_test) with the
  tiered governor and GPU busy edge/rate-limit KUnit cases (41/41 pass).

Signed-off-by: Erik Bourget <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) blast:m1 Macs affected, from Merge risk (bot) blast:m2 Macs affected, from Merge risk (bot) ci-failing A check failed at the PR head (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants