Skip to content

drm/asahi: fix global upper-half TLBI fallback and enable T6050 range TLBI - #4284

Merged
RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
tully-8888:fix/asahi-global-tlbi-and-t6050-range
Dec 5, 2026
Merged

RyanTheTide merged 2 commits into
aurora-silicon:mainfrom
tully-8888:fix/asahi-global-tlbi-and-t6050-range

Conversation

@tully-8888

@tully-8888 tully-8888 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What: Prevent tlbi_pages() and tlbi_range_or_asid() from falling back to ASID-only TLBI ASIDE1OS on global upper-half kernel mappings, and enable ARMv8.4 range TLBI (page_tlbi = false) on T6050 M5 Pro (clean_tables remains true).

Tested: J714s MacBook Pro 14" M5 Pro (Mac17,9, T6050) at 3c14eebe3558, in the batched Boot #11 kernel 7.3.0-j714s-b11+ (main 9ece2d8202d2 plus 16 open PR heads unchanged, this one included, plus local J714s patches), 2026-12-04: boots, 0 failed units, 0 new kernel warnings against the previous boot. 3 full gpubench-vk records (82 results each) and gpubench-stress-vk 17 of 17 pass, 0 GPU or UAT fault, timeout or recovery lines. Same-kernel A/B of the range TLBI change (switched back to page TLBI, blocks off, on, on, off, core set): 23 of 23 rows overlap, no measurable difference. compute.light d=4 20.62 us (18.58-22.29) vs 20.64 (19.16-21.45); render.light triangle d=4 31.62 (31.07-32.06) vs 31.70 (31.46-32.09). The single-run Boot #7 to #8 deltas under Evidence are not reproduced.

Boot #11 row

Kernel: local branch j714s-boot11-test at e7ab6d7b65c2. Its last commit is a test-only patch with runtime switches that turn single PR changes off, for same-kernel A/B runs. In an A/B row the "off" arm is that switch, which emulates the old code; it is not the old tree.

Non-default command line: nvme_apple.flush_interval=0 cpuidle.governor=teo ane_t6021.irq_wait=0 ane_t6021.irq_wait_switch=1 ane_t6021.bridge_record=1 appledrm.ext_pq_as_hlg=1 kvm.halt_poll_ns_grow_start=100000 macsmc.m5_pcio_budget=2 macsmc.m5_n1_budget=3 arm64.nowfxt zswap.enabled=0 softlockup_panic=1.

  • The switch covers the page_tlbi commit only; the mem.rs fix is in both arms.
  • Run-to-run spread over 530 rows: 65 to 73 rows outside +-5 % between any two full records.
Earlier rows

J714s MacBook Pro 14" M5 Pro (Mac17,9, T6050), local kernel 7.3.0-j714s-b8+ carrying both commits patch-identical to 3c14eebe on another base; drivers/gpu/drm/asahi/mem.rs and drivers/gpu/drm/asahi/hw/t6050.rs are byte-identical to the head: boots cleanly and passes the full gpubench-vk suite (>100,000 submits across copy.bw, render.heavy/light, compute.heavy/light, idle.wake) with 0 GPU or UAT faults. All 441 Asahi host tests pass (g17- 382/382, g14-v27-2 34/34, g15- 18/18, g16- 2/2, t6050 4/4, hardware-defaults 1/1) and W=1 LLVM=1 adds 0 warnings.

Risk: two-way door · all Apple Silicon Macs using drm/asahi (global upper-half TLBI safety fix in mem.rs) and T6050 / M5 Pro Macs (page_tlbi = false; Max/Ultra and M4 Pro/Max stay unchanged).

Not yet: explicit 32 MiB+ kernel-upper mapping drop torture on hardware; a second-generation row for the shared mem.rs change. No performance claim: the A/B above shows no measurable difference.

Details
  1. drm/asahi: mem: do not use ASID-only TLBI for global upper mappings: upper-half GPU VAs (bit 63 set) carry global (nG == 0) leaves, which tlbi aside1os leaves cached. In tlbi_pages() above PAGE_TLBI_MAX_PAGES (2048 pages), upper-half ranges now call tlbi_all() (vmalle1os); in tlbi_range_or_asid() when va == 0 || len >= 32 MiB, upper-half ranges now use tlbi_range_ops() (rvae1os by VA, which matches global leaves regardless of ASID). Lower-half non-global user ranges keep tlbi_asid().
  2. drm/asahi: hw: t6050: enable range TLBI (page_tlbi = false): sets page_tlbi: false on t6050::CONFIG (M5 Pro) while keeping clean_tables: true inherited from CONFIG_ULTRA.uat_quirks.
Evidence
  • Branch: fix/asahi-global-tlbi-and-t6050-range, head 3c14eebe3558d on 9c9e5f035baa2
  • scripts/checkpatch.pl --strict --no-tree --git 9c9e5f035baa2..3c14eebe3558d: 0 errors, 0 warnings, 0 checks on both commits
  • make ARCH=arm64 LLVM=1 W=1 drivers/gpu/drm/asahi/: 0 new warnings
  • tools/asahi/run-host-tests.py: 441/441 passed (g17- 382, g14-v27-2 34, g15- 18, g16- 2, t6050 4, hardware-defaults 1)
  • Hardware verification on Mac17,9 / J714s (7.3.0-j714s-b8+, touched files byte-identical to the head): full gpubench-vk suite (>100,000 submits), 0 GPU/UAT faults

Diagnostics, not an A/B of this change: gpubench-vk on 7.3.0-j714s-b7+ vs 7.3.0-j714s-b8+. Boot #8 adds 15 commits to Boot #7: this PR's two, the commits of #4286 (clpc), #4283 (drm/apple) and #4282 (Centauri Wi-Fi), and one more Centauri commit. Each value is a single run with no spread, so these deltas are not a measure of this change.

  • render.light d=4: 28.30 -> 27.27 us
  • compute.light d=4: 19.92 -> 19.15 us
  • idle.wake: 651.22 -> 627.56 us

Kernel mappings live in the upper half of the GPU VA space, in the one
table that is not owned by a user VM, and its leaves are written global
(nG clear). tlbi aside1os only removes non-global entries, so it leaves
cached global translations of an unmapped kernel range behind.

tlbi_range_or_asid() falls back to an ASID flush for ranges of 32 MiB
or more, and tlbi_pages(), used in page TLBI mode, does the same above
2048 pages. A kernel mapping of that size that is unmapped through
either path keeps stale translations for its old pages.

For an upper-half range, never take the ASID fallback. In range mode,
issue as many tlbi rvae1os operations as the range needs: a by-VA
operation matches global entries whatever the ASID, and even the whole
64 GiB kernel window takes two operations. In page mode, which avoids
range operations, use tlbi vmalle1os. Lower-half ranges, whose leaves
are all non-global, keep the ASID fallback.

Signed-off-by: vlad <tulituvlad@gmail.com>
The M5 Pro inherited page_tlbi from the M5 Ultra policy. With it, every
unmap of up to 2048 pages issues one tlbi vae1os per 16 KiB page, and
any larger one flushes the whole ASID. The CPU is ARMv8.4, and the
PublishedRoots path already encodes tlbi rvae1os operations for 16 KiB
granules, so a range below 32 MiB takes one instruction. Larger user
ranges flush the ASID, and larger kernel ranges, whose leaves are
global, take range operations as well.

Clear page_tlbi for the M5 Pro only. clean_tables stays set: no M4 or
M5 SoC has run without it (T6040 and T6041 set it, and the T8142 entry
stops at the identity check before the UAT is touched), so there is no
proof yet that the walker snoops the CPU caches.

Signed-off-by: vlad <tulituvlad@gmail.com>
@tully-8888
tully-8888 requested review from a team and DjDeveloperr as code owners December 4, 2026 07:50
@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) blast:all 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 Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Merge readiness at 3c14eebe: not ready yet

Check Detail
CI at head ok 4 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes ok none
Hardware row at head ok in the PR body at 3c14eebe
Conflicts ok none
PR text ok Risk: two-way · all Apple Silicon Macs using drm/asahi (global upper-half TLBI safety fix in mem.rs) and T6050 / M5 Pro Macs (pagetlbi = false; Max/Ultra and M4 Pro/Max stay unchanged).

Areas: area:gpu

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

@tully-8888

Copy link
Copy Markdown
Contributor Author

Hardware row: T6050 / J714s MacBook Pro 14" M5 Pro (Mac17,9), local candidate 7.3.0-j714s-b10+ (0efead389e67). It is not a merge of this PR, but drivers/gpu/drm/asahi/mem.rs and drivers/gpu/drm/asahi/hw/t6050.rs are byte-identical to 3c14eebe. Default cmdline, no extra parameters.

  • Boots, GPU probes and runs the Hyprland desktop on eDP-1 3024x1964@120 and HDMI-A-1 3840x2160@144 for 50+ minutes.
  • Chrome VA-API AV1 paused-seek run, 3 of 3: 60 frames each, 0 stale, 0 invalid.
  • 0 failed systemd units. 0 WARNING/BUG/Oops in the kernel log. 0 GPU fault, UAT or timeout lines (the only GPU driver lines with "failed" are the probe-time EPROBE_DEFER retries before the GPU came up).

This is a regression row only. The gpubench numbers in the description are from Boot #7 vs Boot #8, which differ by 15 commits, so I am not using them as a measure of this change.

Evidence
$ uname -r
7.3.0-j714s-b10+
$ systemctl --failed --no-legend | wc -l
0
$ journalctl -k -b 0 | grep -ciE "WARNING:|BUG:|Oops"
0
$ journalctl -k -b 0 | grep 2300000000.gpu | grep -iE "fault|error|timeout|fail"
aurora 2300000000.gpu: M5 bare-metal bootstrap failed at session: EPROBE_DEFER   (x6, at probe, 14:38:26)

@AlexVittorioCastellano

Copy link
Copy Markdown
Contributor

Hardware row: T6050 / J716s (MacBook Pro 16-inch, M5 Pro), pass

  • Kernel: the linux-aurora 7.3.0.aurora1-53 recipe from alarm-aurora main (linux main 1675a623), with this PR's two commits 174fed54 and 3c14eebe applied as patches. drivers/gpu/drm/asahi/mem.rs and hw/t6050.rs in the build tree are byte-identical to this head. macOS 27.2 (26B123) stub, aura 1.0.0b19, mesa-aurora 26.3.0_devel (d1c183b2c39), KDE Plasma on Wayland, internal 3456x2234 panel.
  • Boot: 18 CPUs, ctxr-execmem: reserved exec window, aurora (drm/asahi) bound, renderer Apple M5 Pro (G17S B1), 0 failed units. The Stage 2 trial for this kernel committed.
  • glmark2-wayland --fullscreen, one run each:
    • Before: the packaged 7.3.0.aurora1-51 kernel, score 4686.
    • After: 53 + this PR, score 4713.
    • Per-scene results are within ±1.5% except [function] fragment-complexity=medium (5976 → 6676 fps) and [loop] fragment-loop=false (5985 → 6108). With one run each those two are likely noise.
  • Faults: no watchdog gave up, render timeout, GPU work of a client failed or MMU/TLB fault in the kernel log on this boot, during the run or after it.

Note: the before kernel is the older packaged pin (51), not 53 without this PR, so the score comparison spans more than these two commits.

@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 3c14eebe3558d72d99f063f5b984779f4f94f4c7

Blockers: None.

Checked: The UAT kernel window has bit 63 set. Above the page-by-page threshold it takes a full flush, and large ranges on the range-capable path retain address-based invalidation. The user window keeps the ASID fallback. The T6050 config changes only the range-invalidation setting and still cleans page-table writes.

Evidence

Executed the exact Rust routing helpers with the instruction invocations recorded on the host. All 13 address, zero-length and threshold cases passed. The ARM instruction definitions confirm that range invalidation covers global entries matching the address. No DT files change. The author reports 441 host tests and a J714s run from a different base with both changed files byte-identical. Exact-head fork CI still requires workflow approval.

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

ORCH5 merge sweep: passes the six-point gate (CI green at 3c14eeb, independent review approval by aurora-silicon-review[bot], no taint, no Stage 1/LocalPolicy change).

@RyanTheTide
RyanTheTide merged commit 2cca873 into aurora-silicon:main Dec 5, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) blast:all 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)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants