Skip to content

drm/asahi: g16: submit on the channels of the queue records' class - #3059

Closed
DjDeveloperr wants to merge 1 commit into
djdev/g16-compute-overlap-persistent-ringsfrom
djdev/g16-app-priority-class-2
Closed

DjDeveloperr wants to merge 1 commit into
djdev/g16-compute-overlap-persistent-ringsfrom
djdev/g16-app-priority-class-2

Conversation

@DjDeveloperr

@DjDeveloperr DjDeveloperr commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #3057. It does not depend on the soft-fault PR.

What and why

Every G16 queue record declares scheduling class 2: +0x30/+0x34 = 2, mask 0xffff000000000000, class_c = 2. These are the words macOS 26B123 writes into its application queues' records on the J773g; its WindowServer and system queues declare class 0.

The firmware has one submit channel per pipe for each class. In our hypervisor trace of macOS 26B123 on the J773g:

  • channel k's RUNTIME descriptor names write cell 0x20 * (k % 3) + 8 * (k / 3);
  • every store to that cell is followed by doorbell k % 3 | (k / 3) << 2;
  • class-2 queues are submitted on channels 6, 7 and 8 (doorbells 0x8, 0x9, 0xa), and channels 0, 1 and 2 carry only class-0 queues.

G16 submitted its class-2 queues on channels 0, 1 and 2. Now:

  • Channel stays the pipe;
  • its ring and doorbell come from the class the records declare, through one named constant (qinfo_row2::CLASS_VALUE);
  • the record kind stays the pipe, as in macOS's channel 6–8 records.

All twelve channel pairs were already allocated and published at boot, so InitData does not change. The stall dump's ch0/ch1 labels become ta_ch/fs_ch.

Testing

Host.

  • The asahi-m4 host suite: 26/26 at this head. test-abi-26b123.py now compiles the production mapping and queue image against the trace's write-cell/doorbell pairs and its class-2 and class-0 record words.
  • checkpatch --strict: 0/0/0. git diff --check is clean.

Hardware (Mac mini M4, J773g, G16G B0, firmware 26B123), on our M4 integration tree carrying this commit.

  • Boot: context registration on channel 6 succeeds at boot.

  • Health: in about 4.0 M GPU jobs (Vulkan, ray tracing, OpenGL, the robustness subset) there was 0 GPU faults and 0 recoveries. The 16-process render row passed 3/3, and a deep sleep and resume passed.

  • Performance: same-machine A/B against the tree without it. The soft-fault advertisement was added in the same step, and the two are not separated.

    Row Change
    Geomean, 202 Vulkan rows −0.28 % (within noise)
    Geomean, 111 standard rows −0.77 %
    Geomean, two smaller sets +0.27 % and +0.36 %
    render.light tri d4 +7.5 %
    render.light tri, 2 processes +6.5 %
    16-process render row 69.5 → 68.3 µs
    compute.light queues d8 −5.4 %
    sync.signal cross-queue d2 −3.4 %
    mem.image 1024 −18 %

It is a draft until an A/B of this change on its own decides whether it stays.

Every G16 queue record declares scheduling class 2: +0x30 and +0x34
are 2, the +0x38 mask is 0xffff000000000000 and class_c is 2. Those
are the words macOS 26B123 writes into its application queues' records
on the J773g. Its WindowServer and system queues declare class 0
instead (0, 0, mask 0xffffffffffff0000, +0x40 = 1, class_c 1).

The firmware has one submit channel per pipe for each class. In an HV
trace of macOS 26B123 on the J773g, the RUNTIME descriptor of channel
k names write cell 0x20 * (k % 3) + 8 * (k / 3), and every store to
that cell is followed by doorbell k % 3 | (k / 3) << 2. macOS submits
its class-2 queues on channels 6, 7 and 8 (doorbells 0x8, 0x9, 0xa),
and only its class-0 queues on channels 0, 1 and 2.

G16 submits its class-2 queues on channels 0, 1 and 2, the class-0
channels, a combination macOS never uses. Keep the pipe as Channel's
identity and derive its ring and doorbell from the class the records
declare, one named constant for both. The record kind stays the pipe,
as in macOS's channel 6-8 records. All twelve channel pairs are already
allocated and published at boot, so no initdata changes.

The 26B123 ABI host test now compiles the production mapping and
record image against the pairs and record words of that trace.

Signed-off-by: Diljit Singh <hey@djdev.me>
@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Verdict at 6580c922d5: HOLD: draft, until its own A/B decides whether it stays. No code blockers.

Blockers: none while it is a draft. Before it leaves draft it needs a row at its head (the A/B the PR describes).

Checked: the diff: the ring and doorbell now follow the class the queue records declare, through one named constant, and the record kind stays the pipe; all twelve channel pairs are already published at boot, so no InitData change; the host test checks the mapping against our own HV trace of macOS 26B123; no Apple material; no gates; no new parameters; one commit with the author and Signed-off-by, no AI attribution.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Recommend closing #3059. The J773g trace confirms that submissions move to the intended class-2 channels. The isolated change delivered no overall speedup. The two triangle-render rows that had improved on the integration kernel were both slower here.

On the M4 mini (G16G B0, firmware 26B123), A was main d7b0aec41be6. B was local merge a5cbe912df80, with parents 6580c922d57b and d7b0aec41be6. The A→B diff has the same stable patch ID as the PR commit, 4bdeb2c7535750e8d88a299ed2377fa26c097b1a. Both arms used the same DTB, kernel configuration apart from the release suffix, and Borealis d4ad4a4dce. The published PR head is still 6580c922d57b.

Vulkan speed geomean B vs A
All 200 comparable rows −0.49%
Standard suite, 111 rows −0.94%
Two extension plans, 57 and 32 comparable rows +0.04% and +0.13%

Both arms recorded 200 successful rows and the same two unsupported descriptor-buffer rows. Percentages use the benchmark’s primary metric and account for whether higher or lower is better.

Individual workloads, channel receipts, and health
Workload A B
Triangle render, depth 4 75.73 µs 79.82 µs
Triangle render, 2 processes 100.08 µs 112.61 µs
Triangle render, 16 processes, median of 3 additional runs 66.93 µs 69.35 µs
Light compute, 8 queues 41.88 µs 44.10 µs
Light compute, 8 processes 97.81 µs 97.92 µs
Heavy compute, ALU, depth 4 545.85 µs 548.25 µs
Cross-queue timeline signal, depth 2 37.44 µs 38.10 µs
Async compute/render overlap 1.1807× 1.1571×
Concurrent compute/render, queues 1.1340× 1.1343×
Image allocation cycle, 1024 226.50 µs 229.52 µs
PostFX, 1080p 4× MSAA, depth 1 1315.79 µs 1344.09 µs
  • Routing. An untimed trace of submit messages on endpoint 0x21 recorded doorbells 0/1/2 on A (5,794 / 5,794 / 6,518) and 8/9/a on B (5,731 / 5,731 / 5,789), corresponding to channels 0–2 and 6–8. Tracing was disabled for the timed runs.
  • Correctness. The 16-process render repeats passed 3/3 on each arm. PostFX returned the expected CRC 668d6f0a at depths 1 and 2. Native OpenGL render smoke passed on the M4 GPU.
  • Vulkan CTS. With four workers, each arm recorded 6,529 passes, 10,768 unsupported cases, and zero failures across API smoke, synchronization, compute, draw, ray query, and robustness. The three ray-query cases passed using RT-capable Borealis c3a8399de3 on both arms.
  • Kernel health. A/B finished at 2,394,698 / 2,346,824 jobs with zero observed GPU faults, recoveries, or hang kills. Both retained the production kernel’s error messages with no new errors during the workloads.
  • Restore. J773g returned to production 7.3.0-ARCH-m4mainefed1ae3 with the display manager active, zero failed units, Wi-Fi up, and the test modules removed.
  • Sleep coverage. Both kernels exposed only [s2idle] in mem_sleep on this boot path. Deep suspend was unavailable.

@DjDeveloperr

Copy link
Copy Markdown
Contributor Author

Closing based on the isolated J773g (G16G B0) A/B results above (#3059 (comment)): switching doorbells 0/1/2 -> 8/9/a regressed the 200-row gpubench-vk speed geomean by -0.49% (-0.94% on the 111 standard rows, including render.light d=4 75.73 -> 79.82 us, 2-process light compute 100.08 -> 112.61 us, and 8-queue light compute 41.88 -> 44.10 us).

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.

1 participant