Skip to content

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

Open
sithglan wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/t8152-psd
Open

sithglan wants to merge 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)

On T8152 the video decoder, the USB4 routers and their PHYs and the USB
controllers are powered through PMGR2 PSD services instead of PMGR
power-state registers. Each service has a 0x100-byte block with a target
state, an acknowledge bit and the current state.

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.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@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)

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, and the USB controllers (services 175 and 176) 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 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)

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.

2 participants