Skip to content

drm/asahi: accept FRAGMENT_BARRIERS on G13 and G14 - #1811

Closed
RyanTheTide wants to merge 5 commits into
integration/aurorafrom
gpuperf/legacy-fragment-barriers
Closed

RyanTheTide wants to merge 5 commits into
integration/aurorafrom
gpuperf/legacy-fragment-barriers

Conversation

@RyanTheTide

@RyanTheTide RyanTheTide commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

G13/G14: the legacy queue puts a render's wait for earlier renders on its vertex (tiling) queue, so the tiling of render N+1 cannot start before the fragment work of render N has finished, even when only the fragment half of N+1 depends on it.

This advertises the existing DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS on the G13/G14 backend. For a render with DRM_ASAHI_RENDER_FRAGMENT_BARRIERS, the wait named by vdm_barrier only refers to earlier fragment work of the same queue (index 0 is the queue's last fragment event, later indices are renders of the same submission). The fragment workqueue already runs that work first, so no barrier is added. Each fragment half still waits for its own vertex half, and compute dependencies keep ordering the vertex half. Renders without the flag are unchanged.

Userspace: mesa Borealis sets the flag on serialized G13/G14 queues only when the recorded dependencies show the vertex half reads nothing an earlier render produced (aurora-silicon/mesa#265).

Results (gpubench 0dae261, us per submission, lower is better; same boot, Mesa with the flag off vs on, two interleaved runs each, which agree within 1%):

row M1 Pro (G13X) off -> on M2 (G14G) off -> on
render.heavy geom 1080p d16 339 -> 162 553 -> 294
render.tvb 32k tris d4 3378 -> 2049 5102 -> 2717
render.heavy fill 720p d16 210 -> 139 315 -> 256
render.heavy fill 1080p d16 391 -> 312 643 -> 577
render.light tri d16 49.9 -> 46.0 62.7 -> 56.0
depth-1 rows, compute.light, compute.heavy unchanged unchanged

Vulkan CTS 1.4.7.0: a 2,402-case render-ordering subset (synchronization2 graphics write -> vertex/fragment/indirect reads, pipeline barriers, transform feedback, renderpass2 suballocation, occlusion queries) is case-for-case identical with the flag off and on, on both Macs (833 Pass / 1569 NotSupported / 0 Fail). On the M2 a 46,515-case broad run (api, query_pool, synchronization, synchronization2, ubo, glsl, texture, graphicsfuzz, ssbo, transform_feedback.simple, draw indirect) is also case-for-case identical (20947 Pass / 25564 NotSupported / 4 QualityWarning in both / 0 Fail).
vkmark: M1 Pro 10463 -> 10492, M2 8541 -> 8641. 0 AVC denials, no GPU faults or timeouts.

Assisted-by: LLM (Claude:Opus 5.5)

The cluster DVFS controller holds the performance state it was last
asked for while every CPU of the cluster is idle, and the cluster
voltage follows that state. schedutil only runs from scheduler events
on the cluster's own CPUs, so nothing lowers the request once the
cluster goes idle. Real-time tasks get uclamp_min 1024 by default, so
a short periodic RT thread (an audio data loop, a threaded IRQ
handler, a 100 Hz supervisor loop) leaves an otherwise idle cluster at
its fastest state until the next wakeup.

On the MacBook Pro M1 Pro (J316s) at idle, the P clusters sat at
3036 MHz for 6-48% of the time. Setting sched_util_clamp_min_rt_default
to 0 dropped system power from 3.29 W to 2.98 W (SMC Total System
Power, 120 s rows, same boot), which is what the stale request costs.
The sysctl also takes the clock away from RT threads while they run,
so it cannot be the fix.

Add an idle state that parks the cluster instead. cpuidle-apple gets
a "WFI-park" state (exit latency 50 us, target residency 1 ms) and
calls the cpufreq driver's hooks around its WFI, and around the CPU
power-down state on M1 to M3. Once every online CPU of a cluster is in
one of those states, the driver requests the slowest state. The first
CPU to wake restores the last request, and the transition finishes
while it runs. Requests that arrive while the cluster is parked are
recorded and applied on wakeup, and the driver keeps reporting the
requested frequency. RT threads still run at the frequency their clamp
asks for.

Only SoCs that do not verify transitions park (T8103, T6000, T8112,
T6041). On M4 the second idle state used to be a copy of WFI kept for
s2idle; it is now the parking state, and s2idle uses it as before.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
T8140 verifies every DVFS request, so the first version left it out.
Parking fits that scheme: the park request becomes the expected state
and the request that restores the cluster verifies it, the same way a
request finding the cluster idle verifies the one before it.

A cluster does not park while waited-for requests own it, while a
request is pending, or after a transition has failed. Fast-switch
requests and new fast die-temperature limits that arrive while the
cluster is parked are recorded and applied when it wakes. A waited-for
request unparks the cluster and is applied and verified at once.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The legacy queue puts a render's wait for earlier renders on its vertex
queue, so the tiling of render N+1 cannot start until the fragment work
of render N has finished, even when only the fragment half of N+1
depends on it.

Advertise DRM_ASAHI_FEATURE_FRAGMENT_BARRIERS on the G13/G14 backend.
For a render carrying DRM_ASAHI_RENDER_FRAGMENT_BARRIERS that wait names
only earlier fragment work of the same queue, which its fragment
workqueue already runs first, so no barrier is added at all. The
fragment half still waits for its own vertex half, and compute
dependencies keep ordering the vertex half.

Assisted-by: LLM
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.

The host-tests failure is not the GPU change. This branch also carries two cpufreq commits (6b72af7 "park an idle cluster at its slowest state" and b17d649 "park idle clusters on lazy_verify SoCs too"). They add a WFI-park state between WFI and the deep state in cpuidle-apple.c, and apple-dcp › cpuidle-s2idle fails because it expects two idle states on t8140, with the deep state at index 1 for s2idle.

Please drop those two commits from this PR. The FRAGMENT_BARRIERS commit (6a743fa) looks right on its own: it only advertises the flag on the G13/G14 GpuManager, renders without the flag keep the vertex-queue barrier, and the G17 backend reports no new feature bit. With only that commit and green CI, it can merge.

The cluster parking needs its own PR. It changes the idle-state table, including the state s2idle picks, on every apple-cpuidle SoC, so it needs the cpuidle-s2idle test updated and an s2idle check on the affected machines.

This reverts commit b17d649.

Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
This reverts commit 6b72af7.

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

Copy link
Copy Markdown
Contributor Author

Dropped the two cpufreq commits with reverts on top (f9ae816c3424, 7227c87f3ff5), so the net diff is now only 6a743fa60ac7 (drm/asahi: gpu.rs, queue/mod.rs, queue/render.rs). The cluster parking moved to its own draft, #1988, which owes the cpuidle-s2idle test update and s2idle rows.

tools/testing/selftests/drivers/gpu/apple-dcp/run.py on 7227c87f3ff5: 88 ok, 0 not ok, including ok 47 - cpuidle-s2idle.

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

The cpufreq commits are out (reverted on top, and moved to #1988), so the net diff is only 6a743fa, which I was happy with on 11-13. Approving that.

It needs a rebase before it can merge, because it now conflicts with integration/aurora in all three files:

Please:

  • Rebase onto integration/aurora with only that commit. Drop the two cpufreq commits and their reverts, so they don't land as four no-op commits.
  • Check one thing while rebasing. 3d6b26b waits for the queue's last render before growing its TVB. With FRAGMENT_BARRIERS, the vertex half of N+1 can run beside the fragment half of N, so make sure that wait is on the fragment completion.
  • Post a build of the rebased head. CI doesn't compile drm/asahi, so a W=1 build of drivers/gpu/drm/asahi/ with CONFIG_DRM_ASAHI=m is enough.

Then it merges. The M1 Pro and M2 gpubench rows and the CTS subset on the rebased head come after the merge, with a revert ready.

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2637: the same commits rebased onto current integration/aurora.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor Author

Superseded by #2637, which carries this change on a current base. Branch kept.

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.

2 participants