Skip to content

kboot: T8152: hand the J873g's unused DCPEXT0/1 to Linux for an RTKit wake - #300

Open
sithglan wants to merge 2 commits into
aurora-silicon:mainfrom
sithglan:thomas/j873-dcpext-rtkit-wake
Open

sithglan wants to merge 2 commits into
aurora-silicon:mainfrom
sithglan:thomas/j873-dcpext-rtkit-wake

Conversation

@sithglan

Copy link
Copy Markdown
Contributor

On the J873g (M6 Mac mini), iBoot loads the firmware of both external display controllers (DCPEXT0 and DCPEXT1) and leaves each coprocessor running, waiting for the RTKit wake. No AFK endpoint has been started on them. apple_dcpib (aurora-silicon/linux#2176) drives the rear USB-C displays from those controllers. It wakes a controller only when the loader:

  • reserved the controller's firmware, and
  • set apple,rtkit-wake and apple,afk-active-endpoints on its node.

aura did neither, so the M6 needed both properties added to its DTB by hand. The DCPEXT nubs' 12 MiB buffer has its remap view at the start of the memory Linux gets, and only another reservation happened to cover it.

What this changes (dt_prepare_t8152(), minimal-boot path, after the internal display's reservations)

  • For each DCPEXT that aura did not start:
    • DCPEXT0 is skipped when aura used it for its second display, HDMI next to USB-C. That session is a running one, not one to wake.
    • Read the controller's PSD service. Only if it reads powered, read the coprocessor's CPU control register. A coprocessor read while gated hangs the bus.
    • A running controller gets both views (phys and remap) of every firmware and nub segment reserved, as the internal DCP's already are. Then it gets apple,afk-active-endpoints = <0> and apple,rtkit-wake. All of this happens in one dt_display_transaction.
    • A controller in any other state gets neither. A promise already in the tree, such as a hand-added one, is withdrawn first.
  • The segment reservation loop becomes dt_reserve_t8152_dcp_segments(), shared with the internal DCP (no behavior change there).
  • Small read-only helpers: t8152_psd_state() in dcp.c and display_second_attempted() in display.c.

The internal DCP's AFK report is not part of this PR; it stays with #89.

Hardware test (E2E A/B on the J873g, macOS 27.2)

aura main cannot launch the desktop kernel on the M6 yet. That is a separate open issue: the kernel never prints under main, while the aura-test lineage boots the same files. So the test ran this change on the M6's installed self-boot loader (aura-test lineage a30a589a). All seven new or changed functions are byte-identical to this PR. The only difference is the call site: there dt_prepare_t8152() calls it directly, while here it sits in the aurora,minimal-boot branch, which the J873 desktop DTB carries.

Both runs used the same flow and inputs:

  • VDM debugusb reboot, then the installed Stage 1's proxy window, then chainload.py -r --call of the image with boot= appended.
  • The same kernel (7.3.0) and initramfs.
  • The ESP DTB with apple,rtkit-wake and apple,afk-active-endpoints removed from both DCPEXT nodes.
a30a589a (control) a30a589a + this change
aura log no DCPEXT lines FDT: dcpext0 firmware reserved, left to the kernel to wake and the same for dcpext1
Live DT, DCPEXT0/1 no handoff properties apple,rtkit-wake, apple,afk-active-endpoints = <0>
memreserve — both views of every DCPEXT0/1 firmware and nub segment
apple_dcpib error -22: bootloader AFK endpoint handoff required (both) firmware handoff: CPU control 0x10 status 0xd, quiesced DCP wake: 0 (both)
USB-C displays none EV2780 at 2560x1440@60 (DCPEXT0), S2431W through a USB-C to HDMI adapter at 1920x1200@60 (DCPEXT1)

In both runs the internal DCP's firmware crashed on a buffer request ("no mapping for firmware buffer"). That comes from chainloading over a Stage 1 that already drove the display, and it is identical in the control. The installed boot, which does not chainload, is unaffected.

Not exercised on hardware

  • The refactored internal-DCP reservation in main's minimal-boot path. The loop is unchanged.
  • The skip for a DCPEXT0 that aura started for HDMI.
  • The not-powered branch.

Build: default LLVM build with no new warnings; git clang-format is clean.

@sithglan

Copy link
Copy Markdown
Contributor Author

Installed on the J873g as its Stage 1 (the a30a589a self-boot lineage plus this change, v0.1.0-260-gb64f2266, enrolled from 1TR) with the hand-added DCPEXT properties removed from the device tree. The loader logs FDT: dcpext0/1 firmware reserved, left to the kernel to wake, the live DT carries both properties on both DCPEXT nodes, and Linux wakes both controllers. Both USB-C displays and HDMI come up at boot and after a display off/on cycle.

@sithglan

Copy link
Copy Markdown
Contributor Author

The only failing check here is format-check. It fails on main too (3d517e6), in src/sptm_virt_s2r.c, which this PR doesn't touch. #303 formats that file; after it, this PR's format-check should pass unchanged.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks, the A/B table makes this easy to follow. Two small things before it goes in:

  1. In dt_set_dcpext_t8152(), apple,rtkit-wake is withdrawn before the dcpext0 HDMI check, but apple,afk-active-endpoints only after it. On the path where aura started dcpext0, a hand-added afk-active-endpoints stays in the tree. Could both delprops go before the skip, so the withdraw is complete on every path?
  2. t8152_psd_state() (src/dcp.c) masks with & 7, while t8152_psd_power_on() just above treats the whole register as the state. Could the mask be a named field next to T8152_PSD_STATE, with both readers using it? This also touches the same lines as kboot: T8152: publish the internal DCP's hand-off state #301 (dcp.h, display.h, dt_prepare_t8152), so one of the two will need a quick rebase after the other lands.

… wake

iBoot loads the firmware of the J873g's two external display controllers
and leaves each coprocessor running, waiting for the RTKit wake, with no
AFK endpoint started. apple_dcpib (aurora-silicon/linux#2176) wakes such
a controller for a rear USB-C display when its node carries
apple,rtkit-wake and apple,afk-active-endpoints and the loader reserved
its firmware. aura did none of this, so the M6 needed both properties
added to its device tree by hand, and the nub's 12 MiB buffer, whose
remap view lies at the start of the memory Linux gets, was reserved only
by chance.

For each DCPEXT that aura did not start (DCPEXT0 drives aura's second
display when HDMI runs next to USB-C), dt_prepare_t8152() reads the
controller's PSD service and, only when that reads powered, its CPU
control register: a coprocessor read while gated hangs the bus. A
controller that is running gets both views of every firmware and nub
segment reserved, as the internal DCP's are, then
apple,afk-active-endpoints = <0> and apple,rtkit-wake, in one display
transaction. Any other controller gets neither, and a promise already in
the tree is withdrawn first. The segment reservation becomes a helper
shared with the internal DCP.

Tested on the J873g (macOS 27.2): with a device tree that lacks both
properties, Linux wakes DCPEXT0 and DCPEXT1 and runs a USB-C EV2780 at
2560x1440 and an S2431W at 1920x1200. The same boot without this change
refuses both controllers ("bootloader AFK endpoint handoff required").

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

Both PSD readers in dcp.c take the current power state from bits 2:0
of the state register (T8152_PSD_STATE_CUR), as the kernel's dcpib
driver does. t8152_psd_power_on() read the whole register before.

dt_set_dcpext_t8152() leaves apple,afk-active-endpoints alone on the
dcpext0 that aura started for HDMI. There the value describes the
running session, so it belongs to the display hand-off that runs before
this one (aura#89 publishes it there, after removing any value already
in the tree). Removing it here would undo that. A comment now says so.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan force-pushed the thomas/j873-dcpext-rtkit-wake branch from 9923ddb to c04cefa Compare November 19, 2026 16:46
@sithglan

Copy link
Copy Markdown
Contributor Author

Thanks. Rebased onto main 5c70a29, which has #294, so format-check passes now. New head c04cefa; the first commit is unchanged apart from the rebase.

  1. apple,afk-active-endpoints on the aura-started dcpext0. I left this one as it is on purpose and added a comment. On that path the property describes the HDMI session aura is running, and it belongs to the display hand-off. J873: report live AFK endpoints to Linux at display handoff #89 (dt_set_afk_handoff_t8152(), called at the end of dt_set_display_t8152()) first removes the property from every apple,t8152-dcp-iboot node and then publishes it only for a controller aura owns. dt_set_dcpext_t8152() runs after that, so deleting it here before the skip would remove J873: report live AFK endpoints to Linux at display handoff #89's mask for dcpext0, and apple_dcpib would then refuse the HDMI adoption ("bootloader AFK endpoint handoff required"). Running this function first instead doesn't help either, because J873: report live AFK endpoints to Linux at display handoff #89's delete-all would then drop the promise this function makes for dcpext1. With both in, a hand-added value is withdrawn on every path, by J873: report live AFK endpoints to Linux at display handoff #89 on the aura-started path and here on the others.
  2. PSD state. T8152_PSD_STATE_CUR (GENMASK(2, 0), 0 powered, 6 idle) sits next to T8152_PSD_STATE. t8152_psd_state() uses FIELD_GET with it, and t8152_psd_power_on() now reads through t8152_psd_state() for both of its reads instead of the whole register. That matches the kernel side, which masks the same register with 7.

Checked: clang build (LLVM 22, BUILDSTD=1) with no warnings, and make format-check with clang-format 20.1.8 on the whole tree. I have not booted this on the J873g; the M6 tether is off right now.

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