Skip to content

arm: apple: ignore non-RAM apple,dma-range for bypass RTKit helper allocations - #79

Merged
RyanTheTide merged 1 commit into
aurora-wipfrom
satchlj/rtkit-helper-dma-range-ram-overlap
Dec 1, 2026
Merged

RyanTheTide merged 1 commit into
aurora-wipfrom
satchlj/rtkit-helper-dma-range-ram-overlap

Conversation

@satchlj

@satchlj satchlj commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

rtkit_helper_read_dma_window() treats the helper DART's apple,dma-range as a physical DRAM ceiling for bypass-mode allocations (lmb_alloc_mem(LMB_MEM_ALLOC_MAX, ...)).

Since aurora-silicon/aura#519 (507cd792) removed the M3 allowlist from dt_set_mtp_dma_window(), Aura now writes /arm-io/dart-mtp's 32-bit translated IOVA window [0x4000, 0xffff4000) onto T8112's iommu@24e808000. Physical RAM on T8112 starts at 0x8_0000_0000, so rtkit_helper_alloc() always returns NULL, rtkit_helper_probe() aborts after starting the MTP ASC (burning the one-shot macOS 27.2 MTP epoch), apple,rtkit-handoff is never published, and Linux fails to wake MTP with -62 (-ETIME).

Only clamp bypass physical allocations to apple,dma-range when the range overlaps [gd->ram_base, gd->ram_top), preserving the existing clamping on T8122/T8132/T8140 while falling back to normal DRAM allocation when apple,dma-range is a translated IOVA window disjoint from RAM.

Tested:

  • At 944606df3f4 on MacBook Air M2 (J413): PASS — booted on MacBook Air M2 (J413 / T8112, macOS 27.2 stub 26B123) paired with Aura main (76d2f9ae) and Linux main (a40c5131071d1): apple,dma-range present on iommu@24e808000, apple,rtkit-handoff = "mtp-live-v1", rtkit-helper 24e400000.mtp: adopted the running RTKit session (4 retained buffers), built-in keyboard, trackpad, Force Click, and haptics working before and after GPU-bound s2idle with 0 MTP/DART errors.
  • Host unit tests in test/py/tests/test_apple_helper_handoff.py (all 7 tests including new test_dma_window_requires_dram_overlap) pass.
  • Cross-built both apple_m1_defconfig and apple_j873_defconfig with CONFIG_WERROR=y.

Risk: two-way · Low. Scoped to rtkit_helper_read_dma_window(); SoCs whose apple,dma-range overlaps DRAM (T8122/T8132/T8140/T6041) retain identical allocation bounds.

…locations

rtkit_helper_read_dma_window() reads apple,dma-range from the helper's DART node and rtkit_helper_alloc() uses it as a physical LMB allocation ceiling because U-Boot runs the DART in bypass mode.

That works when apple,dma-range overlaps physical RAM (e.g. T8122/T8140 where DRAM starts at 0x10000000000 and the window covers the low 4 GiB), but fails on T8112 (M2 / J413) once Aura propagates /arm-io/dart-mtp's 32-bit translated IOVA window [0x4000, 0xffff4000) into apple,dma-range: DRAM on T8112 starts at 0x800000000, so lmb_alloc_mem() below 0xffff4000 always returns NULL. On macOS 27.2 firmware, rtkit_helper_probe() then aborts after setting REG_CPU_CTRL_RUN, burning the one-shot MTP epoch and leaving Linux without keyboard or trackpad (-ETIME).

Only constrain physical bypass allocations to apple,dma-range when the window overlaps [gd->ram_base, gd->ram_top), falling back to normal DRAM allocation otherwise. Add a host unit test covering T8112, T8122/T8140, above-RAM, and overflow ranges.

Signed-off-by: Satya Benson <[email protected]>
@github-actions github-actions Bot added blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Merge readiness at 944606df: ready to merge

Check Detail
CI at head ok 2 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 944606df
Conflicts ok none
PR text ok Risk: two-way · Low. Scoped to rtkithelperreaddmawindow(); SoCs whose apple,dma-range overlaps DRAM (T8122/T8132/T8140/T6041) retain identical allocation bounds.

Areas: none matched in CODEOWNERS
Merge: gh pr merge 79 --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.

@satchlj

satchlj commented Nov 29, 2026

Copy link
Copy Markdown
Member Author

Second-machine row at 944606df3f4b on MacBook Air M3 13" (J613 / T8122), where apple,dma-range overlaps RAM: PASS, with the clamp exercised.

Chain: Stage 1 1.0.0b5-hsusb2 (unchanged). Stage 2 is Aura main 1.0.0b17-gc0af820e (RELEASE=1 CHAINLOADING=1 ESP_STAGE2=1 USE_CLANG=1, includes aura#519) plus U-Boot 2026.07-g944606df3f4b (apple_m1_defconfig). The device trees and m1n1.conf are byte-identical to the previous stage2. Linux 7.3.0-1-43-ARCH, macOS 26.6.2 OS firmware.

Previous stage2 (Aura c13j1, U-Boot 250385f8) This PR
apple,dma-range on iommu@2fa808000 absent <0x100 0x00004000 0x0 0xffff0000>, overlapping RAM (base 0x100_0000_0000)
MTP helper buffers (mtp-rtkit reserved-memory) 0x103_da3e_8000, 0x103_da3f_0000, 0x103_da3f_8000: outside any window 0x100_fffe_4000, 0x100_fffe_8000, 0x100_fffe_c000: inside the window, so the clamp applied
apple,rtkit-handoff mtp-live-v1 mtp-live-v1
Linux rtkit-helper 2fa400000.mtp: adopted the running RTKit session (4 retained buffers) same

Built-in keyboard, multi-touch, Force Click and haptics all come up. No MTP or DART errors in the kernel log. Not covered: s2idle/deep sleep with this stage2.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 944606df after the boot-path merge gate.

Checked: I ran the added host case against the PR source. It passes for disjoint, overlapping and overflowing windows. The overlap check preserves the clamped LMB path when the range intersects DRAM and leaves DART discovery in place. The exact J413 run adopted the live helper where the translated window lies below RAM. The exact J613 run exercises the retained clamp, with the same live handoff and working input.

Keep the guarded Stage 2 receipts and the boot-path approval with the merge. The J613 receipt covers boot and input, with suspend still outstanding.

@satchlj

satchlj commented Nov 29, 2026 •

Copy link
Copy Markdown
Member Author

Suspend row at this head on J613 (MacBook Air 13" M3, T8122): 20/20 s2idle cycles with 15 s RTC wakes, and the keyboard and trackpad worked afterwards.

Setup: Stage 2 Aura 1.0.0b17-gc0af820e + U-Boot 2026.07-g944606df3f4b (this PR's head), Stage 1 Aura 1.0.0b17-g36b6f2bd. Packaged linux-aurora 7.3.0.aurora2-1 (7.3.0-2-1-ARCH) on the default command line. Each cycle: a forced Wi-Fi scan, then rtcwake -m no -s 15 and systemd-suspend.service.

Results:

  • 20 PM: suspend entry (s2idle), 0 suspend aborts, and every cycle woke on the RTC by itself. Wi-Fi was back within 2.5–3.5 s after each wake.
  • After the 20th wake the keyboard and trackpad devices (Apple MTP keyboard, Apple MTP multi-touch) were still bound, with no MTP, DockChannel or HID errors in the kernel log over the run. Keys and a trackpad swipe were then checked by hand on the machine, and both responded.

Scope: s2idle never leaves Linux, so U-Boot is not on the suspend path. This row shows that the handoff from this Stage 2 leaves suspend/resume and the input devices working; Deep sleep, which does come back through the boot object, was covered earlier the same evening on this same Stage 2: 3/3 mem/deep cycles on a trial kernel (main + linux#3590, #3504, #2163 and #1490), each resuming through the boot object (see linux#3590 and #3504).

@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: MERGE at 944606df

Blockers: none.

Checked: apple,dma-range now bounds bypass allocations only when it overlaps [ram_base, ram_top). That leaves T8122, T8132, T8140 and T6041 with the same bounds, and stops T8112's 32-bit translated window, which lies below RAM, from failing every allocation. DART discovery is unchanged, and the overflow check still runs first. The decision comes from the DT and RAM layout, with no chip check. Rows are at this head on J413, where the live MTP handoff is adopted and input works before and after s2idle, and on J613, where the clamp is exercised and 20/20 s2idle cycles keep input. Build and host tests are green.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed needs-review No approving review from Core or Omarchy Mac yet (bot) labels Nov 30, 2026
@RyanTheTide
RyanTheTide merged commit 1ee10f7 into aurora-wip Dec 1, 2026
4 checks passed
@RyanTheTide
RyanTheTide deleted the satchlj/rtkit-helper-dma-range-ram-overlap branch December 1, 2026 06:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

blast:m3 Macs affected, from Merge risk (bot) blast:m4 Macs affected, from Merge risk (bot) blast:neo Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge 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.

3 participants