Skip to content

pmdomain: apple: T8152 PSD services as power domains - #2459

Merged
Acelogic merged 2 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/t8152-psd
Nov 22, 2026
Merged

Acelogic merged 2 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/t8152-psd

Conversation

@sithglan

@sithglan sithglan commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

On T8152 several blocks are powered through PMGR2 PSD services rather than PMGR power-state registers: the video decoder (service 50), the USB4 routers and their PHYs (the CIO services), and, by the ADT, the USB controllers (175, 176). So far #2139 and #2178 each carried their own variant of a PSD power domain: one compatible per user, AVD always on, CIO with power-off. As agreed on #1797, this replaces them with one generic per-service provider.

  • dt-bindings: power: add the Apple T8152 PSD service (apple,t8152-psd): one node per service, its 0x100-byte block as reg, #power-domain-cells = <0>, an optional label, and an optional apple,always-on for a service whose consumers can't yet restore what another agent set up in its blocks.
  • pmdomain: apple: add the T8152 PSD power domains. Power-on requests state 0 and power-off the cold state 6. The driver waits for the acknowledge (bit 0 of +0xbc) before reading the state (bits 2:0 of +0x80), because that read consumes the acknowledge. An apple,always-on service is powered at probe and kept on. Any other starts in the state the hardware reports, so genpd powers off a service nobody uses.

Users:

Checks: pmgr-psd.o builds with no W=1 warnings, dt_binding_check passes for the new schema, checkpatch is clean. Hardware results for the AVD power-off and the CIO services are in the comments.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan

Copy link
Copy Markdown
Contributor Author

J873g results, on #2178's stack (which carries #2139's AVD with this provider) plus a TEST-only commit that logged every transition.

  • IRQ-safe: the first version used sleeping polls. genpd then refused to power off the AVD domain, because its DART is an IRQ-safe device (PM domain avd will not be powered off). The domains are now GENPD_FLAG_IRQ_SAFE and poll atomically, like pmgr-pwrstate.
  • Transition times (AVD, service 50): state 0 in 390–500 µs, the cold state in 236–242 µs. The atomic timeout is 10 ms.
  • AVD: with the decoder idle at boot, the domain went off 2 s after probe (state register 6) and genpd shows avd off-0. Decoding H.264, HEVC, HEVC Main10, VP9 and AV1 (60 frames each, framemd5 against software) powered it on and stayed bit-exact across 292 on/off transitions: the decoder autosuspends after 100 ms, so it cycled between files. 4K60 H.264 to a null sink ran at 150 fps. 11 s after the last decode the domain was off again. No DART or AVD errors, so the cold Gen3 DART re-init and the decoder setup on resume both hold up.
  • CIO: the twelve CIO services probe and read off-0 while no USB4 cable is attached, as with J873g: USB4 on the rear USB-C ports through tipd and atc.c (T8152 routers, PCIe-C, M6 Mac mini) #2178's previous variant. No cable was on the J873g for this run.

I'm taking this out of draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor

No blockers.

I checked drivers/pmdomain/apple/pmgr-psd.c and the binding. The ack-then-state poll is atomic and bounded (10 ms against the measured 240-500 us). The early state read before writing the target clears any stale acknowledge. An always-on domain is powered before pm_genpd_init() so its initial state is consistent. The provider and genpd are torn down in the right order on error and unbind. GENPD_FLAG_IRQ_SAFE matches the DART consumers. apple,always-on follows the existing apple,pmgr-pwrstate binding.

  1. Nit: drivers/pmdomain/apple/Makefile:11 builds pmgr-psd.o under CONFIG_APPLE_PMGR_PWRSTATE, so this T8152-only driver can't be configured on its own and isn't named in Kconfig. A small APPLE_PMGR_PSD symbol (depends on ARCH_APPLE || COMPILE_TEST, default ARCH_APPLE) would make that clear.

HW row: J873g on the default command line: a USB4 device hot-plugged on a rear port (CIO services go from cold to on, the device enumerates, then back to cold within a few seconds of unplug), the USB controllers on services 175/176 working with apple,always-on, and the AVD on/off cycle as already shown. 0 SELinux denials, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

host-tests fails in hardware-defaults-tests (test_shared_profile_covers_native_driver_options): AssertionError: Lists differ: ['APPLE_PMGR_PSD'] != []. The test checks that every native Apple driver option is set in the shared kernel profile every distro builds from. This PR adds CONFIG_APPLE_PMGR_PSD without an entry there, so adding it to that profile (=y or =m, whichever T8152 needs at boot) in this PR should clear it. Locally: python3 -I tools/asahi/run-host-tests.py --only hardware-defaults.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide fixed in c02baf450d3a: CONFIG_APPLE_PMGR_PSD=y is in arch/arm64/configs/asahi.config, next to APPLE_PMGR_PWRSTATE. The T8152 USB DARTs and controllers need their domains at boot, so it's built in. run-host-tests.py --only hardware-defaults passes.

The J873g row (rear-port USB4 hotplug, services 175/176 with apple,always-on, the AVD cycle, and the regression line) needs a PR-stack kernel with this head. I'll post it once that boot is done.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan

Copy link
Copy Markdown
Contributor Author

J873g rows. The kernel was the #2178 stack (6968ed26fa87) plus:

Kernel 7.3.0-aurora-j873-prs2459+, firmware 27.2 (26B123).

AVD, service 50 (not always-on). off-0 at idle. Three rounds of a hardware H.264 decode (v4l2request, 24 frames):

round during frames vs software after exit
1 on identical off-0 0.10 s after exit
2 on identical off-0 0.12 s after exit
3 on identical off-0 0.10 s after exit

CIO services, rear USB4 ports.

  • Router 0 (401ac0000) has a peer, the Linux mini over USB4. Its services 59/63/67/86 are on.
  • Routers 1 and 2 have nothing attached. Their services (60/64/68/87 and 62/66/70/89) stay off-0.
  • Three rounds of unbind/bind of router 0's driver: all four services went to off-0 when unbound and back on after bind, and the peer was back in 7 s each time.
  • Rebinding the empty router 1 twice left its services off-0.
  • These rows are router restarts, not a cable replug. The USB4 enclosure is on the M5 now.

Services 175/176 (USB controllers' DARTs): not done, and the description was wrong about them.

  • I added test nodes at the PSD window's base + 0x100 * service (0x303a1af00, 0x303a1b000) with apple,always-on.
  • The first register access in apple_psd_set_state() at probe took a synchronous external abort, and the boot panicked.
  • So 175 and 176 are not in the window that services 50-89 use, and their users need the right blocks before they can use this driver.
  • Nothing in this PR touches them. I've changed the description to say they're a later user whose registers still have to be found.
  • The USB controllers still run on the loader's setup on this kernel: hub, keyboard and receiver enumerate on buses 3/4.

Regression line.

  • 0 new kernel errors or warnings during the AVD, USB4 and guest rows.
  • SELinux is not enabled (0 denials).
  • One failed unit, j873-gpu.service: this stack's GPU driver has no 26B123 firmware profile ("stage 10 needs /chosen aurora,g18g-gpu-firmware-profile"). That's unrelated to the PSD driver.

The M6 is back on its default kernel.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 28434d5. Both earlier points are fixed: APPLE_PMGR_PSD has its own symbol (drivers/pmdomain/apple/Kconfig:29, Makefile:11) and c02baf4 sets it in arch/arm64/configs/asahi.config, which clears hardware-defaults. pmgr-psd.c is unchanged since the last review.

The new binding text in 28434d5 is right: the driver takes each service's block from reg (pmgr-psd.c:105) and never derives an address from a service number, which the 175/176 abort rules out anyway. Small things left:

  • 28434d5 corrects text added by 5613682 in this same PR. Please squash it into the binding commit, and wrap its body (it is one 156-character line, which checkpatch flags).
  • The same correction is missing in three places:
    • the c02baf4 commit message ("and the USB controllers (services 175 and 176) use it");
    • the 5613682 commit message ("... and the USB controllers are powered through PMGR2 PSD services");
    • the Kconfig help at drivers/pmdomain/apple/Kconfig:36-38 ("the USB and USB4 DARTs and controllers").
      None of them is a user yet. They should name the video decoder and the USB4 routers and PHYs only, like the new binding text.

Rows: the AVD and CIO rows from 11-21 were on a kernel with pmgr-psd.c identical to c02baf4, and the new commit only touches the binding, so they carry over to this head. One row is still missing: a real cable unplug and replug on a rear USB4 port (CIO services go from cold to on, the device enumerates, then back to cold after unplug). The router unbind/bind rounds cover the driver side but not the port's own hotplug path.

Assisted-by: LLM (Claude:Opus 5.5)

@Acelogic

Acelogic commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

I applied the binding correction in 28434d512d3a and tested that revision on our physical J873g Mac mini (M6) before merging. The driver already maps the register resource from each device-tree node. The binding now describes that resource directly.

I built the PR on public integration/aurora at e0a9448a75df and booted the same kernel image twice. Both test device trees used the confirmed 0x100-byte video-decoder register block at 0x303a13200 (AVD service 50). A test-only simple-pm-bus consumer exercised the driver through Linux runtime PM. After each transition I checked the consumer status, the generic power-domain status, and the hardware state bits at offset 0x80.

Binding on the J873 Consumer active Consumer suspended Result
Normal Domain on, hardware state 0 Domain off, hardware state 6 3/3 cycles passed
apple,always-on Domain on, hardware state 0 Domain stayed on, hardware state 0 3/3 cycles passed

All 12 CPUs were online and kernel taint was 0 after each run. The corrected schema, both test DTBs and the hardware-defaults suite passed validation. This hardware run covered the provider and its two power policies on service 50. The author's separate J873 run covers hardware video decode and USB4 router rebinds. Earlier J873 consumer results

The PR was subsequently updated to 5eaa2136d623. I compared its proposed merge into the same public base with the tree used for both J873 boots. The sole difference is the help paragraph for APPLE_PMGR_PSD, which now names the confirmed consumers. The driver, binding and Kconfig settings are byte-identical, so the hardware results above also cover the updated revision.

I also ran the repository’s eight CI jobs locally on the proposed merge tree 8ce25e82a306 in an ARM64 Ubuntu 26.04 VM. All 138 Apple device trees built on both revisions, with zero new warnings. The corrected binding, ADT coverage and DART checks passed. 461/461 host cases passed. 308/308 apple_sep KUnit tests passed in QEMU on ARM64. The SEP source checks, ARM64 Rust driver build and all three DWC3/ATC compile configurations also passed. The host total includes 25 cases that passed on rerun after I supplied their historical Git objects or linked the ARM64 system loader for the mixed C/Rust tests.

On T8152 the video decoder and the USB4 routers and their PHYs are
powered through PMGR2 PSD services instead of PMGR power-state
registers. Each service has a 0x100-byte block, given by its node's
reg, with a target state, an acknowledge bit and the current state. The
address comes from reg, not from the service number: the USB
controllers' service numbers point at blocks that abort when read.

Describe one service per node as a power domain, with an optional
apple,always-on for a service whose consumers cannot restore what
another agent set up in its blocks yet.

Co-developed-by: Acelogic <miguelc4600@gmail.com>
Signed-off-by: Acelogic <miguelc4600@gmail.com>
Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Provide each T8152 PMGR2 PSD service as a power domain. Power-on
requests state 0 and power-off the cold state 6. The driver waits for the
acknowledge before it reads the state, because reading the state
consumes the acknowledge. A service marked apple,always-on is powered at
probe and kept on. Otherwise the domain starts in the state the
hardware reports, so genpd powers off a service that nothing uses.

The consumers include IRQ-safe devices, the DARTs, so the domains are
IRQ-safe and a transition is polled atomically, as the PMGR power states
are. On the J873g the AVD service (50) reaches state 0 in 390-500 us and
the cold state in about 240 us; the timeout is 10 ms.

The AVD and the USB4 routers' CIO services, which so far each had their
own variant of this, use it.

It has its own Kconfig symbol, APPLE_PMGR_PSD, on by default with
ARCH_APPLE and built in by the shared asahi.config profile.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide done, head 5eaa213:

  • Squash. 28434d5 is squashed into the binding commit (now 4e07891), credited with Co-developed-by:/Signed-off-by: Acelogic. The YAML is byte-identical to 28434d5. The message is rewrapped and says the address comes from reg, not from the service number, because the USB controllers' numbers point at blocks that abort when read.
  • The other three places. The binding commit's message, the driver commit's message (5eaa213, the "USB controllers (services 175 and 176)" clause is gone) and the Kconfig help now all name only the video decoder and the USB4 routers and their PHYs.
  • The tree differs from 28434d5 only in that Kconfig help text; checkpatch has nothing new.

The rear USB4 cable unplug and replug row needs a hand at the M6; the enclosure is on the back-right port now. I'll run it in the morning: CIO services from cold to on, the enclosure enumerating, then back to cold after the unplug.

Assisted-by: LLM (Claude:Opus 5.5)

@Acelogic
Acelogic merged commit 4a17f73 into aurora-silicon:integration/aurora Nov 22, 2026
8 checks passed
@sithglan

Copy link
Copy Markdown
Contributor Author

The rear USB4 cable unplug and replug row I said was owed, now that this has merged.

Kernel: 7.3.0-aurora-j873-unlit+ = the rebased #2178 stack (6589921, which has this PR from integration b10280c) + #2873. Setup: a Ugreen USB4 enclosure (Samsung 980 PRO) on the back-right port, i.e. router 2 (411ac0000), CIO services 62/66/70/89. Router 0 has the mini over USB4; router 1 has nothing.

The PSD states and the router devices were polled every 0.5 s from pm_genpd_summary while the cable was pulled by hand and plugged back in:

time services 62 / 66 / 70 / 89 router 2 devices nvme1
06:19:12.9 (booted with it attached) on / on / on / on host + Ugreen yes
06:19:29.97 (cable out) on host + Ugreen gone
06:19:30.98 off-0 / off-0 / off-0 / off-0 none -
06:19:50.01 (cable in) on / on / on / on host -
06:19:50.51 on host + Ugreen -
06:19:54.03 on host + Ugreen yes
  • Power: the four services went cold 1.0 s after the unplug and came back on with the replug. The enclosure enumerated 0.5 s later and its namespace 4.0 s later.
  • Other routers: router 0's services (59/63/67/86, on) and router 1's (60/64/68/87, off-0) did not change at any point.
  • Data: read-only SHA-256 of two 256 MiB direct reads (offsets 0 and 256 MiB), before and after the replug: identical (6a7f0d08…, 28ff3941…).
  • Kernel log: no errors, warnings, oopses or DART faults after boot.

Assisted-by: LLM (Claude:Opus 5.5)

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.

3 participants