Repository navigation
drm/asahi: g18: end a render at once when its parameter buffer growth is refused - #2758
Conversation
|
Reviewed the last commit (4db28d0). Thanks for doing this so quickly. The control flow is right. One case to check before merge: the flag is also set for The commit message could also say that the refused client's render ends with EIO and the client sees it on its next submit, as the description says. Assisted-by: LLM (Claude:Opus 5.5) |
The G18 render path backs the tiler's parameter buffer with 8 blocks (4 MiB) and never grows it. When a scene needs more, the firmware posts event type 6, a TVB grow request in the M5 TvbGrowEventRecord layout, and the tiler waits for the host. Nothing answered, so the frame stalled until the 10 s job watchdog requested a recovery, and the client's submit failed with EIO. Zooming into Google Maps in Firefox or Chromium on the J873 (M6 Mac mini) hits this. Answer the request as the M5 driver does for a firmware-requested growth (Manager::commit_growth without a descriptor): back 16 more blocks as one object, write their first page numbers into the block table at the ring slots after the total cursor, advance total and committed, and reply with a TvbGrowReply (device-control opcode 8, grew = 1) plus the 0x84/0x11 control doorbell. The firmware builds the page-list entries itself. A "not grown" reply leaves the tiler stalled, so it is only sent when growth fails or the buffer is at its limit. The PB grows to at most 254 blocks (127 MiB): the block table before the shared header holds 256 ring slots. The graphics-pb VA window grows from 16 to 128 MiB for that; its biased half stays inside the COMPACT_BIAS + [32 MiB, 2 GiB) that Mesa leaves to the kernel. The new blocks are homed in the PB's storage VM like the initial ones and are aliased into the running client's VM; a later client maps every block. Two per-frame checks assumed the PB and the control ring never change: the PB row's page count may now grow up to the backed blocks, and the outer-ring publication expects the primary control ring past the grow replies published since boot. A headless GLES test drawing N triangles of about 200 px into 2560x1440 stalled at 60000 triangles before. Now 150000 and 600000 triangles grow the PB on their first frame and render in 10 and 44 ms afterwards; the images match llvmpipe apart from single edge pixels, as small scenes do. One million triangles reach the limit and still stall. Two clients alternating 600000-triangle frames render all frames. Tiny frames of two alternating clients take the same time with an 8-block and a 254-block PB (2.66-2.88 s vs 2.71-2.77 s for 2x2000 frames). Zooming into Google Maps in Firefox now grows the PB to 40 blocks (20 MiB) without a stall. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
…e is given The PB's ring is described to the firmware with PB_CAPACITY (1650) slots, but growth stopped at 254 blocks, because the block table in front of the shared header held 256 entries. A scene that needs more than 127 MiB of PB, about 1.1M triangles of the headless test, made the firmware ask again after a refused grow and then wait until the job watchdog: a 10 s stall and EIO, as before the growth support. Telling the firmware a lower maximum (state +0x7c) changed nothing; it does not render partially there. Make room for the whole ring instead. The block table stays at the start of the PM graph and holds PB_CAPACITY entries; the shared header, the counter and the scene records move up behind it (0x3400, 0x3500, 0x4000). Placing the table behind the scene records, at +0x8000 of a larger graph, faulted the first frame. PB_MAX_BLOCKS follows PB_CAPACITY, and the graphics-pb window grows to 832 MiB to hold that many blocks, still inside the COMPACT_BIAS + [32 MiB, 2 GiB) range Mesa leaves to the kernel. The job's ring capacity now comes from PB_CAPACITY rather than a second 1650. The PB is retained with the session, as before: a scene that grows it to N blocks keeps N * 512 KiB allocated. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
A PB growth was a kernel object: the device and per-client memory limits never applied to it, and its bytes were counted as nobody's. The PB lives with the session and is shared by later clients, so one client drawing a large scene could pin up to 1649 blocks (about 824 MiB) until reboot. Admit each growth against the requesting client's limit and the device limit first, as g17 admits its pools, and keep the blocks as that client's held memory (a user charge on a kernel object). A refused admission fails the growth with ENOMEM: the firmware gets "not grown", and only the render that asked fails, as at the block limit. A growth with no client to charge is refused the same way, so nothing grows unadmitted. The G18 driver's probe never configured the limits (memacct's configure() ran only in the other generations' probe), so on the J873 both read 0, "none", and nothing could be refused. Configure them there too. That applies the limits to every G18 GEM allocation, not only to PB growth: at the limit, GEM_CREATE fails with ENOMEM as it does on the other generations. Grown blocks are not given back. The firmware's ring is only ever extended: it asks with event 6, and the host answers by writing the new table slots and advancing total and committed. No message is known that makes the firmware drop blocks it was given. Lowering total behind its back would take away slots it may still hold, so until such a message is found the grown blocks stay with the session, held by the client that grew them. The limits bound how much that can be. The ring keeps one slot empty to tell a full ring from an empty one, so PB_MAX_BLOCKS is PB_CAPACITY - 1. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The parameter buffer growth code added to this file in the previous commits kept several statements per line, like the rest of the file. Format the whole file with rustfmt (the tree's .rustfmt.toml), so the next change to it can be read and reviewed line by line. No functional change; rustfmt --check passes and the driver builds with the same warnings as before. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
4db28d0 to
519f007
Compare
|
@RyanTheTide rebased with #2242 onto integration/aurora
Ring limit (
The row needs the J873g's GPU module swapped, and that Mac is in use right now. I'll run it when it's free and post the result. If the render completes there, I'll limit the recovery to the memory-limit refusal, as you suggest. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Adversarial review of top commit 519f007e7f0e (stacked on #2242) against the pre-PR checklist.
0 code/policy/attribution/CI blockers. Holding only for prerequisite #2242 and the remaining §5 hardware rows on live head 519f007e7f0e.
Verified
- §1–§3 (Control flow & safety):
growth_refusedis cleared atwait_job()entry, stale-epoch grow requests return before setting it, andelse if core::mem::take(&mut self.growth_refused)sits behindif let Some(ended) = recoveryso a refusal during an active recovery cannot stack another recovery. - Note to watch during stress testing (non-blocking):
wait_job()triggersself.recover(label, true)immediately on the same poll iteration afteranswer_tvb_grow()publishesTvbGrowReply(..., false)+CONTROL_NOTIFYonEP_GFX_INTERRUPTS(incrementingcontrol_published). Because subsequent submissions checkcontrol_counters() == control_retired()(initdata/application.rs:40), this relies on GFX firmware consuming theTvbGrowReplybefore/during recovery in FIFO order onEP_GFX_INTERRUPTS. Your 6000-frame J873g run confirms that held in practice, but it's worth verifying across the ring-limit test too. - §4 (Clean-room & attribution): Clean across all 5 commits in the branch (
Thomas Glanzmannhuman author/committer +Signed-off-by:only, zero AI trailers in commits;Assisted-by:in PR body). - §6 (Naming) & CI: Clean;
host-testspassed on519f007e7f0e.
Remaining prerequisites & §5 hardware rows needed for approval
- Stacking prerequisite:
#2242(whose 4 commits are carried in this PR targetingintegration/aurora) must land first. - J873g
Ok(0)PB ring-limit row (> PB_MAX_BLOCKS, ~7.5M triangles on#2242alone vs#2758): settle whether firmware stalls until the watchdog or completes partially at the ring limit (as noted by@RyanTheTideand already queued); if it completes partially, narrowgrowth_refusedto memory-limit/error refusals only. - Post-rebase verification + §5 regression row on
519f007e7f0e: re-verify after theG18Sessionconflict resolution with#1652, including explicit §5 regression counts (0 SELinux denials, 0 failed units, 0 new kernel errors).
Assisted-by: LLM (Gemini 4 Neon)
|
@RyanTheTide the ring-limit row ( Setup. J873g, kernel
Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Upgrading to APPROVE at live head 519f007e7f0e4c1bb1b2f75c1b47fc0f90daeb60 after the newly posted J873g ring-limit and regression rows (#issuecomment-7077031525).
§5 Hardware Verification Now Complete (519f007e7f0e)
- Ring-limit (
Ok(0)) A/B on J873g (8M & 10M triangles,> 1648-block ring): With#2242alone, 22/22 refused renders stalled (G18_APP_PB_STALLat 5 s) until the 10 s watchdog (~102 s/run, 0 completed, pixel00000000), confirming firmware never partially completes at the ring limit. With#2758, 4/4 ended viaG18_GROW_REFUSED ... ms=112with recovery in 4–8 ms (0 stalls, 0 watchdogs, ~1 s/run) — confirminggrowth_refusedis right to coverOk(0)as well as memory-limit refusals. TvbGrowReply+ immediate recovery FIFO ordering: Held across all 4 ring-limit refusals and subsequent clients (drawbench,mesa#622vertex-output checks) on the same boot with 0 job failures.- Regression counts:
0failed units,0AVC denials,0job failures (alongside the default-limits row: 71 grows to 1144 blocks, 0 refusals, 0 watchdogs).
Checklist & Merge Ordering
- §1–§6 & CI: All checks pass;
host-testsisCOMPLETED / SUCCESSon519f007e7f0e; all 5 commits carry human author/committer and humanSigned-off-by:only. - Stacking note: Merge after (or together with) already-approved prerequisite
#2242(c48d68d78dff, currentlyOPENand approved by@RyanTheTide).
Assisted-by: LLM (Gemini 4 Neon)
|
Merge-train adversarial review (MERGETRAIN-LINUX3) at 519f007, together with #2242 (c48d68d, which is an ancestor of this head): NO BLOCKERS for either. Both merge cleanly onto integration. The train merges #2758 on Dj's APPROVE, and that lands #2242's commits with it. Notes:
|
…rol ring reply_tvb_grow() placed the TvbGrowReply at the 26A428 control ring offset, a fixed constant. The shared-memory layout is per firmware build since the InitData profiles, and the IdlePowerOff record next to it already takes the ring from self.layouts. With 26B123, which the J873g loads today, the reply went to the wrong place: the tiler waited for it and every render that needed a second parameter buffer block stalled until the watchdog. Take the ring from the admitted profile, as IdlePowerOff does. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
… is refused When a TVB grow request is answered "not grown" (the client is at its memory limit, or the PB is at its ring limit), the tiler that asked stays stalled. The render then ended only when the 10 s job watchdog requested a recovery. Jobs run one at a time, so every other client waited out each of those stalls too: in the refusal row of the parameter buffer growth change, a 20000-triangle client next to a refused 5M-triangle scene averaged 65 fps over 92 s instead of about 490. Remember a refused answer in the session, and have wait_job() request the recovery on its next poll, the same recovery the watchdog would request. The refused render fails with EIO as before, only now within milliseconds; its client sees the error on its next submit. A growth that succeeds, or a request from before the current recovery epoch, changes nothing. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
519f007 to
61f7b3d
Compare
|
@RyanTheTide @DjDeveloperr both notes, and the smoke found a real bug, so the heads moved:
The smoke on the merged tip.
Same smoke with the fix (asyncbench, frames/s):
The nit: the grow-request queue. New last commit in #2758, "answer a repeated grow request once, keep the rest in the ring":
Both heads build (arm64, LLVM 22) and checkpatch Assisted-by: LLM (Claude:Opus 5.5) |
|
Merge-train re-review (MERGETRAIN-LINUX3) at 61f7b3d, which includes #2242 at 83ccd92: NO BLOCKERS. Against 519f007 the tree delta is one file, g18/initdata/mod.rs:
Nit, not blocking: while a grow record is held, any completion-stamp events behind it in the same ring also wait for the next drain. That is fine as long as answering the queued grows always leads to another drain. If the session only drains on a new interrupt, the comment could say what guarantees that next drain. Dj's earlier APPROVE was at 519f007. The train merges this head once Dj approves it. |
… the ring The drain held at most four grow requests until the session answered them. A fifth one in the same pass failed the drain with EBUSY before the session could answer any of them, and since every later drain met the same full queue, the device could not recover until a reboot. An identical request that is already queued is now dropped, as G17's queue_tvb_grow() does, so the firmware repeating a request gets one reply. A new request that finds the queue full stays in the event ring: the drain stops for that ring, the session answers the queued ones, and the next drain takes it. Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
61f7b3d to
37631b5
Compare
|
@RyanTheTide on the nit: the session drains on every poll of its waits, not on an interrupt. Assisted-by: LLM (Claude:Opus 5.5) |
DjDeveloperr
left a comment
There was a problem hiding this comment.
Re-reviewed live head 37631b53dbe49b3c0d04061a76520c5587787a26 against 519f007e and the pre-PR checklist (§1–§6). READY TO MERGE (cleared for MERGETRAIN-LINUX3).
Verified
- Delta
519f007e..37631b53dbe4(drivers/gpu/drm/asahi/g18/initdata/mod.rs):reply_tvb_grow()now writes intoself.layouts.shared.control_ring[0](matchingpublish_idle_wake()) instead of the fixed 26A428 offset, fixing the 26B123 control-ring mismatch caught by the merged-tip smoke.drain_reports()deduplicates repeated identicalG18TvbGrowRequestentries and breaks before advancingreport_countsor the ring consumer cursor whenself.tvb_grow.len() >= TVB_GROW_QUEUE, so overflow leaves the record in the ring for the next poll (poll_faults()/check_faults()) instead of poisoning subsequent drains withEBUSY. The comment-only update from61f7b3d3to37631b53dbe4accurately documents the polling guarantee.
- §4 Commit hygiene: All 7 commits carry human author/committer (
Thomas Glanzmann <thomas@glanzmann.de>) andSigned-off-by:, with zero AI commit trailers. - §5 Hardware evidence: Merged-tip J873g (26B123) smoke on
integration/aurorad1b022dc34fb+#1797+#2758passes 200/20k/1M/5M triangles (PB grew in 103 steps to 1649 blocks,err=0) and ends 8M triangles cleanly at the ring limit viaG18_GROW_REFUSED ... ms=144->EIO(0 watchdogs, 0 failed units), in addition to the prior memory-limit and ring-limit A/B rows. - CI:
Host tests/host-testsgreen.
Assisted-by: LLM (Gemini 4 Neon)
5f1a255
into
aurora-silicon:integration/aurora
Stacked on #2242 (parameter buffer growth). Review the last commit.
This is the follow-up from Ryan's review of #2242. A TVB grow request can be answered "not grown": either the client is at its memory limit, or the PB is at its ring limit. The tiler that asked then stays stalled, and the render ended only when the 10 s job watchdog requested a recovery. Jobs run one at a time, so every other client sat through each of those stalls too.
The session now remembers a "not grown" answer.
wait_job()requests the recovery on its next poll, the same recovery the watchdog would request. The refused render still fails with EIO, but within milliseconds. A successful growth, or a stale request from before the current recovery epoch, changes nothing.Tests (M6 Mac mini, J873g). As in #2242's rows, the code was ported onto the J873 desktop tree, kernel 7.3.0-aurora-j873-avd-usb4-perf+.
client_mem_limit_pct=3, a 5M-triangle scene next to a 20k clientG18_GROW_REFUSED ... ms=28andms=15, each followed by a recovery done in 5.4 ms; 0 watchdogs; the 20k client runs 6000 frames in 12.1 s (494 fps), err=0drivers/gpu/drm/asahi/builds with the same warnings as before, all in other files.cc @DjDeveloperr @RyanTheTide @Acelogic @LiamRay10
Assisted-by: LLM (Claude:Opus 5.5)