Skip to content

drm/asahi: G14 compute on GPU firmware 27.2 - #2544

Open
satchlj wants to merge 10 commits into
satchlj/g14-v27-2-sharedfrom
satchlj/g14-v27-2-compute
Open

satchlj wants to merge 10 commits into
satchlj/g14-v27-2-sharedfrom
satchlj/g14-v27-2-compute

Conversation

@satchlj

@satchlj satchlj commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Claude Opus 5.5 on @satchlj's behalf.

Second of three PRs that replace #2473: the compute backend as the G14 firmware-27.2 path. It builds on #2543. #2545 removes its build dependency on CONFIG_DRM_ASAHI_M3_T8122.

Selection. A G14G GPU (apple,agx-t8112, the existing T8112 configuration) whose DT apple,firmware-version is 27.2.0 takes this path in probe, before anything starts the coprocessor. There is no board name and no extra compatible. Other firmware versions keep the existing code.

What changes

  • fw/initdata.rs, rust/macros/versions.rs: raw InitData and HwDataB gain a V27_2 layout. A new AGX_V27_2 version group instantiates only those two types for G14/V27_2. Compile-time checks pin the 27.2 offsets against 13.5. GpuManager and the other versioned types are unchanged.
  • gpu/v27_2.rs: the 27.2 root. It is built on the records of a 13.5 G14 manager (GpuManager::build_graph with GraphProfile::G14V27_2: no register mappings, and the private range stays below the 27.2 timestamp aperture). It holds the hardware data from the 13.5 values, the chip's 27.2 register table (hw/t8112.rs), the power and thermal controller, the two idle-policy records, and one queue with a kernel-owned boot compute job. The firmware never sees the 13.5 root.
  • g14_v27_2.rs: start sequence, runtime and DRM backend. It mirrors the kernel window into the loader's shared second-level table and names it in TTBAT context 0 (mmu::FirmwareWindow). It then starts the ASC, sends the root, holds the GPU powered and retires the boot job. Clients submit through the 26.x front end (m3_submit). Each compute command is encoded in the 27.2 layout from a 48-slot pool and published in order on the root's queue. The runtime runs from the firmware's endpoint-0x20 messages, which it sends after publishing event, statistics or log records: each one queues a run of the service, which consumes the event, statistics, log and trace rings (the firmware waits when one is full) and retires completed commands. Completion follows the queue's retired position, which the firmware advances in order. There is no poll or timer; the DRM scheduler's job timeout runs the service as the backstop for a hung command. Each command goes into the next of 48 pool slots that is neither in flight nor still held by the firmware (tracking +0x94). The scheduler has one run queue per priority. Render commands get EINVAL. Unbind lets published work retire, detaches the message route, drains the service's workqueue, then stops the firmware (allow-off, RTKit power-off if it is still running, ASC halt) and keeps its memory for the rest of the boot.
  • Smaller pieces: CrashLog::from_firmware, GpuArray::shared_index, EventManager::try_get_polled, the Fender operating-point read, rtkit_dump.c (crash log to devcoredump), and the G14 skip of the 26.x CDM launch check, which decodes the G15 launch format.

Against #2473

Tested, this head (f890a9c9, slot-cursor fix) on phellos (J413, firmware 27.2), the up3 default kernel (7.3.0-1-up3-ARCH), this branch's module built against it (through #2545), loaded with no parameters under the same watchdog arrangement, trials h1–h8: 8/8 PASS. Each ran 3 × 1024 and 300 × 4096 words, every word checked, 303 of 303 dispatches; "GPU stopped: allow-off=Ok(()) running=Ok(0) forced-off=None submitted=303 completed=303 notifications=307 late=0 skipped-slots=0 deferred-cursors=45…48"; clean rmmod; unattended return. Cause and bisect are in the PR comment of 2026-11-20.

Tested, previous head (9454ef44, review rework) on phellos, J413 with firmware 27.2, the up2 default kernel (integration/aurora 458f759 + open PRs; this module built from the #2545 head over it), loaded with no parameters under the same watchdog arrangement, trial d8: PASS (later, on the up3 kernel, this head passed only 2 of 7 boots: the pool-slot cursor race fixed by f890a9c), 3 × 1024 and 300 × 4096 words, every word checked, 303 of 303 dispatches; "GPU stopped: allow-off=Ok(()) running=Ok(0) forced-off=None submitted=303 completed=303 notifications=307 late=0 skipped-slots=11945"; clean rmmod; unattended return to the default. The 300 dispatches took 77 ms (6.3 s with the old 20 ms idle poll). Start takes about 5 ms instead of 1.5 s.

Tested, earlier heads on phellos, a J413 (M2 MacBook Air) with firmware 27.2. The packaged default kernel (integration/aurora 61295c2 + open PRs) loaded this PR's module with no parameters, under a watchdog with unattended return:

  • trial c3, this head (module built in the distribution's default config, which has DRM_ASAHI_G15 and DRM_ASAHI_M3_T8122): PASS, 303 of 303 dispatches, 0 bad words; normal stop; clean rmmod; return to the default;
  • trial c1, this PR before a cfg-only change (gating unused helpers): the same.
    Each trial ran Vulkan compute through Mesa's Borealis driver: 3 × 1024 and 300 × 4096 words, data[i] = data[i]*mul + add + i, every word checked on the CPU after each dispatch. That is 303 dispatches, past the 256-entry submission ring. Then a normal stop (allow-off acknowledged, firmware reported off, no forced power-off) and a clean rmmod.

The boot loader on those trials was a trial Stage 2 that publishes the GPU on 27.2. Its DTB names the GPU apple,agx-t8112-identify, apple,agx-t8112; the first compatible is the loader's own trigger. The Aura in phellos's default (main + aura#381) leaves the GPU disabled on 27.2, so this path needs an Aura change before it runs on a default install. That change is not part of this series.

Waits that remain. Each is a bounded check of a word the firmware writes and sends no message for: the loader's handoff answer, the ready status (+0x14), the command-handler installation (+0x4c24 cleared), the idle-policy acknowledgement and the running flag at stop (the existing G14 path waits for its device-control channel the same way), and, after a notification, at most 2 ms for the retired position when the completion stamp is already there (never needed in the trials: late=0). The stop line reports the notifications received, those waits, and how many held slots were passed over.

Untested

  • Render (refused), and performance above the first operating point: globals +0x98 caps the state at 100, as in every trial.
  • Other G14G machines, other 27.2 builds, and firmware other than 27.2.
  • More than one client at a time, and runs much longer than 303 dispatches.
  • All 48 pool slots held at once (then the next notification, submission or scheduler timeout publishes; nothing else wakes it). Why the firmware keeps retired slots linked, and links some again after releasing them, is not known.
  • Rebind after unbind (the window stays installed, so a second probe gets EBUSY), suspend, and GPU fault recovery.
  • An Aura that publishes the GPU without the -identify compatible.

Assisted-by: LLM (Anthropic:Claude Opus 5.5)

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: hardware run.

PR head Checked Result
650176f1 Stacked series in the default kernel (CONFIG_DRM_ASAHI_G14_V27_2=y). Default loader leaves the GPU disabled; one-shot with a trial loader that publishes it: insmod with no parameters, Vulkan compute 3 × 1024 + 300 × 4096 words, every word checked on the CPU, "GPU stopped: … submitted=303 completed=303", rmmod clean. Render not tested Pass, 303/303

Build: phellos (MacBook Air M2, J413, macOS 27.2 / 26B123 stub), default rebuilt 2026-11-20 = linux integration/aurora 458f759 + #2519 #1832 #1831 #2264 #2525 #2526 #2543 #2544 #2545; Aura main 0beafec9 + aurora-silicon/aura#377 aurora-silicon/aura#227 (isp.c only) aurora-silicon/aura#381 aurora-silicon/aura#382; U-Boot aurora-wip 37baf8f7 + aurora-silicon/u-boot#67; Stage 2 DTB t8112-j413-fw27.dtb. One-shot boot under the SoC watchdog, then made the default (two default boots healthy).

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the split. This step drops all the module parameters and the timed re-kick, and selects the path by G14G plus apple,firmware-version 27.2, which is what we hoped for.

One point is left. We avoid sleep/poll loops where the firmware gives a signal:

  • g14_v27_2.rs:48-49 and :285-291: completion and ring draining run from delayed work every 1 ms while busy and every 20 ms forever when idle, while recv_message (:111) drops every message on endpoints 0x20/0x21.
  • :214 waits a fixed 1 s for initialization to "settle", and :217 ignores the timeout of the command-service wait.
  • :482-495 stops the poll work with fsleep loops and a fixed 20 ms sleep instead of cancelling and flushing it.

Could completion and ring service run from the firmware's endpoint messages (as the existing G14 path does), with the idle poll gone, and cancel_delayed_work_sync in stop? If 27.2 really sends nothing, a code comment saying so would cover it. We will run rows on our M2 (G14G) as each step lands.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

@RyanTheTide: done in 9454ef44 (new commit, plus a merge of #2543's new head). The firmware does give a signal: on 27.2 it sends endpoint 0x20 a message after it publishes event, statistics or log records.

  • :48-49, :285-291 and :111. recv_message on 0x20 now queues one run of the service on its own ordered workqueue. Each run drains every ring, reads the retired position and publishes pending work. The delayed work, the 1 ms busy re-run and the 20 ms idle poll are gone, and there is no timer. As a backstop for a command the firmware never completes, the DRM scheduler's job timeout queues a service run, which reaches the existing 5 s command timeout. A firmware crash queues one too.
  • :214. The fixed 1 s "settle" is replaced by the firmware's ready word (status +0x14), bounded at 2 s, failing on timeout.
  • :217. The timeout is now an error. Making it one showed that the old condition (+0x4c00, +0x4c24) == (2, 0) never held once the handlers were installed: the old start always ran out the 500 ms. Installation is acknowledged by the firmware clearing +0x4c24, so that is the only condition now. Start takes about 5 ms instead of 1.5 s. A failed start names the step.
  • :482-495. stop now does three things in order. It waits on a condition variable that the service signals when nothing is pending or published, up to 2 s. It detaches the message route, so nothing can queue more work. Then it drains the workqueue. The fsleep loops, the queued counter and the 20 ms sleep are gone. The Rust workqueue binding has no cancel_delayed_work_sync, and since there is no delayed work any more, the owned queue's drain is the equivalent.
  • Waits that remain. Each is bounded and checks a word the firmware writes without sending a message: the loader handoff answer, the ready status, the +0x4c24 clear, the idle-policy acknowledgement and the running flag at stop. The existing G14 path waits for its device-control channel the same way (TxChannel::wait_for). There is also one wait after a notification, at most 2 ms, for the retired position when the completion stamp is already written. It never ran in the trials.

One finding the old poll had hidden. With completion now sub-millisecond, the fixed round-robin over the 48 pool slots stopped at the first reuse: the firmware kept the retired command's tracking slot (+0x94) linked indefinitely, and a diagnostic run showed it linking slot 0 again after releasing it. Pump now takes the next slot that is neither in flight nor held. If all 48 were held, it kicks the retirement scan once and the next notification, submission or scheduler timeout retries. I don't know why the firmware holds slots this way; the PR body says so.

Head Check Result
7fcd6e20 (#2545 head, contains this one), module built against phellos's up2 default kernel phellos (J413, firmware 27.2), loaded with no parameters, watchdog-protected one-shot boot (trial d8): Vulkan compute 3 × 1024 + 300 × 4096 words, every word checked on the CPU PASS, 303/303. GPU stopped: allow-off=Ok(()) running=Ok(0) forced-off=None submitted=303 completed=303 notifications=307 late=0 skipped-slots=11945, clean rmmod, unattended return. 300 dispatches in 77 ms (6.3 s before)
same arm64 module build: up2 config (G15, M3_T8122, G14_V27_2 on), and G14_V27_2 without M3_T8122 OK, no warnings on lines this stack touches
same asahi-m4 run-host-tests.py (Linux), m3-runtime-tests.rs 23/23, 83/83

Trials d1–d7 were the failures that led here: the never-satisfied command-service condition (d1), then the held-slot stall at command 48 (d2–d7, including the diagnostic run). Each one stopped the firmware cleanly and returned unattended.

Untested: everything in the body's Untested list, and in particular all 48 slots held at once, concurrent clients, and runs much longer than 303 dispatches.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for 9454ef4, it covers what we asked:

  • service now runs on endpoint 0x20's messages, with the scheduler timeout as the backstop;
  • the ready word and the +0x4c24 clear replace the fixed settle, and their timeouts are real errors;
  • stop drains the queue.

The waits that remain are bounded, poll words the firmware writes without sending a message, and say so in a comment. That's fine. The held tracking-slot finding is worth keeping in the description, as you did.

We'll run rows on our M2 (J413, 27.2) on this head: compute workloads, rmmod and reload, and one s2idle cycle.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

New commit f890a9c on this branch fixes a pool-slot stall in the notification rework (9454ef4). #2545 has it merged as 6c5d3db.

Symptom. On phellos (J413, firmware 27.2) the 300 × 4096 compute check stalled at the first pool wrap on most boots. Every slot was still linked (+0x94), so the 49th command was never published: submitted=48 completed=48 skipped-slots=480, then a clean stop. 3 × 1024 always passed.

Bisect. The asahi tree of the up2 trial that passed (d8) is byte-identical to this branch, so the base kernel was not the cause.

  • This branch's asahi tree on the older base (458f759), built against the up3 kernel: 0/2. One of the two was a timeout variant, a command that never completed.
  • The pre-rework heads (650176f / 7375638) against the up3 kernel: 3/4.
  • This head (9454ef4) against the up3 kernel, with a 1.5 s settle added before the boot job: 1/4. So start timing is not the cause.
  • Earlier: 2/7 on the up3 default (e1–e4, c6–c8). Every rework build before d8 (d2–d7, up2 kernel) stalled at the first reuse.

Cause. Dumps of the 48 tracking slots and the queue's timestamp queue at the wrap (diagnostic module, 7 runs):

  • The firmware links the slots LIFO into the queue's list: +0x98 next, +0xa0 the previous entry's next field. Each slot's +0xc reads 1.
  • Every slot's retirement cursor reads 0.
  • In the 5 failing runs, no slot was unlinked. In the 2 passing runs, exactly one slot had cursor 1, and it was the one slot the firmware had unlinked. The pool then reused that slot for the whole run, which is why the passing runs show skipped-slots near 47 per command.

The firmware writes +0xc in its post-processing, which can run after the queue's retired position advances. retire() ran on the first notification after the position moved, read +0xc as 0, and wrote 0 to the cursor, so the slot was never unlinked. The old 1 ms / 20 ms poll retired later and usually missed this window (3/4 here, 5/5 in c1–c5).

Fix. CommandPool::retire advances the cursor only once +0xc is recorded, and returns whether it did. A slot retired too early goes into a pending set. acknowledge() advances its cursor the next time the service runs: on the firmware's next notification, a submission or the scheduler timeout. There is no fixed wait or poll. Slot selection still skips slots that are still linked. The stop line now reports deferred-cursors.

Tested on hardware. phellos (J413, macOS 27.2 stub 26B123), up3 default kernel 7.3.0-1-up3-ARCH, this branch's module built against it, loaded with no parameters, trial loader gpu-up1-loader.bin, watchdog-protected one-shots with unattended return. Trials h1–h8: 8/8 PASS. Each ran 3 × 1024 and then 300 × 4096, every word checked on the CPU, 303/303 dispatches. Every run ended GPU stopped: allow-off=Ok(()) running=Ok(0) forced-off=None submitted=303 completed=303 notifications=307 late=0 skipped-slots=0 deferred-cursors=45…48, with a clean rmmod and the return to the default. With the slots now reused in order, skipped-slots is 0.

Host tests. tools/testing/selftests/drivers/gpu/asahi-m4 run-host-tests.py on the #2545 head: 23/23 ok.

Untested. Workloads other than this serial Vulkan compute check (many commands in flight at once, several clients). Render is still out of scope. The boot job's own tracking slot is never retired; it stays linked at the tail of the list, which these runs show is harmless.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for f890a9c and the clear bisect. Advancing a slot's cursor only once the firmware has recorded +0xc, with early slots deferred to the next service run (notification, submission or scheduler timeout), keeps the runtime event-driven with no fixed wait. The h1-h8 8/8 runs with skipped-slots=0 are convincing.

We will run our M2 (J413, 27.2) rows on f890a9c rather than on 9454ef4: compute workloads, rmmod and reload, and one s2idle cycle. We'll post them here.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

Open finding at f890a9c (not fixed): s2idle with the GPU bound, then a hang around unload.

On phellos (J413, 27.2, up4 kernel with this series, GPU published by aura#402 at 10373aae, aurora autoloaded), one boot, 2026-11-20:

  • The rtc1 s2idle with the 27.2 firmware running logged apple-pmgr-pwrstate … PS gfx: Failed to reach power state 0xf (requested 0xf00200f, now: 0xf002b0f). The system resumed.
  • About 50 s later, fuser /dev/dri/renderD128; rmmod aurora; systemctl restart sddm hard-hung the machine. The journal holds nothing after 107.8 s, so I can't tell which of the three hung. A power cycle was needed.
  • Without a prior s2idle, rmmod is clean: every trial (c1–c8, d8, e2, h1–h8, u1–u3) stopped normally with running=Ok(0) and unloaded cleanly.

So the 27.2 runtime has no suspend handling. The gfx domain can't reach its target while the firmware is up, and an unload after that may not be safe. Until this is handled, the series should keep the GPU unpublished by default. Next steps:

  • stop or block s2idle while the firmware runs (a PM callback that halts it, or refuses suspend);
  • reproduce the unload-after-s2idle under the trial watchdog, to tell whether rmmod's stop path is what hangs.

Untested: s2idle with the GPU idle but bound, without any later unload.

🤖 Generated with Claude Code

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for flagging the s2idle finding at f890a9c rather than leaving it for a reviewer to hit. Agreed that the GPU should stay unpublished by default until suspend is handled.

For the fix, we would prefer a suspend callback that stops the firmware through its own shutdown handshake and starts it again on resume, over refusing suspend, so a bound GPU does not block sleep. If the stop path turns out to be what hangs after the s2idle, that would be good to know first.

Our M2 rows on f890a9c will cover compute, rmmod and reload now; we will keep the s2idle row for the head that adds suspend handling.

@satchlj

satchlj commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf.

Suspend handling is in as 0aac788 ("let the G14 firmware-27.2 GPU through suspend-to-idle"), merged into #2545 as a8d3cd3. That merge only moves the callbacks' cfg gate to CONFIG_DRM_ASAHI_G14_V27_2. The DT half is #2614.

What hung, first. It was not the stop path. The driver had no callback for suspend-to-idle (its prepare acts only on firmware suspend), so genpd gated the GFX domain under the running firmware in the noirq phase. At the wake pmgr logged PS gfx: Failed to reach power state 0xf (requested 0xf00200f, now: 0xf002b0f): target active, actual gated, BUSY. The next GPU access then hung a CPU: an RCU stall with CPU 2 not answering the NMI, about 35 s after a post-resume compute dispatch, and the earlier unbind hang. This is the J713 case that apple,sleep-retained was added for.

Your preferred design, tried first. Stop through the firmware's handshake (idle policy allow-off, then wait until it reports not running) and start it again on resume (keep-powered).

  • The stop works: "stopped for sleep: submitted=303 completed=303".
  • The restart does not. The first try was refused, because the idle ring only took its two build-time records. With the record encoded into the next slot, the firmware took the keep-powered record and crashed in that wake: RTKit crash, an EL1 exception with FAR in its own text region (0x800b306f8).

I did not go further into that. A cold restart (ASC halt, then start again) is not possible with this runtime, because its stop keeps the firmware's memory for the rest of the boot.

What the commit does instead.

  • Before suspend-to-idle: hold new publications and let published work retire (EBUSY if it doesn't within the stop drain time). The firmware keeps its keep-powered policy.
  • After the wake: publish what was held.
  • Domain: apple,sleep-retained on the J413 fw27 GFX domain keeps it on through the sleep.
  • Firmware-mediated sleep: still refused.

Rows (phellos, up4 default kernel df62a8c + our PRs, this commit as the module, aura#402 Stage 2 with the property). Each boot ran 3 × 1024 + 300 × 4096 Vulkan compute dispatches with every word checked, then one rtc1 s2idle, then the same again. No unload anywhere: rmmod after s2idle was never run.

boot before sleep after sleep PS gfx reboot after
s3 (same code as an experiment build) PASS, 50.3 ms PASS, 53.3 ms none (test script fault, WD1 reset)
s4 PASS, 51.1 ms PASS, 49.0 ms none (same fault)
s5 PASS, 58.2 ms PASS, 49.3 ms none (same fault)
s7 PASS, 51.2 ms PASS, 53.9 ms none clean

For s3–s5, the test's watchdog pinger kept the test's SSH session open, so the reboot step never ran; WD1 reset the machine instead. A control boot without s2idle (s6) did the same, and s7 with the fix rebooted cleanly. Every boot logged "GPU held for sleep: submitted=303 completed=303 pending=0" and "released after sleep: running=Ok(1)".

Untested: sleep with commands queued in pending, i.e. a client submitting while the system freezes; long sleeps and many cycles per boot; lid-close sleep; idle power, since the GPU stays powered through the sleep.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for trying the handshake route first and for the clear account of why it can't work here. Knowing that the hang was genpd gating the domain under a running firmware, not the stop path, is very useful, and given the restart crash, holding publications, draining, and keeping the domain through apple,sleep-retained (#2614) is a reasonable design.

We'll run our s2idle row on 0aac788 with the #2614 property: compute before and after, a few cycles in one boot, and the power drawn during the sleep, since the GPU now stays powered through it.

@satchlj

satchlj commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Claude Opus 5.5 on @satchlj's behalf: trailer-only rewrite, removed Co-Authored-By from 4 commit(s); same trees, Signed-off-by kept (0aac788 -> 81446c7, --force-with-lease).

With the G14 firmware-27.2 runtime bound, a suspend-to-idle on phellos
(J413) left the GPU unusable. At the wake the GFX power domain did not
come back ("PS gfx: Failed to reach power state 0xf"), and the next GPU
access, a compute dispatch or an unbind, hung a CPU. The driver had no
callback for that sleep. Linux gated the domain under the running
firmware, as on J713 before apple,sleep-retained.

The domain is now kept through the sleep by the device tree
(apple,sleep-retained on the J413 firmware-27 GFX domain). Before
suspend-to-idle, the runtime holds new publications and lets published
commands retire, so the sleep starts with nothing in flight; after the
wake it publishes what was held. The firmware keeps running with its
keep-powered policy. The ASC, the root and every mapping stay as they
are.

Its own power-off handshake (idle policy allow-off before the sleep,
keep-powered after it) was tried and not kept: the firmware crashed in
the wake that followed it.

The sleep is refused (EBUSY) if published work does not retire within
the stop drain time. A sleep that powers the SoC down is still refused:
the firmware would be lost, and this runtime has no cold restart.

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj
satchlj force-pushed the satchlj/g14-v27-2-compute branch from f5dfd26 to 4c4f313 Compare November 22, 2026 10:43
@satchlj
satchlj force-pushed the satchlj/g14-v27-2-shared branch from a111d34 to 119cce5 Compare November 22, 2026 10:43
@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 4c4f313. This is a rebase onto the updated satchlj/g14-v27-2-shared that drops the merge commit. Range-diff shows commits 2-4 unchanged, and the first changes only in conflict context (the Makefile line and the rxc.stats.set_manager() call the base added). The code is the same as f5dfd26, so the points raised at that head are all still open. The M2 s2idle row I mentioned is still to come and will be run at this head.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Test rows from a second G14G machine: Mac mini M2 (J473, T8112) on the macOS 27.2 stub, GPU published by the Stage 2 from aurora-silicon/aura#402. Kernel: integration/aurora a463112 with #2543 → #2544 → #2545 → #2610 merged on top (local merge, no other changes), distribution command line, one-boot trials with a watchdog and unattended return. Userspace: Fedora mesa-aurora 26.3.0-30 (Borealis), dEQP-VK 1.4.7.1, clpeak 2.1.1 (Vulkan backend).

This stack, unchanged (state cap 100):

  • Binds in about 5 s ("G14 firmware 27.2 running; compute-only DRM device registered"), renderD128, Apple M2 (G14G B0).
  • dEQP-VK compute.pipeline.* without cooperative-matrix and explicit-layout groups and without the 6 max_workgroup_memory cases: 738/776 Pass, 0 Fail, 38 NotSupported.
  • clpeak: fp32 905 / 957 / 1035 GFLOPS (float / float2 / float4), fp16 up to 1122, int32 282 GOPS, global memory 58.5–60.7 GB/s, kernel launch round trip 2.66 µs.
  • 600 s clpeak soak: 244 iterations, 0 failures, fp32 steady at 980.7 GFLOPS, SoC die 33 → 36 °C, no fault, crash, timeout or AVC.

Two dispatches that hang the firmware at the first state, both deterministic:

  • dEQP-VK.compute.pipeline.zero_initialize_workgroup_memory.max_workgroup_memory.1, alone, as the first submission of a boot: compute command timed out: stamp=0x100 expected=0x200 submitted=1 completed=0. In a full run it fails at the same submission every time. The same case passes with 13.5 firmware on an M2.
  • clpeak's int8 dot-product test.

After the timeout the runtime is marked failed and every later client gets ENODEV until reboot. A lab build that prints the MMU fault status on a timeout reads FAULT_INFO = 0 for both, so these are not page faults.

Performance states (lab builds, only the globals +0x98 cap changed):

cap state (DT OPP) fp32 float4 result
100 1 (444 MHz) 1035 GFLOPS stable
200 2 (612 MHz) 1424 GFLOPS stable: CTS subset 738/776, 120 s soak clean
500 5 (1110 MHz) 2788 GFLOPS stable: CTS subset 738/776, 600 s soak 252 iterations 0 failures, die max 39 °C
600, 700, ceiling 6 (1236 MHz) and up — first heavy dispatch never retires, FAULT_INFO = 0

So the cap tracks the state index in hundredths, states 1–5 run here, and the hang starts at state 6 (1236 MHz / 875 mV in the DT). A fixed 500 would be another magic number, so we are not proposing it as a change; it narrows where the 27.2 state-change inputs go wrong.

Not tested here: render (refused, as expected), suspend, more than one client at a time.

Row details
  • Trial Stage 2: aura#402 G14G handoff build, sha256 1cbfed26…; production boot object untouched; each trial is one boot (aura-try + GRUB next_entry) with a watchdog dead-man.
  • Kernel 7.3.0-aurora-m2gpu1+, merge of drm/asahi: report the G14 firmware-27.2 device as compute-only #2610's head on integration a463112 (no conflicts).
  • dEQP list: compute.pipeline.* minus cooperative_matrix and workgroup_memory_explicit_layout (782 cases), minus the 6 zero_initialize_workgroup_memory.max_workgroup_memory.* cases.
  • Before the hanging case, the full list gave 122 Pass / 25 NotSupported / 0 Fail over 148 cases; the timeout line was stamp=0xcc00 expected=0xcd00 submitted=204 completed=203.
  • Lab-only builds (not proposed): (a) print the MMU FAULT_INFO register (SGX + 0x17030, as the 13.5 path reads it) when a command times out; (b) the +0x98 cap taken from a test-only module parameter so one build covers the bisection.
  • cap 500: fp16 2792 GFLOPS, int32 708 GOPS, global memory 63.9–66.4 GB/s, local 922–1388 GB/s, launch 2.39 µs.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Follow-up to the J473 row above: a three-word change on top of this stack runs every performance state and fixes the two compute hangs. It is one commit on #2610's head (patch below); happy for you to take it into the series in whatever form you prefer.

What it changes (gpu/v27_2.rs only):

  • The word before the per-state alarm table that the stack already copies to controller +0x62b8 (the slot 13.5 HwDataShared3 gives unk_8) is written with the DT state count, and globals +0x98 takes the DT ceiling (perf_max_pstate * 100, as +0x88/+0x8c).
  • The compute start operation keeps the 13.5 G14 StartCompute layout (unk_pointer +0x04, job parameters +0x0c, stats +0x14, queue +0x1c, VM slot +0x24). Its +0x28 word is 13.5's unk_28, which the 13.5 path sets to 1; the stack writes 0.

Rows on the J473 (firmware 27.2, fleet command line, no module parameters, one-boot trials, aura#402 Stage 2):

stack as is with the change
clpeak fp32 float4 1035 GFLOPS 3504 GFLOPS
clpeak int8 dot product hangs the GPU 324 GOPS
max_workgroup_memory.1 hangs on the first submission Pass
dEQP-VK compute subset (776) 738 Pass, 0 Fail 738 Pass, 0 Fail
soak 600 s clean 300 s and 600 s clean, SoC die max 41.5 °C

Also tried: the full 13.5 HwDataShared3 values around the table (floor 5, hysteresis 500, retry 1) still stop the firmware at the upper states, so the change keeps that alarm out of every state (nothing on the machine describes its hysteresis or retry interval). Without the alarm change, a cap bisection showed states 1–5 run and 6–8 hang.

Still open on this machine: max_workgroup_memory.128 (hangs; the other sizes pass) and recovery after a hung command (the device stays failed until reboot).

Patch
From 959b0b3128c4dbb8c421f06e55137fd609e36a48 Mon Sep 17 00:00:00 2001
From: Ryan Murray <ryan@aurorasilicon.org>
Date: Mon, 23 Nov 2026 06:59:46 +1100
Subject: [PATCH] drm/asahi: G14 firmware 27.2: run every performance state,
 and set the compute start word the 13.5 path sets

The 27.2 G14 runtime kept the GPU at its first performance state
(globals +0x98 = 100). Two things kept the other states and some
dispatches from working:

- The temperature alarm's per-state table is copied from the 13.5
  configuration, but the word before it (the 13.5 HwDataShared3
  position of unk_8) stayed 0. The alarm then runs in every state, and
  at the upper states the firmware stops retiring work (no fault). No
  machine property describes the alarm's hysteresis or retry interval,
  so keep it off: a floor of the DT state count lies above every state.
  The state cap is then the DT ceiling, like +0x88/+0x8c.
- The compute start operation keeps the 13.5 G14 StartCompute layout
  (unk_pointer +0x04, job parameters +0x0c, stats +0x14, queue +0x1c,
  VM slot +0x24). Its +0x28 word is 13.5's unk_28, which the 13.5 path
  sets to 1; with 0, an integer dot-product kernel and a maximum
  threadgroup-memory dispatch never retire.

On a J473 (Mac mini M2) with firmware 27.2: all eight DT states run,
fp32 3.5 TFLOPS instead of 1.0, the int8 dot-product and
max_workgroup_memory.1 dispatches complete, the dEQP-VK compute subset
is unchanged (738/776, 0 failures) and a 10-minute soak is clean.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
---
 drivers/gpu/drm/asahi/gpu/v27_2.rs | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/asahi/gpu/v27_2.rs b/drivers/gpu/drm/asahi/gpu/v27_2.rs
index 8db6c0ded49fd..720c2fd425d3b 100644
--- a/drivers/gpu/drm/asahi/gpu/v27_2.rs
+++ b/drivers/gpu/drm/asahi/gpu/v27_2.rs
@@ -37,9 +37,6 @@ const TRACE_RECORDS: u32 = 512;
 const RING_RECORDS: u32 = 256;
 /// Queue capacity at position block +0x50 (16 x the 0x50 channels).
 const QUEUE_CAPACITY: u32 = 0x500;
-/// Upper performance-state cap, in hundredths, at globals +0x98: the first state above idle.
-/// Only this cap has run on hardware.
-const STATE_CAP: u32 = 100;
 
 /// Board facts the root needs, read from the device tree at probe.
 pub(crate) struct BoardV27_2 {
@@ -119,6 +116,8 @@ fn encode_compute(
     put64(cmd, 0x334, timestamps + 0x20);
 
     put32(stream, 0, 11);
+    // 13.5 StartCompute.unk_28, at the same place in this layout (the 13.5 G14 path writes 1).
+    put32(stream, 0x28, 1);
     put64(stream, 0x160, job.sequence);
     put64(stream, 0x04, cmd_va + 0x18);
     put64(stream, 0x0c, cmd_va + 0x68);
@@ -810,7 +809,7 @@ impl RootV27_2 {
                 data[offset..offset + 2].copy_from_slice(&value.to_le_bytes());
             }
             let ceiling = pwr.perf_max_pstate * 100;
-            for (at, value) in [(0x84, pwr.max_power_mw), (0x88, ceiling), (0x8c, ceiling), (0x98, STATE_CAP)] {
+            for (at, value) in [(0x84, pwr.max_power_mw), (0x88, ceiling), (0x8c, ceiling), (0x98, ceiling)] {
                 put32(data, at, value);
             }
             put32(data, 0x6e, 1);
@@ -942,6 +941,11 @@ impl RootV27_2 {
         for (word, value) in policy[0x62b8..0x62f8].chunks_exact_mut(4).zip(cfg.shared3_tab) {
             word.copy_from_slice(&value.to_le_bytes());
         }
+        // The temperature alarm's service floor, the word before its per-state thresholds (13.5
+        // HwDataShared3 places it there too). The alarm runs only in states at or above the
+        // floor. Nothing on the machine describes the alarm's hysteresis or retry interval, so
+        // keep it off: a floor of the DT state count lies above every state.
+        put32(policy, 0x62b4, pwr.perf_states.len() as u32);
         // Cold-wake operand: the board's base operating point.
         put32(policy, 0xa4, pwr.perf_base_pstate);
         for (source, bits) in [
-- 
2.54.0

Assisted-by: LLM (Claude:Opus 5.5)

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

Independent source review at 4c4f313592fa. The suspend follow-up drains current work, but the earlier submission and safety findings are still present in the current source. The SRAM table is optional and the missing-table path still invents a voltage floor. In Runtime::submit(), the health check is still before the state lock, and pump() still has a fallible in-flight insertion after publication. Please close those earlier findings, then exercise both suspend recovery and unbind with the final device-tree handoff. The register layout and firmware ABI selection also need a hardware-described contract shared with the loader.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Please establish in-flight ownership before publishing the compute ring entries, and retain that ownership through retirement or confirmed shutdown if notification returns an error. The staged submit path can keep the same invariant for both compute and render.

Stage both ring entries before changing the producers. Store the packet and VM binding in the in-flight list, publish the cursors, then notify the firmware. Keep that ownership if the kick fails or another command in the packet is still in flight.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Close submission admission under the runtime mutex before unbind drains the queue. If staging a later command fails, retain the packet and its VM guard until the already-published prefix retires, then complete the fence with the staging error.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Read each SRAM operating-point voltage from the loader-provided ADT table. Refuse the handoff if the table is absent or inconsistent with the core operating points.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor

J473 on the 27.2 stub, with the Stage 2 handoff from aurora-silicon/aura#402 and trial kernel 7.3.0-aurora-m2gpu1+. These are follow-on driver builds based on the compute stack.

Module source Boot options First client compute Triangle
12788059cbe0f Multi-user diagnostic target 1/1 Pass, dEQP-VK.compute.pipeline.basic.atomic_barrier_sum_small 0/1, VK_ERROR_DEVICE_LOST
edd2f83fe500a Saved production BLS options — 0/1, VK_ERROR_DEVICE_LOST

The first row successfully retired a command on a client-created queue after the firmware bootstrap retired. Both rows restored fleet85 with the saved default, empty next_entry, SELinux Enforcing and zero failed units outside the existing aurora-sep.service baseline.

Against this PR's 4c4f313592fa head, the attached series stages entries before moving the producers, closes admission when unbind starts draining, and reports a staging failure after the published part of the packet retires. It also requires the handoff's SRAM operating-point table and rejects a mismatched frequency or invalid voltage. All three patches apply in sequence to that head. The focused tests passed 4/4 on x86-64 and 4/4 under arm64 QEMU on both the compute supplement and the render follow-on.

The exact-head unbind and suspend rows, firmware selection, and machine-sourced thermal settings still need qualification.

Three git am patches for 4c4f313
From 27d1f77bb267eaea865880fe20c9fbda3223d313 Mon Sep 17 00:00:00 2001
From: Ryan Murray <ryan@aurorasilicon.org>
Date: Mon, 23 Nov 2026 21:57:08 +1100
Subject: [PATCH 1/3] drm/asahi: establish G14 compute ownership before
 firmware publication

Stage both ring entries before changing the producers. Store the packet and VM binding in the in-flight list, publish the cursors, then notify the firmware. Keep that ownership if the kick fails or another command in the packet is still in flight.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
---
 drivers/gpu/drm/asahi/g14_v27_2.rs | 48 ++++++++++--------
 drivers/gpu/drm/asahi/gpu/v27_2.rs | 79 ++++++++++++++++++++----------
 2 files changed, 82 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/asahi/g14_v27_2.rs b/drivers/gpu/drm/asahi/g14_v27_2.rs
index 773693a0cdfcb..9e6697eda1d2e 100644
--- a/drivers/gpu/drm/asahi/g14_v27_2.rs
+++ b/drivers/gpu/drm/asahi/g14_v27_2.rs
@@ -395,6 +395,7 @@ impl Runtime {
         }
         let mut guard = self.state.lock();
         let state = Option::as_mut(&mut *guard).ok_or(ENODEV)?;
+        if !self.healthy() { return Err(EIO); }
         state.pending.push((packet, 0), GFP_KERNEL)?;
         self.pump(state);
         Ok(())
@@ -417,7 +418,9 @@ impl Runtime {
         self.healthy.store(false, Ordering::Release);
         self.idle.notify_all();
         for (packet, _) in state.pending.drain(..) {
-            packet.release_guard();
+            if !state.inflight.iter().any(|flight| Arc::ptr_eq(&flight.packet, &packet)) {
+                packet.release_guard();
+            }
             packet.finish(Err(error));
         }
         // Published work stays owned: the firmware may still read it.
@@ -447,7 +450,7 @@ impl Runtime {
     /// Publishes pending commands while pool slots are free.
     fn pump(&self, state: &mut State) {
         self.acknowledge(state);
-        if self.asleep.load(Ordering::Acquire) { return; }
+        if !self.healthy() || self.asleep.load(Ordering::Acquire) { return; }
         while state.inflight.len() < POOL_SLOTS - 1 && !state.pending.is_empty() {
             // A slot is reused only once the firmware has unlinked it from its tracking list
             // (+0x94), which its retirement scan does after the slot's cursor is advanced.
@@ -485,10 +488,13 @@ impl Runtime {
                 packet.finish(Err(EINVAL));
                 continue;
             };
-            let result = (|| -> Result<(mmu::VmBind, event::EventValue)> {
+            let slot = state.next_slot;
+            let stamp = state.last.next();
+            let ordinal = state.published + 1;
+            let last = index + 1 == packet.commands.len();
+            let result = (|| -> Result {
                 let bind = self.graph.kernel_uat().bind(&packet.vm)?;
                 let preempt = packet.preempt.as_ref().ok_or(EINVAL)?.gpu_va().get();
-                let stamp = state.last.next();
                 let job = ComputeJob {
                     context: bind.slot(),
                     sequence: state.sequence,
@@ -497,35 +503,33 @@ impl Runtime {
                     usc_base: control.usc_base,
                     preempt,
                 };
-                let command = state.pool.encode(state.next_slot, &state.queue, stamp.raw(), &job)?;
+                let command = state.pool.encode(slot, &state.queue, stamp.raw(), &job)?;
+                let publication = state.root.stage_compute(command)?;
+                state.inflight.push(Inflight { packet: packet.clone(), last, stamp, slot, ordinal,
+                    started: Instant::now(), _bind: bind }, GFP_KERNEL)?;
                 packet.mark_published();
-                state.root.publish(command)?;
-                state.peer.as_mut().send_message(EP_DOORBELL, gpu::COMPUTE_KICK)?;
-                Ok((bind, stamp))
+                publication.commit();
+                Ok(())
             })();
             match result {
-                Ok((bind, stamp)) => {
+                Ok(()) => {
                     state.last = stamp;
                     state.sequence += 1;
-                    let slot = state.next_slot;
                     state.busy |= 1 << slot;
-                    state.published += 1;
-                    let ordinal = state.published;
-                    state.next_slot = (state.next_slot + 1) % POOL_SLOTS;
+                    state.published = ordinal;
+                    state.next_slot = (slot + 1) % POOL_SLOTS;
                     state.submitted += 1;
-                    let last = index + 1 == packet.commands.len();
-                    if state.inflight.push(Inflight { packet: packet.clone(), last, stamp, slot, ordinal,
-                        started: Instant::now(), _bind: bind }, GFP_KERNEL).is_err() {
-                        self.fail_all(state, ENOMEM);
+                    if last { let _ = state.pending.remove(0); } else { state.pending[0].1 += 1; }
+                    if let Err(err) = state.peer.as_mut().send_message(EP_DOORBELL, gpu::COMPUTE_KICK) {
+                        self.fail_all(state, err);
                         return;
                     }
-                    if last { let _ = state.pending.remove(0); } else { state.pending[0].1 += 1; }
                 }
+                Err(EBUSY) if !state.inflight.is_empty() => return,
                 Err(e) => {
                     dev_err!(self.dev, "GPU: compute publication failed {:?}\n", e);
                     let _ = state.pending.remove(0);
-                    // Earlier commands of a published packet fail it when they retire.
-                    if !(packet.may_be_published() && index != 0) {
+                    if !state.inflight.iter().any(|flight| Arc::ptr_eq(&flight.packet, &packet)) {
                         packet.release_guard();
                     }
                     packet.finish(Err(e));
@@ -594,6 +598,10 @@ impl Runtime {
                     state.retired += 1;
                     if done.last {
                         done.packet.retired();
+                    } else if !state.inflight.iter().any(|flight| Arc::ptr_eq(&flight.packet, &done.packet))
+                        && !state.pending.iter().any(|(packet, _)| Arc::ptr_eq(packet, &done.packet))
+                    {
+                        done.packet.release_guard();
                     }
                 }
                 continue;
diff --git a/drivers/gpu/drm/asahi/gpu/v27_2.rs b/drivers/gpu/drm/asahi/gpu/v27_2.rs
index 8db6c0ded49fd..e4692492ff8b4 100644
--- a/drivers/gpu/drm/asahi/gpu/v27_2.rs
+++ b/drivers/gpu/drm/asahi/gpu/v27_2.rs
@@ -358,6 +358,27 @@ impl CommandPool {
     }
 }
 
+/// Ring contents prepared while the firmware still owns the old producer.
+pub(crate) struct ComputePublication<'a> {
+    positions: &'a fw::types::GpuArray<u8>,
+    indices: &'a fw::types::GpuArray<u8>,
+    head: &'a core::sync::atomic::AtomicU32,
+    producer: &'a core::sync::atomic::AtomicU32,
+    next_head: u32,
+    next_producer: u32,
+}
+
+impl ComputePublication<'_> {
+    pub(crate) fn commit(self) {
+        self.head.store(self.next_head, Ordering::Release);
+        crate::pgtable::clean_poc(self.positions.as_slice().as_ptr(), 0x60);
+        crate::pgtable::poc_barrier();
+        self.producer.store(self.next_producer, Ordering::Release);
+        crate::pgtable::clean_poc(self.indices.as_slice().as_ptr(), 0x30);
+        crate::pgtable::poc_barrier();
+    }
+}
+
 /// The firmware 27.2 root and every record it names.
 pub(crate) struct RootV27_2 {
     graph: Arc<GpuManagerG14V13_5>,
@@ -410,42 +431,50 @@ impl RootV27_2 {
         Ok((Self::word(&self.boot.positions, 0x40)?, Self::word(&self.boot.positions, 0)?))
     }
 
-    /// Publishes `command` as the queue's next command: pointer, queue head, then the compute
-    /// submission entry and its producer.
-    pub(crate) fn publish(&self, command: u64) -> Result {
+    /// Prepares a work pointer and channel entry without advancing either producer.
+    pub(crate) fn stage_compute(&self, command: u64) -> Result<ComputePublication<'_>> {
         let job = &self.boot;
+        let indices = &self.channels[2 * SUBMISSION_RING];
+        let ring = &self.channels[2 * SUBMISSION_RING + 1];
+        crate::pgtable::clean_invalidate_poc(job.positions.as_slice().as_ptr(), 0x60);
+        crate::pgtable::clean_invalidate_poc(indices.as_slice().as_ptr(), 0x30);
+        crate::pgtable::poc_barrier();
         let head = job.positions.shared_index(0x40)?;
         let old = head.load(Ordering::Acquire);
         let capacity = Self::word(&job.positions, 0x50)?;
-        if capacity == 0 || (old % capacity) as usize * 8 + 8 > job.pointers.as_slice().len() {
-            return Err(EINVAL);
+        let retired = Self::word(&job.positions, 0)?;
+        if capacity <= 1 || old >= capacity || retired >= capacity
+            || capacity as usize > job.pointers.len() / 8
+        {
+            return Err(EIO);
         }
-        let at = (old % capacity) as usize * 8;
+        let next_head = (old + 1) % capacity;
+        if next_head == retired { return Err(EBUSY); }
+
+        let producer = indices.shared_index(0x20)?;
+        let write = producer.load(Ordering::Acquire);
+        let read = Self::word(indices, 0)?;
+        let entries = crate::m3::m3_channel_format::SLOTS;
+        if write >= entries || read >= entries { return Err(EIO); }
+        let next_producer = (write + 1) % entries;
+        if next_producer == read { return Err(EBUSY); }
+        let slot = u8::try_from(job.event.slot()).map_err(|_| EINVAL)?;
+        let entry = crate::m3::submission_entry(COMPUTE as u32, job.queue.gpu_va().get(),
+            u16::try_from(next_head).map_err(|_| EINVAL)?, slot, false).map_err(|_| EINVAL)?;
+
+        let at = old as usize * 8;
         job.pointers.shared_index(at)?.store(command as u32, Ordering::Relaxed);
         job.pointers.shared_index(at + 4)?.store((command >> 32) as u32, Ordering::Relaxed);
         crate::pgtable::clean_poc(job.pointers.as_slice()[at..].as_ptr(), 8);
-        crate::pgtable::poc_barrier();
-        let new = (old + 1) % capacity;
-        head.store(new, Ordering::Release);
-        crate::pgtable::clean_poc(job.positions.as_slice().as_ptr(), 0x60);
-        crate::pgtable::poc_barrier();
-        let state = &self.channels[2 * SUBMISSION_RING];
-        let ring = &self.channels[2 * SUBMISSION_RING + 1];
-        let w = Self::word(state, 0x20)?;
-        if w >= crate::m3::m3_channel_format::SLOTS { return Err(EIO); }
-        let slot = u8::try_from(job.event.slot()).map_err(|_| EINVAL)?;
-        let entry = crate::m3::submission_entry(COMPUTE as u32, job.queue.gpu_va().get(),
-            u16::try_from(new).map_err(|_| EINVAL)?, slot, false).map_err(|_| EINVAL)?;
-        let base = w as usize * entry.len();
-        for (k, word) in entry.chunks(4).enumerate() {
-            ring.shared_index(base + 4 * k)?.store(u32::from_le_bytes([word[0], word[1], word[2], word[3]]), Ordering::Relaxed);
+        let base = write as usize * entry.len();
+        for (index, word) in entry.chunks_exact(4).enumerate() {
+            ring.shared_index(base + 4 * index)?.store(
+                u32::from_le_bytes([word[0], word[1], word[2], word[3]]), Ordering::Relaxed);
         }
         crate::pgtable::clean_poc(ring.as_slice()[base..].as_ptr(), entry.len());
         crate::pgtable::poc_barrier();
-        state.shared_index(0x20)?.store((w + 1) % crate::m3::m3_channel_format::SLOTS, Ordering::Release);
-        crate::pgtable::clean_poc(state.as_slice().as_ptr(), 0x30);
-        crate::pgtable::poc_barrier();
-        Ok(())
+        Ok(ComputePublication { positions: &job.positions, indices, head, producer,
+            next_head, next_producer })
     }
 
     /// Publishes the boot job, whose command and ring entry the root already holds. The GPU
-- 
2.54.0


From 027f0b26de789e05f4ea094f559afbbdcd0ee7b5 Mon Sep 17 00:00:00 2001
From: Ryan Murray <ryan@aurorasilicon.org>
Date: Mon, 23 Nov 2026 23:32:43 +1100
Subject: [PATCH 2/3] drm/asahi: drain G14 submissions before completing or
 stopping

Close submission admission under the runtime mutex before unbind drains the queue. If staging a later command fails, retain the packet and its VM guard until the already-published prefix retires, then complete the fence with the staging error.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
---
 drivers/gpu/drm/asahi/g14_v27_2.rs | 43 +++++++++++++++++++++---------
 1 file changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/asahi/g14_v27_2.rs b/drivers/gpu/drm/asahi/g14_v27_2.rs
index 9e6697eda1d2e..682a23f0c96e2 100644
--- a/drivers/gpu/drm/asahi/g14_v27_2.rs
+++ b/drivers/gpu/drm/asahi/g14_v27_2.rs
@@ -299,6 +299,7 @@ pub(crate) fn start<'a>(pdev: &'a platform::Device<device::Core<'_>>, cfg: &'sta
 struct Inflight {
     packet: Arc<Packet>,
     last: bool,
+    publication_error: Option<Error>,
     stamp: event::EventValue,
     slot: usize,
     /// Queue publications up to and including this command, counted from take-over.
@@ -335,10 +336,26 @@ struct State {
     capacity: u32,
     inflight: KVec<Inflight>,
     pending: KVec<(Arc<Packet>, usize)>,
+    accepting: bool,
     submitted: u64,
     retired: u64,
 }
 
+impl State {
+    /// Stop publishing this packet. Report failure only once any published prefix retires.
+    fn fail_publication(&mut self, packet: &Arc<Packet>, err: Error) {
+        let _ = self.pending.remove(0);
+        if let Some(last) = self.inflight.iter_mut().rev()
+            .find(|flight| Arc::ptr_eq(&flight.packet, packet))
+        {
+            last.publication_error = Some(err);
+        } else {
+            packet.release_guard();
+            packet.finish(Err(err));
+        }
+    }
+}
+
 #[pin_data(PinnedDrop)]
 pub(crate) struct Runtime {
     dev: ARef<device::Device>,
@@ -396,6 +413,7 @@ impl Runtime {
         let mut guard = self.state.lock();
         let state = Option::as_mut(&mut *guard).ok_or(ENODEV)?;
         if !self.healthy() { return Err(EIO); }
+        if !state.accepting { return Err(ENODEV); }
         state.pending.push((packet, 0), GFP_KERNEL)?;
         self.pump(state);
         Ok(())
@@ -483,9 +501,7 @@ impl Runtime {
             let (packet, index) = (state.pending[0].0.clone(), state.pending[0].1);
             let Command::Compute(control) = packet.commands[index] else {
                 // Queues of this backend accept only compute commands (Queue::submit).
-                let _ = state.pending.remove(0);
-                if !(packet.may_be_published() && index != 0) { packet.release_guard(); }
-                packet.finish(Err(EINVAL));
+                state.fail_publication(&packet, EINVAL);
                 continue;
             };
             let slot = state.next_slot;
@@ -506,7 +522,7 @@ impl Runtime {
                 let command = state.pool.encode(slot, &state.queue, stamp.raw(), &job)?;
                 let publication = state.root.stage_compute(command)?;
                 state.inflight.push(Inflight { packet: packet.clone(), last, stamp, slot, ordinal,
-                    started: Instant::now(), _bind: bind }, GFP_KERNEL)?;
+                    publication_error: None, started: Instant::now(), _bind: bind }, GFP_KERNEL)?;
                 packet.mark_published();
                 publication.commit();
                 Ok(())
@@ -528,11 +544,7 @@ impl Runtime {
                 Err(EBUSY) if !state.inflight.is_empty() => return,
                 Err(e) => {
                     dev_err!(self.dev, "GPU: compute publication failed {:?}\n", e);
-                    let _ = state.pending.remove(0);
-                    if !state.inflight.iter().any(|flight| Arc::ptr_eq(&flight.packet, &packet)) {
-                        packet.release_guard();
-                    }
-                    packet.finish(Err(e));
+                    state.fail_publication(&packet, e);
                 }
             }
         }
@@ -596,7 +608,10 @@ impl Runtime {
                     }
                     state.busy &= !(1 << done.slot);
                     state.retired += 1;
-                    if done.last {
+                    if let Some(err) = done.publication_error {
+                        done.packet.release_guard();
+                        done.packet.finish(Err(err));
+                    } else if done.last {
                         done.packet.retired();
                     } else if !state.inflight.iter().any(|flight| Arc::ptr_eq(&flight.packet, &done.packet))
                         && !state.pending.iter().any(|(packet, _)| Arc::ptr_eq(packet, &done.packet))
@@ -666,17 +681,20 @@ impl Runtime {
     /// Stops the firmware: retire or fail outstanding work, allow power-off, then halt the ASC
     /// with every mapping still in place (RTKit power-off if the firmware does not stop).
     pub(crate) fn stop(&self) {
-        // Let published work retire; the service signals `idle` when nothing is left.
+        // Close admission while the service retires work already accepted.
         {
             let mut guard = self.state.lock();
+            let Some(state) = Option::as_mut(&mut *guard) else { return; };
+            state.accepting = false;
             let start = Instant::<Monotonic>::now();
             while self.healthy() && start.elapsed() < Delta::from_millis(STOP_DRAIN_MS.into()) {
                 let Some(state) = guard.as_ref() else { break; };
                 if state.inflight.is_empty() && state.pending.is_empty() { break; }
                 let _ = self.idle.wait_timeout(&mut guard, msecs_to_jiffies(STOP_DRAIN_MS));
             }
+            // Serialize the last permitted publication with the transition to shutdown.
+            self.healthy.store(false, Ordering::Release);
         }
-        self.healthy.store(false, Ordering::Release);
         // Nothing queues service work after the detach, and none is queued or running once the
         // drain returns, so no work outlives the module.
         drop(self.notify.detach());
@@ -790,6 +808,7 @@ impl Backend {
             capacity,
             inflight: KVec::new(),
             pending: KVec::new(),
+            accepting: true,
             submitted: 0,
             retired: 0,
         });
-- 
2.54.0


From 6f67df239dd57bc0bf8e24c631c75c4d714ee4bf Mon Sep 17 00:00:00 2001
From: Ryan Murray <ryan@aurorasilicon.org>
Date: Mon, 23 Nov 2026 23:32:43 +1100
Subject: [PATCH 3/3] drm/asahi: require the firmware handoff SRAM voltage
 table

Read each SRAM operating-point voltage from the loader-provided ADT table. Refuse the handoff if the table is absent or inconsistent with the core operating points.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
---
 drivers/gpu/drm/asahi/gpu/v27_2.rs | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/asahi/gpu/v27_2.rs b/drivers/gpu/drm/asahi/gpu/v27_2.rs
index e4692492ff8b4..37d09ac8a19be 100644
--- a/drivers/gpu/drm/asahi/gpu/v27_2.rs
+++ b/drivers/gpu/drm/asahi/gpu/v27_2.rs
@@ -758,18 +758,11 @@ impl RootV27_2 {
         }
         for (i, state) in states.iter().enumerate() {
             let [mv] = state.volt_mv.as_slice() else { return Err(EINVAL); };
-            let sram_mv = match &sram_table {
-                Some(table) => {
-                    let (freq, voltage) = table[i * 8..i * 8 + 8].split_at(4);
-                    if u32::from_le_bytes(freq.try_into().map_err(|_| EINVAL)?) != state.freq_hz {
-                        return Err(EINVAL);
-                    }
-                    let value = u32::from_le_bytes(voltage.try_into().map_err(|_| EINVAL)?);
-                    if value < *mv || value > 1100 { return Err(EINVAL); }
-                    value
-                }
-                None => (*mv).max(850),
-            };
+            let (freq, voltage) = sram_table[i * 8..i * 8 + 8].split_at(4);
+            let sram_mv = u32::from_le_bytes(voltage.try_into().map_err(|_| EINVAL)?);
+            if u32::from_le_bytes(freq.try_into().map_err(|_| EINVAL)?) != state.freq_hz || sram_mv < *mv || sram_mv == 0 {
+                return Err(EINVAL);
+            }
             let mhz = state.freq_hz / 1_000_000;
             for series in [abi::COMMON26_HW_PERF_FREQUENCY, 0x1924] {
                 put32(hw, series + i * 4, mhz);
@@ -911,8 +904,8 @@ impl RootV27_2 {
     }
 
     /// The loader's `adt-perf-states-sram` table under `/chosen/aurora-gpu-resources/sgx`
-    /// (frequency and SRAM millivolts per state), if it published one. The node itself must exist.
-    fn sram_table(states: usize) -> Result<Option<KVec<u8>>> {
+    /// (frequency and SRAM millivolts per state).
+    fn sram_table(states: usize) -> Result<KVec<u8>> {
         let chosen = kernel::of::chosen().ok_or(ENODEV)?;
         let is = |name: Option<KVec<u8>>, want: &[u8]| {
             name.as_deref().is_some_and(|n| n.strip_suffix(b"\0").unwrap_or(n) == want)
@@ -921,8 +914,9 @@ impl RootV27_2 {
             if !is(parent.get_opt_property::<KVec<u8>>(c"name")?, b"aurora-gpu-resources") { continue; }
             for child in parent.children() {
                 if is(child.get_opt_property::<KVec<u8>>(c"name")?, b"sgx") {
-                    let table = child.get_opt_property::<KVec<u8>>(c"adt-perf-states-sram")?;
-                    if table.as_ref().is_some_and(|t| t.len() != states * 8) { return Err(EINVAL); }
+                    let table = child.get_opt_property::<KVec<u8>>(c"adt-perf-states-sram")?
+                        .ok_or(ENODEV)?;
+                    if table.len() != states * 8 { return Err(EINVAL); }
                     return Ok(table);
                 }
             }
-- 
2.54.0

Assisted-by: LLM (Codex)

Select the wire layout from the loader compatibility tuple before starting the GPU and pass the register description selected by the GPU compatible.

Notify suspend when the in-flight queue empties. Pending commands stay held until resume, and unrelated wakeups exhaust the original timeout budget.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide

Copy link
Copy Markdown
Contributor

The review fixes are available in #2979, stacked on 4c4f313592fa. The follow-up also selects the G14 wire layout from the loader’s apple,firmware-compat and wakes suspend once published work drains.

The new selector and suspend fixtures passed 4/4 native and 4/4 in AArch64 QEMU. The port through the G14 Kconfig to the J473 trial base (bb6fbdf1b6af) passed 8/8 compute transport checks in KVM and linked with a verified module signature against 7.3.0-aurora-m2gpu1+. The earlier 1/1 J473 compute row used a different module. Exact-module compute, suspend, post-resume compute and unbind are still due. The freeze and power limits still depend on the loader and thermal work referenced in the draft.

@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 adversarial pre-PR checklist re-review (§1–§6) at 4c4f313592fa57186dba793752de61c1b41edda0.

Stack & Superseded Status

  • Not superseded on integration/aurora (g14_v27_2.rs is not present on integration/aurora).
  • Stack order: #2543 (satchlj/g14-v27-2-shared, still open with active REQUEST_CHANGES) -> #2544 -> #2545 -> #2610.
  • Rebase onto #2543 (119cce51da9f) cleanly dropped the prior merge commit; all 4 commits (96c882e9, a47acf0b, 660936a3, 4c4f3135) pass §4 DCO hygiene. However, the source tree of the G14 27.2 implementation is unchanged from f5dfd2617395, so all four prior blockers remain open on 4c4f313592fa (note: follow-up fixes exist in draft #2979 but are not yet folded into this PR).

Unresolved Blockers on 4c4f313592fa

  1. §3 Safety — hardcoded SRAM voltage fallback and bare thermal/alarm literals (drivers/gpu/drm/asahi/gpu/v27_2.rs):
    • sram_table() still returns Result<Option<KVec<u8>>> and RootV27_2::build() still falls back to None => (*mv).max(850) (with a hardcoded > 1100 ceiling) instead of failing closed when adt-perf-states-sram is absent.
    • RootV27_2::controller() still writes bare literals (0x22d4, 11000), (0x2284, 900), (0x2f30, 125), and crate::f32!(5.3) instead of sourcing limits/coefficients from HwConfig / DT / ADT.
  2. §2 Concurrency bug — Runtime::submit() vs Runtime::stop() race (drivers/gpu/drm/asahi/g14_v27_2.rs):
    • Runtime::submit() still checks if !self.healthy() before acquiring self.state.lock(), pump() does not check self.healthy(), and stop() does not close submission admission under self.state.lock() prior to draining/halting.
  3. §2 Post-publish ENOMEM VmBind drop, partial multi-command VmJobGuard bug, and unstaged ring publication (g14_v27_2.rs, gpu/v27_2.rs):
    • pump() still calls state.root.publish(command)? and send_message(EP_DOORBELL, COMPUTE_KICK)? before state.inflight.push(...) — an ENOMEM on push (or doorbell error after producer advance) drops VmBind while the firmware owns the published command.
    • On failure of a non-first command in a multi-command Packet, pump() skips release_guard() and immediately calls packet.finish(Err(e)) while command 0 is still executing; when command 0 retires (done.last == false), release_guard() is never called.
    • RootV27_2::publish() advances queue head before verifying submission-ring space (next_head == retired / next_producer == read) or encoding submission_entry.
    • Folding the staged-publication / admission-gate / required-SRAM fixes (drafted in #2979) into this PR will close Blockers #1 (SRAM part), #2, and #3.
  4. §1 Chip-ID & firmware-version gating (drivers/gpu/drm/asahi/g14_v27_2.rs, driver.rs):
    • g14_v27_2::start() still matches literal cfg.chip_id { 0x8112 => ... } instead of carrying the 27.2 register table/mask via HwConfig / hardware description.
    • driver.rs still gates on exact apple,firmware-version == &[27, 2, 0] without a §1 justification or loader capability contract (e.g. apple,firmware-compat).
  5. Blocked parent PR (#2543) & §5 Evidence:
    • Parent #2543 has open REQUEST_CHANGES; host-tests has not run against integration/aurora (though source, rust-build, kunit, and DWC3/ATC 3/3 passed on 4c4f313592fa).
    • Also note the J473 (second G14G machine) findings in thread: STATE_CAP = 100 pins P1 and missing StartCompute.unk_28 = 1 / temperature-alarm floor caused deterministic hangs on clpeak int8 dot-product and dEQP-VK.compute.pipeline.zero_initialize_workgroup_memory.max_workgroup_memory.1 (fix patch shared in comments).
    • Still needed on the fixed head: exact-head rmmod after s2idle, §5 regression gate counts (0 SELinux denials / 0 failed units / 0 new kernel errors), and a G13/G14 13.5-stub no-regression boot row.

Checklist Summary (§1–§6)

  • §1 No model gating: Blocked (Blocker #4).
  • §2 Production-ready, no hacks: Blocked (Blockers #2, #3; also sleep_prepare() still polls every 50 ms on idle.wait_timeout).
  • §3 Safety: Blocked (Blocker #1).
  • §4 Clean-room & attribution: Pass (all 4 commits carry human author/committer and human Signed-off-by: only, 0 AI commit trailers; PR body includes Assisted-by:).
  • §5 Evidence: Incomplete (host-tests not run on integration base; exact-head post-fix s2idle+unbind, regression gate counts, and 13.5-stub no-regression row still needed).
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

bind_inner() cleaned the TTBAT slot directly when UatInner::clean_poc was set without quirks.clean_tables, leaving VmInner::drop() — which clears ttb0/ttb1 and calls only UatShared::publish_slot() — without a cache clean on adopted non-snooping UATs. If the walker later reads the cleared slot before the cache line is evicted, it can still see the stale root after the VM's page tables are freed.

Mirror clean_poc onto UatShared (true in new_adopted_inner, matching quirks.clean_tables in make_inner), check self.clean_poc || self.quirks.clean_tables in UatShared::publish_slot(), and drop the bind-only duplicate in bind_inner(). Extend the asahi-m4 retention host harness to assert that both bind() and VmInner::drop() write back the TTBAT slot once when clean_poc or clean_tables is set and not at all for a coherent walker.

Signed-off-by: Satya Benson <satya@benson.earth>
@RyanTheTide

Copy link
Copy Markdown
Contributor

MERGETRAIN6 source review at 4c4f313592fa. Blocking: the runtime can publish before it has recorded an owning VM binding, and the SRAM table fallback guesses a voltage if the handoff omits it. A submit can also pass the health check before teardown closes admission. The runtime is selectable at this intermediate tip.

The relevant ownership, staging and SRAM-table changes are in the follow-up drafts #2979 and #3031. Please bring one version into this branch before enabling it and carry the required machine-supplied thermal policy with it. The running m2pub1 trial contains this commit and the later render fixes together. Its row can describe that combined tree.

Assisted-by: LLM (Codex)

@satchlj

satchlj commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Gemini 4 Neon on @satchlj's behalf: reviewed #2979 and #3031 against your MERGETRAIN6 review at 4c4f313592fa and paused before pushing so we align cleanly on two points:

  1. Base commits: Ryan Murray's four signed commits in #2979 sit directly on #2544 and cover VM ownership before publication, admission closure before teardown, and SRAM voltage-table validation (with #3031 carrying the render-aware versions downstream of #2610). Confirming you want us to carry #2979's four commits unchanged onto #2544 (and rebase #2545/#2610 on top) while #3031 stays downstream?
  2. Machine-supplied G14 thermal policy: Neither #2979 nor #3031 currently carries the machine-sourced G14 thermal/alarm thresholds and sensor corrections. Which machine-provided handoff/DT fields (and units/validation rules) should supply those, and should the driver fail probe/firmware start if any required field is missing or malformed?

No branch updates, builds, or J413/J473 hardware tests have been run yet pending alignment on those two points.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Yes. Please carry the four signed commits from #2979 onto the compute base with a normal push. Bring in the current #2543 teardown fix first. That gives #2545 and #2610 a safe base. The render branch should keep only its render-specific ownership changes on top.

For the thermal handoff, the merged producer in aurora-silicon/aura#448 is the starting point. It passes the ADT gpu-fast-die0-target as apple,fast-die0-target in integer degrees Celsius and requires it before enabling that interface. Aura also has a machine-sourced apple,fast-die0-sensor-mask representation. Reuse those properties if the J473 and J413 ADTs confirm they describe the same inputs. Check the cell widths, that the mask selects reported sensors, and use a checked conversion to the firmware field's temperature units. The existing power-state, power-limit and gain properties in PwrConfig cover part of the policy. Its legacy fallbacks for required protection values should not flow into the new backend.

I have no verified machine source yet for every alarm threshold or sensor correction used by the G14 controller. Treat the ADT alarm property as a lead and confirm its scope and units before mapping it. Missing or malformed required protection inputs should stop this firmware start and leave the GPU disabled. Keep the previously qualified performance ceiling until the sourced policy is exercised on J473 and the fanless J413.

Assisted-by: LLM (Codex)

@RyanTheTide

Copy link
Copy Markdown
Contributor

On the controller() thermal literals (Dj's §3 blocker on this PR, carried in #3031), here is what the machine hands over. On the J473 (M2 mini, macOS 27.2) it hands over none of these values. This needs a decision before anyone writes code.

  • 0x22d4 = 11000 and 0x2284 = 900 are the same words the 13.5 G14 path writes from the per-chip table in hw/t8112.rs (HwDataA unk_8cc/unk_87c; on T8122 0x22d4 is noted as the fast-die target in centi-degrees C). The J473 /arm-io/sgx node has no gpu-fast-die0-target.
  • 0x2288 = 4 and 0x229c = 1.0 are controller constants that are literals in the 13.5 path (initdata.rs) and in G15 (g15/board/record.rs) as well.
  • 0x2f30 = 125 / 0x2f34 = 1 are an alarm value and its enable. G15 writes the same pair. The J473 ADT has no gpu-sochot-temp or gpu-fast-die0-alarm-threshold. The M1 J313 ADT has both, but with other values.
  • The per-sensor 5.3 corrections have no 13.5 or G15 equivalent and nothing matching in the ADT.
  • Two inputs that look machine-sourced are not, on this Mac: fast_die0_release_temp_cc falls back to its DT default (80), and the fast sensor mask comes from the hw/t8112.rs table. Only the fast-die gains (ADT 200.0 / 5.0) and the ppm/avg-power/perf words come from the ADT.

The options as I see them:

  • (A) Strict: aura publishes apple,fast-die0-target/-alarm-threshold/-release-temp/-sensor-mask when the ADT has them, and the kernel reads them with no defaults. Result: the J473 GPU stays off.
  • (B) One implementation with the existing path: controller() takes 11000/900/4/1.0 and the sensor mask from the same T8112 hardware config the 13.5 path already uses on every G14 Mac (no new literals in the 27.2 code), plus any ADT value that is present. The 125 alarm stays shared with G15 and documented. The 5.3 corrections stay open until we have a source.

I lean towards (B) for the existing values, keeping 5.3 as the open item, but this is a policy call for Dj and Ryan.

Assisted-by: LLM (Claude:Opus 5.5)

Signed-off-by: Satya Benson <satya@benson.earth>
@satchlj

satchlj commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Codex GPT-6.2 Astra on @satchlj's behalf:

Compute advanced by normal fast-forward. The shared and compute branches diverged at 119cce5. The merge takes the fixed shared head 152822e as first parent and Ryan’s 9111ff5 as second parent, preserving all four original commit objects and sign-offs.

Published heads

On each head, the Rust MMU retention harness passed the bind and teardown cache-clean checks. The batching, stamp, runtime and firmware host suites compiled with rustc and passed all 119 tests. No full kernel build or J413/J473 hardware tests were run here.

RootV27_2::controller() already consumes the calibrated fast-die release temperature and PI gains through the existing hardware-data record. PwrConfig also carries the proportional target delta, sampling period, average-power, PPM and performance parameters. The delta alone does not establish an absolute target. Machine-sourced replacements for the remaining thermal thresholds, alarm selection and per-sensor corrections await the locked aura#402 DT property contract.

RyanTheTide added a commit that referenced this pull request Nov 24, 2026
Bring in the restacked #2610 (6a15a79: #2545 and #2544 on #2543
152822e, the TTBAT slot PoC clean in UatShared::publish_slot). The
#2979 ownership fixes it also carries are already here. The rewritten
#2545/#2610 commits re-add the compute-only refusals (render rejected in
m3_submit, COMPUTE_ONLY feature flag); this series supports rendering,
so those resolve to this series' version. Net change: the #2543 MMU
teardown fix and its retention test only.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>

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

Live pre-PR checklist re-review (§1–§6) at exact head db645f40085205cc63286b9eaee5392026d191aa (OPEN, non-draft, MERGEABLE, base satchlj/g14-v27-2-shared).

Live CI & Commit Hygiene (§4)

  • CI (6/6 PASS on db645f400852): source, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, and DWC3/ATC builtin-modular-atc all succeeded (host-tests will run once retargeted to integration/aurora).
  • §4 Hygiene (PASS): Compares 9 commits ahead of satchlj/g14-v27-2-shared (152822e24034). All commits carry human author/committer (Satya Benson or Ryan Murray) with matching human Signed-off-by: and zero AI commit trailers, with no duplicate commits. Fast-forward merge db645f400852 (parents: 152822e24034, 9111ff5b8874, signed by Satya Benson) preserves Ryan Murray’s 4 original signed commit objects from merged #2979 unchanged alongside #2543’s PoC clean (152822e24034).

Prior Blockers Verified Cleared

All four code/safety/gating blockers from 4c4f313592fa plus #2543’s teardown PoC clean are cleanly present on db645f400852:

  1. SRAM voltage floor/cap (6f67df239dd5, drivers/gpu/drm/asahi/gpu/v27_2.rs:617, 759-765, 908-925): sram_table() now returns Result<KVec<u8>> (ENODEV if adt-perf-states-sram is absent, EINVAL on length mismatch/missing node) and RootV27_2::build() validates freq == state.freq_hz, sram_mv >= *mv, and sram_mv != 0. The hardcoded (*mv).max(850) fallback and > 1100 cap are gone.
  2. submit() / stop() race (027f0b26de78, drivers/gpu/drm/asahi/g14_v27_2.rs:408-420, 469-471, 691-708): stop() sets state.accepting = false under self.state.lock() before draining and marks healthy = false under the lock after drain; submit() re-checks both self.healthy() and state.accepting under self.state.lock(); pump() checks self.healthy() at entry.
  3. VmBind, staged publication, VmJobGuard, and 50 ms suspend poll (27d1f77bb267, 027f0b26de78, 9111ff5b8874, gpu/v27_2.rs:435-478, g14_v27_2.rs:352-362, 511-550, 569-573, 615-631, 654-673): stage_compute() validates both ring spaces, encodes and PoC-cleans both entries before returning ComputePublication; pump() binds VmBind and pushes Inflight before mark_published() + publication.commit(); fail_publication() retains VmJobGuard until any published prefix retires (publication_error); sleep_prepare() replaces the 50 ms poll with a remaining-jiffies CondVar::wait_timeout woken when inflight.is_empty() while asleep.
  4. Chip-ID & firmware-version gate (9111ff5b8874, driver.rs:156, 204, 380-409, 503-511, g14_v27_2.rs:214-223): driver.rs selects via ProbeConfig::LegacyWithG14Handoff + DT apple,firmware-compat == [27, 2, 0] and passes hw::t8112::REGISTERS_V27_2 / WRITABLE_V27_2 directly, removing match cfg.chip_id { 0x8112 => ... } and the exact apple,firmware-version gate.
  5. #2543 152822e24034 PoC clean (mmu.rs:2054, 2084-2092, 3637, 4247, test-mmu-retention.py): Present via first parent 152822e24034 (UatShared::clean_poc in publish_slot()).

Remaining Blockers

  1. §3 Safety — hardcoded thermal/alarm literals in RootV27_2::controller() (drivers/gpu/drm/asahi/gpu/v27_2.rs:953-962) awaiting the aura#402 DT property contract / policy resolution:
    • Already consumed from PwrConfig / 13.5 hwdata_a: max_state (perf_states), perf_base_pstate, pwr_sample_period_aic_clks, pwr_min_duty_cycle, perf_integral_gain/2, perf_proportional_gain/2, max_freq_mhz, ppm_filter_time_constant_ms / power_sample_period, plus hwdata_a PPM/avg-power/perf/SE fields and fast_die0_release_temp_cc (note: defaults to 80 when absent in DT), fast_die0_sensor_mask (from hw/t8112.rs), fast_die0_ki_dt, and fast_die0_kp. (PwrConfig also carries fast_die0_prop_tgt_delta, which alone does not establish an absolute target.)
    • Exact literals still present in controller() (gpu/v27_2.rs:954-961):
      • 0x22d4 = 11000 (fast-die target in centi-°C; matches hw/t8112.rs HwConfigA::unk_8cc)
      • 0x2284 = 900 (matches hw/t8112.rs HwConfigA::unk_87c)
      • 0x2288 = 4 and 0x229c = crate::f32!(1.0) (controller constants also literal in 13.5 initdata.rs and G15 g15/board/record.rs)
      • 0x2f30 = 125 and 0x2f34 = 1 (SoC-hot alarm threshold and enable; matches HwConfigA::unk_e24 / G15)
      • 0x2320, 0x2420, 0x2f38, 0x3038 per-sensor crate::f32!(5.3) corrections for every set bit in sensors (no 13.5/G15 equivalent and no verified ADT source yet)
    • These remain blocked pending the locked aura#402 DT property contract and maintainer decision on Option A (strict fail-closed) vs Option B (shared chip-config constants + ADT overrides, keeping 5.3 open until sourced).
  2. Stacked parent (#2543) & §5 Evidence on final head:
    • Parent #2543 (152822e24034) is still open with active CHANGES_REQUESTED; retarget to integration/aurora once #2543 lands so host-tests runs on the final base.
    • Only the Rust MMU retention harness + 119 host tests have been run on db645f400852 so far. Before merge, record exact-head J413 + J473 hardware validation (including s2idle + rmmod unbind), §5 regression gate counts (0 SELinux denials / 0 failed units / 0 new kernel errors), and a 13.5-stub G13/G14 no-regression boot row.

Checklist Summary (§1–§6)

  • §1 No model gating: Pass (chip-ID and exact firmware-version gates cleared).
  • §2 Production-ready, no hacks: Pass (all concurrency, staging, VmBind/VmJobGuard, and 50 ms poll blockers cleared).
  • §3 Safety: Blocked (SRAM fallback cleared; controller() thermal/alarm literals and per-sensor 5.3 corrections remain open pending aura#402 contract / policy decision).
  • §4 Clean-room & attribution: Pass.
  • §5 Evidence: Incomplete (6/6 stacked CI checks pass; exact-head hardware/s2idle+unbind/regression-gate/13.5-stub rows and host-tests on integration/aurora pending).
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The thermal input contract for G14G firmware 27.2, which aura#402 asked for (Dj's §3). In short: apply what the merged T8122 path does, with no new properties and no literals in the runtime code. One value (5.3) has no source and needs a decision. The J473's 27.2 ADT carries no GPU thermal limits.

Contract

What the machine provides (J473, /arm-io/sgx)

  • Present: gpu-fast-die0-integral-gain (200.0), gpu-fast-die0-proportional-gain (5.0), gpu-avg-power-, gpu-ppm-,
    gpu-perf-*, gpu-power-sample-period, gpu-pwr-min-duty-cycle, perf-states, perf-states-sram; nub coredump-copy-buffer.
  • Absent: gpu-fast-die0-target, gpu-fast-die0-sensor-mask, gpu-fast-die0-alarm-threshold, gpu-sochot-temp.

What the merged T8122 path does (aura#448 + kernel m3/hw/t8122.rs)

aura#448 publishes apple,fast-die0-target from the ADT (88 on the J613), but no kernel code reads it.
m3/hw/t8122.rs writes the firmware word 11000 from its per-chip HwConfigA (unk_8cc, "how the two relate is not
known"). The ADT-to-word mapping is unproven on every chip we have (T8122: 88 vs 11000; T8103: 94 vs 9880).
So "aura#448 parity" in practice means: ADT values the kernel can use go through DT, and firmware words with no proven
ADT source come from the chip's hardware config. One copy per chip, shared with the chip's 13.5 path, never in the
runtime code.

Contract

  1. aura (G14G handoff, aura#402): no new properties are needed for the values the kernel uses. Gains, ppm, avg-power,
    perf and sample period are already published and read through hw/mod.rs prop! (required, no default; missing =
    probe fails). perf-states-sram and coredump-copy-buffer are required (j616s: PMP boots and stays up (endpoint 7, pmp-gfx report) #402: missing = GPU left disabled).
    Optional: when the ADT has gpu-fast-die0-target / -sensor-mask / -alarm-threshold / gpu-sochot-temp, aura copies them
    as-is to apple,fast-die0-target / apple,fast-die0-sensor-mask / apple,fast-die0-alarm-threshold / apple,sochot-temp
    (aura#448 names, raw ADT value and units). The kernel does not derive firmware words from them until the mapping is
    proven; they are for diagnostics and for that proof.
  2. linux#2544 RootV27_2::controller():
    • 0x22d4 = cfg.da.unk_8cc, 0x2284 = cfg.da.unk_87c, 0x2f30 = cfg.da.unk_e24: hw/t8112.rs HwConfigA (11000 / 900 / 125),
      the same fields the G14 13.5 InitData writes (initdata.rs:327/338). Nothing changes on the wire; the literals leave
      the runtime code.
      unk_8cc/unk_87c map by offset (27.2 = 13.5 + 0x1a08). unk_e24 maps by position: in the 13.5 HwDataA it directly
      follows the sensor mask, as 0x2f30 follows the alarm mask at 0x2f28 in 27.2. It is per-chip (T8103 112, J313 ADT
      gpu-sochot-temp 111), so it is likely the SoC-hot alarm temperature in C. Likely, not proven.
    • 0x2288 = 4, 0x229c = 1.0, 0x2f34 = 1: controller constants (filter count, unity scale, alarm enable) that are
      literals in the 13.5 InitData and in G15 as well. They are not protection limits. Keep them, named and commented.
    • Already machine-sourced, unchanged: fast-die release temperature, sensor mask and PI gains (hwdata_a), ppm gains
      and max power (PwrConfig from DT).
  3. OPEN (the one value with no source): the per-sensor 5.3 corrections at 0x2320/0x2420/0x2f38/0x3038. They have no
    13.5, G15, G16 or G17 equivalent and nothing in the ADT. They need a decision (Dj/Ryan): either a documented source,
    or proof that the controller runs safely with the field left at its default, or the value is accepted as a named
    controller constant like 4/1.0.

Proposed #2544 change (owner: Satya, or us if he hands it over)

Replace (0x22d4, 11000), (0x2284, 900), ... (0x2f30, 125) with cfg.da.unk_8cc, cfg.da.unk_87c as u32,
cfg.da.unk_e24. Name the three controller constants. Leave 5.3 as is, with a comment pointing at the open item,
until it is decided.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Correction to the contract above: its line "Already machine-sourced, unchanged: fast-die release temperature, sensor mask and PI gains" is wrong for the J473. Only the PI gains (and the ppm gains and max power) come from the ADT. The fast-die sensor mask comes from hw/t8112.rs (fast_sensor_mask 0x6800). The release temperature uses the hw/mod.rs default of 80 C, because this ADT has no source for apple,fast-die0-release-temp. Both fall under the same per-chip hardware config decision as 11000/900/125. Corrected text: work/m2gpu-publish/g14g-thermal-contract.md in the lab store.

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