Repository navigation
drm/asahi: mmu: cache dcache line size and stream scatterlist page-table maps - #3032
Merged
DjDeveloperr merged 1 commit intoNov 24, 2026
Merged
Conversation
…ble maps Mapping a multi-segment shmem GEM BO through VmInner::sm_step_map() or VmInner::map_node_prepared() previously invoked UatPageTable::map_pages() once per scatterlist segment. On SoCs with UatQuirks::clean_tables (such as T6041/G17P), every individual 16 KiB segment performed a full L0->L1->L2 walk, an FFI call to read_sanitised_ftr_reg(SYS_CTR_EL0), redundant dc cvac maintenance on the same 64-byte leaf-table cache lines, and a system-wide dsb sy barrier. Cache the sanitized DminLine cache-line stride in an AtomicUsize, add UatPageTable::map_segments() (backed by a streaming SegmentCursor with KUnit coverage) to fill all scatterlist segments in a single walk with one PoC clean per leaf-table slice and a single final dsb sy barrier, and switch sm_step_map() and map_node_prepared() to use it. Signed-off-by: AxxzyWasTaken <[email protected]>
DjDeveloperr
approved these changes
Nov 24, 2026
DjDeveloperr
left a comment
Contributor
There was a problem hiding this comment.
Formal §1–§6 pre-PR review at verified head 5bf9b71aee899207c72c1fa274fbef91cbf1bfe4.
- Code & correctness:
DCACHE_LINE_SIZE: AtomicUsizelazily caches arm64 sanitizedCTR_EL0.DminLine(FTR_STRICT | FTR_LOWER_SAFE, always>= 4, idempotentRelaxedload/store).UatPageTable::map_segments()+SegmentCursorstream(PhysicalAddr, usize)scatterlist segments through a singleself.walk()(one PoC clean per leaf slice + one finaldsb sy), preserving alignment checks,EBUSYcollision refusal,one_pagerepeat, androllback_failed_map()insm_step_map(). Bonus safety improvement: explicitly returnsEINVALon truncated scatterlists instead of silently returningOk(())withleft > 0.- KUnit suite
asahi_pgtable_segmentscovers multi-segment offset/zero-len streaming,one_pagerepeat, and unaligned/short rejection.
- §1–§4 / §6: Uniform across all Asahi UAT users (no chip gates, no hacks), human author/committer + human
Signed-off-by:only (0 AI trailers),host-testsSUCCESS(MERGEABLE/CLEAN). - §5: Exact-head
J616CA/B (1.63x16 MiBVM_BIND,3.56xmem.buffer alloc_us), CRC valid, 0 faults/errors/failed units. (Note for merge train: touches sharedmmu.rs/pgtable.rs, so pair with a second-Mac regression row per merge policy if needed.)
Approved.
Assisted-by: LLM (Gemini 4 Neon)
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Contributor
|
Thank you for the contribution, @AxxzyWasTaken! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What: Cache dcache line size and stream scatterlist page-table maps in the Asahi MMU.
Tested: J616C M4 Max (T6041, G17P B1) at 5bf9b71: 16 MiB fresh-BO VM_BIND 678.5 -> 416.6 us (1.63x), gpubench mem.buffer alloc_us 3.71 -> 1.04 us (3.56x), 0 MMU/GPU faults, 0 failed units, host-tests green.
Risk: two-way · all Apple Silicon Macs using drm/asahi MMU.
Not yet: None (approved and CI green).
Original details and measurements
Cache the arm64 sanitized
CTR_EL0.DminLinedata-cache line stride and stream multi-segment scatterlist page-table mappings through a single UAT page-table walk instead of callingUatPageTable::map_pages()once per scatterlist segment.Cause
Mapping a multi-segment shmem GEM BO through
VmInner::sm_step_map()orVmInner::map_node_prepared()previously calledUatPageTable::map_pages()once per scatterlist segment. On SoCs withUatQuirks::clean_tables(such as T6041/G17P), every individual 16 KiB segment performed:L0 -> L1 -> L2page-table walk,read_sanitised_ftr_reg(SYS_CTR_EL0)insideclean_poc(),dc cvacmaintenance across the same 64-byte leaf-table cache lines, anddsb sy(poc_barrier()).Fix
CTR_EL0.DminLinestride lazily inDCACHE_LINE_SIZE: AtomicUsize(drivers/gpu/drm/asahi/pgtable.rs). On arm64CTR_EL0.DminLineisFTR_STRICT+FTR_LOWER_SAFE, so it is invariant once SMP boot completes.UatPageTable::map_segments()backed bySegmentCursor(drivers/gpu/drm/asahi/pgtable.rs) to stream(PhysicalAddr, usize)scatterlist segments (with initialoffsetandone_pagerepeat support) through a singleself.walk(), emitting at most one point-of-coherency clean per leaf-table slice and a single finaldsb sybarrier.VmInner::sm_step_map()andVmInner::map_node_prepared()(drivers/gpu/drm/asahi/mmu.rs) to callmap_segments(), preserving full alignment checks, collision refusal (EBUSY), and failure rollback semantics (and explicitly rejecting truncated scatterlists withEINVAL).asahi_pgtable_segmentscovering multi-segment streaming withoffsetand zero-length entries,one_pagerepeat, and unaligned / truncated input rejection.Hardware Results (Exact-Head Live M4 Max A/B)
J616C,T6041/G17P B1, 32-core GPU, FW25G83), AC power, Mesaa4f0da8300(Borealis).integration/aurora70a00e583b03(7.3.0-j616c-ia35+, baselineaurora.koSHA-256934255e5...) vs exact PR head5bf9b71aee899207c72c1fa274fbef91cbf1bfe4(aurora.koSHA-256c90c5327..., unmodified70a00e583b03DTB, default cmdline +panic=10trial guard).gpubench-vk --test mem.buffermedian over 5 runs):70a00e583b03)5bf9b71aee89)alloc + VM_BIND(16 MiB, med of 3×8)678.5 us(24.7 GB/s)416.6 us(40.3 GB/s)1.63xalloc + VM_BIND(64 MiB, med of 3×8)1477.6 us(45.4 GB/s)1485.6 us(45.2 GB/s) (mean1511 -> 1460 us)1.03xmeanalloc + VM_BIND(128 MiB, med of 3×8)3377.6 us(39.7 GB/s)2679.0 us(50.1 GB/s)1.26xgpubench-vk mem.bufferalloc_us(d=1)3.709 us1.042 us3.56xgpubench-vk mem.buffermap_us(d=1)0.667 us0.559 us1.19xgpubench-vk mem.bufferfree_us(d=1)0.083 us0.042 us1.98xgpubench-vk compute.blur_fp32(taps=9, 1080p, d=4)valid: true,status: ok.0GPU/MMU/UAT faults or recoveries,0 SELinux denials (N/A — Arch Linux ARM),0 failed systemd units,0 new kernel errors(only pre-existingbrcmf_pcie_setupboot retry,nvmeudev kyber rule,bluetoothdBAP, anddbus-brokerduplicate FileManager1).Build & Host Testing
integration/aurora70a00e583b03python3 -I tools/asahi/run-host-tests.py --only g17 --jobs 4: 90/90 passedpython3 -I tools/asahi/run-host-tests.py --only asahi --jobs 4: 3/3 passed (includesasahi-m4,asahi-g15,asahi-stats-raw-tests)make ARCH=arm64 LLVM=1 drivers/gpu/drm/asahi/aurora.o(regular andCONFIG_KUNIT=yonia33.config, compilingasahi_pgtable_segmentsKUnit tests): compiles cleanly with 0 new warningsscripts/checkpatch.pl --strictN/A).