Skip to content

soc: apple: start and stop the T8140 MTP without a live handoff - #1764

Open
RyanTheTide wants to merge 3 commits into
mainfrom
djcarry/t8140-mtp-restart
Open

RyanTheTide wants to merge 3 commits into
mainfrom
djcarry/t8140-mtp-restart

Conversation

@RyanTheTide

ghost commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Carries two of Diljit Singh's T8140 commits unchanged (author, date and message kept). They let Linux start the Neo's MTP itself and stop it again, for a U-Boot that stops the MTP with an RTKit sleep before the OS instead of handing over a running session (aurora-silicon/u-boot#37).

  • soc: apple: t8140-sleep: reset the MTP's CPU in place adds apple_sleep_aon_cpu_reset(). The original targeted t8140-sleep.c, so the function now sits in drivers/soc/apple/sleep.c and reads the shared apple_sleep state. Nothing else changed.
  • soc: apple: rtkit-helper: start and stop the T8140 MTP itself: for apple,t8140-mtp without a live handoff, the helper resets the CPU before the run bit and stops the MTP with an RTKit sleep on remove. It frees the DMA buffers the firmware dropped and refuses hibernation. Hunks were rebased onto the current helper (inventory handoff, PM notifier). The diff matches the original.

A session handed over as mtp-live-v1 is still adopted, as current U-Boot does, so production Neos take the same path as before. Other SoCs' helpers are unchanged.

Testing

  • Builds on integration/aurora 7945f4b (fleet recipe).
  • Neo (J700) on the shipping chain: results below.

Authored by Diljit Singh (@DjDeveloperr).

A third commit, soc: apple: describe an always-on coprocessor CPU in the device tree, replaces the T8140 address table and the apple,t8140-mtp check with device tree properties on the MTP node (apple,aon-pmgr, apple,aon-power-words, apple,aon-cpu-word, apple,aon-sram-word) and their binding, so a helper is restartable when its node has apple,aon-cpu-word; it builds with -fsyntax-only -Werror, the binding passes dt-doc-validate and t8140-j700.dtb compiles with no new dtc warnings.

Diljit Singh and others added 3 commits November 13, 2026 16:52
The MTP's CPU and the SRAM its firmware runs from sit on the always-on
die, and the device tree describes neither. In the ADT's PMGR devices
table they are MTP_CPU (+0xc028) and MTP_SRAM (+0xc048). MTP_SRAM has
MTP_CPU as a parent, so the CPU's power state has to stay as it is.

An RTKit firmware that stopped for a sleep starts again only from its
reset vector, and the run bit alone doesn't reset the CPU. Add
apple_sleep_aon_cpu_reset() for rtkit-helper. It sets DEV_DISABLE,
waits for BUSY to clear, pulses RESET and then clears both, as the PMGR
driver's device reset does, and logs the words. It refuses unless both
words target on, since the PMGR's own idling can lower the actual
states.

Signed-off-by: Diljit Singh <[email protected]>
U-Boot no longer hands the T8140 MTP over running. It stops the
firmware with an RTKit sleep before the OS and publishes nothing, and a
firmware stopped that way starts again only from its reset vector.

For apple,t8140-mtp without a live handoff:
- reset the CPU with apple_sleep_aon_cpu_reset() before the run bit and
  RTKit's wake. An image iBoot loaded and nobody started boots cold
  after the reset too. With no reset available it starts as before,
  which only brings up a never-started image.
- stop it on remove with an RTKit sleep instead of QUIESCED, so a module
  reload can start it again. One that doesn't answer is left running.
- free the DMA buffers given to the firmware when RTKit drops them after
  an answered sleep. Other helpers still keep theirs.
- refuse hibernation, as for an adopted session, since the image can't
  recreate the firmware's DMA.

The AP idle and AP on notices around a sleep don't change. A session
from an older U-Boot (apple,rtkit-handoff) is still adopted, and other
SoCs' helpers don't change.

Signed-off-by: Diljit Singh <[email protected]>
Whether a helper can be restarted, and where the reset words of its CPU
and firmware SRAM are, was decided by the apple,t8140-mtp compatible and
a table keyed by the ASC's physical address. Another SoC with the same
arrangement would need a new compatible check and a new table row.

Describe it on the coprocessor node instead: apple,aon-pmgr points at
the always-on PMGR, apple,aon-cpu-word and apple,aon-sram-word give the
words of the CPU and of the SRAM holding its firmware, and
apple,aon-power-words lists the whole power chain, parents first.
apple_sleep_aon_cpu_reset() reads the words through the PMGR's syscon
regmap, and a helper is restartable when its node has
apple,aon-cpu-word. The reset sequence itself is unchanged.

The T8140 MTP node gets the words the table had (MTP_CPU +0xc028,
MTP_SRAM +0xc048) and its power chain, and pmgr_mini grows to 0x10000 to
cover them. Nodes without the properties keep the quiesce path.

Signed-off-by: Ryan <[email protected]>

ghost commented Nov 21, 2026

Copy link
Copy Markdown
Author

Blockers: 3.

  1. The stated goal isn't shown to work, and the stacked follow-up says it doesn't. soc: apple: rtkit-helper: start a parked T8140 MTP from its pristine image #1813, built on this PR, reports that after this in-place reset a firmware that has already run starts with dirty SRAM data and never answers INIT (endpoint discovery failed: -62). The U-Boot case this PR is for (arm: apple: stop the T8140 MTP with an RTKit sleep at OS entry u-boot#37, still open) leaves exactly such a firmware. The body says "results below", but no J700 result follows. Show a J700 row where a sleep-stopped MTP restarts and survives a module reload, or fold this into soc: apple: rtkit-helper: start a parked T8140 MTP from its pristine image #1813.
  2. drivers/soc/apple/sleep.c:1421-1466 reimplements the PMGR device reset (DEV_DISABLE, wait for BUSY, RESET, clear) through four new bespoke properties, while pmgr_mini already has pwrstate children with #reset-cells (t8140-pmgr.dtsi:549, :1293). Describe MTP_CPU (+0xc028) and MTP_SRAM (+0xc048) as pwrstate nodes under pmgr_mini, give the MTP node resets = <&ps_mtp_cpu> and power-domains, and call reset_control_reset(). That removes the apple,aon-* binding, the MFD_SYSCON select and the dependency on the sleep driver. Restartability can then key off resets being present.
  3. sleep.c:1428 if (!apple_sleep) return -ENODEV;: the function never uses apple_sleep, but this makes the reset depend on whether the sleep driver probed first (and with CONFIG_APPLE_SOC_SLEEP=n the stub always returns -ENODEV). rtkit-helper.c:274-277 then only warns and starts the firmware anyway, which by the PR's own reasoning won't come back. On a restartable helper whose CPU had run, a failed reset should fail or defer the probe rather than start an unanswering firmware.
  4. apple,aon-power-words is in the binding (apple,rtk-helper-asc4.yaml:128) and the DT (t8140.dtsi:1158), but no code reads it. Drop it, or use it if the power chain really needs pinning, as soc: apple: rtkit-helper: start a parked T8140 MTP from its pristine image #1813 says it does.
  5. The branch conflicts with integration/aurora and no CI has run on it. Rebase, then get CI.

HW row: J700 on the rebased head with u-boot#37: cold boot, MTP keyboard/trackpad input, modprobe -r/reload of the helper with input back, an s2idle cycle, and a production-U-Boot (mtp-live-v1) boot showing the adopt path unchanged; 0 AVC, 0 failed units, no new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

ghost commented Nov 22, 2026

Copy link
Copy Markdown
Author

Closing: the in-place MTP restart was not shown to work on the Neo, and production boots keep the live handoff; it can come back with the U-Boot change and a restart row.

@ghost ghost closed this Nov 22, 2026
@ghost ghost reopened this Nov 22, 2026

ghost commented Nov 22, 2026

Copy link
Copy Markdown
Author

Reopened and kept as a draft; the comment above lists what it still needs before review.

ghost commented Nov 23, 2026

Copy link
Copy Markdown
Author

FYI from KUnit coverage work: #2941 adds an apple-rtkit-helper suite (setup/placement, inherited list, sleep state machine). It asserts nothing about shmem_destroy, because this PR makes that free conditional on free_buffers (a quiesced firmware may still write its log). A case for it is ready once this lands: with free_buffers set, a DMA buffer from setup is freed on destroy; without it, or for a mapped buffer, it is kept. Say if you'd like it added here instead.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Assignees

Couldn't load assignees.