Repository navigation
drm/asahi: keep timestamp buffers out of the shared firmware range, charge binds to their client, and bound per-file window share - #2531
Conversation
df120a7 to
d92d363
Compare
|
No blockers. What I checked at d92d363. On G17 the only consumer of a bound timestamp buffer is drivers/gpu/drm/asahi/g17/completion.rs:50-66. It goes through Nit: file.rs:1593-1602 checks the 4096 cap only after HW row: the run lists the M5 Ultra only. The Assisted-by: LLM (Claude:Opus 5.5) |
d92d363 to
60e5bda
Compare
|
Thanks, Ryan. The nit is fixed in the second commit, now at 60e5bda: J775D on this head (stacked with #1973 and our other three open drm/asahi PRs on integration/aurora cc14570, 27.0 firmware, default command line; the kernel also carries a local fix for an appledrm boot oops, see #1973):
Rows we can't run: we only have the M5 Ultra, where every bind takes the host path. Could your lab, or a J616s or Neo owner, run this head with the timestamp window filled (bind timestamp buffers until binds land outside it)? The row we need is |
|
Re-review of 60e5bda: No blockers.
The first commit is unchanged since the last review; the second changes only in HW row: the new numbers are from the M5 Ultra, which takes only the host path, on an integration stack with other open PRs and a local appledrm fix. Still needed: J616s or Neo on this head with the 64 MiB window filled, Assisted-by: LLM (Claude:Opus 5.5) |
There was a problem hiding this comment.
Adversarial pre-PR checklist review (§1–§6) on 60e5bdaae4cec3e495996a83d412b5bf8e3ef61b: 0 code, policy, attribution, naming, or CI blockers; holding for §5 hardware proof rows on non-M5 G17 and G13.
Verified against surrounding source:
- §1 No model gating:
Buffer::HostvsBuffer::Firmware(window: true) is selected by whether the buffer fits in the timestamp window (firmware.uat.is_m5()was pre-existing), and the 4096-object cap lives in shareddrivers/gpu/drm/asahi/file.rsacross every GPU family. - §2 / §3 Code & safety verification:
bound_size()(drivers/gpu/drm/asahi/timestamp.rs:16-22) enforces non-empty,UAT_PGMSK-aligned, in-bounds ranges with overflow checks and KUnit coverage (asahi_timestamp_buffer).Buffer::host()(timestamp.rs:72-83) refusesis_vm_private()withEINVAL, maps viaTimestampVmap::new(&bo.gem)->owned_vmap::<0>()(which refuses external/user_memoryBOs atrust/kernel/drm/gem/shmem.rs:261and pins shmem pages viadrm_gem_shmem_vmap_locked), and wraps the buffer incleanup::Deferredsodma_resv_lock-taking drop runs off fence-producer paths. Verifieddrivers/gpu/drm/asahi/mmu/residency.rs:481, 519, 615only walk VM-private BOs (for_each_private_bo), so omittingKernelMappingPinonHostBuffercannot race with idle reclaim or purge.Buffer::timestamp_offset()(timestamp.rs:153-166) checksoffset + 8 <= buffer.size(ERANGE/EOVERFLOW) and returnsbuffer.start + offset;window_va()returnsNoneandfirmware_mapping()/timestamp_mapping()returnErr(EINVAL). Verifieddrivers/gpu/drm/asahi/g17/completion.rs:45-65, 160-188routeswindow_va == Noneexclusively towrite_timestamp().do_gem_bind_object()(drivers/gpu/drm/asahi/file.rs:1595-1609) reserves the XArray slot (1..=4096,GFP_KERNEL_ACCOUNT) beforemap_timestamp_buffer(), so binds past 4096 fail withEBUSYbefore creating any window alias or vmap; failed mapping releases the slot onReservationdrop;resv.fill(obj)?unlocks the XArray before dropping any rejectedStoreError. Verifiedrust/kernel/xarray.rs:321, 558:remove()on an unfilled reservation coercesXA_ZERO_ENTRYtoNULL(ENOENT), and any concurrent race fails cleanly withEBUSY. (cleanup::Deferred::newatcleanup.rs:93still usesGFP_KERNELfor the work item wrapper, which is pre-existing, small, and now bounded by the 4096/file cap — non-blocking.)
- §4 Clean-room & attribution: Both commits (
a9d3d1658565,60e5bdaae4ce) carry human author/committer + humanSigned-off-by(plusReported-by/Suggested-by) and zero AI trailers; PR body includesAssisted-by:. - §6 Naming: Clean.
- CI:
host-testspassed (sole workflow matchingdrivers/gpu/drm/asahi/**).
Holding for §5 hardware proof rows on 60e5bdaae4ce:
Your J775D (M5 Ultra) run covers the host-only path, cap enforcement, KUnit, and render CTS, though on a stacked branch with other open PRs + a local appledrm fix, and M5 Ultra does not exercise the 64 MiB timestamp-window spillover path. Still needed:
- Non-M5 G17 (J616s or Neo) on this head with the 64 MiB timestamp window filled so binds spill into
Buffer::Host:dEQP-VK.query_pool.*timestamp*and a GLGL_TIMESTAMPquery test unchanged before/after, out-of-window binds succeeding with monotonic timestamps, KUnit pass counts, 0 failed units, and 0 new kernel errors. - One G13 Mac (M1/M2) running the same timestamp tests unchanged (covering the shared 4096-cap path), with clean regression counts.
|
Thanks, dj. Here is the J775D row on this PR's own base: integration/aurora b21dcc6 plus this PR, and only what the board needs for a GPU, which is #1973 (the J775D GPU node). The baseline is the same kernel without this PR. 27.0 firmware, default command line, read-only root, one boot each.
The two CTS failures are the stage-stamp ordering cases ( On 27.2 firmware, on this branch's merge-base 61295c2, the cap, timestamp-buffer, CTS and GL rows came out the same, with and without this PR. Those kernels also need #1650 and two of our GPU-driver commits that aren't public yet, so the body lists them only as extra evidence, as it does the earlier stacked row. The spill path isn't exercised here. The M5 Ultra has no timestamp window, so all of its timestamp binds take the host-written path, which is what the rows above test. The body now has a "Why this shape" section, and its Testing section leads with this row. On RyanTheTide, could you run the two open rows: this head on your J616s or J700 with the timestamp window held full, and the same timestamp tests on your M1 Pro? We only have the M5 Ultra, which has no window. To hold the window: it is one 64 MiB range per device, so one process that keeps more than 64 MiB of timestamp binds open (for example five 16 MiB buffers bound with Assisted-by: LLM (Claude:Opus 5.5) |
|
Review notes (non-author):
|
Several ioctls size a kernel allocation straight from userspace: - SUBMIT copies cmdbuf_size bytes (a u32, so up to 4 GiB) into a KVec. Only G16 bounds it before the copy (4 MiB); every other GPU kept the trait default of usize::MAX. - SUBMIT allocates in_sync_count + out_sync_count sync items before any per-GPU check. - VM_BIND copies stride * num_binds bytes and then reserves num_binds prepared operations. Without a GPU batch limit (bind_batch_limit() returns None), both are up to u32::MAX. A request past the page allocator's largest order hits WARN_ON_ONCE_GFP() in __alloc_pages(). Any user with the render node can trigger it, and with panic_on_warn it takes the machine down. Short of that limit, a valid but large request still needs high-order contiguous pages: an order-3 allocation of the sync array failed on J616s under deqp-vk. For SUBMIT: - Copy the command stream and build the sync array in KVVec with GFP_KERNEL_ACCOUNT. kvmalloc() falls back to vmalloc() instead of failing on fragmented memory, and the memory is charged to the caller's memcg. The sync array keeps this type through every generation's submit() (G13/G14, G15, G16, G17, G18, M3, M5); the G17 job vectors are converted in aurora-silicon#2858. - kvmalloc() refuses, and warns about, more than INT_MAX bytes. The trait default for max_cmdbuf_size() is now INT_MAX, so a larger command stream fails with E2BIG. This rejects no stream any GPU could accept before. A sync array larger than INT_MAX bytes fails with E2BIG too. - G17 returns its own bound: the largest valid G17 stream, MAX_COMMANDS_PER_SUBMISSION * (1 + 5) * (size_of::<drm_asahi_cmd_header>() + u16::MAX) = 25,168,512 bytes, checked at build time to be at most INT_MAX. - G15 returns its 4 MiB MAX_CMDBUF, as G16 already does. Its parser refused a longer stream before, but only after the copy, with EINVAL. Such a stream now fails before the copy, with E2BIG. - G18, M3 and M5 use the shared default until their own largest stream is known. For VM_BIND, pass __GFP_NOWARN on the user-sized allocations, so a request that is too large fails with ENOMEM and no warning. Its sizes are not changed. The timestamp mapping limit is left to aurora-silicon#2531. Checked by reading the call paths (file.rs submit, parse_array, vm_bind, vm_bind_g17, mmu/bind.rs, and each generation's submit()). rustfmt is clean on the changed code. The kernel Rust code was not compiled here. What userspace can see: on G17, a stream over 25,168,512 bytes, which its parser cannot accept, now fails before the copy; on G15, a stream over 4 MiB fails with E2BIG before the copy instead of EINVAL after it; on G13, G14, G18, M3 and M5, only streams over 2 GiB fail early. The allocation path changes on every GPU, so deqp-vk or CTS runs on G13, G14 and G17 (J616s among them) are needed before this is merged.
There was a problem hiding this comment.
Formal §1–§6 re-review on 60e5bdaae4ce:
What passes
- G17
Buffer::Host& shared object-table cap (file.rs,g17/mod.rs,gem.rs,timestamp.rs): Code correctness, locking,is_vm_private()guard,TimestampVmaplifetime +cleanup::Deferreddrop, and reserving the XArray slot (1..=4096,GFP_KERNEL_ACCOUNT) beforemap_timestamp_buffer()are all sound. - §4 Attribution & §6 Naming: Clean — both commits (
a9d3d1658565,60e5bdaae4ce) carry human author/committer + humanSigned-off-by:only (zero AI commit trailers), and the PR body carriesAssisted-by:. - Clean-base J775D (M5 Ultra) row & live CI: The updated J775D A/B run on
integration/aurora b21dcc633b32 + #1973cleanly covers the M5 host-only path, cap enforcement, Vulkan/GL timestamps, and KUnit; livehost-testsCI is green on60e5bdaae4ce.
Blocking findings
- §1 Cross-generation shared timestamp window protection (per @RyanTheTide's open review note): The 64 MiB shared firmware timestamp window on G13/G14 (
IOVA_KERN_TIMESTAMP_RANGEindrivers/gpu/drm/asahi/gpu.rs:141,1698), G15 (drivers/gpu/drm/asahi/g15/timestamp.rs:27), and M3 (drivers/gpu/drm/asahi/m3/m3_runtime.rs) is still first-come with no per-file byte quota or per-buffer range cap. Even with the 4096-object cap, a single client can exhaust the 64 MiB window with a handful of large binds (e.g., 4 × 16 MiB). Please bound the bytes one file may hold in the firmware timestamp window so G13/G14/G15/M3 receive equivalent protection before merge, and trim the hold-scenario description from "Still to run" in the PR body until that lands. - KUnit coverage:
asahi_timestamp_buffercurrently testsbound_size()only. Please add KUnit coverage for the per-file cap (and window quota / host-buffer bounds where reachable from KUnit). - §5 Hardware proof rows still open: M5 Ultra (
uat.is_m5()) has no 64 MiB timestamp window, so the non-M5 G17 spillover path (J616sorNeospilling intoBuffer::Hostonce the window is full) and aG13(M1/M2) regression row covering the shared cap/quota path still need to be run on the updated head.
60e5bda to
13f0a8a
Compare
|
Thanks for the review, @DjDeveloperr and @RyanTheTide. This update rebases onto
Hardware rows still to run on Assisted-by: LLM (Claude:Opus 5.5, Gemini:Neon) |
|
Fresh own-base J775D (Mac Studio, M5 Ultra) A/B hardware row at live head
Assisted-by: LLM (Gemini:Neon) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: HOLD at 13f0a8aa2b26
Blockers:
drivers/gpu/drm/asahi/g14_v27_2.rs:1213(onmain,CONFIG_DRM_ASAHI_G14_V27_2isdefault y) —Backend::map_timestamp_bufferstill takes 2 arguments while this PR addswindow: booltogpu::Gpu::map_timestamp_buffer(drivers/gpu/drm/asahi/gpu.rs:504-509). Merging ontomainwill fail to compile the default config. Rebase ontomainand add_window: booltog14_v27_2.rs:1213.drivers/gpu/drm/asahi/timestamp.rs:71-76&drivers/gpu/drm/asahi/file.rs:1639-1643—Bounddrops_window: Option<WindowShare>synchronously on unbind/retirement, whereasBuffer::Firmware(Deferred<FirmwareBuffer>)only enqueues unmap ontoaurora-ts-cleanup(which takesdma_resv_lockand runs the UAT unmap + TLB flush asynchronously). Rapid bind/unbind cycles let one file credit back its 4 MiB quota while priorKernelMappingaliases still occupy the 64 MiB firmware timestamp window. Move_windowintoFirmwareBufferordered aftermapping: mmu::KernelMappingso the share is released only after the IOVA range is unmapped.- PR body (§4 attribution) — remove the AI-attribution footer from the PR body (and omit it from future comments).
- PR body & §5 hardware rows — add the required
**What:**,**Tested:**,**Risk:**, and**Not yet:**header lines (folding the J775D A/B row intoTested:once rebased), and add the two remaining hardware rows at the updated head: non-M5 G17 (J616sorNeo) spillover past the 4 MiB share / 64 MiB window ontoBuffer::Host, plus one firmware-window family (G13/G14,G15, orM3) proving normal timestamp queries unchanged and 1/16 per-fileENOSPCisolation with clean regression counts.
Checked: Code diff across all 16 files and interaction with main (drivers/gpu/drm/asahi/), all 3 commits, §1–§6 pre-PR checklist, CI (host-tests green), and J775D / KUnit evidence at 13f0a8aa2b26.
Evidence
- §1 No model gating: Pass.
Buffer::HostvsBuffer::Firmwareturns on window capacity/share (pre-existinguat.is_m5()), and both the per-bind ledger charge and the 1/16 window share live in sharedfile.rs+memacct.rsacross every GPU family. - §2 / §3 Code, lifetime, and safety:
- Commit 1 (
2e017801f7bd,Buffer::Host):bound_size()andhost_offset()bounds/overflow checks,is_vm_private()guard,TimestampVmaplifetime,cleanup::Deferreddrop off fence-producer paths, andg17/completion.rsrouting (window_va == None->write_timestamp) are sound. Verifiedg17/mod.rsinitializesshared.statebefore DRM registration sotimestamp_window_size()cannot raceNone -> Some. - Commit 2 (
5bdb6e744374, per-bind ledger charge):admit_bind()+reserve_limit(..., GFP_KERNEL_ACCOUNT)run before mapping;FirmwareBufferownsKernelMappingdirectly andfirmware_mapping()returns a borrow, so G13/G14 (fw/job.rs), G15 (g15/command.rs,g15/job.rs), M3 (m3/m3_submit.rs), G16/G18 (timestamp.rs), and G17 (g17/completion.rs) all retainArc<timestamp::Bound>through retirement. - Commit 3 (
13f0a8aa2b26, 1/16 window share):Client::take_window()uses lockless CAS (try_add_within) with no concurrent overshoot, andshare.filter(|_| buffer.window_bytes() > 0)returns the share immediately when G17 spills toBuffer::Host. Two blockers remain: missingg14_v27_2.rstrait update againstmain(205 commits ahead of PR basec91527272e90), andWindowSharedropping beforeDeferred<FirmwareBuffer>unmapsKernelMapping.
- Commit 1 (
- §4 Clean-room & attribution: All 3 commits (
2e017801f7bd,5bdb6e744374,13f0a8aa2b26) carry human author/committer (Jeff Queisser) and humanSigned-off-by:only, with zero AI trailers; PR title is clean. PR body still has an AI-attribution footer (blocker above). - §5 Evidence & PR structure:
- Clean-base J775D (M5 Ultra, 27.0 fw, aura
mainf13056d9, default cmdline) A/B at13f0a8aa2b26passes bind-charge accounting (+152B/bind,ENOMEMat limit,refused 0 -> 1), 256 × 256 MiB timestamp binds (+0 MiB), Borealis Vulkan timestamp CTS (421 Pass / 2 Fail / 54 NS;672 Pass), GL timer (30/30), render CTS (571 Pass), and 0 GPU errors. - KUnit (
kunit-vz,pr2531-r4k3) at13f0a8aa2b26: 80 suites, 395/397 pass, 0 fail, 2 skip (asahi_bound_object_charge2/2,asahi_timestamp_buffer2/2). - Still missing:
What:/Tested:/Risk:/Not yet:PR header lines, non-M5 G17 spillover row, and a G13/G14/G15/M3 window-share row.
- Clean-base J775D (M5 Ultra, 27.0 fw, aura
- §6 Naming: Pass (Borealis and aura used properly; no prohibited terms in title, body, commits, or diff).
- CI:
host-testspassed (COMPLETED/SUCCESS) on13f0a8aa2b26. - Non-blocking notes:
drivers/gpu/drm/asahi/cleanup.rs:96(Deferred::new) still allocatesItem<T>withGFP_KERNELrather thanGFP_KERNEL_ACCOUNT(pre-existing shared helper; commit 2's message impliesGFP_KERNEL_ACCOUNTfor buffer heap records).drivers/gpu/drm/asahi/file.rs:1633callstake_window()before rejectingdata.range == 0inmap_timestamp_buffer(); harmless since the error path drops the 0-byteWindowShare,Reservation, andCommit.
On M5, and on the other G17 GPUs once the 64 MiB timestamp window is full, GEM_BIND_OBJECT mapped a timestamp buffer into the kernel VM's dynamic range, the range every firmware object (queues, kick rings, render state) is allocated from. The driver never gives the firmware that address: outside the window the host writes every stamp through the buffer's CPU mapping. The mapping only held shared address space, as much as the bound range, for as long as the buffer stayed bound. Give such a buffer only its CPU mapping (timestamp::Buffer::Host), as G16 and G18 keep theirs without a firmware alias. It refuses the same ranges and VM-private objects the alias did. Buffers mapped in the window, and every other GPU family, are unchanged. Share the bound-range check with Buffer::cpu, and the VM-private test with gem::validate_vm_binding, and test the range check in a new asahi_timestamp_buffer KUnit suite. Reported-by: Erik Bourget <[email protected]> Suggested-by: Erik Bourget <[email protected]> Signed-off-by: Jeff Queisser <[email protected]>
…stay within its memory limit GEM_BIND_OBJECT stores a record in the file's object table for every bind, and the number of records per file was not limited. The record and the timestamp buffer it names are small kernel allocations that no GEM object accounts for, and they were not charged to the client. The buffer's pages and its CPU mapping belong to the object: the shmem helper shares one vmap between every mapping of an object, and the object's size is charged when it is created. Charge every bind the size of what it keeps (the table entry, the buffer record and the buffer's heap records) against the client's and the device's memory limits, through the Ledger::admit() that object creation uses, as a user object of that size would be. A bind past either limit fails with ENOMEM. The charge is held with the bound buffer and given back with its last reference: after the unbind, or when the file is closed, once no command still uses the buffer. To ensure no command can keep a firmware timestamp mapping alive after unbind without also keeping its Bound record (and charge) alive, store the KernelMapping directly in FirmwareBuffer, return a borrowed &mmu::KernelMapping from firmware_mapping() instead of cloning an Arc, and have G13/G14 (fw::job::UserTimestamp), G15 (g15::command/job) and M3 (m3::m3_submit::Destination) retain Arc<timestamp::Bound>, matching G16, G17 and G18. The bind charges and takes its table slot before it maps the buffer, so a refused bind gets no window alias or CPU mapping at all. The record, the buffer and the table's nodes are allocated with GFP_KERNEL_ACCOUNT, so they also count towards the memory cgroup of the task that binds. Also add a host_offset() KUnit case (a_host_stamp_lies_inside_the_bound_range) in asahi_timestamp_buffer alongside the new asahi_bound_object_charge suite. This applies to every GPU family and to every GEM_BIND_OBJECT usage: the table is shared code. Reported-by: Erik Bourget <[email protected]> Suggested-by: Erik Bourget <[email protected]> Suggested-by: Ryan Murray <[email protected]> Signed-off-by: Jeff Queisser <[email protected]>
…dow, so other clients' timestamp binds still fit Every family that aliases timestamp buffers for its firmware does so in one fixed range per device: IOVA_KERN_TIMESTAMP_RANGE on G13/G14, the timestamp arena on G15, TIMESTAMP_RANGE on M3 and the timestamp window on G17 (64 MiB each). Binds from every file share it, and one file could fill it. Every other client's timestamp bind then failed with ENOSPC on G13/G14, G15 and M3, which Mesa reports as out of device memory for a query pool, or fails GL context creation with. Give each file a share of that range: a sixteenth of its size, 4 MiB of a 64 MiB window. Mesa binds one small buffer per GL context, one per timestamped query pool and one debug buffer. A bind takes its range from the file's share before it maps anything and passes the resulting WindowPermit into the backend so FirmwareBuffer holds its WindowShare as its last field from construction; the share is therefore credited back only after the cleanup worker unmaps the IOVA alias (and after unmap on mapping-setup error paths), not on synchronous unbind. Past its share a file's buffer may not be mapped in the window: G17 gives it a host-written buffer, as for a full window, and the families whose firmware writes the stamps refuse the bind with ENOSPC, as for a full window. Every other file keeps its own share. Each backend reports its range's size (timestamp_window_size(), 0 for none) and receives the WindowPermit, so the policy lives in one place, the bind. G14 v27.2, G16, G18 and the M5 backend alias nothing and are unchanged, as is G17 on the M5 firmware graph, which has no window. The share is counted per open file in the file's memacct::Client, next to its committed bytes (bounding one open file, matching memacct's per-file model). Reported-by: Erik Bourget <[email protected]> Suggested-by: Erik Bourget <[email protected]> Suggested-by: Ryan Murray <[email protected]> Signed-off-by: Jeff Queisser <[email protected]>
DjDeveloperr
left a comment
There was a problem hiding this comment.
Verdict: FINISH, then merge at 13f0a8aa2b26
Blockers:
drivers/gpu/drm/asahi/g14_v27_2.rs:1213onmain: this backend still implementsmap_timestamp_buffer(&self, _bo, _range)with two arguments, but this PR addswindow: boolto the trait (gpu.rs:471). The PR merges without a text conflict, butmainwith this PR doesn't build withDRM_ASAHI_G14_V27_2. Fix: update the branch tomainand add_window: boolthere (it returns ENOTSUPP either way).drivers/gpu/drm/asahi/timestamp.rs:70:Bounddrops_window(the file's window share) as soon as the last reference goes. But the firmware alias it accounts for is only unmapped later, on the cleanup queue, throughDeferred<FirmwareBuffer>. With a fast bind/unbind loop, a file gets its share back while its old aliases still occupy the 64 MiB window, so it can hold more than a sixteenth. Fix: move theWindowShareintoFirmwareBuffer, aftermapping, so it is released only after the unmap.
Checked: no Apple material, no new gates. Buffer::Host is chosen by window capacity, the bind charge goes through Ledger::admit() before mapping, and every family keeps Arc<timestamp::Bound> until its commands retire. J775D A/B at this head on bare main 5746ef8a: gltimer 30/30, render CTS subset 571/0 fail, unchanged against the baseline, 0 GPU faults. CI green. This replaces my earlier reviews: the template lines and the footer aren't blockers, and I removed the footer from the body myself.
Evidence
Read the three commits against main (g14_v27_2.rs landed after this branch's base, which is why CI didn't see item 1) and the 11-24 J775D row. Rows on a non-M5 G17 (J616s or Neo) and on a firmware-window family (G13/G14, G15 or M3) are checks after the merge.
Superseded by the review at 13f0a8a
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
13f0a8a to
008896a
Compare
|
Thanks for the review — addressed both blockers, re-ran the own-base J775D A/B row at the new head
|
Resolve conflicts in drivers/gpu/drm/asahi/gpu.rs and drivers/gpu/drm/asahi/g14_v27_2.rs after G14 v27.2 gained its own firmware timestamp aperture (self.timestamp_range). Use self.timestamp_range in GpuManager::timestamp_window_size() and map_timestamp_buffer(), and delegate G14V27_2::timestamp_window_size() and map_timestamp_buffer() to GpuManagerG14V13_5 so G14 v27.2 enforces the same per-file sixteenth window share. Signed-off-by: Jeff Queisser <[email protected]>
|
Merged
Ready for re-check, @DjDeveloperr. |
DjDeveloperr
left a comment
There was a problem hiding this comment.
LGTM — re-audited the full diff at 33501d81b0a8. Both prior blockers are cleanly resolved: G14V27_2 now reports its timestamp window via timestamp_window_size() and enforces WindowPermit, and FirmwareBuffer drops _window_share last (with an explicit drop(mapping) before returning on timestamp_vmap() error) while firmware_mapping() returns a borrow so every backend retains Arc<timestamp::Bound> until job retirement. Holding merge for a 2nd-gen non-M5 hardware row alongside the exact-head J775D A/B pass since shared bind/window accounting spans all AGX families.
|
33501d8 J616s (M4 Pro T6040, Apple M4 Pro G16S B1 / g17, macOS 26.6.2 fw) PASS: paired against unmodified stock 7.3.0-aurora-fleet89 on the same host/Mesa (guarded one-shot aura-try, verbatim fleet89 config on 4c9c91d carrying exact 33501d8 + 3dccaef, default cmdline, boot-ctxr.bin untouched); GL ordered query probe 16/16 GL_TIME_ELAPSED (med 57250 ns pre-wake, 57042 ns post-wake; stock 57417 ns) + 32/32 monotonic GL_TIMESTAMP (gl_err=0); Borealis gpubench-vk --timestamps on (render.light 109.41 us / gpu_us 103.71 pre-wake, 115.21 us / gpu_us 135.33 post-wake; compute.light 95.94 us / gpu_us 2.83 pre-wake, 105.71 us / gpu_us 2.79 post-wake) + GL render.postfx 1080p crc=2133faaa valid=true; Vulkan CTS exact 100% parity with stock fleet89 (timestamp.misc_tests 33/35 Pass 0 Fail 2 NS, timestamp.transfer_tests 96/120 Pass 0 Fail 24 NS, query_pool.statistics_query 18770/18775 Pass 0 Fail 5 NS, query_pool.concurrent_queries 2/2 Pass 0 Fail, synchronization2.op.multi_queue.binary_semaphore 1422/5622 Pass 0 Fail 4200 NS, write_ssbo_compute_read_vertex 4/4 Pass 0 Fail; timestamp.basic_graphics_tests 0/1 Pass / 1/1 Fail identically on both stock fleet89 and trial, 0 regressions); s2idle 1/1 (rtc1 success=1 fail=0), 0 GPU faults, 0 failed units, Enforcing + 0 AVC, 0 kernel errors; restored and verified 7.3.0-aurora-fleet89. |
Merge origin/main (8a76aa1, including aurora-silicon#2531) to resolve the conflict at the end of drivers/gpu/drm/asahi/file.rs, keeping both the asahi_vm_table and asahi_bound_object_charge KUnit test modules. Signed-off-by: Jeff Queisser <[email protected]>
What: Keep G17 timestamp buffers outside the 64 MiB firmware window on a CPU-only host path (
Buffer::Host) instead of consuming shared kernel VM dynamic range, charge everyGEM_BIND_OBJECTbind's kernel record memory againstmemacct(Ledger::admit()) while holdingArc<timestamp::Bound>until referencing commands retire across all families, and bound each open file to 1/16 of its backend's fixed firmware timestamp window (4 MiB of 64 MiB) with quota released only afteraurora-ts-cleanupunmaps the alias.Tested: J775D (Mac Studio, M5 Ultra) at
33501d81b0a8on baremain8b0a38328c94(published Auramain7bf44a6374af, 27.0 stub, default command line, own-base A/Bpr2531-m6vspr2531-m6b): bind-charge accounting (+152.0 B/bind,161/256thenENOMEMat client limit vs256/256uncharged on baseline), 256 x 256 MiB timestamp binds (256/256at+0 MiBvs223/256thenENOSPCon baseline), Vulkan timestamp CTS 1149 cases identical (345/78/54+648/24,0case diffs), GL timer30/30, render CTS subset571/57/0,0GPU faults/recoveries/oops,2/2baseline failed units,0new kernel errors (10vs10baseline; ALARM has no SELinux). Automated: modular build (pr2531-m6, all 8 GPU backends includingCONFIG_DRM_ASAHI_G14_V27_2=y) has0warnings indrivers/gpu/drm/asahi/;kunit-vz(pr2531-m6k) 86 suites436/440pass,0fail,4baseline skips (asahi_bound_object_charge2/2,asahi_memacct11/11,asahi_timestamp_buffer2/2,asahi_g17_timestamp_window2/2);tools/asahi/run-host-tests.py(ht-2531m6)545/549pass on both base and series (0of549runs differ).Risk: two-way door · affects all AGX GPU families (
file.rsshared bind accounting; commit 1 affects G17 host-written spillover; commit 3 and merge33501d81b0a8bound each open file to 4 MiB of the 64 MiB firmware timestamp window on G13/G14, G14 v27.2, G15, M3, and non-M5 G17 — a single bind larger than 4 MiB now returnsENOSPCon G13/G14, G14 v27.2, G15, and M3, where Mesa's binds are much smaller; G16, G18, and the M5 backend keeptimestamp_window_size() == 0).Not yet: Post-merge checks on a non-M5 G17 (J616s / Neo), a G14 v27.2 Mac, and a G13/G14, G15, or M3 firmware-window Mac.
Details
Problem
On M5, and on other G17 GPUs once the 64 MiB timestamp window is full,
GEM_BIND_OBJECTmapped a timestamp buffer into the kernel VM's dynamic range (shared with firmware queues, kick rings, and render state), even though outside the window the host writes every stamp through the buffer's CPU mapping and the firmware is never given that address. Across all families, two shared-bind gaps also remained:ENOSPC(or spill out of the window on G17).Why this shape
map_timestamp_buffer(). G13/G14 (gpu.rs), G14 v27.2 (g14_v27_2.rs->gpu.rsIOVA_G14_V27_2_TIMESTAMP_RANGE), G15 (g15/mod.rs), and M3 (m3/m3_drm.rs) alias into their fixed 64 MiB firmware timestamp range; G16 and G18 keep CPU mappings (Buffer::cpu); the M5 backend (m5/) returnsENOTSUPP; G17 aliased into the 64 MiB window when it fit and otherwise spilled into the shared kernel VM dynamic range. The shared object table infile.rsaccepted unbounded binds without charging their records or bounding per-file window share.Buffer::Host(CPU mapping only), keyed on whether the window has room, not chip or firmware version.Ledger::admit()(limits derived from machine RAM) and usesGFP_KERNEL_ACCOUNT, releasing only when the lastArc<timestamp::Bound>reference drops after referencing commands retire across all families.timestamp_window_size()(0 for none);file.rsreserves up towindow_size / 16per open file viamemacct::Client::take_window()and passestimestamp::WindowPermit(Unrestricted | Share(WindowShare) | Denied) intomap_timestamp_buffer().FirmwareBufferholds_window_shareas its last field from construction (andnew_firmware()explicitly dropsmappingbefore returning ontimestamp_vmap()error), somappingalways unmaps onaurora-ts-cleanupbefore the share is credited back.Change
Three feature commits plus a non-force-push merge of
main(8b0a38328c94):drm/asahi: g17: keep timestamp buffers out of the shared firmware range(80e130f592aa): Addtimestamp::Buffer::Hostand route G17 timestamp binds that do not fit in the timestamp window (and M5 firmware graphs with no window) to it instead of the kernel VM dynamic range.drm/asahi: charge each bound object to its client, so a file's binds stay within its memory limit(50d485b788b2): Charge each bind's record + deferred cleanup item memory (Deferred::HEAP_BYTES) viaLedger::admit()before mapping, storeKernelMappingdirectly inFirmwareBufferwith borrowedfirmware_mapping(), retainArc<timestamp::Bound>in G13/G14 (fw/job.rs), G15 (g15/command.rs,g15/job.rs), and M3 (m3/m3_submit.rs) matching G16/G17/G18, and addasahi_bound_object_charge+a_host_stamp_lies_inside_the_bound_rangeKUnit coverage.drm/asahi: let one file hold at most a sixteenth of the timestamp window, so other clients' timestamp binds still fit(008896a365e1): AddGpu::timestamp_window_size(),memacct::Client::take_window()/WindowShare, andtimestamp::WindowPermitpassed toGpu::map_timestamp_buffer()across all backends, holding_window_shareas the last field ofFirmwareBufferso quota is released only after unmap onaurora-ts-cleanup.Merge branch 'main' into pr/asahi-timestamp-window(33501d81b0a8): Mergemain(8b0a38328c94), reconcilinggpu.rs(self.timestamp_range) andg14_v27_2.rsso G14 v27.2 reports its 64 MiBIOVA_G14_V27_2_TIMESTAMP_RANGEwindow viatimestamp_window_size()and enforcesWindowPermitinmap_timestamp_buffer().Evidence
Testing
J775D (Mac Studio, M5 Ultra) own-base A/B row at
33501d81b0a8Bare
main8b0a38328c94(no extra PRs), published Auramain7bf44a6374af, 27.0 stub, default command line, read-only root, ALARM (no SELinux): kitpr2531-m6(windowpr2531m6g@20261124-2040) vs baseline kitpr2531-m6b(windowpr2531m6g@20261124-2040). Peak SMC sensor 49.1 C, peak DC input 45.9 W.pr2531-m6b)pr2531-m6)4112/4112accepted, committed+0 B(0.0 B/bind)4112/4112accepted, committed+625024 B(152.0 B/bind), returns to baseline on close256/256accepted161/256accepted, thenENOMEM(exact expected161at152 B/bind)223/256accepted, 224thENOSPC; client BQUEUE_CREATEok256/256accepted,+0 MiBcommitted /kernel_resident/ fdinfo; client BQUEUE_CREATEoka477 +b672)a:345 Pass / 78 Fail / 54 NS;b:648 Pass / 24 Fail0case diffs)GL_TIME_ELAPSED/GL_TIMESTAMP, 3 x 10 rounds)30/30pass30/30pass571 Pass / 57 NotSupported / 0 Fail571 Pass / 57 NotSupported / 0 Fail002(iwd.service,systemd-networkd-persistent-storage.service) /102(same) /10(0new kernel errors)Automated checks at
33501d81b0a8pr2531-m6, all 8 GPU backends includingCONFIG_DRM_ASAHI_G14_V27_2=y):0compiler/rustc warnings indrivers/gpu/drm/asahi/.kunit-vz,pr2531-m6k,CONFIG_KUNIT=y,CONFIG_DRM_ASAHI=y,CONFIG_IIO_AOP_SENSOR_MOTION=n): 86 suites,436/440pass,0fail,4baseline skips;asahi_bound_object_charge2/2,asahi_memacct11/11,asahi_timestamp_buffer2/2,asahi_g17_timestamp_window2/2;0warnings in touched files.tools/asahi/run-host-tests.py,ht-2531m6on baremain8b0a38328c94):545/549pass on both base and series;0of549runs differ.