Skip to content

drm/asahi: keep timestamp buffers out of the shared firmware range, charge binds to their client, and bound per-file window share - #2531

Merged
DjDeveloperr merged 4 commits into
aurora-silicon:mainfrom
funkzy:pr/asahi-timestamp-window
Nov 25, 2026

Conversation

@funkzy

@funkzy funkzy commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

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 every GEM_BIND_OBJECT bind's kernel record memory against memacct (Ledger::admit()) while holding Arc<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 after aurora-ts-cleanup unmaps the alias.
Tested: J775D (Mac Studio, M5 Ultra) at 33501d81b0a8 on bare main 8b0a38328c94 (published Aura main 7bf44a6374af, 27.0 stub, default command line, own-base A/B pr2531-m6 vs pr2531-m6b): bind-charge accounting (+152.0 B/bind, 161/256 then ENOMEM at client limit vs 256/256 uncharged on baseline), 256 x 256 MiB timestamp binds (256/256 at +0 MiB vs 223/256 then ENOSPC on baseline), Vulkan timestamp CTS 1149 cases identical (345/78/54 + 648/24, 0 case diffs), GL timer 30/30, render CTS subset 571/57/0, 0 GPU faults/recoveries/oops, 2/2 baseline failed units, 0 new kernel errors (10 vs 10 baseline; ALARM has no SELinux). Automated: modular build (pr2531-m6, all 8 GPU backends including CONFIG_DRM_ASAHI_G14_V27_2=y) has 0 warnings in drivers/gpu/drm/asahi/; kunit-vz (pr2531-m6k) 86 suites 436/440 pass, 0 fail, 4 baseline skips (asahi_bound_object_charge 2/2, asahi_memacct 11/11, asahi_timestamp_buffer 2/2, asahi_g17_timestamp_window 2/2); tools/asahi/run-host-tests.py (ht-2531m6) 545/549 pass on both base and series (0 of 549 runs differ).
Risk: two-way door · affects all AGX GPU families (file.rs shared bind accounting; commit 1 affects G17 host-written spillover; commit 3 and merge 33501d81b0a8 bound 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 returns ENOSPC on G13/G14, G14 v27.2, G15, and M3, where Mesa's binds are much smaller; G16, G18, and the M5 backend keep timestamp_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_OBJECT mapped 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:

  • Each bind's kernel record in the file's object table was neither charged to the client nor bounded per file.
  • On every family that aliases timestamp buffers into a fixed 64 MiB firmware timestamp range (G13/G14, G14 v27.2, G15, M3, and non-M5 G17), one open file could fill the whole 64 MiB range and cause other clients' timestamp binds to fail with ENOSPC (or spill out of the window on G17).

Why this shape

  • Where the policy lived: Each GPU backend decided where a timestamp buffer goes in map_timestamp_buffer(). G13/G14 (gpu.rs), G14 v27.2 (g14_v27_2.rs -> gpu.rs IOVA_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/) returns ENOTSUPP; G17 aliased into the 64 MiB window when it fit and otherwise spilled into the shared kernel VM dynamic range. The shared object table in file.rs accepted unbounded binds without charging their records or bounding per-file window share.
  • Narrower alternatives: capping G17 dynamic-range timestamp mappings, enlarging the window, keeping a fixed per-file object count cap (earlier draft's 4096 cap), or duplicating per-backend quota checks.
  • The source used:
    1. A G17 buffer outside the window takes Buffer::Host (CPU mapping only), keyed on whether the window has room, not chip or firmware version.
    2. Each bind charges its record size through Ledger::admit() (limits derived from machine RAM) and uses GFP_KERNEL_ACCOUNT, releasing only when the last Arc<timestamp::Bound> reference drops after referencing commands retire across all families.
    3. Each backend reports timestamp_window_size() (0 for none); file.rs reserves up to window_size / 16 per open file via memacct::Client::take_window() and passes timestamp::WindowPermit (Unrestricted | Share(WindowShare) | Denied) into map_timestamp_buffer(). FirmwareBuffer holds _window_share as its last field from construction (and new_firmware() explicitly drops mapping before returning on timestamp_vmap() error), so mapping always unmaps on aurora-ts-cleanup before the share is credited back.

Change

Three feature commits plus a non-force-push merge of main (8b0a38328c94):

  1. drm/asahi: g17: keep timestamp buffers out of the shared firmware range (80e130f592aa): Add timestamp::Buffer::Host and 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.
  2. 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) via Ledger::admit() before mapping, store KernelMapping directly in FirmwareBuffer with borrowed firmware_mapping(), retain Arc<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 add asahi_bound_object_charge + a_host_stamp_lies_inside_the_bound_range KUnit coverage.
  3. drm/asahi: let one file hold at most a sixteenth of the timestamp window, so other clients' timestamp binds still fit (008896a365e1): Add Gpu::timestamp_window_size(), memacct::Client::take_window() / WindowShare, and timestamp::WindowPermit passed to Gpu::map_timestamp_buffer() across all backends, holding _window_share as the last field of FirmwareBuffer so quota is released only after unmap on aurora-ts-cleanup.
  4. Merge branch 'main' into pr/asahi-timestamp-window (33501d81b0a8): Merge main (8b0a38328c94), reconciling gpu.rs (self.timestamp_range) and g14_v27_2.rs so G14 v27.2 reports its 64 MiB IOVA_G14_V27_2_TIMESTAMP_RANGE window via timestamp_window_size() and enforces WindowPermit in map_timestamp_buffer().
Evidence

Testing

J775D (Mac Studio, M5 Ultra) own-base A/B row at 33501d81b0a8

Bare main 8b0a38328c94 (no extra PRs), published Aura main 7bf44a6374af, 27.0 stub, default command line, read-only root, ALARM (no SELinux): kit pr2531-m6 (window pr2531m6g@20261124-2040) vs baseline kit pr2531-m6b (window pr2531m6g@20261124-2040). Peak SMC sensor 49.1 C, peak DC input 45.9 W.

Check Baseline (pr2531-m6b) This PR (pr2531-m6)
4112 binds of 16 KiB BO 4112/4112 accepted, committed +0 B (0.0 B/bind) 4112/4112 accepted, committed +625024 B (152.0 B/bind), returns to baseline on close
Binds at per-client limit (24576 B left) 256/256 accepted 161/256 accepted, then ENOMEM (exact expected 161 at 152 B/bind)
256 x 256 MiB timestamp binds (64 GiB) 223/256 accepted, 224th ENOSPC; client B QUEUE_CREATE ok 256/256 accepted, +0 MiB committed / kernel_resident / fdinfo; client B QUEUE_CREATE ok
Vulkan timestamp CTS (1149 cases: list a 477 + b 672) a: 345 Pass / 78 Fail / 54 NS; b: 648 Pass / 24 Fail Identical (0 case diffs)
GL timer (GL_TIME_ELAPSED / GL_TIMESTAMP, 3 x 10 rounds) 30/30 pass 30/30 pass
Render CTS subset (628 cases) 571 Pass / 57 NotSupported / 0 Fail 571 Pass / 57 NotSupported / 0 Fail
GPU faults / recoveries / oops 0 0
Failed units / kernel errors 2 (iwd.service, systemd-networkd-persistent-storage.service) / 10 2 (same) / 10 (0 new kernel errors)

Automated checks at 33501d81b0a8

  • Modular build (pr2531-m6, all 8 GPU backends including CONFIG_DRM_ASAHI_G14_V27_2=y): 0 compiler/rustc warnings in drivers/gpu/drm/asahi/.
  • KUnit (kunit-vz, pr2531-m6k, CONFIG_KUNIT=y, CONFIG_DRM_ASAHI=y, CONFIG_IIO_AOP_SENSOR_MOTION=n): 86 suites, 436/440 pass, 0 fail, 4 baseline skips; asahi_bound_object_charge 2/2, asahi_memacct 11/11, asahi_timestamp_buffer 2/2, asahi_g17_timestamp_window 2/2; 0 warnings in touched files.
  • Host tests (tools/asahi/run-host-tests.py, ht-2531m6 on bare main 8b0a38328c94): 545/549 pass on both base and series; 0 of 549 runs differ.

@funkzy
funkzy force-pushed the pr/asahi-timestamp-window branch from df120a7 to d92d363 Compare November 20, 2026 21:24
@RyanTheTide

Copy link
Copy Markdown
Contributor

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 window_va(), which is None for Host, through timestamp_offset() (timestamp.rs:157, which bounds the offset against the bound range and returns the object offset) and through read/write on the vmap, which take object offsets. The paths that call firmware_mapping() (queue/common.rs:36, g15/command.rs:369, m3/m3_submit.rs:22) never see a Host buffer. A Host buffer holds no KernelMappingPin, but it can't be idle-reclaimed or purged under the vmap: Buffer::host refuses VM-private objects (timestamp.rs:75), and reclaim and purge only walk a VM's private BOs (mmu/residency.rs:481, :519, :615). bound_size keeps the same range checks as the old Buffer::cpu, and the KUnit cases cover the edges.

Nit: file.rs:1593-1602 checks the 4096 cap only after map_timestamp_buffer(), so a bind past the cap still takes a window alias or a vmap for a moment before it is dropped. The result is the same, but checking the table count first would avoid the churn.

HW row: the run lists the M5 Ultra only. The Host fallback also runs on the non-M5 G17s once the 64 MiB window is full, and the 4096 cap applies to every family. Please add: J616s or Neo on this build, with the window filled (bind timestamp buffers until binds land outside it), dEQP-VK.query_pool.*timestamp* and a GL GL_TIMESTAMP query test pass with the same results before and after, with binds outside the window succeeding and their stamps read back monotonic; one G13 Mac (M1/M2) running the same timestamp tests with no change; KUnit pass counts per suite; 0 AVC, 0 failed units, 0 new kernel errors on each.

Assisted-by: LLM (Claude:Opus 5.5)

@funkzy
funkzy force-pushed the pr/asahi-timestamp-window branch from d92d363 to 60e5bda Compare November 21, 2026 19:14
@funkzy

funkzy commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks, Ryan. The nit is fixed in the second commit, now at 60e5bda: do_gem_bind_object() now reserves the object-table slot (reserve_limit, as VM_CREATE and queue creation do) before map_timestamp_buffer(), and fills it after. A bind past 4096 is refused before the buffer gets a window alias or a vmap, and a failed mapping just releases the slot. The commit message says so, and I've added your Suggested-by. git range-diff: the first commit is unchanged; the second changes only in do_gem_bind_object() and that message paragraph.

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):

  • 4112 binds of a 16 KiB object in one file: 4096 accepted, then EBUSY.
  • 256 binds of a 256 MiB timestamp buffer (64 GiB of ranges, all past the window): 256 accepted, with +0 MiB in the client's committed memory, the kernel's resident memory and fdinfo, and a second client's queue creation still succeeds.
  • Render CTS subset: 571 Pass, 57 NotSupported, the same as without the series.
  • KUnit, per suite: 79 suites, 366 of 368 cases pass (two skips, as on the base: apple_g17_rx_util_min_test without UCLAMP and j713_accepts_all_loaded_images); asahi_timestamp_buffer 1 of 1. The base has 75 suites, 353 of 355. Host tests: 436 of 436 on base and head.
  • Regression: 0 new failed units (iwd.service and systemd-networkd-persistent-storage.service fail on the read-only test root with and without the series) and 0 new kernel error lines. ALARM has no SELinux, so there is no AVC count.

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 dEQP-VK.query_pool.*timestamp* and a GL GL_TIMESTAMP query test with the same results before and after, binds outside the window succeeding with their stamps read back monotonic, KUnit pass counts per suite, and 0 failed units and 0 new kernel errors. The same timestamp tests on one G13 Mac (M1 or M2), unchanged, would cover the cap on the families without the window.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-review of 60e5bda: No blockers.

  1. Cap checked after map_timestamp_buffer() (nit): resolved. drivers/gpu/drm/asahi/file.rs:1596-1607 now takes reserve_limit(1..=MAX_BOUND_OBJECTS_PER_FILE) before the mapping and fills it after, the same pattern as VM_CREATE (file.rs:737) and queue creation (file.rs:1725). A bind past 4096 fails before any window alias or vmap, a failed mapping releases the slot through the Reservation drop, and fill() takes the XArray lock itself, so a rejected object is dropped outside it.

The first commit is unchanged since the last review; the second changes only in do_gem_bind_object() and its message.

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, dEQP-VK.query_pool.*timestamp* and a GL GL_TIMESTAMP query test unchanged before and after, binds outside the window succeeding with monotonic stamps; one G13 Mac (M1/M2) running the same timestamp tests unchanged; KUnit pass counts; 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

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

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::Host vs Buffer::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 shared drivers/gpu/drm/asahi/file.rs across 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) refuses is_vm_private() with EINVAL, maps via TimestampVmap::new(&bo.gem) -> owned_vmap::<0>() (which refuses external/user_memory BOs at rust/kernel/drm/gem/shmem.rs:261 and pins shmem pages via drm_gem_shmem_vmap_locked), and wraps the buffer in cleanup::Deferred so dma_resv_lock-taking drop runs off fence-producer paths. Verified drivers/gpu/drm/asahi/mmu/residency.rs:481, 519, 615 only walk VM-private BOs (for_each_private_bo), so omitting KernelMappingPin on HostBuffer cannot race with idle reclaim or purge.
    • Buffer::timestamp_offset() (timestamp.rs:153-166) checks offset + 8 <= buffer.size (ERANGE/EOVERFLOW) and returns buffer.start + offset; window_va() returns None and firmware_mapping() / timestamp_mapping() return Err(EINVAL). Verified drivers/gpu/drm/asahi/g17/completion.rs:45-65, 160-188 routes window_va == None exclusively to write_timestamp().
    • do_gem_bind_object() (drivers/gpu/drm/asahi/file.rs:1595-1609) reserves the XArray slot (1..=4096, GFP_KERNEL_ACCOUNT) before map_timestamp_buffer(), so binds past 4096 fail with EBUSY before creating any window alias or vmap; failed mapping releases the slot on Reservation drop; resv.fill(obj)? unlocks the XArray before dropping any rejected StoreError. Verified rust/kernel/xarray.rs:321, 558: remove() on an unfilled reservation coerces XA_ZERO_ENTRY to NULL (ENOENT), and any concurrent race fails cleanly with EBUSY. (cleanup::Deferred::new at cleanup.rs:93 still uses GFP_KERNEL for 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 + human Signed-off-by (plus Reported-by/Suggested-by) and zero AI trailers; PR body includes Assisted-by:.
  • §6 Naming: Clean.
  • CI: host-tests passed (sole workflow matching drivers/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:

  1. 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 GL GL_TIMESTAMP query test unchanged before/after, out-of-window binds succeeding with monotonic timestamps, KUnit pass counts, 0 failed units, and 0 new kernel errors.
  2. One G13 Mac (M1/M2) running the same timestamp tests unchanged (covering the shared 4096-cap path), with clean regression counts.

@funkzy

funkzy commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

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.

J775D without this PR with this PR
4112 binds of a 16 KiB object in one file 4112 accepted 4096, then EBUSY
256 binds of a 256 MiB timestamp buffer 223, then ENOSPC 256, +0 MiB
Vulkan CTS timestamp cases (1149) 1093 Pass, 2 Fail, 54 NotSupported the same, with the same two failures
dEQP-VK.query_pool.*timestamp* 0 cases in this CTS 0 cases
GL GL_TIMESTAMP (3 x 10 rounds) 30 of 30 30 of 30
render CTS subset (628) 571 Pass, 57 NotSupported the same
KUnit 76 suites, 375 of 377, 2 skips 77 suites, 376 of 378, 2 skips (asahi_timestamp_buffer 1 of 1)
failed units / new kernel errors 2 the same 2 / 0 (only USB enumeration retries differ, before any test)

The two CTS failures are the stage-stamp ordering cases (timestamp_stage_top_of_pipe_stage, timestamp_stage_host_stage). They fail the same way without this PR, as does our own compute-timestamp check (0 of 10 rounds on both). vulkan-cts-1.4.7.1 has no query_pool timestamp group, so I ran every mustpass case naming timestamp or calibrat instead. ALARM has no SELinux, so there is no AVC count.

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 cleanup::Deferred::new: the firmware-mapped path already allocated one Deferred per bound timestamp buffer with GFP_KERNEL before this PR, and the host-written path now takes the same one. It is shared cleanup code that the G16 paths use too, and it is now bounded at 4096 per file. Moving it to GFP_KERNEL_ACCOUNT for every caller would be a separate change.

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 DRM_ASAHI_BIND_OBJECT_USAGE_TIMESTAMPS) sends every query pool created meanwhile to the host-written path. While it holds them, run the dEQP-VK timestamp cases and a GL GL_TIMESTAMP test, before and after this PR; the rows to compare are those results, KUnit per suite, failed units and new kernel errors. I can send the small hold program and our GL timer test if that helps. The hold works on the J775D (five 16 MiB binds held while those tests ran, then released), though with no window there it only checks the procedure.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Review notes (non-author):

  • The 64 MiB timestamp window used on G13/G14 (IOVA_KERN_TIMESTAMP_RANGE), G15 (g15/timestamp.rs) and M3 (m3_runtime.rs) is still first-come: please bound the bytes one file may hold in it (a per-file quota or a per-buffer range cap) before merging, so these generations get the same protection as G17/M5.
  • asahi_timestamp_buffer exercises the refactored range check only; please add a case for the per-file cap (and the host-buffer path if it can be reached from KUnit).
  • Until the first point lands, please trim the 'Still to run' description of the hold scenario from the body.

Alyx-ML added a commit to Alyx-ML/linux that referenced this pull request Nov 23, 2026
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.

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

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, TimestampVmap lifetime + cleanup::Deferred drop, and reserving the XArray slot (1..=4096, GFP_KERNEL_ACCOUNT) before map_timestamp_buffer() are all sound.
  • §4 Attribution & §6 Naming: Clean — both commits (a9d3d1658565, 60e5bdaae4ce) carry human author/committer + human Signed-off-by: only (zero AI commit trailers), and the PR body carries Assisted-by:.
  • Clean-base J775D (M5 Ultra) row & live CI: The updated J775D A/B run on integration/aurora b21dcc633b32 + #1973 cleanly covers the M5 host-only path, cap enforcement, Vulkan/GL timestamps, and KUnit; live host-tests CI is green on 60e5bdaae4ce.

Blocking findings

  1. §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_RANGE in drivers/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.
  2. KUnit coverage: asahi_timestamp_buffer currently tests bound_size() only. Please add KUnit coverage for the per-file cap (and window quota / host-buffer bounds where reachable from KUnit).
  3. §5 Hardware proof rows still open: M5 Ultra (uat.is_m5()) has no 64 MiB timestamp window, so the non-M5 G17 spillover path (J616s or Neo spilling into Buffer::Host once the window is full) and a G13 (M1/M2) regression row covering the shared cap/quota path still need to be run on the updated head.

@funkzy
funkzy force-pushed the pr/asahi-timestamp-window branch from 60e5bda to 13f0a8a Compare November 24, 2026 00:31
@funkzy funkzy changed the title drm/asahi: keep timestamp buffers out of the shared firmware range, and cap bound objects per file drm/asahi: keep timestamp buffers out of the shared firmware range, charge binds to their client, and bound per-file window share Nov 24, 2026
@funkzy

funkzy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @DjDeveloperr and @RyanTheTide. This update rebases onto integration/aurora (c91527272e90, new head 13f0a8aa2b26) and addresses the blocking items:

  1. Cross-generation shared firmware timestamp window quota (new commit 3, 13f0a8aa2b26). Each backend now reports the size of its fixed firmware timestamp window through Gpu::timestamp_window_size() (IOVA_KERN_TIMESTAMP_RANGE on G13/G14, TIMESTAMPS_SIZE on G15, TIMESTAMP_RANGE on M3, TIMESTAMP_WINDOW on non-M5 G17 via a single Firmware::timestamp_window() helper; 0 on G16, G18, M5, and G17's M5 graph). do_gem_bind_object() reserves the bound range from a per-file 1/16 share (memacct::Client::take_window(), 4 MiB of a 64 MiB window) before calling map_timestamp_buffer(..., window). Past a file's share, G17 falls back to Buffer::Host and G13/G14, G15 and M3 return ENOSPC, leaving the rest of the window available to other clients; buffers mapped outside the window drop the share immediately. The share is per file, matching the review ask and the existing per-file accounting model; a single-client-full-window policy like queue_share can be considered separately if large query pools hit 4 MiB.
  2. Per-bind ledger charge replacing the 4096 count cap (updated commit 2, 5bdb6e744374). Instead of a fixed 4096-object cap returning EBUSY, every bind now charges its kernel record memory (BOUND_OBJECT_BYTES, computed from the types' sizes — 152 bytes on arm64 in the default all-backends config including commit 3's Option<WindowShare>, after storing mmu::KernelMapping directly in FirmwareBuffer without a redundant inner Arc) through Ledger::admit() before taking the table slot or mapping anything, failing with ENOMEM past the client's or device's memory limit. Buffer::firmware_mapping() now returns a borrowed &mmu::KernelMapping, and G13/G14 (fw::job::UserTimestamp), G15 (g15::command/g15::job), and M3 (m3::m3_submit::Destination) commands now retain Arc<timestamp::Bound> alongside G16, G17, and G18, so both the bind charge and the 1/16 window share stay held until every referencing command retires. Commit 1 (2e017801f7bd) is unchanged.
  3. KUnit coverage and all-backends build. Both new suites now cover the range check, host-buffer offset bounds, per-bind ledger charge/refusal, and per-file timestamp-window quota:
    • asahi_timestamp_buffer: a_bound_range_is_whole_pages_inside_the_object and a_host_stamp_lies_inside_the_bound_range (2 of 2 pass).
    • asahi_bound_object_charge: a_bind_is_charged_its_records_and_refused_past_the_client_limit and a_file_holds_at_most_its_share_of_the_timestamp_window (2 of 2 pass).
    • Full KUnit run on this head (13f0a8aa2b26 on c91527272e90, kit pr2531-r4k3, kunit-vz): 80 suites, 395 of 397 cases pass, 0 fail, 2 skips (apple_mbox_g17_stall/apple_g17_rx_util_min_test needing CONFIG_UCLAMP_TASK, and asahi_fwid/j713_accepts_all_loaded_images).
    • All-backends modular build (pr2531-r4m3, G15/G16/G18/M3_T8122/M5 all enabled): builds cleanly with 0 new warnings.
  4. PR body and title updated: the hold-scenario description has been trimmed from "Still to run" and the title updated to match the ledger charge and per-file window share.

Hardware rows still to run on 13f0a8aa2b26: our J775D (M5 Ultra) own-base A/B re-run on c91527272e90 + #1973, plus a non-M5 G17 (J616s or Neo) spillover row and a G13/G14/G15/M3 window-share regression row from machines with a firmware timestamp window.

Assisted-by: LLM (Claude:Opus 5.5, Gemini:Neon)

@funkzy

funkzy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Fresh own-base J775D (Mac Studio, M5 Ultra) A/B hardware row at live head 13f0a8aa2b26 on bare integration/aurora 5746ef8a5afd (no extra PRs needed now that #1973 is merged):

  • Baseline arm: kit pr2531-r4b (window r2531@20261123-1856) — bare integration/aurora 5746ef8a5afd.
  • PR arm: kit pr2531-r4 (window r2531@20261123-1856) — 5746ef8a5afd + this PR at 13f0a8aa2b26.
  • Environment: 27.0 firmware stub (26A428), published Aura main (f13056d95af6, aura-main-f13056d9), read-only root, default kernel command line.
Check pr2531-r4b (base) pr2531-r4 (PR at 13f0a8aa2b26)
4112 binds of a 16 KiB object, one file 4112/4112 accepted, committed +0 bytes (0.0/bind) 4112/4112 accepted, committed +625024 bytes (152.0/bind), released on close
Binds with 16384 bytes left of the 48293 MiB client limit 256/256 accepted, refused 0 107/256 accepted, then ENOMEM (expected 107 at 152 B each), gpu_memory refused 0 -> 1
256 binds of a 256 MiB timestamp buffer (64 GiB of ranges) 223/256, then ENOSPC 256/256 accepted, +0 MiB; client B QUEUE_CREATE ok before and after close
Timestamp CTS (477 + 672 cases, Borealis) 421 Pass / 2 Fail / 54 NS; 672 Pass 421 Pass / 2 Fail / 54 NS (same 2 baseline cases); 672 Pass
GL timer test (gltimer, 3 × 10 rounds) 30/30 Pass 30/30 Pass
Render CTS subset (628 cases, Borealis) 571 Pass, 57 NotSupported, 0 Fail 571 Pass, 57 NotSupported, 0 Fail
GPU recoveries / faults / WARNING / BUG / Oops 0 0
Failed units / kernel errors (ALARM, no SELinux) 2 / 10 same 2 / 11 (1 unrelated DP boot timeout dcp_dptx_connect: timed out waiting for port 0 link configuration; 0 GPU errors)

Assisted-by: LLM (Gemini:Neon)

@github-actions github-actions Bot added area:gpu Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026

@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: HOLD at 13f0a8aa2b26

Blockers:

  • drivers/gpu/drm/asahi/g14_v27_2.rs:1213 (on main, CONFIG_DRM_ASAHI_G14_V27_2 is default y) — Backend::map_timestamp_buffer still takes 2 arguments while this PR adds window: bool to gpu::Gpu::map_timestamp_buffer (drivers/gpu/drm/asahi/gpu.rs:504-509). Merging onto main will fail to compile the default config. Rebase onto main and add _window: bool to g14_v27_2.rs:1213.
  • drivers/gpu/drm/asahi/timestamp.rs:71-76 & drivers/gpu/drm/asahi/file.rs:1639-1643 — Bound drops _window: Option<WindowShare> synchronously on unbind/retirement, whereas Buffer::Firmware(Deferred<FirmwareBuffer>) only enqueues unmap onto aurora-ts-cleanup (which takes dma_resv_lock and runs the UAT unmap + TLB flush asynchronously). Rapid bind/unbind cycles let one file credit back its 4 MiB quota while prior KernelMapping aliases still occupy the 64 MiB firmware timestamp window. Move _window into FirmwareBuffer ordered after mapping: mmu::KernelMapping so 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 into Tested: once rebased), and add the two remaining hardware rows at the updated head: non-M5 G17 (J616s or Neo) spillover past the 4 MiB share / 64 MiB window onto Buffer::Host, plus one firmware-window family (G13/G14, G15, or M3) proving normal timestamp queries unchanged and 1/16 per-file ENOSPC isolation 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::Host vs Buffer::Firmware turns on window capacity/share (pre-existing uat.is_m5()), and both the per-bind ledger charge and the 1/16 window share live in shared file.rs + memacct.rs across every GPU family.
  • §2 / §3 Code, lifetime, and safety:
    • Commit 1 (2e017801f7bd, Buffer::Host): bound_size() and host_offset() bounds/overflow checks, is_vm_private() guard, TimestampVmap lifetime, cleanup::Deferred drop off fence-producer paths, and g17/completion.rs routing (window_va == None -> write_timestamp) are sound. Verified g17/mod.rs initializes shared.state before DRM registration so timestamp_window_size() cannot race None -> Some.
    • Commit 2 (5bdb6e744374, per-bind ledger charge): admit_bind() + reserve_limit(..., GFP_KERNEL_ACCOUNT) run before mapping; FirmwareBuffer owns KernelMapping directly and firmware_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 retain Arc<timestamp::Bound> through retirement.
    • Commit 3 (13f0a8aa2b26, 1/16 window share): Client::take_window() uses lockless CAS (try_add_within) with no concurrent overshoot, and share.filter(|_| buffer.window_bytes() > 0) returns the share immediately when G17 spills to Buffer::Host. Two blockers remain: missing g14_v27_2.rs trait update against main (205 commits ahead of PR base c91527272e90), and WindowShare dropping before Deferred<FirmwareBuffer> unmaps KernelMapping.
  • §4 Clean-room & attribution: All 3 commits (2e017801f7bd, 5bdb6e744374, 13f0a8aa2b26) carry human author/committer (Jeff Queisser) and human Signed-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 main f13056d9, default cmdline) A/B at 13f0a8aa2b26 passes bind-charge accounting (+152 B/bind, ENOMEM at 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) at 13f0a8aa2b26: 80 suites, 395/397 pass, 0 fail, 2 skip (asahi_bound_object_charge 2/2, asahi_timestamp_buffer 2/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.
  • §6 Naming: Pass (Borealis and aura used properly; no prohibited terms in title, body, commits, or diff).
  • CI: host-tests passed (COMPLETED / SUCCESS) on 13f0a8aa2b26.
  • Non-blocking notes:
    • drivers/gpu/drm/asahi/cleanup.rs:96 (Deferred::new) still allocates Item<T> with GFP_KERNEL rather than GFP_KERNEL_ACCOUNT (pre-existing shared helper; commit 2's message implies GFP_KERNEL_ACCOUNT for buffer heap records).
    • drivers/gpu/drm/asahi/file.rs:1633 calls take_window() before rejecting data.range == 0 in map_timestamp_buffer(); harmless since the error path drops the 0-byte WindowShare, Reservation, and Commit.

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 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: FINISH, then merge at 13f0a8aa2b26

Blockers:

  1. drivers/gpu/drm/asahi/g14_v27_2.rs:1213 on main: this backend still implements map_timestamp_buffer(&self, _bo, _range) with two arguments, but this PR adds window: bool to the trait (gpu.rs:471). The PR merges without a text conflict, but main with this PR doesn't build with DRM_ASAHI_G14_V27_2. Fix: update the branch to main and add _window: bool there (it returns ENOTSUPP either way).
  2. drivers/gpu/drm/asahi/timestamp.rs:70: Bound drops _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, through Deferred<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 the WindowShare into FirmwareBuffer, after mapping, 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.

@DjDeveloperr
DjDeveloperr dismissed stale reviews from themself November 24, 2026 19:02

Superseded by the review at 13f0a8a

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 33501d81: ready to merge

Check Detail
CI at head ok 19 checks passed
Review ok approved by DjDeveloperr
Requested changes ok none
Hardware row at head ok in the PR body at 33501d81
Conflicts ok none
PR text ok Risk: two-way · affects all AGX GPU families (file.rs shared bind accounting; commit 1 affects G17 host-written spillover; commit 3 and merge 33501d81b0a8 bound 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 returns ENOSPC on G13/G14, G14 v27.2, G15, and M3, where Mesa's binds are much smaller; G16, G18, and the M5 backend keep timestampwindowsize() == 0).

Areas: area:gpu
Merge: gh pr merge 2531 --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.

@funkzy
funkzy force-pushed the pr/asahi-timestamp-window branch from 13f0a8a to 008896a Compare November 24, 2026 21:49
@funkzy
funkzy requested review from a team as code owners November 24, 2026 21:49
@funkzy
funkzy requested review from LiamRay11 and malik-na November 24, 2026 21:49
@github-actions github-actions Bot added the needs-hw-row No hardware row at the PR head (bot) label Nov 24, 2026
@funkzy

funkzy commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review — addressed both blockers, re-ran the own-base J775D A/B row at the new head 008896a365e1, and updated the PR body to the What / Tested / Risk / Not yet format (zero AI attribution):

  1. drivers/gpu/drm/asahi/g14_v27_2.rs:1213: rebased onto main (50d1cd084c01, merges cleanly on 065904c137fa) and updated G14V27_2's map_timestamp_buffer() signature to take _window: crate::timestamp::WindowPermit (still returns Err(ENOTSUPP)).
  2. WindowShare release ordering (drivers/gpu/drm/asahi/timestamp.rs, file.rs, backends): moved _window_share: Option<memacct::WindowShare> into FirmwareBuffer as its last field (after mapping, cpu, and window) and passed timestamp::WindowPermit (Unrestricted | Share(WindowShare) | Denied) directly into Gpu::map_timestamp_buffer() / Buffer::firmware() / Buffer::firmware_window(). Because Rust drops struct fields in declaration order, mapping now always unmaps on aurora-ts-cleanup before _window_share drops and credits the file's quota back (and new_firmware() explicitly drops mapping before returning on timestamp_vmap() error as well). cleanup.rs keeps commit 2's HEAP_BYTES with no extra Deferred mutation method, so test-job-guard-release.py passes cleanly.
  3. Verification at exact head 008896a365e1:
    • J775D own-base A/B on bare main 065904c137fa (published Aura main f13056d95af6, 27.0 stub, default command line, ALARM has no SELinux): kit pr2531-r5v4 (window pr253031r7@20261124-1336) vs baseline kit pr2531-r5v4b (window pr253031r7@20261124-1336) — 4112 binds charged +152.0 B/bind (returning to baseline on close), client-limit test 107/256 then ENOMEM (exact expected 107 vs 256/256 uncharged on baseline), 256 x 256 MiB timestamp binds 256/256 at +0 MiB (vs 223/256 then ENOSPC), Vulkan timestamp CTS 1149 cases identical (345/78/54 + 648/24, 0 diffs), GL timer 30/30, render CTS subset 571/57/0, 0 GPU faults/recoveries, 2/2 baseline failed units, 0 new kernel errors (10 vs 11 baseline).
    • KUnit (kunit-vz arm64): 81 suites, 400/402 pass, 0 fail, 2 baseline skips (asahi_bound_object_charge 2/2, asahi_timestamp_buffer 2/2, asahi_g17_timestamp_window 2/2); 0 warnings in touched files.
    • Host tests (tools/asahi/run-host-tests.py): asahi-m4 ok (20.6 s), 0 regressions across all non-timeout runs.

@github-actions github-actions Bot added blast:all Macs affected, from Merge risk (bot) door:two-way Revertible or not, from Merge risk (bot) merge-conflict Conflicts with the base branch (bot) and removed needs-hw-row No hardware row at the PR head (bot) needs-template PR body lacks Tested or Risk (bot) labels Nov 24, 2026
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]>
@funkzy
funkzy requested a review from a team as a code owner November 25, 2026 05:27
@funkzy

funkzy commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Merged main (8b0a38328c94) cleanly into pr/asahi-timestamp-window at 33501d81b0a8 (no force push) and updated the PR body for the new head:

  • g14_v27_2.rs / gpu.rs: wired G14V27_2 to report its 64 MiB IOVA_G14_V27_2_TIMESTAMP_RANGE window via timestamp_window_size() and enforce WindowPermit in map_timestamp_buffer() (matching upstream main giving G14 v27.2 its own firmware timestamp aperture); verified 0 warnings in drivers/gpu/drm/asahi/ with all 8 backends including CONFIG_DRM_ASAHI_G14_V27_2=y compiled.
  • Deferred window-share release: already carried in 008896a365e1 (_window_share is the last field of FirmwareBuffer, released only after mapping unmaps on aurora-ts-cleanup).
  • Exact-head J775D own-base A/B (33501d81b0a8 on bare main 8b0a38328c94, published Aura 7bf44a6374af, 27.0 stub, kit pr2531-m6 vs baseline pr2531-m6b, window pr2531m6g@20261124-2040): 152.0 B/bind (161/256 then ENOMEM at client limit vs 256/256 uncharged), 256/256 256 MiB host-written timestamp binds at +0 MiB (vs 223/256 then ENOSPC), Vulkan timestamp CTS 1149 cases identical (0 diffs), GL timer 30/30, render CTS 571/57/0, 0 GPU faults/recoveries/oops, 2/2 baseline failed units, 0 new kernel errors (10 vs 10, ALARM has no SELinux).
  • Automated checks at 33501d81b0a8: kunit-vz 86 suites 436/440 pass, 0 fail (asahi_bound_object_charge 2/2, asahi_memacct 11/11, asahi_timestamp_buffer 2/2, asahi_g17_timestamp_window 2/2); run-host-tests.py 545/549 pass on both base and series (0 of 549 runs differ).

Ready for re-check, @DjDeveloperr.

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026

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

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.

@github-actions github-actions Bot added ready-to-merge Meets the merge policy: merge it (bot) and removed changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) ci-failing A check failed at the PR head (bot) labels Nov 25, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor

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.

@DjDeveloperr
DjDeveloperr merged commit 8a76aa1 into aurora-silicon:main Nov 25, 2026
22 of 24 checks passed
funkzy added a commit to funkzy/linux that referenced this pull request Nov 25, 2026
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]>
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) 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