Skip to content

arm: apple: park the T8140 MTP at OS entry with its pristine image - #49

Draft
RyanTheTide wants to merge 3 commits into
aurora-wipfrom
mtp/t8140-park
Draft

RyanTheTide wants to merge 3 commits into
aurora-wipfrom
mtp/t8140-park

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

U-Boot starts the T8140 MTP for its own keyboard and trackpad, and today hands the running session to the OS (mtp-live-v1). This parks it at OS entry instead, so the OS can start it as a firmware nobody ran. The counterpart on the Linux side is aurora-silicon/linux#1813.

It carries #37's commit unchanged (the RTKit sleep stop at OS entry), plus one commit on top.

Why a CPU reset isn't enough

The MTP keeps its firmware in SRAM, and a run changes the firmware's data there. #37's stop plus a CPU reset in Linux started the firmware from its reset vector with that data dirty, and it never read INIT. The only clean image a later stage can get is the SRAM as iBoot loaded it, before the first run.

What this does

It applies only when the boot loader before U-Boot sets /chosen/aurora,mtp-handoff = "off", which an aura Stage 2 passes with the configuration line chosen.aurora,mtp-handoff=off.

  • Probe, before the first run bit: copy the whole firmware SRAM (reg-names "firmware") into memory U-Boot never gives back, and take its CRC-32.
  • OS tree fixup: the image as no-map reserved memory (mtp-image@...). On the mtp node, apple,sram-image = <address size> and apple,sram-image-crc32. No apple,rtkit-handoff and no live buffers.
  • OS entry: the arm: apple: stop the T8140 MTP with an RTKit sleep at OS entry #37 stop (RTKit sleep, run bit cleared). Then every word of the MTP's power chain in the always-on PMGR is set fully on with automatic power management off (apple,aon-pmgr, apple,aon-power-words, parents first). The MTP SRAM has two parents, the SCM fabric and the CPU. Last, the CPU is disabled and held in reset (apple,aon-cpu-word).

Without the property, or if the image can't be kept or passed on, the OS gets the running session as before. So a kernel without linux#1813 keeps its keyboard.

Tested

  • apple_m1_defconfig with CONFIG_APPLE_MTP_KEYB=y and CONFIG_WERROR=y: builds with no warnings.
  • test_apple_helper_handoff.py and test_apple_mtp_keyboard.py: 9 passed. The T8140 cases now check that a parked MTP passes its image on and adopts nothing, and that the stop parks it once, after the run bit is clear.
  • Not yet run on hardware. The J700 row (U-Boot keyboard, GRUB, then Linux starting the firmware fresh) needs the DT properties from linux#1813 in the Stage 2 DTB.

DjDeveloperr and others added 3 commits November 13, 2026 22:41
U-Boot starts the T8140 MTP for its own keyboard and used to hand the
running session to the OS. It reserved the firmware's DRAM buffers, left
the DART stream in bypass and set apple,rtkit-handoff = "mtp-live-v1".
Linux then had to adopt that session and could never restart it.

Stop it before the OS instead. The remove path now asks for an RTKit
sleep rather than QUIESCED, clears the run bit and releases the DART
bypass, and the OS device tree fixup publishes nothing for this helper.
A firmware stopped for a sleep starts again from its reset vector, so
the OS can reset the MTP's CPU and run it as its own.

U-Boot's keyboard and its INIT replay into the FIFO don't change. J713,
J614s and the other helpers keep their handoffs and the QUIESCED stop.
A failed stop is now logged.

A kernel without the matching rtkit-helper restart loses the internal
keyboard and trackpad, as the Kconfig help says.

Signed-off-by: Diljit Singh <[email protected]>
The T8140 MTP keeps its firmware in SRAM and a run changes the
firmware's data there, so the OS can't start a firmware U-Boot ran just
by resetting its CPU (INIT is never read). U-Boot has handed the running
session over instead.

When the boot loader before U-Boot sets /chosen/aurora,mtp-handoff =
"off", park it instead:

- before the first run, copy the whole firmware SRAM (reg "firmware")
  into memory U-Boot never gives back, and take its CRC-32;
- at OS entry, stop the firmware with an RTKit sleep and clear the run
  bit (as before), then put every word of the MTP's power chain in the
  always-on PMGR fully on with automatic power management off
  (apple,aon-pmgr, apple,aon-power-words), and disable the CPU and hold
  it in reset (apple,aon-cpu-word);
- the OS tree gets the image as no-map reserved memory, its address and
  size in apple,sram-image and its CRC in apple,sram-image-crc32, and
  no live session.

The OS writes the image back and starts the firmware as one nobody ran.
Without the property, or if the image couldn't be kept or passed on,
the OS gets the running session as before.

Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
Assisted-by: LLM
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Early note on this draft (no full review yet):

  1. arch/arm/mach-apple/rtkit_helper.c:114: parking is limited to one SoC compatible. The mechanism is driven by DT data (reg-names "firmware", apple,aon-pmgr, apple,aon-power-words, apple,aon-cpu-word), so key it on those properties being present. Then any helper that describes them gets the same behaviour without a SoC list.
  2. arch/arm/mach-apple/rtkit_helper.c:112: the feature only turns on through an opt-in configuration line (chosen.aurora,mtp-handoff=off), which is a manual step. Once linux#1813 has shipped, make parking the default. Keep the live handoff only as the fallback when the image can't be kept or the needed properties are missing.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Besides the two points in the earlier note, commits cfb83d5 and f82884b carry Co-Authored-By and Assisted-by trailers in the commit message; they need replacing with commits that carry only the author's Signed-off-by. This also still waits on aurora-silicon/linux#1813 (open, draft) and on #37, whose commit it carries, plus a J700 row with parking as the default.

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