Repository navigation
drm/asahi: g17: keep G17P work nodes and compute descriptors firmware-cached - #3186
Conversation
…-cached linux#3170 made every firmware-mutable pooled G17 object uncached after a J716c (T6050) compute queue record, rebound in place, had a dirty firmware line revert the host's owner fields. On the MacBook Neo (J700, A18 Pro) that made light submissions 20-30% slower, because the G17P firmware reads and updates these objects on every kick. In one boot, giving each family back its pre-linux#3170 cached prefix showed where the time goes (gpubench-vk, us per submission): family re-cached render.light queue d4 d8 d32 compute.light d4 none (main) 43.6 38.2 37.0 26.4 render queue records 41.9 36.3 34.6 26.5 work nodes 36.4 31.6 29.5 22.7 compute descriptors 43.9 38.2 36.5 24.5 compute graph 43.7 38.2 36.6 26.4 all of them (pre-linux#3170) 34.1 29.1 27.3 21.1 The host rewrites neither the work nodes nor the compute descriptors while the firmware may still be updating them: - It rewrites a work node only after WorkStorage::drained() has read the firmware's final completed count from memory, and zeroes a returned work state only once its pool fence is met. - It rewrites a compute descriptor slot only after the kick that last used it retired; at most DESCRIPTORS kicks are in flight. A test-only detector on J700 checked this while the full dEQP-VK.synchronization2.op.multi_queue.* family, render.light, compute.light and the compute CRCs ran. It read each work node back just before the host re-initialised it, and hashed each compute descriptor after the host wrote it and again just before the host rewrote it. With the cached mappings, across 1,151,688 node re-inits and 778,522 descriptor rewrites, no host-written word of a node was ever reverted. The firmware's stores to node lines 2-3 were already in memory at every re-init, and its stores near the end of a descriptor at 99.94% of rewrites: the same fractions as with the uncached mappings (1,007,416 and 700,934 checks). The CTS family passed 4266/0 in both modes. Objects the host rewrites in place while their queue may run keep linux#3170's uncached mappings everywhere: render queue records (retargeted, and bound to a work slot on every G17P render submission), the compute graph, and the M5 scheduler pages. M5 keeps all of linux#3170. On G17P, map the work-node page and the compute descriptor ring firmware-cached again, and pin the policy in tools/asahi/g17-object-fence-tests.py with four mutations. On origin/main 16da002, separate one-shot J700 boots, without and with this change: render.light queue d4/d8/d32 42.5/37.8/36.4 -> 35.9/31.2/29.4 us, queues d2/d4/d8 57.5/47.4/43.8 -> 52.5/42.2/38.4 us, compute.light d4 26.4 -> 21.3 us; the multi_queue CTS family 4266/0 three times, compute CRCs 5/5, offline Geekbench 6 Vulkan 8/8 with no validation errors, and no GPU fault, WARN or AVC. Signed-off-by: Diljit Singh <[email protected]>
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
|
J773g (M4 Mac mini, G16G) no-regression row at How it was run: two guarded one-shots on the default cmdline.
|
RyanTheTide
left a comment
There was a problem hiding this comment.
Verdict at 8fd602eb: MERGE.
Blockers: none.
Checked
- On G17P, only the work-node page (not the counter page the host writes every kick) and the compute descriptors become firmware-cached. M5 stays uncached (linux#3170). The no-rewrite-while-firmware-updates argument holds:
- nodes are rewritten only after
WorkStorage::drainedreads the finalcompletedcount, and zeroed only once the pool fence is met; - descriptor slots are rewritten only after the kick that used them has retired.
- nodes are rewritten only after
- The host-test cache-policy check pins all four choices, with four new mutations killed (224/224).
- Row: J700 at this head against main, the same day. Submit costs are back near the 7.3.0-41 level, sync2 multi_queue CTS is 4266/0 with 0 recoveries ×3, compute CRCs 5/5, GB6 Vulkan 8/8 ×2, and there are 0 GPU faults or timeouts. CI is green.
Nit: Risk names M4 Pro/Max as G17P. The M4 Pro in our lab reports G16S, so please check that wording.
Bring the branch up to date with main. main made the G17P compute descriptors firmware-cached (#3186); this branch maps them firmware-only. Keep both: cached on G17P as main does, firmware-only on every G17. Signed-off-by: Ryan Murray <[email protected]>
What: Map the G17P work-node page and the compute descriptor ring firmware-cached again.
tools/asahi/g17-object-fence-tests.pywith four mutations.Tested: J700 (A18 Pro, G17P), system Mesa
26.3.0-30, separate one-shot boots oforigin/main16da00248bc9without and with this commit (same change, rebased here onto61c7b88aca91). Results without → with:7.3.0-41dEQP-VK.synchronization2.op.multi_queue.*: 4266 Pass / 0 Fail / 0 recoveries, three times.python3 -I tools/asahi/run-host-tests.py --only g17224/224 at this head (main: 220; the 4 new mutations are all killed). 0 new warnings in the touched files.Risk: two-way door · G17P Macs (A18 Pro, M4 Pro/Max); M5 unchanged.
Not yet:
An M4 G16 row (J773g or J616s)Done: J773g PASS at8fd602ebb8b9(drm/asahi: g17: keep G17P work nodes and compute descriptors firmware-cached #3186 (comment)). The multi_queue CTS family faults G16 on the control boot too, so that is pre-existing.Details
Where the time goes
One J700 boot with a test-only debugfs knob (never for merge) that gives each #3170 family back its pre-#3170 cached prefix (µs/submit):
Why these two are safe to cache and queue records are not
set_ownerretargets them, and on G17Pbind_work_slotwrites+0x38on every render submission while the previous kick may still run. They stay uncached.WorkStorage::drained()has read the firmware's finalcompletedfrom memory, and zeroes a returned work state only after its pool fence.DESCRIPTORSkicks are in flight).Test-only detector (J700, never for merge)
The detector read every work node back just before the host re-initialised it. It also hashed every compute descriptor in 256-byte chunks right after the host wrote it and again just before the host rewrote it. Each mode ran the full multi_queue CTS family, render.light, compute.light and the CRCs:
+0xfacaccounting word). So G17P descriptors are not firmware-read-only. The safety argument is the ordering above, and with the cached mappings those stores are in memory at the same rate as uncached.