Skip to content

soc: apple: rtkit-helper, iommu: apple-dart: adopt the T6040/T6041 MTP by its compatible - #2308

Merged
RyanTheTide merged 1 commit into
mainfrom
sweep/soc-gates-mtp
Nov 26, 2026
Merged

RyanTheTide merged 1 commit into
mainfrom
sweep/soc-gates-mtp

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The retained live MTP handoff on T6040/T6041 was taken only on the J614s. drivers/soc/apple/rtkit-helper.c (inventory rule at :200, preserved at :294, strict_buffers at :344 on 0abc2f3) checked of_machine_is_compatible("apple,j614s") next to apple,t6041-mtp. drivers/iommu/apple-dart.c (:5881) kept the MTP DART in bypass only for apple,j614s, a fixed MMIO address and a fixed node path. Both came from 49d9477 ("soc: apple: retain the live J614s MTP handoff").

The MTP firmware cannot be restarted once it has run. On any other T6040/T6041 board that receives a live handoff, Linux would reset the DART under a running firmware and treat the session as restartable.

Change

  • rtkit-helper: one helper, apple_rtkit_helper_retained_mtp(), keys the retained form on the MTP compatible (apple,t8132-mtp or apple,t6041-mtp). The inventory requirement, strict_buffers and preserved follow it. U-Boot uses the same compatibles to choose the retained form (arm: apple: choose the MTP handoff in one place u-boot#55, apple_rtkit_helper_retained()).
  • apple-dart: an apple,t6041-dart that the apple,t6041-mtp node's iommus points to keeps its bypass for an advertised mtp-live-v1 session, and refuses an invalid one. The board, address and path checks are gone.

Every T6040 and T6041 board has the same MTP node (t604x.dtsi, mtp@514600000, apple,t6041-mtp), so they all get one rule. No other SoC uses apple,t6041-mtp or apple,t6041-dart.

If the device tree carries no handoff, nothing changes. J616s, J614c, J616c, J773s and J575c cold-start the MTP as they do today. The change only takes effect when the boot loader publishes apple,rtkit-handoff. U-Boot#55 will do that on every T6040/T6041 board.

The J614s handoff was written by Michal S.

Testing

  • Build, release config, LLVM: make W=1 drivers/soc/apple/rtkit-helper.o drivers/iommu/apple-dart.o and make drivers/soc/apple/. No new warnings.

  • Hardware (one-shot test kernel 7.3.0-aurora-swl1 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):

    • T6040 J616s with the current U-Boot (no live MTP handoff in the DT): no 'adopted the running RTKit' / 'live MTP' lines, as expected; keyboard/trackpad path unchanged; 3 s2idle cycles clean. The live-handoff row needs a u-boot#55 boot (still to run).

Still to run

  • J616s (T6040), current U-Boot (no handoff): expect no change. dmesg | grep -E "adopted the running RTKit|live MTP" prints nothing. Keyboard and trackpad work.
  • J616s (T6040), one-shot U-Boot from u-boot#55: dmesg | grep -E "Retaining the live MTP bypass|adopted the running RTKit session" shows both lines. There is no "Refusing invalid live MTP DART handoff". Keyboard and trackpad work.
  • Neo J700 (T8140), M1 Pro J316s (T6000), M2 J413 (T8112): not reached (no apple,t6041-mtp). A boot with a working keyboard is enough.
Reach and safety
Board SoC Before After
J614s T6040 retained when handed over same
J616s, J773s T6040 handoff ignored, DART reset retained when handed over
J614c, J616c, J575c T6041 handoff ignored, DART reset retained when handed over

The checks that refuse a bad handoff (unknown handoff string, CPU not running, DART not in bypass, DART locked or tunneled, no inventory) now apply on every board. Before, they ran on the J614s only.

The T8132 preserved check still uses apple_t8132_live_mtp(). That is outside this change.

The retained live MTP handoff (buffer inventory required, the session
marked preserved, no buffer allocation after adoption) was taken only when
the machine was a J614s and the MTP was apple,t6041-mtp. The DART behind
it was kept in bypass by the same machine check, a fixed MMIO address and
a fixed node path.

The handoff form belongs to the MTP firmware, which cannot be restarted
once used, not to the board: every T6040 and T6041 board has the same MTP
(apple,t6041-mtp in t604x.dtsi), and the boot loader picks the retained
form by the MTP compatible alone (apple,t8132-mtp or apple,t6041-mtp). Key
both sides on that:

- rtkit-helper: the inventory and strict-buffer rules and the preserved
  flag follow apple,t6041-mtp, as they already follow apple,t8132-mtp.
- apple-dart: an apple,t6041-dart that the apple,t6041-mtp's iommus points
  to keeps its bypass for an advertised mtp-live-v1 session and refuses an
  invalid one, on every board.

Without a handoff in the device tree nothing changes: the J616s and the
T6041 boards cold-start the MTP as before. With a boot loader that hands
the MTP over on those boards, Linux now adopts it instead of resetting the
DART under a firmware that cannot be restarted.

The J614s handoff this generalizes was written by Michal S.

Fixes: 49d9477 ("soc: apple: retain the live J614s MTP handoff")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

Checked at 6f0ce98. rtkit-helper: preserved (drivers/soc/apple/rtkit-helper.c:306-310), the inventory requirement (:214) and strict_buffers (:354) are all still inside the live branch. apple_rtkit_helper_live() (:136) only returns 1 for an mtp-live-v1 string with the ASC CPU running, so a DT without apple,rtkit-handoff cold-starts as before on every T6040/T6041 board. apple-dart: every apple,t6041-dart now enters the block at drivers/iommu/apple-dart.c:5884. For DARTs the MTP's iommus does not point to, advertised is false and nothing changes. With no MTP node, iommu is NULL and the && stops before mtp is dereferenced. One fix over the old code: a DART that is not the MTP's no longer reaches the -EINVAL refusal (the old iommu != dev->of_node term). Node refs are balanced on both exits. CI is green and the PR merges cleanly. It can leave draft.

  1. Suggestion: apple-dart.c:5889-5895 still names the MTP compatible inside the DART driver and takes only the first apple,t6041-mtp node. apple_dart_has_live_rtkit_client() (:5074) already does this generically for T8142: it walks every available node with apple,rtkit-handoff = mtp-live-v1 and matches its iommus against this DART. Using it here, together with the existing dart->hw->type/locked/tunneled/bypass checks, makes the DART side independent of which coprocessor sits behind it. Keep the refusal for an advertised but invalid string by checking the property separately.
  2. The only hardware result is the no-handoff J616s boot, on a combined test kernel. That is enough for this PR, because nothing changes without a handoff. The adoption path on any board other than the J614s is still unrun. The row below has to pass before u-boot#55 starts publishing the handoff on these boards.

HW row: before u-boot#55 merges: J616s on this head plus one-shot u-boot#55. The log has "Retaining the live MTP bypass" and "adopted the running RTKit session", and no "Refusing invalid live MTP DART handoff". Keyboard and trackpad work from boot and across 3x s2idle. 0 DART faults, 0 AVC, 0 failed units. Also a J614s owner boot on the head showing the same two lines, to confirm the original board did not regress.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide
RyanTheTide marked this pull request as ready for review November 22, 2026 10:15
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Adversarial pass at 6f0ce98: no code blockers. One problem with the test plan:

  • The body says u-boot#55 will hand the MTP over on every T6040/T6041 board, and lists a J616s row on a u-boot#55 boot that expects "Retaining the live MTP bypass". At u-boot#55's head (59d31da2), arch/arm/mach-apple/rtkit_helper.c:114-115 still picks the live handoff for apple,t6041-mtp only on apple,j614s, and every other T6040/T6041 board gets the cold OS handoff (see the comment at :98-103). On a J616s that row will print nothing. Either drop it, or note that it needs a u-boot change that widens that table.
  • Because of that, the only board where the new code runs today is the J614s, and its DART check changed shape (fixed address and node path replaced by the MTP's iommus link, apple-dart.c:5884-5895). A J614s boot at this head showing "Retaining the live MTP bypass" and "adopted the running RTKit session", with the keyboard working, is the row that covers the change.
  • Ordering note for whoever widens the u-boot table: a live handoff on a non-J614s T6040/T6041 board with a kernel that lacks this PR resets the DART under an MTP that can't be restarted. The u-boot change has to wait until a kernel with this PR is the default.

Assisted-by: LLM (Claude:Opus 5.5)

@DjDeveloperr DjDeveloperr 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.

Formal §1–§6 pre-PR review at verified live head 6f0ce9838d5b314b0151900d14d42078818479f1 against live integration/aurora (70a00e583b03, not superseded — commit 43f0791f35d2 only generalized the J613 bypass-handoff/suspend paths, leaving the apple,j614s checks in apple-dart.c:6211 and rtkit-helper.c:201,296,345 intact; MERGEABLE/CLEAN).

Verified Clean (§1–§4, §6)

  • Code & lifetime audit (§1–§3): apple_rtkit_helper_retained_mtp() cleanly keys the apple,rtkit-buffers requirement, helper->preserved, and helper->strict_buffers on apple,t6041-mtp within the live branch (leaving cold-start unchanged when no apple,rtkit-handoff property is present). In drivers/iommu/apple-dart.c, replacing the apple,j614s + hardcoded 0x514800000ULL + "/mtp@514600000" checks with apple,t6041-dart + of_find_compatible_node(NULL, NULL, "apple,t6041-mtp") + iommus phandle matching is refcount-balanced (of_node_put(iommu); of_node_put(mtp); on both normal and error paths) and null-safe (iommu == dev->of_node guarantees mtp != NULL).
  • Attribution (§4): Commit 6f0ce9838d5b carries human Author/Committer and full-name human Signed-off-by: Ryan Murray <[email protected]> only (zero AI commit trailers); PR body discloses assistance and credits Michal S.
  • Live CI (§6): All 7 applicable checks (source, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc, host-tests) completed SUCCESS on 6f0ce9838d5b.

Blockers Before APPROVE

  1. §5 Missing exact-head hardware verification of the modified live-handoff path & regression triad:
    • The only hardware test posted is a combined multi-PR test kernel (7.3.0-aurora-swl1 on older base 0abc2f38) on a J616s with no live MTP handoff in the DT — so neither the rewritten DART of_find_compatible_node()/iommus lookup nor the rtkit-helper apple_rtkit_helper_retained_mtp() / preserved path has been executed on hardware on any board (not even on J614s, where this code is already live today!). The J616s note also omits the §5 regression triad (0 SELinux denials, 0 failed units, 0 new kernel errors).
    • Please post an exact-head default-cmdline boot on J614s confirming "Retaining the live MTP bypass", "adopted the running RTKit session", working keyboard/trackpad + s2idle, and the §5 regression triad — plus a clean exact-head no-handoff T6040/T6041 regression row.
  2. Inaccurate PR body, test plan, and commit-message claim about u-boot#55:
    • The PR body states "U-Boot#55 will do that on every T6040/T6041 board" and lists a J616s u-boot#55 test row expecting "Retaining the live MTP bypass", and the commit message states "the boot loader picks the retained form by the MTP compatible alone (apple,t8132-mtp or apple,t6041-mtp)". As noted in your Nov 22 comment, u-boot#55 (59d31da2) still limits the apple,t6041-mtp live handoff to apple,j614s. Please update the PR description/test plan (and clarify the commit message if amended) to accurately reflect the current U-Boot state and §1 ordering.

Non-Blocking Note

  • In drivers/iommu/apple-dart.c, of_find_compatible_node() matches status = "disabled" nodes too (unlike apple_dart_has_live_rtkit_client() at line 5360, which checks of_device_is_available()). Checking of_device_is_available(mtp) (or sharing the generic client-walk pattern) would harden against a disabled MTP node on desktop T6040/T6041 boards (J773s/J575c).

@github-actions github-actions Bot added area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-hw-row No hardware row at the PR head (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 6f0ce983: ready to merge

Check Detail
CI at head ok 7 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok comment at 6f0ce983
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:platform
Merge: gh pr merge 2308 --merge (Owners and Core through the bypass: add --admin).

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

@DjDeveloperr DjDeveloperr 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: FINISH, then merge at 6f0ce9838d5b: the code is ready; it needs only a row at this head.

Blockers: none in the code. Missing row: the only run is a J616s with no live MTP handoff in the DT, so the rewritten paths (DART lookup by compatible, apple_rtkit_helper_retained_mtp()) haven't run. Needed: one boot at this head on a J614s, where the live handoff exists today, with Retaining the live MTP bypass and adopted the running RTKit session, and the keyboard and trackpad working across s2idle.

Checked: no Apple material. This removes a board gate: the MTP is adopted by its compatible. The J616s no-handoff boot shows the old path unchanged. CI green. This replaces my earlier review: the body's claim about u-boot#55 is a wording fix, not a blocker.

Evidence

Read 6f0ce983 (rtkit-helper.c, apple-dart.c) and the 11-20 J616s note.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:39

Superseded by the review at 6f0ce98

@github-actions github-actions Bot removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 24, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

6f0ce9838d5b (batched cleanly in J616s Batch #2 5b411e230229 over main 95a983c08be4, 0 merge-tree diffs across all 2 changed files) J616s (MacBook Pro 16" M4 Pro, T6040, Apple M4 Pro (G16S B1), macOS 26.6.2 fw, guarded one-shot 7.3.0-aurora-pr2905+, default cmdline, stock Stage 2 1.0.0b17, boot_id=de17fad3) PASS: 0 failed units, Enforcing, 0 new AVC (1 matching baseline), 0 GPU faults, 0 errors in this subsystem, real rtc1 s2idle 2/2 (success=2 fail=0), eDP connected pre/post-sleep, 406600000.sep + 514600000.mtp RTKit v12 (AppleMTPFirmwareMac-5340.61.4~502, HID keyboard/trackpad/accel/actuator/touch) clean, Borealis VK dEQP-VK.api.smoke.* 8/8 (pre & post-sleep) + glsl.loops.* 624/624, Wi-Fi 3/3 ping pre/post-sleep; stock 7.3.0-aurora-fleet89 restored & verified (b67edc6c).

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-hw-row No hardware row at the PR head (bot) labels Nov 25, 2026
@RyanTheTide
RyanTheTide merged commit a7be171 into main Nov 26, 2026
8 checks passed
@RyanTheTide
RyanTheTide deleted the sweep/soc-gates-mtp branch November 27, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:platform Area from CODEOWNERS (bot) needs-template PR body lacks Tested or Risk (bot) ready-to-merge Meets the merge policy: merge it (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants