Repository navigation
drm/asahi: g16: batch the render root stream reads and read them once - #4033
Conversation
The VDM stream gate reads one root word per render command. Reading through a 256-byte window does extra cache maintenance and can require a separate completion barrier for each pass. Translate the root words in batches of up to 64. Clean only their cache lines, deduplicate shared lines, and complete the maintenance with one barrier per chunk. Use a scope guard so a failed later walk also completes earlier maintenance before the VM reservation is released. Words that cross page boundaries use the single-read helper. Both read paths snapshot userspace-writable mappings through a C READ_ONCE helper. It copies aligned words and byte edges without requiring exclusive access to the source page. Exercise same-line deduplication, page and cache-line boundaries, read sizes, and mixed valid and failing roots in the host stream test. Signed-off-by: DjDeveloperr <hey@djdev.me>
The CDM and VDM stream gates check the leaf permissions and then walk the same leaf again for its physical address under one VM reservation. Derive the frame from the checked entry with the translation helper. Validate each new batch page as System RAM before recording its physical address. The reservation pins that backing through both the maintenance and copy passes. Reuse that validation while keeping alias handling, the barrier on errors and the split-page fallback intact. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
RyanTheTide
left a comment
There was a problem hiding this comment.
Reviewed 0fe0c64. The batched root checks retain readable-mapping and RAM verification under the VM lock, and complete any cache maintenance before copying or returning an error. The single-read path retains the existing byte order and handles unaligned sources. Hardware rows are pending.
|
J516s (M3 Pro) g16batch row: FAIL (judge exit 1). Except for one CPU-time flag that looks like noise, every failure also happens on base. For this PR: the gate refused all 6 bad addresses with no GPU recovery. CTS Kernel Same on both arms:
Why the judge says FAIL:
The J516s is back on its stock kernel ( |
|
J516s |
|
The J516s run refused all six bad roots and matched draw and command-buffer CTS. The remaining row at |
J773g (Mac mini M4, T8132, G16G B0)
|
|
J773g ABBA passed the stream-gate checks, and the J516s control on the same heads had zero CTS differences or new failures. On main 9c9e5f0 the ARM64 W=1 build linked aurora.o (45 warnings, zero errors), and both scoped host suites and checkpatch passed. |
What: Make the g16 check of each render's root stream cheaper: batch the 4-byte root reads with one cache barrier, and walk and check each page once. The reads of GPU-visible memory also become single
READ_ONCEloads instead of a plain copy of memory userspace can write at the same time.Tested: No hardware run at the head of this PR; an earlier combined run is in Evidence. Local checks at
0fe0c64f5da5: arm64 W=1 build ofdrivers/gpu/drm/asahi(clang) with the same warnings as main,run-host-tests.py --only asahi-m41/1 and--only g162/2, checkpatch --strict clean.Risk: two-way · M4 (T8132) and M3 (T8122, T6030) for the batched read.
read_user()(the READ_ONCE copy and the single walk) is shared by the g16 and G15 stream checks.Not yet: J773g and J516s at the head of this PR: the stream-gate negative tests, VK-CTS command buffer and draw groups, and a base/head ABBA on multi-pass renders (
render.postfx,render.mdi,render.lightd16 and d64), with submit CPU time. No performance gain is claimed until that ABBA is in.Details
The gate reads one root word for each render pass. It read through a 256-byte window, which cleaned more cache lines than it needed and could take a barrier per pass.
read_user_u32_batch()translates up to 64 root words, cleans each distinct cache line once, completes the maintenance with one barrier and then reads the words. A guard issues the barrier on error paths too, while the VM reservation is still held. Words that cross a page go through the existing single read.Both read paths checked the leaf permissions and then walked the same leaf again for its address. They now take the address from the checked entry. A batch checks that a new page is System RAM when it first sees it, and the VM reservation pins that page for the maintenance and the copy.
Evidence
Host tests cover same-line deduplication, page and cache-line boundaries, read sizes, mixed valid and failing roots, aliased VAs and a separately protected alias. In the six-root, two-page fixture the checked RAM page borrows fall from 11 to 2, and the PTE walks from 4 to 2.
Hardware, supporting only: the J773g ran these commits as part of the 16-commit tree
53599499071a(module on kernel6c83a2a64539, 12-02). The 36-row gpubench check finished with every CRC valid. It is not an A/B of this change.Checks ran on main
d1ae4f292b93plus this branch.