Skip to content

drm/asahi: g17: one CPU feed policy per generation; mailbox: key the RX clamp on a threaded handler - #2393

Merged
RyanTheTide merged 7 commits into
mainfrom
sweep/asahi-cpufeed
Nov 28, 2026
Merged

RyanTheTide merged 7 commits into
mainfrom
sweep/asahi-cpufeed

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem

  • drivers/gpu/drm/asahi/g17/feed.rs:12-41 (d7d7747) uses the T8140 constant hw::t8140::qos::CLOCK_HZ as the timebase of the G17 CPU feed detector on every G17 SoC.
  • The feed's per-generation differences are spread across the code:
    • The CPU floor (100 % on M5, 50 % otherwise) is picked by an m5 flag inside the request code (feed.rs:165, d4879a4).
    • The receive-thread level is a constant in port.rs:37 (d266c70).
    • M5 skips the receive-thread clamp through a separate clamp_rx flag (a48bc83).
  • drivers/soc/apple/mailbox.c:919-945,979 (564d91c) allows the receive-thread clamp only for the G17 GPU mailbox roles.

Change

  1. drm/asahi: g17: make the CPU feed one policy per generation
    • The detector takes the rate of the firmware command timestamps when it is created: COMMAND_TIMESTAMP_HZ, 24 MHz, the rate the G17 completion path converts them with (not CNTFRQ_EL0, which is 1 GHz on T6040 and T8140). The 2 ms refill limit is now kept in time. A zero rate turns refill detection off.
    • feed::Policy holds the floor, the syncobj wait hint and the receive-thread level used while the GPU is the bottleneck. A comment on each value names the commit that measured or introduced it.
    • Policy::DEFAULT is the G17P policy, measured on J700.
    • Policy::M5 overrides only the two values the M5 work changed: a 100 % floor, and the receive thread left at its default (measured on J775D).
    • Generations without their own measurement use the default.
    • The port reads the receive-thread level from the policy.
  2. soc: apple: mailbox: key the receive-thread clamp on a threaded handler
    • The clamp now checks apple_mbox::rx_threaded. Probe sets it when the receive handler runs in an IRQ thread, and only such a handler has a thread whose minimum utilization can be set.

No value changes on any SoC.

G13-G16 and per-SoC safety
  • G13-G16 GPU mailboxes receive in hard IRQ context, so they have no receive thread. GPU events go to the driver's own receive work item, which already sets its own minimum utilization (legacy_rx_util_min). The mailbox option has no G13-G16 consumer, and this change adds none.
  • The timestamp rate is 24 MHz, the same as the old T8140 constant, so the detector thresholds do not change. (An earlier revision passed CNTFRQ_EL0 here, which is 1 GHz on T6040/T8140; fixed in 27766d3.)
  • G17P SoCs (T8140, T6040, T6041) keep a 50 % floor and a receive-thread level of 256.
  • M5-profile SoCs (T6050, T8142) keep a 100 % floor and leave the receive thread at its default. M5 is selected by the firmware profile. Every M5-profile config uses the M5 firmware variant that used to select the clamp_rx exclusion.
  • Only the G17 GPU coprocessors get a threaded receive handler, both before and after this change.

Testing

  • make LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/ drivers/soc/apple/ on the release config: builds. No new warnings. W=1 drivers/soc/apple/mailbox.o: clean.

  • rustfmt: no new diffs in the touched files.

  • Hardware (one-shot test kernel 7.3.0-aurora-swl1 = integration 0abc2f3 + this and the other open sweep PRs, 2026-11-20):

    • T8140 J700 and T6040 J616s (G17): boot, GPU bound, 3 s2idle cycles rc=0, 0 kernel errors from drm/asahi or the mailbox. No GPU perf row was run; the feed policy values are unchanged on every gen, and the feed rate is the firmware's 24 MHz, the same rate the old T8140 constant gave.

Still to run

No change is expected. gpubench 0dae261 perf.list and the asahi_g17_feed_detector and mailbox KUnit suites:

  • Neo (T8140): pending
  • J616s (T6040): pending

The feed, the receive-thread clamp and the M5 policy are the work of Diljit Singh and Jeff Queisser.

The G17 CPU feed detector took its refill threshold from
hw::t8140::qos::CLOCK_HZ, a T8140 constant, on every G17 SoC, and its
per-generation differences were scattered: the CPU floor was chosen by
an m5 flag inside the request code (100% vs 50%), the syncobj wait hint
and the receive-thread level were file constants, and the M5 exclusion
from the receive-thread clamp was a separate flag passed to the port.

- The detector now takes the rate of the timestamps it is fed at
  creation, from the architected system counter (CNTFRQ_EL0) that the
  firmware command timestamps count and that the driver already reports
  as the timestamp frequency, and keeps its 2 ms refill limit in time. A
  zero rate disables refill detection instead of dividing by zero.
- feed::Policy holds the floor, the wait hint and the receive-thread
  level while the GPU is the bottleneck, each with the commit that
  measured or introduced it. Policy::DEFAULT is the G17P policy (J700);
  Policy::M5 overrides only the two values the M5 work changed (full
  floor; receive thread left at its default, J775D). The port reads the
  receive-thread level from the policy instead of taking a flag.

No value changes on any SoC.

Fixes: d7d7747 ("drm/asahi: request temporary CPU capacity for sustained GPU feeds")
Signed-off-by: Ryan Murray <[email protected]>
apple_mbox_set_rx_util_min() and the handler that applies it checked
for the G17 GPU mailbox roles. What they need is a receive handler that
runs in an IRQ thread: only then is there a thread whose minimum
utilization can be set. Record that at probe in apple_mbox::rx_threaded
and check it instead. Today only the G17 GPU coprocessors get a threaded
handler (for their bounded receive batch), so behaviour is unchanged;
any mailbox that is given a threaded handler later supports the clamp
without another role check.

The G13-G16 GPU mailboxes receive in hard IRQ context and hand GPU
events to a driver work item that already sets its own minimum
utilization, so they have no receive thread to clamp.

Fixes: 564d91c ("soc: apple: mailbox: let a consumer set the receive thread's minimum utilization")
Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide
RyanTheTide marked this pull request as ready for review November 19, 2026 21:28
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

No blockers.

I checked that no value changes. G17P keeps floor 50, the 512/8 ms wait hint and receive-thread level 256. M5 keeps floor 100 and the receive thread at its default: the port now always attaches the handle, and rx_update() returns early because gpu_bound_rx_util_min is None. The detector rate comes from qos::clock().1 (CNTFRQ_EL0, g17/qos.rs:325-334), the counter the command timestamps count, and a zero rate disables refill detection instead of dividing by zero. drivers/soc/apple/mailbox.c:1637 sets rx_threaded only where it requests the threaded IRQ, so the clamp and the threaded handler cannot disagree.

Nit: drivers/gpu/drm/asahi/g17/feed.rs:497-506: gpu_bound_rx_util_min() was inserted between gpu_bound() and its doc comment. Rustdoc now attaches the "Whether the GPU itself is the bottleneck" text to the new function, and gpu_bound() has no doc. Move the new function above that comment block.

HW row: J616s and Neo, this branch on the default command line: gpubench 0dae261 perf.list A/B against the base on the same boot conditions (within noise), and the asahi_g17_feed_detector and mailbox KUnit suites pass. Regression: 0 AVC, 0 failed units, 0 new kernel errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merge-train note: this branch now conflicts in drivers/gpu/drm/asahi/g17/feed.rs with #2607 (merged: one busy run per client, firmware-clock refill window MAX_REFILL_TICKS = CLOCK_HZ / 500). The conflict isn't mechanical. This PR passes counter_hz into Detector::new, while the tip uses a fixed CLOCK_HZ asserted equal to COMMAND_TIMESTAMP_HZ and adds the runs spinlock. The rework needs to keep #2607's per-client runs and pick a single clock source, then a Neo GPU row (dEQP-VK smoke plus the busy-run check) on the merged head. It goes back in the queue once it is clean.

Conflicts: drivers/gpu/drm/asahi/g17/feed.rs (keep the PR's Policy and counter-rate Detector, integration's busy runs and firmware clock; the CLOCK_HZ import stays for the busy runs until the follow-up).

Signed-off-by: Ryan Murray <[email protected]>
The busy runs integration added to the feed (note_work(), busy_run())
convert the firmware idle-off delay and the effort hold to ticks with
hw::t8140::qos::CLOCK_HZ and read the clock at that rate. The feed now
takes the rate of the firmware command timestamps at creation (the
architected system counter); use it there as well, so no T8140 constant
is left in the feed. Without a counter rate no run is reported busy, as
the detector then detects no refill.

No value change: every Apple SoC's system counter runs at 24 MHz.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merged integration/aurora (f5f023b); conflict in drivers/gpu/drm/asahi/g17/feed.rs resolved (PR's Policy and counter-rate Detector kept alongside #2607's busy runs), plus a follow-up commit moving the busy runs from hw::t8140::qos::CLOCK_HZ to the feed's counter rate; drivers/gpu/drm/asahi/ and drivers/soc/apple/ (Rust, arm64 fleet config, LLVM) build with no new warnings.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Rebased onto #2607 and CI is green. Still needed on this head: a Neo GPU row (dEQP-VK smoke plus the busy-run check), the J616s and Neo gpubench A/B against the base, and the feed detector and mailbox KUnit suites; also move gpu_bound_rx_util_min() above the gpu_bound() doc comment.

@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 pre-PR review (§1–§6) at 24be2afb988f7bd6ce71e7e4115815fefee56aef: REQUEST_CHANGES.

Blockers

  1. Correctness (§1/§2 — 41.67× clock-domain mismatch on every G17 SoC):
    • drivers/gpu/drm/asahi/g17/mod.rs:1728 passes qos::clock().1 (CNTFRQ_EL0) as counter_hz to feed::Feed::new(), and the commits/PR body claim "every Apple SoC's system counter runs at 24 MHz" and "firmware command timestamps count the architected system counter (CNTFRQ_EL0)".
    • This is false on G17 SoCs (ARMv8.6+ Apple Silicon: T6040/T6041 M4, T8140 A18 Pro, T8142/T6050 M5): CNTFRQ_EL0 runs at 1 GHz (1_000_000_000 Hz), whereas GPU firmware command timestamps passed to Feed::note_pass() and Feed::note_work() (g17/completion.rs:96,851,864-871) are stamped in the 24 MHz (24_000_000 Hz) firmware clock domain. Both drivers/gpu/drm/asahi/g17/trace.c:109-115 ("24 MHz, while the CPU counter runs at 1 GHz on T6040 and T8140") and drivers/gpu/drm/asahi/g17/qos.rs:379-389 ("Firmware accounting uses a 24 MHz domain independent of host timer speed") explicitly document and scale between these two domains.
    • Passing CNTFRQ_EL0 = 1 GHz breaks all three timing paths in drivers/gpu/drm/asahi/g17/feed.rs by 41.67×:
      • Detector::max_refill_ticks = counter_hz / 500 (feed.rs:104): 2_000_000 ticks = 83.33 ms (at 24 MHz) instead of 2 ms, misclassifying 60/120 Hz paced frames as refill-bound bursts.
      • Feed::note_work() (feed.rs:188): idle_ticks = FIRMWARE_IDLE_OFF_MS * (self.counter_hz / 1000) becomes 2_000_000 ticks (83.33 ms instead of 2 ms).
      • Feed::busy_run() (feed.rs:202-207): hold_ticks = IDLE_HOLD_NS * hz / 1_000_000_000 becomes 16_000_000 ticks (666.7 ms at 24 MHz instead of 16 ms), AND asahi_g17_firmware_clock(1_000_000_000) returns raw 1 GHz CNTVCT, which BusyRuns::bound() (g17/power.rs:259) subtracts from 24 MHz run.last_end — making now.saturating_sub(run.last_end) immediately exceed run.last_busy + idle_ticks and permanently breaking busy_run() after a few ms of uptime.
    • Fix: Pass the firmware timestamp domain frequency (24 MHz — e.g., a G17 firmware timestamp frequency constant/config field rather than CNTFRQ_EL0), and keep the compile-time/runtime domain invariant explicit.
  2. Doc-comment misplacement: drivers/gpu/drm/asahi/g17/feed.rs:540-548 inserts gpu_bound_rx_util_min() in the middle of gpu_bound()'s doc comment, detaching gpu_bound()'s rustdoc onto gpu_bound_rx_util_min(). Move gpu_bound_rx_util_min() above gpu_bound()'s doc block.
  3. §5 (Missing exact-head hardware, perf A/B & KUnit evidence): Live head 24be2afb988f (post-#2607 merge and commit 24be2afb988f) has not been booted on hardware. After fixing the 24 MHz vs CNTFRQ_EL0 bug above, provide on the new exact head (default cmdline):
    • Neo (T8140) and J616s (T6040): boot, dEQP-VK smoke + busy-run verification, same-machine gpubench A/B against base (within noise), asahi_g17_feed_detector and mailbox KUnit passes, and regression gate (0 SELinux denials / 0 failed units / 0 new kernel errors).

Verified Clean

  • Mailbox RX clamp (drivers/soc/apple/mailbox.c, mailbox.h, mailbox-g17-test.h): Keying apple_mbox_set_rx_util_min() and apple_mbox_recv_irq() on mbox->rx_threaded (set in apple_mbox_probe() exactly where devm_request_threaded_irq() is chosen) is clean and eliminates the G17 role gate in the clamp path.
  • §4 Attribution / §6 Naming / CI: All four commits carry human author/committer and Signed-off-by: only (zero AI commit trailers); live CI (Host tests + SEP source checks) is green on 24be2afb988f.

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

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Merge readiness at 30a39db8: not ready yet

Check Detail
CI at head ok 26 checks passed
Review no needs one approving review from Core or Omarchy Mac (not the author)
Requested changes no requested by DjDeveloperr
Hardware row at head ok comment at 30a39db8
Conflicts ok none
PR text adopt when you next edit add a 'Tested:' line; a 'Risk:' line (door and Macs) (guide)

Areas: area:gpu, area:platform

Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels.

@github-actions github-actions Bot added the merge-conflict Conflicts with the base branch (bot) label Nov 24, 2026

@DjDeveloperr DjDeveloperr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: FINISH, then merge at 24be2afb988f

Blockers:

  1. drivers/gpu/drm/asahi/g17/mod.rs:1728: feed::Feed::new(..., qos::clock().1) passes CNTFRQ_EL0 as the counter rate for firmware command timestamps. On T6040 and T8140 that's 1 GHz, but the firmware stamps commands at 24 MHz; the tree says so itself in g17/trace.c:108-111 ("24 MHz, while the CPU counter runs at 1 GHz on T6040 and T8140"). So every duration note_pass()/note_work() computes is off by about 41.7x on those SoCs. Fix: pass the firmware's 24 MHz time base (the rate asahi_g17_firmware_clock() converts to), and correct the commit message and body, which say every SoC's counter runs at 24 MHz.

Checked: no Apple material. One CPU feed policy per generation instead of per-chip copies, and the mailbox RX clamp keyed on a threaded IRQ. The J700 and J616s combined-kernel boots (GPU bound, 3 s2idle cycles, no drm/asahi or mailbox errors) show no crash. CI green. This replaces my earlier review.

Evidence

Checked qos::clock() (g17/qos.rs:325, it reads CNTFRQ_EL0) and asahi_g17_firmware_clock() at this head. After the fix, the row is one G17 Mac with the feed's computed pass times matching the firmware's.

@DjDeveloperr
DjDeveloperr dismissed their stale review November 24, 2026 19:43

Superseded by the review at 24be2af

@github-actions github-actions Bot added merge-conflict Conflicts with the base branch (bot) and removed merge-conflict Conflicts with the base branch (bot) labels Nov 25, 2026
Review follow-up. The feed was created with qos::clock().1, the CPU
counter rate from CNTFRQ_EL0, as the rate of the firmware command
timestamps. On T6040 and T8140 that counter runs at 1 GHz, but the
firmware stamps commands at 24 MHz (see asahi_g17_firmware_clock()), so
every pass and work duration note_pass() and note_work() computed was
off by about 41.7x there. The earlier commit's "every Apple SoC's
system counter runs at 24 MHz" was wrong for those SoCs.

Pass COMMAND_TIMESTAMP_HZ, the 24 MHz the G17 completion path already
converts firmware timestamps with. busy_run() reads the clock through
asahi_g17_firmware_clock() at the same rate, so both sides agree again.

Signed-off-by: Ryan Murray <[email protected]>
# Conflicts:
#	drivers/gpu/drm/asahi/g17/feed.rs
#	drivers/gpu/drm/asahi/g17/port.rs
#	drivers/soc/apple/mailbox.c
@RyanTheTide
RyanTheTide requested review from a team as code owners November 27, 2026 06:54
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row at 9ee9ceaf1c5f (this PR's files byte-identical in the combined test kernel 7.3.0-aurora-fixa2): M1 Pro (J316s, T6000/G13S): PASS, M2 Air (J413, T8112/G14G): PASS.

No-change row on G13/G14. The G17 (Neo) pass-time row is still owed.

Detail

Both rows ran on the default cmdline with the kernel booted once as a non-default entry, then back to fleet89, which was verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). Per Mac: SELinux Enforcing, 0 failed units, 0 AVC, 0 err-level kernel lines, 0 oops; Wi-Fi ping OK; s2idle (rtc1, 15 s) rc=0 with ping and a 64 MiB direct NVMe read after the wake; Apple SoC watchdog armed with time left counting (44 s and 58 s of systemd's 60 s); dEQP-VK api.smoke 8/8 pass. J413 also: glmark2 off-screen (FBO) score 7672, 2 audio sinks. On the M1 Pro, glmark2-wayland never starts rendering: its internal panel is dead and there is no Wayland output, the same on fleet89 (traced), so no GL FBO number there. Silent, no playback. Logs: traces/kernel/20261127-fixa2-rows/ (store).
Kernel kit: kits/test/20261127-fixa2 = main 0a4f97d + forward-merged heads of #2919 #2886 #2302 #2475 #2393 #2384 #2895.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Row at 9ee9ceaf1c5f (byte-identical in 7.3.0-aurora-fixa2): Neo (J700, T8140/G17P): PASS.

G17P at this head: GPU bound, dEQP-VK smoke pass, no mailbox/G17 error or recovery line. Still owed: the feed's computed pass times against the firmware's, which needs a feed trace this row didn't take.

Detail

Neo (J700, T8140/G17P), fixa2 booted once as a non-default BLS entry, then back to fleet89, verified afterwards (saved entry, empty next_entry, kernel removed, 0 failed, Enforcing). SELinux Enforcing, 0 failed units, 0 AVC, 0 oops, 0 err-level kernel lines; Wi-Fi up; G17P Vulkan device; dEQP-VK api.smoke 8/8 and draw.renderpass.simple_draw 4/4; watchdog armed (57 s left of 60); s2idle on rtc0 rc=0 with a 64 MiB direct NVMe read after the wake. Two lines are the same on fleet89 (baseline traced): the boot-time "G17: crash logs from the firmware data segment" note, and Wi-Fi needing ~9 s after the wake before ping answers. Logs: traces/kernel/20261127-fixa2-rows/neo/ (store).

@github-actions github-actions Bot added ci-failing A check failed at the PR head (bot) and removed merge-conflict Conflicts with the base branch (bot) needs-hw-row No hardware row at the PR head (bot) labels Nov 27, 2026
This branch makes Detector::new() take the command timestamp rate.
Two tests that came with the main merge (gpu_bound_long_pass_lingers_
for_full_frame and the 60 Hz case of paced_or_short_runs_are_neither)
still called it without one, so every KUnit build of asahi_core failed
(E0061), which the fleet build does not compile.

Pass CLOCK_HZ as the other tests do.

Signed-off-by: Ryan Murray <[email protected]>
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

CI fix at 30a39db: the SEP and asahi KUnit jobs failed to build asahi_core (E0061). Two detector tests that came with the main merge (gpu_bound_long_pass_lingers_for_full_frame and the 60 Hz case in paced_or_short_runs_are_neither) called Detector::new() without the counter rate this branch adds. They now pass CLOCK_HZ like the other tests. Test-only change.

Tested: KUnit arm64 drivers/gpu/drm/asahi/.kunitconfig 486 run, 482 passed, 4 skipped; sep.kunitconfig 336/336.
Risk: none to the driver (cfg(test) code only). The fixa2 rows at 9ee9cea still apply.

@github-actions github-actions Bot added needs-hw-row No hardware row at the PR head (bot) and removed ci-failing A check failed at the PR head (bot) labels Nov 27, 2026
@RyanTheTide

Copy link
Copy Markdown
Contributor Author

G17P row at this head (30a39db): A18 Pro (T8140, J700). The kernel was the combined fixa5 test kernel, linux main fca33ed plus the heads of #2887 #2959 #3384 #2919 #2393 #2895. Every file this PR changes is byte-identical to this head there, except g17/mod.rs. That file also carries #3384's hunks, and nothing else differs from this head: no lines from anywhere else, and none of this PR's lines missing. One-shot boots, default command line.

Smoke:

  • 0 failed units, Enforcing, 0 AVC denials.
  • aurora bound. dEQP-VK api.smoke.* 8/8 and draw.renderpass.simple_draw.* 4/4.
  • glmark2 off-screen 9986. gpubench quick set rc=0.
  • s2idle x3 on rtc0, all rc=0.
  • 0 kernel errors from drm/asahi or the mailbox.

Feed pass times: gpubench 0dae261 perf.list (41 cases, 5 runs x 250 ms each), interleaved on one Neo: fleet89 A1, fixa5 B1, fleet89 A2, fixa5 B2.

  • Each pair agrees: median A1/A2 spread 2.3 %, B1/B2 spread 2.4 %.

  • Over all 41 cases, fixa5 vs fleet89 has a median delta of -0.9 % (fixa5 slightly faster).

  • Shallow queues are much faster on fixa5, for example render.light tri queue d2 84.3/82.8 -> 48.1/47.6 us/submit, and compute.light queue d4 27.3/25.4 -> 20.8/20.7.

  • Five deep-queue cases are 5-8 % slower:

    case fleet89 A1/A2 (us/submit) fixa5 B1/B2 (us/submit) delta
    render.light tri queue d64 27.5/27.1 29.8/29.4 +8.3 %
    compute.light queue d16 14.1/13.9 14.9/15.0 +6.9 %
    compute.light queue d64 13.4/13.3 14.2/14.1 +6.1 %
    render.light tri queue d8 30.2/29.5 31.7/31.3 +5.6 %
    render.light tri procs d16 36.0/36.2 38.0/38.0 +5.3 %

This compares against the default kernel, as the row asked, so it does not isolate this PR. fleet89 is main 645f7cd, 1100 commits (59 of them in g17/ or the mailbox) behind the fixa5 base fca33ed. The large shallow-queue gains and the small deep-queue costs fit those main changes. The feed policy values and the 24 MHz rate this PR uses are unchanged.

I see nothing here that points at the feed change. Isolating the deep-queue +5-8 % would need a main-only kernel against main plus this PR.

The on-device asahi_g17_feed_detector and mailbox KUnit suites were not run: fleet kernels boot with KUnit disabled. Host KUnit results are in the earlier comment.

The Neo was restored to fleet89 and verified. Evidence (lab store): traces/kernel/20261128-fixa5-rows/neo/ (p-{A1,B1,A2,B2}.jsonl, perf-compare.txt). Comparison script: kits/test/20261128-fixa5/perfcmp.py.

@aurora-silicon-review aurora-silicon-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: MERGE at 30a39db8

Blockers: none (re-run the cancelled readiness check before landing; 26/26 build/host/KUnit/pr-text checks green).

Checked:

  • drivers/gpu/drm/asahi/g17/feed.rs & g17/mod.rs: commit 27766d38 resolves the prior 41.67x clock-domain mismatch blocker by passing the firmware's 24 MHz timestamp rate (COMMAND_TIMESTAMP_HZ) rather than CNTFRQ_EL0 (1 GHz) into Feed::new() / Detector::new(), and 30a39db8 updates main's new detector tests cleanly.
  • Per-generation Policy (Policy::DEFAULT vs Policy::M5) consolidates floor_percent, wait_util_min, wait_hint_ms, and gpu_bound_rx_util_min with documented provenance; mailbox RX clamp keys on threaded handler capability instead of a chip gate.
  • Hardware rows & CI: exact-head J700 (G17P / A18 Pro) row plus M1 Pro and M2 Air regression rows PASS (fixa5/fixa2); 26/27 CI green (MERGEABLE on main).
  • Checked for Apple material, tool attribution, private serials, and gating: clean; human Signed-off-by present.
Evidence
  • Head: 30a39db8572b (base: main, mergeable: MERGEABLE, +144/-54 across 6 files).

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at 30a39db8. The review App approved this head (NEON-PR-REVIEW2's adversarial pass) and hosted CI is green. Rows: J700+M1Pro+M2. Your earlier change request is on an older head, and the App verified the blockers are addressed here. Unless you object or restate a blocker, this merges in 1 h under the 6-point rule.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Merging under the 6-point rule (Ryan 09:29, permanent), at 30a39db8. (1) The review App approved at this head. (2) Full CI is green. (3/4) Rows: J700+M1Pro+M2. (5) There's no blocking review. (6) Dj was pinged here 61 min ago with no objection. Revert: git revert -m 1 <merge>.

@RyanTheTide
RyanTheTide merged commit da7c5d6 into main Nov 28, 2026
27 of 28 checks passed
@RyanTheTide
RyanTheTide deleted the sweep/asahi-cpufeed branch November 28, 2026 12:55
Isaac-Duarte added a commit to Isaac-Duarte/linux that referenced this pull request Nov 28, 2026
On M5 Pro (J714s / T6050), ordinary desktop, browser, and video
workloads with <1% GPU utilization trigger the G17 CPU feed detector
and pin all CPU clusters at 100% max frequency (~4.38 GHz / ~4.61 GHz)
~33-74% of the time. Three interactions cause this:

1. Commit 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on
   GPU-bound streams") raised the shared LINGER_NS constant from 8 ms to
   20 ms so bound_until covers a full 60 Hz frame. That also stretched
   the CPU-floor deadline (`until`) to 20 ms, longer than both 60 Hz
   (16.67 ms) and 120 Hz (8.33 ms) frame periods, so periodic frame
   bursts continuously renew a 100% CPU frequency floor across idle
   frames.

2. A single GPU-wide `last_end`/`streak` merges unrelated DRM contexts
   (e.g., compositor, browser, video player). Staggered paced clients
   whose individual bursts last 1-3 ms chain across each other into
   30-80+ pass global bursts without resetting `streak`.

3. `STREAK_ON = 8` fires on pass count alone regardless of elapsed run
   duration, so a short multi-pass UI redraw raises the CPU floor for
   20 ms.

Track refill-bound streaks per DRM context in a 16-slot LRU `Tracker`
under its own spinlock (updated in `Feed::note_pass(context, start,
end)` after fence signalling, off the wakeup critical path) while
keeping `Detector` deadline/worker state lock-free with monotonic
saturating `fetch_max` deadlines and `SeqCst` wake handoff:
- Split `LINGER_NS` into `FEED_LINGER_NS = 8_000_000` (8 ms for `until`)
  and `BOUND_LINGER_NS = 20_000_000` (20 ms for `bound_until`).
- Scale `Tracker::new(counter_hz)` thresholds from `Feed`'s firmware
  command timestamp rate (disabling detection when `counter_hz == 0`)
  and require a sustained per-context run spanning at least
  `FEED_MIN_RUN_PER_SEC` (`counter_hz / 125`, 8 ms) before emitting
  `Sample::RefillBound` so transient frame bursts stay unboosted.
- Measure `gpu_idle` against `global_last_end` while crediting actual
  busy duration on partially overlapping parallel waves (`start <
  global_prev && end > global_prev`), drop fully subsumed intervals
  (`end <= global_prev`), and use saturating arithmetic in `decay_add`.

Validation (rebased onto main across aurora-silicon#2393 Policy/counter_hz and aurora-silicon#3428):
- Host tests (`run-host-tests.py --only g17`, Rust 1.100.0): 255/255
  pass, including `g17-feed-burst-tests.py` and all 7 mutations.
- KUnit (`arm64` QEMU, `KUnit asahi`): `asahi_g17_feed_detector` 13/13
  pass (including `zero_counter_hz_never_detects_refill_or_bound`).
- Full driver build (`LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/`): passes
  with `CONFIG_CPU_FREQ=y` and `CONFIG_UCLAMP_TASK=y`.
- Hardware rows (run on earlier identical detector logic prior to main
  aurora-silicon#2393 Policy refactor): J714s M5 Pro (`7.3.0-124e30a`) quiet-desktop
  A/B (`policy12` boost 33.15% -> 0.14%, `paced60/120` 99.6%/99.8% ->
  0.64%/0.00%, `gpu_bound` 48.2% -> 0.00%, `refill_d1` 98.5%), 8-loop
  `gpubench` vk/gl soak (232/232 ok, 12/12 fresh VK clients,
  `gpubench-stress-vk` 3/3 pass); J700 MacBook Neo (`G17P`) peer row
  (8/8 `gpubench-vk` soak, 10/10 fresh VK clients, `s2idle` pass).

Fixes: 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams")
Signed-off-by: Isaac Duarte <[email protected]>
Isaac-Duarte added a commit to Isaac-Duarte/linux that referenced this pull request Nov 30, 2026
On M5 Pro (J714s / T6050), ordinary desktop, browser, and video
workloads with <1% GPU utilization trigger the G17 CPU feed detector
and pin all CPU clusters at 100% max frequency (~4.38 GHz / ~4.61 GHz)
~33-74% of the time. Three interactions cause this:

1. Commit 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on
   GPU-bound streams") raised the shared LINGER_NS constant from 8 ms to
   20 ms so bound_until covers a full 60 Hz frame. That also stretched
   the CPU-floor deadline (`until`) to 20 ms, longer than both 60 Hz
   (16.67 ms) and 120 Hz (8.33 ms) frame periods, so periodic frame
   bursts continuously renew a 100% CPU frequency floor across idle
   frames.

2. A single GPU-wide `last_end`/`streak` merges unrelated DRM contexts
   (e.g., compositor, browser, video player). Staggered paced clients
   whose individual bursts last 1-3 ms chain across each other into
   30-80+ pass global bursts without resetting `streak`.

3. `STREAK_ON = 8` fires on pass count alone regardless of elapsed run
   duration, so a short multi-pass UI redraw raises the CPU floor for
   20 ms.

Track refill-bound streaks per DRM context in a 16-slot LRU `Tracker`
under its own spinlock (updated in `Feed::note_pass(context, start,
end)` after fence signalling, off the wakeup critical path) while
keeping `Detector` deadline/worker state lock-free with monotonic
saturating `fetch_max` deadlines and `SeqCst` wake handoff:
- Split `LINGER_NS` into `FEED_LINGER_NS = 8_000_000` (8 ms for `until`)
  and `BOUND_LINGER_NS = 20_000_000` (20 ms for `bound_until`).
- Scale `Tracker::new(counter_hz)` thresholds from `Feed`'s firmware
  command timestamp rate (disabling detection when `counter_hz == 0`)
  and require a sustained per-context run spanning at least
  `FEED_MIN_RUN_PER_SEC` (`counter_hz / 125`, 8 ms) before emitting
  `Sample::RefillBound` so transient frame bursts stay unboosted.
- Measure `gpu_idle` against `global_last_end` while crediting actual
  busy duration on partially overlapping parallel waves (`start <
  global_prev && end > global_prev`), drop fully subsumed intervals
  (`end <= global_prev`), and use saturating arithmetic in `decay_add`.
- Keep the GPU-bound streak device-wide, as before: busy contexts that
  alternate each wait longer than a refill gap between their own passes
  while the GPU never idles, so per-context streaks alone would drop the
  syncobj wait hint. Per-context streaks only gate CPU-floor requests.

Validation (rebased onto main across aurora-silicon#2393 Policy/counter_hz and aurora-silicon#3428):
- Host tests (`run-host-tests.py --only g17`, Rust 1.100.0): g17 host tests
  pass, including `g17-feed-burst-tests.py` and all 8 mutations.
- KUnit (`arm64` QEMU, `KUnit asahi`): `asahi_g17_feed_detector` 13/13
  pass (including `zero_counter_hz_never_detects_refill_or_bound`).
- Full driver build (`LLVM=1 ARCH=arm64 drivers/gpu/drm/asahi/`): passes
  with `CONFIG_CPU_FREQ=y` and `CONFIG_UCLAMP_TASK=y`.
- Hardware rows (run on earlier identical detector logic prior to main
  aurora-silicon#2393 Policy refactor): J714s M5 Pro (`7.3.0-124e30a`) quiet-desktop
  A/B (`policy12` boost 33.15% -> 0.14%, `paced60/120` 99.6%/99.8% ->
  0.64%/0.00%, `gpu_bound` 48.2% -> 0.00%, `refill_d1` 98.5%), 8-loop
  `gpubench` vk/gl soak (232/232 ok, 12/12 fresh VK clients,
  `gpubench-stress-vk` 3/3 pass); J700 MacBook Neo (`G17P`) peer row
  (8/8 `gpubench-vk` soak, 10/10 fresh VK clients, `s2idle` pass).

Fixes: 6cfa2da ("drm/asahi: g17: provide syncobj wait hint on GPU-bound streams")
Signed-off-by: Isaac Duarte <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:gpu Area from CODEOWNERS (bot) area:platform Area from CODEOWNERS (bot) changes-requested A reviewer requested changes (bot) needs-review No approving review from Core or Omarchy Mac yet (bot) needs-template PR body lacks Tested or Risk (bot)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants