Skip to content

drm/asahi: keep timestamp buffers out of the shared firmware range, and cap bound objects per file - #2531

Open
funkzy wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
funkzy:pr/asahi-timestamp-window
Open

funkzy wants to merge 2 commits into
aurora-silicon:integration/aurorafrom
funkzy:pr/asahi-timestamp-window

Conversation

@funkzy

@funkzy funkzy commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Problem

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 gave the firmware that address: outside the window the host writes every stamp through the buffer's CPU mapping. So the mapping only held shared address space for as long as the buffer stayed bound, and the number of objects a file could bind was not limited.

Why this shape

  • Where the policy lived. Each GPU backend decides where a timestamp buffer goes in its own map_timestamp_buffer(). G13/G14 (gpu.rs), G15 and M3 give it a firmware mapping, because their firmware writes the stamps. G16 and G18 keep only a CPU mapping (Buffer::cpu), because the host writes them. The separate M5 backend (m5/, T8142) refuses timestamp buffers (ENOTSUPP), so only the slot reservation below is new there. G17 maps into the 64 MiB window when the buffer fits. Otherwise, and always on the G17 code's M5 firmware graph (uat.is_m5()), it mapped the buffer into the kernel VM's dynamic range instead, although the host writes those stamps and the firmware is never given that address. The number of bound objects had no limit anywhere: the per-file object table in file.rs, which every family shares, accepted any number of slots.
  • The narrower alternatives: a size or count limit on G17's dynamic-range timestamp mappings, or a larger window. Either would still spend firmware address space on buffers the firmware never reads, and would leave the object table unbounded on the other families.
  • The source used. A G17 buffer outside the window takes the host-written path, with a CPU mapping only, as G16 and G18 already do. The choice still turns on whether the window has room, not on the chip or firmware version. The cap is one limit, in the shared object table: a bind reserves its slot within the 4096 limit before anything is mapped. It is a count because what each bind keeps (its record and, for a timestamp buffer, a CPU mapping or window alias) is not charged to the client's memory limit.
  • What it gives. G17 buffers that fit the window, and every other family's placement, are unchanged. Non-M5 G17 buffers past a full window, and every timestamp buffer on the M5 graph, no longer take firmware address space. Every family refuses binds past 4096 per file with EBUSY.

Change

  1. Timestamp buffers outside the window take no firmware address space. Such a buffer gets only its CPU mapping, as G16 and G18 keep theirs. It refuses the same ranges and VM-private objects as before. Buffers mapped in the window, and every other GPU family, are unchanged.
  2. At most 4096 bound objects per file. A bind past that fails with EBUSY, the ID allocator's own error. The bind takes its table slot before it maps the buffer, so a refused bind gets no window alias or CPU mapping at all. The per-bind records are allocated with GFP_KERNEL_ACCOUNT. Mesa binds one small buffer per GL context, one per timestamped query pool and one debug buffer, so 4096 leaves room for hundreds of query pools. The object table is shared code, so this applies to every GPU family.

The host-written path is selected by whether the buffer fits the window, not by chip or firmware. Since RyanTheTide's review, the cap is checked before the mapping (second commit).

Testing

On this PR's own base (kit pr2531-1, baseline kit pr2531-1b): J775D (Mac Studio, M5 Ultra), 27.0 firmware, default command line, read-only root, one boot each. The kernel is integration/aurora b21dcc6 (its head when the kits were made) plus this PR and only what the board needs for a GPU: #1973, the J775D GPU node (integration has none for this board yet). The baseline is the same kernel without this PR. Boot loader: Aura main 3efa4a81 with aura#407 and aura#408, both since merged.

J775D, kits pr2531-1b and pr2531-1 without this PR with this PR
4112 binds of a 16 KiB object in one file 4112 accepted 4096 accepted, the 4097th EBUSY
256 binds of a 256 MiB timestamp buffer (64 GiB of ranges) 223 accepted, then ENOSPC 256 accepted, +0 MiB client and kernel memory
a second client's queue creation after those binds succeeds succeeds
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 / GL_TIME_ELAPSED (3 runs of 10 rounds) 30 of 30 rounds pass 30 of 30
render CTS subset (628) 571 Pass, 57 NotSupported the same
KUnit, per suite 76 suites, 375 of 377 pass, 2 skips 77 suites, 376 of 378, 2 skips; asahi_timestamp_buffer 1 of 1
GPU errors, recoveries, faults, oopses 0 0
failed units 2 the same 2
kernel error lines 9 8

Without this PR the 223 binds fill the kernel VM's dynamic range down to a remainder smaller than one 256 MiB bind; a queue's firmware objects are small and still fit there, so the second client's queue creation succeeds, while the next timestamp bind does not.

Regression run on those kits (ALARM has no SELinux, so there is no AVC count): 0 new failed units (iwd.service and systemd-networkd-persistent-storage.service fail on the read-only root in both boots) and 0 new GPU or kernel errors. The only kernel lines that differ between the two boots are USB enumeration retries, two in the boot without this PR and one in the boot with it, all before any test ran; the other 7 error lines are the same in both.

Not exercised here: the spill from a full 64 MiB window to the host-written path. The M5 Ultra has no timestamp window, so every timestamp bind on it takes the host-written path (the rows above), and filling the window needs a non-M5 G17.

Extra evidence, not this PR's own row: the same tests on 27.2 firmware and on the earlier stacked kernel, in the details below.

Still to run

  • A J616s or Neo on this head with the timestamp window held full: the window is one 64 MiB range per device, so one process holding more than 64 MiB of timestamp binds (for example five 16 MiB buffers, kept bound) sends every query pool created meanwhile to the host-written path. While it holds them: dEQP-VK.query_pool.*timestamp* and a GL GL_TIMESTAMP query test with the same results before and after, binds outside the window succeeding and their stamps read back monotonic, KUnit pass counts per suite, 0 failed units and 0 new kernel errors.
  • A G13 Mac (for example an M1 Pro) running the same timestamp tests, unchanged.
  • Rows from RyanTheTide's lab or the owners of those Macs welcome; the M5 Ultra takes the host path for every bind and has no window to fill.
Full description of the two commits
  1. Keep timestamp buffers out of the shared firmware range (G17). A buffer that does not fit the 64 MiB timestamp window is bound as timestamp::Buffer::Host: it keeps a CPU mapping of the bound range and no firmware alias. The host writes its stamps through that mapping (the only consumer is the G17 completion path, which takes object offsets). It refuses the same ranges and VM-private objects the alias did. The bound-range check is shared with Buffer::cpu and the VM-private test with gem::validate_vm_binding; a new KUnit suite, asahi_timestamp_buffer, tests the range check.
  2. Cap bound objects at 4096 per file. GEM_BIND_OBJECT reserves a slot in the file's object table (up to 4096) first, then maps the buffer, then fills the slot; a bind past the cap fails with EBUSY before any mapping exists, and a failed mapping releases the slot. The record, the buffer it names and the table's nodes are allocated with GFP_KERNEL_ACCOUNT.
Full test results

Own base, 27.0 firmware (kit pr2531-1: integration/aurora b21dcc6 + #1973 + this PR; baseline kit pr2531-1b: the same without this PR), Mac Studio (M5 Ultra), read-only root, one boot each, 2026-11-22:

  • Cap: 4112 binds of a 16 KiB object in one file. Without the PR all 4112 are accepted; with it 4096 are accepted and the 4097th is refused with EBUSY.
  • Timestamp buffers: 256 binds of a 256 MiB object (64 GiB of ranges). Without the PR 223 are accepted and the 224th fails with ENOSPC (the binds have filled the kernel VM's dynamic range); with it all 256 are accepted, with +0 MiB in the client's committed memory, the kernel's resident memory and the client's fdinfo. A second client's QUEUE_CREATE after the binds succeeds in both, and again after the binding file is closed.
  • Vulkan CTS timestamp cases: every case in the mustpass (vulkan-cts-1.4.7.1) whose name contains timestamp or calibrat, 1149 in all: pipeline.monolithic.timestamp (278), multiview.*queries*_and_timestamps* (144), wsi.*.present_timing (54), one API case, and the graphics timestamp groups of the other six pipeline variants (672). Both kernels: 1093 Pass, 2 Fail, 54 NotSupported, with the same two failures. The two failures are pipeline.monolithic.timestamp.misc_tests.timestamp_stage_top_of_pipe_stage and timestamp_stage_host_stage (the stage stamp reads 0.8-3.3 us before the preceding guard stamp), the same on both kernels, so they are not from this change. The 54 NotSupported are the present-timing cases, which need a window system the test boot lacks. This mustpass has no query_pool timestamp group: of its 19276 query_pool cases none names a timestamp, and deqp-vk --deqp-case='dEQP-VK.query_pool.*timestamp*' selects 0 cases.
  • GL: a small test of ours (offered on request), desktop GL 4.6 core on the asahi Gallium driver, EGL surfaceless: 64 counter bits for GL_TIME_ELAPSED and GL_TIMESTAMP; 10 rounds of a GL_TIME_ELAPSED query around 1 to 512 full-target triangles with GL_TIMESTAMP queries before and after. In every round the stamps increase and the elapsed time lies inside the two stamps' difference; 3 runs, 30 of 30 rounds pass on both kernels (512 triangles: 1.27-1.45 ms).
  • Render CTS subset (628 cases): 571 Pass, 57 NotSupported on both.
  • With the window held: another process holding 80 MiB of timestamp binds (five 16 MiB binds, the hold described under Still to run) while the timestamp CTS list of 477 cases and the GL test ran, then released: on the M5 Ultra this only checks the procedure, since it has no window. All 5 binds were accepted and released on both kernels, GL 30 of 30, and the CTS list gave the same results, except that one of the two stage-ordering cases passed in that run on the kernel with this PR (they fail intermittently).
  • Our own compute-timestamp check fails 0 of 10 rounds on both kernels: the same stage-stamp ordering as the two CTS failures, unrelated to this change.
  • KUnit: with the PR, 77 suites, 376 of 378 cases pass, 2 skipped (apple_g17_rx_util_min_test, which needs CONFIG_UCLAMP_TASK, and j713_accepts_all_loaded_images); without it 76 suites, 375 of 377, the same two skips. The one new suite is asahi_timestamp_buffer, 1 of 1; every other suite's counts are the same.
  • Kernel log and units: GPU client failures, recoveries, firmware restarts, timeouts, faults and WARN/BUG/Oops 0 in both boots. Kernel lines compared after removing timestamps and numbers: the only differences are the USB enumeration retries (9 error lines without the PR, 8 with it, 7 of them common). The failed units are iwd.service and systemd-networkd-persistent-storage.service in both boots.

Extra evidence, not this PR's own row: 27.2 firmware (kits o2531p and o2531b, on integration/aurora 61295c2, this branch's merge-base; boot loader Aura main 3efa4a81 with aura#407 and aura#408, both since merged). Besides #1973's binding and GPU node, these kits carry sithglan's #1650 (rolotrealanis98's #1173, the 27.2 firmware initialisation data) and two GPU-driver commits of ours that are not public yet and that the J775D needs on 27.2: 11b7aff60364 "drm/asahi: t6050: Run the Mac Studio's (M5 Ultra) GPU under the 27.2 boot stub: admit its 26B123 G17D firmware" and 2f4c1c6028c4 "drm/asahi: t6050: Give the M5 Ultra's 27.2 firmware the power-controller status config of its own 26B123 layout". With and without this PR: the same cap (4096 then EBUSY; 4112 without), timestamp-buffer (256 of 256 at +0 MiB; 223 then ENOSPC without), timestamp CTS (1093 Pass, 2 Fail, 54 NotSupported, identical case by case), GL (30 of 30), render CTS (571/57) and failed-unit results. The differences from the 27.0 rows: the two CTS failures' stamps were 0.5-1.9 us early (0.8-3.3 us on 27.0); KUnit had fewer suites on this older base, 73 suites and 354 of 356 with the PR against 72 and 353 of 355 without (the PR adds the same one suite); and the boot with this PR logged one USB enumeration retry at 6 s, before any test.

Extra evidence, stacked kernel (kit rr21r, the earlier row: integration/aurora cc14570 + the appledrm fix since merged as #2733 + #1973 + #2530 + this PR + #2501 + #2520, 27.0 firmware; baseline cc14570 + the appledrm fix + #1973): cap 4096 of 4112 then EBUSY; 256 of 256 timestamp binds at +0 MiB, a second client's QUEUE_CREATE succeeding before and after close; render CTS subset 571 Pass, 57 NotSupported with and without the series; KUnit 79 suites, 366 of 368, against 75 suites and 353 of 355; host tests 436 of 436 on base and head; no new error line beyond the intended ENOMEM refusals of #2501's render tests in the same boot.

Thanks to ewb, who reported the unbounded binds and suggested the fix, and to RyanTheTide for the review.

  • Clean-room: no Apple code, strings, firmware, RE output or tuning values
  • No chip/board/firmware-version gate where a hardware property can decide
  • Works on the default kernel command line; no hacks, delays or lab-only paths
  • Safety limits come from the machine, not from constants in code
  • Hardware safety rules followed for every test boot
  • Third-party commits unchanged; reporters and testers credited
  • Commits: human Signed-off-by only; no co-author or Assisted-by trailers
  • Tested on the affected hardware; no regression (M5 Ultra, host-written path; the non-M5 G17 window spill and a G13 row are under Still to run)

Assisted-by: LLM (Claude:Opus 5.5)

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

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 <erik@ebourget.net>
Suggested-by: Erik Bourget <erik@ebourget.net>
Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
…bounded

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. Each record is
a small kernel allocation that is not charged to the client's memory
limit, and a timestamp buffer also keeps a CPU mapping of its backing
for as long as it is bound.

Refuse a bind past 4096 objects in one file with EBUSY, as the table's
allocator reports a full range. The bind takes its table slot before it
maps the buffer, so a refused bind gets no window alias or CPU mapping
at all. Mesa binds one object per GL context, one per timestamped query
pool and one debug buffer, so 4096 leaves room for hundreds of pools.

Allocate the record, the buffer it names and the table's nodes with
GFP_KERNEL_ACCOUNT, so they count towards the memory cgroup of the task
that binds.

This applies to every GPU family and to every GEM_BIND_OBJECT usage: the
table is shared code.

Reported-by: Erik Bourget <erik@ebourget.net>
Suggested-by: Erik Bourget <erik@ebourget.net>
Suggested-by: Ryan Murray <ryan@aurorasilicon.org>
Signed-off-by: Jeff Queisser <funkzy@users.noreply.github.com>
@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.

Assisted-by: LLM (Gemini 4 Neon)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants