Skip to content

arm: apple: choose the MTP handoff in one place - #55

Draft
RyanTheTide wants to merge 3 commits into
aurora-wipfrom
sweep/mtp-one-handoff-policy
Draft

RyanTheTide wants to merge 3 commits into
aurora-wipfrom
sweep/mtp-one-handoff-policy

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Refactor with no intended behaviour change, apart from the two cases listed below. Squash-merge recommended: the branch history keeps an earlier, wider version of this change followed by its revert. The behaviour changes that version made now live in the stacked draft #57.

What it does

Once MTP firmware newer than the M2's has run, it cannot be started again: taken to QUIESCED or SLEEP and started by the next owner, it faults or never answers (T8122 J613 #30, T8132 J604 #44, T8140 J700 c523219/#37, T8142 J813 fbfe606). Every board got its own fix for that, and the choice between them was spread over board lists in apple_rtkit_helper_allowed(), apple_mtp_kbd_probe(), board_late_init() and ft_board_setup().

This PR makes the choice in one place, apple_rtkit_helper_handoff(), which reads the MTP node:

Handoff When Why
RESTART apple,t8112-mtp, apple,t6020-mtp, or a helper that is not an MTP M2-generation firmware restarts cleanly. Our MacBook Air M2 (J413) boots this way today: Linux cold-starts the MTP after U-Boot, and the keyboard and trackpad register.
OS apple,t8142-mtp, apple,t6050-mtp iBoot already runs this MTP before the OS, so U-Boot never touches it.
PARK every other MTP, when /chosen/aurora,mtp-handoff = "off" and the MTP can be parked The intended path for every MTP that cannot be restarted: U-Boot parks it at OS entry with the image it had before its first run, and the OS starts it fresh. The park sequence itself plugs into rtkit_helper_can_park(), which returns false here (see "Relation to #49").
LIVE the fallback The session is handed to the OS running (mtp-live-v1).

Until each board has a hardware row, the unparked fallback keeps today's per-board behaviour. It comes from one table next to the selector:

  • live on J700 (every T8140), J613, J713 and J614s;
  • cold on the J604 and the other T6041 boards (J616s, J614c/J616c);
  • the restart path everywhere else, as today.

The live publication form also follows the MTP: retained for T8132/T6041, with an inventory for T8122, plain for T8140. It used to be picked by j713/j614s/j613. Every caller (helper bind and probe, keyboard bind and probe, board_late_init()'s keyboard start and retained-input drain, ft_board_setup()) now asks the selector.

Behaviour changes (only these two)

Credit: this reworks the per-board handoffs by DjDeveloperr (T8140), Eryk Wieliczko (J713), Michal S. (J614s) and Satya Benson (J613), and the J813/J604 cold paths by Acelogic and aeries0x.

Relation to #49 (park)

This PR does not stack on #49. #49 is still a draft and has not run on hardware, and it carries #37, which fails on hardware. This PR gives it a hook instead:

Tests

  • apple_m1_defconfig, GCC 16.1 aarch64, KCFLAGS=-Werror: builds clean.
  • test/py/tests/test_apple_*.py with --noconftest: 36 passed, 2 skipped. Two of these tests are new:
    • test_helper_handoff_follows_the_mtp checks the handoff, the retained form and allowed() for 16 MTP/board rows (J413, J414, J813, J815, J714c, J700, J613, J504, J514c, J713, J604, J715, J614s, J616s, J616c, and a non-MTP helper), with no aurora,mtp-handoff, with "off" and with "live". Each row matches today's behaviour, apart from the T8142 J815.
    • test_live_publish_plain_and_inventory_forms runs the generic live publication against real libfdt in both forms.

Hardware rows owed

None are needed for the refactor beyond a regression boot. Each is a one-shot U-Boot boot to the prompt, then Linux through EFI, checking the keyboard in U-Boot/GRUB and the keyboard and trackpad in Linux:

  • Neo J700: live, expected unchanged.
  • J616s: cold, expected unchanged.
  • M2 J413: restart, expected unchanged.
  • M1 Pro: no MTP, expected unchanged.

Stacked behaviour changes (unparked MTPs go live on every board, one live publication form): #57 (draft).

RyanTheTide and others added 3 commits November 19, 2026 22:26
Once MTP firmware has run, it cannot be started again. Taken to QUIESCED
or SLEEP and restarted by the next owner, it faults or never answers.
This has been seen on T8122 (J613), T8132 (J604), T8140 (J700) and T8142
(J813). Each board got its own fix: a live handoff on J700, J713, J614s
and J613, a cold MTP on J813, J604 and T6050, and three board lists that
decide which board gets which.

Choose the handoff once, in apple_rtkit_helper_handoff(), from the MTP
node's compatible:

- An M2-generation MTP (apple,t8112-mtp, apple,t6020-mtp) restarts
  cleanly, and so does a helper that is not an MTP. U-Boot stops it at
  OS entry, as before.
- iBoot already runs the T8142 and T6050 MTPs before the OS, so U-Boot
  never touches them: the helper and keyboard do not bind.
- Every other MTP is started only if its DART is in bypass, and is
  handed to the OS running (mtp-live-v1). The T8132 and T6041 MTPs keep
  the retained form (system endpoint mask, startup drain, legacy
  marker). Linux keys its adoption of these MTPs on the same compatibles.

The live handoff is now the same on every SoC that uses it. The buffer
inventory is always published. No session is published before the
keyboard's READY. A failed publication stops the MTP and disables it
and its keyboard in the OS tree. A published session whose DART
retention fails refuses OS entry. OSLog stays in SRAM unless the helper
has no SRAM region, or on T8140, where the handoff has only been run
with OSLog in DRAM.

The board lists in apple_rtkit_helper_allowed(), apple_mtp_kbd_probe(),
board_late_init() and ft_board_setup() go away. The J713 startup drain
runs for every retained-form MTP, found through the DockChannel
keyboard's helper.

This reworks the per-board handoffs by DjDeveloperr (T8140), Eryk
Wieliczko (J713), Michal S. (J614s) and Satya Benson (J613), and the
J813 and J604 cold paths by Acelogic and aeries0x.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 9e748a1. It moved several boards from a cold MTP
to the live handoff without hardware rows and made the live handoff the
target policy. The next commit keeps the single selector and every
board's current behaviour; the behaviour changes follow separately.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Once MTP firmware newer than the M2's has run, it cannot be started
again, and every board got its own fix for that, spread over board
lists in apple_rtkit_helper_allowed(), apple_mtp_kbd_probe(),
board_late_init() and ft_board_setup(). Gather the decision in
apple_rtkit_helper_handoff(), which reads the MTP node:

- RESTART: M2-generation MTPs (apple,t8112-mtp, apple,t6020-mtp) and
  helpers that are not an MTP; U-Boot stops them at OS entry.
- OS: apple,t8142-mtp and apple,t6050-mtp, which iBoot already runs;
  U-Boot never touches them.
- PARK: every other MTP when /chosen/aurora,mtp-handoff is "off" and the
  MTP can be parked. The park sequence plugs into
  rtkit_helper_can_park(), which returns false for now.
- LIVE: the fallback, on the boards where it is qualified (J700, J613,
  J713, J614s). Until each board has a hardware row, the J604 and the
  other T6041 boards keep a cold MTP and the remaining boards keep the
  restart path, from one table next to the selector.

The live publication form follows the MTP too: retained for T8132 and
T6041, with an inventory for T8122, plain for T8140. Every caller asks
the selector instead of a board compatible.

Behaviour is unchanged except in two places. The J815 and other T8142
boards now leave the MTP to the OS like the J813. A failed J613
publication now stops the MTP and disables it and its keyboard in the
OS tree, as on J713, instead of panicking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@RyanTheTide RyanTheTide changed the title arm: apple: choose the MTP handoff from the MTP, not the board arm: apple: choose the MTP handoff in one place Nov 19, 2026
@term-guy

Copy link
Copy Markdown

J704 (MacBook Pro 14-inch, M5, apple,t8142-mtp) on this PR's head, 59d31da (apple_m1_defconfig), as the ESP Stage 2 payload after aura (aura → U-Boot → GRUB → Fedora 44 KDE, LUKS root), normal boot:

  • U-Boot 2026.07-g59d31da2b0c4 finds the SSD and boots GRUB and Linux.
  • The MTP comes up normally in Linux (MTP Says Hello, AppleMTPFirmwareMac-6300.85.6 at 0.86 s). There is no RTKit crash dump, no Failed to wake up coprocessor and no deferred probe pending.
  • The internal keyboard registers at 1.34 s and the trackpad by 2.05 s (394b30000.input). The password was typed on the internal keyboard at the LUKS prompt, and the desktop works.

With plain aurora-wip (37baf8f), the same setup has a crashed MTP and no keyboard at the prompt (control run on #66). So this covers the J704, and I'll close #66 in favour of this PR.

AI-assisted (Assisted-by: LLM), tested by me on the hardware.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Collecting the handoff choice into apple_rtkit_helper_handoff() is a good step, but the rtkit_helper_unparked[] table in arch/arm/mach-apple/rtkit_helper.c still keys it on machine compatibles: apple,t8132-mtp is LIVE on apple,j713 but OS on apple,j604, and apple,t6041-mtp is LIVE only on apple,j614s. Two boards with the same MTP and firmware get different handoffs, and a new board silently falls into whatever the NULL row says. The production version decides from the MTP node itself (its compatible, the firmware version it reports, or a property the earlier stage publishes) with no board column, and the per-board rows go away as the hardware rows come in. Until then this should stay a draft.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Blockers: 3.

These build on the earlier comment about the board column in rtkit_helper_unparked[].

  1. arch/arm/mach-apple/rtkit_helper.c:109-137: a machine that isn't in the table gets the fallback, which is RESTART. The header comment at :63-67 says that path faults on T8132 and T8122, and the table sends Macs with those same MTPs there:
    • the J715, with the same apple,t8132-mtp as the J713;
    • the J615, with the same apple,t8122-mtp as the J613;
    • the M3 Pro and M3 Max (apple,t6030-mtp, and apple,t6031-mtp with the t8122 helper fallback).
      That matches today's behaviour, but now the code states it as the policy. For any MTP that isn't t8112/t6020, the safe default is the cold OS handoff, which the J604 and T6041 boards already run: U-Boot loses the internal keyboard, Linux gets a fresh MTP. LIVE should apply only where the MTP node says the session can be adopted, not where a board row says so.
  2. rtkit_helper.c:85-91, :120-121: rtkit_helper_can_park() always returns false, so /chosen/aurora,mtp-handoff = "off" and the whole PARK branch can never run. That is untested plumbing, and it adds a per-boot DT switch that would pick a hardware path. Please drop it here and let arm: apple: park the T8140 MTP at OS entry with its pristine image #49 bring it in together with the park sequence and a row.
  3. Commits: none of the three commits has a Signed-off-by. All three carry Co-Authored-By: Claude Opus 5.5, and 9e748a1 / 8b023c5 are a change and its revert. Please replace them with one signed commit with no agent trailers. The branch also conflicts with aurora-wip.

What I checked: the old and new per-board choices for J413, J700, J613, J713, J614s, J604, J813, T6041 and T6050. Apart from the two changes listed, they agree. ft_board_setup() now fails for any non-zero fixup, but apple_rtkit_helper_fdt_fixup() only returns an error for strict candidates, so nothing changes outside the J613 case listed. rtkit_helper_dram_oslog() gives the same SRAM/DRAM split, because the T6041 node is the only one without an "sram" reg (t604x.dtsi:1300). The J704 row in the comments covers the T8142 OS path.

HW row: this head as a one-shot Stage 2 on the J700 (live), J616s (cold), J413 (restart) and M1 Pro (no MTP). On each: U-Boot keyboard in GRUB where it applies, Linux keyboard and trackpad, no RTKit crash dump, 0 failed units and 0 new kernel errors. Add a J715 or J615 if the default changes.

Assisted-by: LLM (Claude:Opus 5.5)

@rjianwei

rjianwei commented Dec 1, 2026

Copy link
Copy Markdown

Verified on MacBook Pro (14-inch, M5, 24 GB, apple,j704, macOS 27.2 stub):

Skipping apple_mtp_kbd init on apple,t8142 (built atop aurora-wip@1ee10f7e with aarch64-linux-gnu-gcc) resolves the 394600000.mtp probe crash and hands off cleanly to Linux: built-in keyboard, multi-touch trackpad, and Force Touch all work reliably (including across deep S2R wake).

Tested-by: WJW [email protected]

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