Skip to content

J873g: report G18 GPU work to the CLPC (memory and fabric floor, +34% GPU-bound throughput) - #2623

Merged
Acelogic merged 4 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/g18-clpc-demand
Nov 23, 2026
Merged

Acelogic merged 4 commits into
aurora-silicon:integration/aurorafrom
sithglan:thomas/g18-clpc-demand

Conversation

@sithglan

@sithglan sithglan commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

On the J873g (Mac mini M6), GPU-bound rendering runs about a third faster with this PR: the G18 GPU driver now reports its work to the CLPC, as the G17 backend does on the M5.

Problem

The T8152 CLPC raises the memory controller (DCS) and fabric floor only for busy CPU clusters. It takes no GPU input, and the G18 backend reports none, so GPU work alone leaves both at their lowest states. GPU throughput then depends on how much CPU time the driver's own job waits use:

  • The job wait polls shared memory, which makes a CPU cluster busy and raises the floor for the GPU as a side effect.
  • Every change that made the wait cheaper made the GPU slower. With the floor in place, those changes stop costing GPU throughput.

Change

  1. clpc: the T8152 CLPC takes GPU input (gpu_input), as T8142 does. While the GPU driver reports work in flight, both rails go to the top of the map (DCS 7, fabric 4). apple_clpc_gpu_get() accepts the T8152 CLPC.
  2. dts: the J873g GPU node names its CLPC (apple,clpc = <&clpc>), as the J813 does.
  3. drm/asahi: g18: each job wait holds the request from the job's start until it ends, on every path out of the wait. A delayed work item drops the request 16 ms after the last job ended, so frame-paced clients keep the floor between frames and an idle GPU releases it. A mutex orders the request against that work, and the session's teardown cancels the work and puts the CLPC reference. Without an apple,clpc provider nothing changes.

Testing

Throughput on the J873g. asyncbench is a surfaceless EGL loop: N triangles into an FBO, optional CPU work, then a flush, with at most two frames in flight. Four interleaved rounds ran on one boot, with the floor against without it:

Frame With Without
20000 triangles 789 fps (783–794) 585 fps (529–618)
200 triangles 1847 fps (1755–1903) 1636 fps (1591–1682)
20000 triangles + 2 ms application CPU 490 fps 488 fps

The last row is CPU-bound, so it doesn't change.

This exact code on the J873g:

  • Setup: the three commits on the J873g's running 7.3 source, with aurora.ko and clpc.ko.
  • CLPC status while rendering: host_gpu: active 1, floor 0x47 (DCS 7, fabric 4), reason bits cpu|host_gpu.
  • Throughput: 200 triangles at 1810–1840 fps, 20000 triangles at 647–779 fps.

Checks:

  • arm64 build (Image, modules, dtbs) is clean, and W=1 on clpc.o and g18/demand.o gives no warnings.
  • apple-dt-check.sh against b4cd7b3e15f4: 0 new and 0 removed warnings, 138 DTBs.
  • tools/asahi/run-host-tests.py: 450/451. The one failure is the GCC 16 pmp-floor-tests --mutant class-twice case, which doesn't compile with the host compiler and is unrelated.

Not in this PR

I also tested two other changes on the J873g. Neither helped, so neither is here:

  • Waking job waits on the firmware's events message: the GFX firmware sends one per retired job, and receiving it works with apple_mailbox.ascwrap_v8_rx_irq=1. It saves CPU time but loses 2–7% throughput: the message arrives a few tens of microseconds before the last retirement words, and the CPU clocks down while it sleeps.
  • Skipping the report-ring copies the drain does not use: about 20% less CPU per frame, at up to 8% throughput on tiny frames.

cc @DjDeveloperr @RyanTheTide @Acelogic @LiamRay10

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

The CLPC side and the DT hook look right: gpu_input on the T8152 map and the apple,clpc phandle are the same shape as T8142, and without a provider nothing changes. One behaviour problem and two smaller points in the G18 side:

  • g18/boot/recovery.rs: demand.busy() runs once before the wait loop and once when the job retires. Nothing refreshes it while the job runs, so for any job longer than 16 ms the delayed work fires during the job and drops the floor (g18_demand_idle()) until it retires. The comment above the call says the floor is held "until 16 ms after the last job ends", but that only holds for jobs shorter than 16 ms. The 20000-triangle case is around 1.3 ms per frame, so the table doesn't show this. A heavy frame or a long compute job would. Calling busy() from the loop's periodic branch (where reported is updated), or having the idle work check for a job still in flight and re-arm, would keep the floor for the whole job. A run with a job well over 16 ms (a large asyncbench triangle count, or a long compute dispatch), with the DCS/fabric state sampled mid-job, would show it.
  • g18_demand_busy() calls apple_clpc_gpu_set_active(true) and then mod_delayed_work(). If the idle work is already running, its set_active(false) can land after the set_active(true). The floor then stays off until the next report, even though the work has been re-queued. Re-arming first and setting active second narrows this. A small lock or sequence count in struct g18_demand closes it.
  • The demand object and its CLPC reference are never released, and nothing cancels the delayed work. That is fine while the G18 session really lives until reboot. If the driver can be unbound, or asahi unloaded, a queued g18_demand_idle() would run after its code and data are gone. A cancel_delayed_work_sync() plus apple_clpc_gpu_put() on the session's teardown path would make that safe.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan
sithglan force-pushed the thomas/g18-clpc-demand branch from 15d7b93 to 75e26d8 Compare November 21, 2026 00:55
@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide thanks. All three points are in 75e26d8b92cf (the G18 commit, amended):

  • Long jobs. Each job wait now holds the request from the job's start until it ends, through a guard (G18Demand::job()) dropped on every path out of wait_job(): retired, stranded or error. g18_demand_end() re-arms the 16 ms idle work. The idle work drops the request only while no job is in flight.
  • Race. One mutex in struct g18_demand covers the job count and set_active() in begin and in the idle work. A set_active(false) therefore can't land after the set_active(true) of a job that started meanwhile.
  • Teardown. G18Demand now implements Drop: g18_demand_put() runs cancel_delayed_work_sync(), then apple_clpc_gpu_put() (which also clears the request), then frees. Today the session is leaked with the module pinned, so this only runs if the session's construction fails after the demand was taken. It keeps unbinding safe if that changes.

J873g, the run you asked for. asyncbench with 1M triangles a frame gives ~48 ms jobs. A sampler read the CLPC debugfs status every 2 ms, and I counted the middle 80% of each run. Three runs each:

host GPU request off DCS < 7 or fabric < 4 ms/frame
previous head (busy at start and retire) 61.7 / 53.7 / 54.8 % 3.7 / 0.0 / 0.2 % 48.1-48.3
this head 0.0 / 0.0 / 0.0 % 0.0 / 0.0 / 0.0 % 48.2-48.3

At 48 ms the CLPC's own 32 ms hold covers most of the gap the old code left: the request dropped 16 ms into the job. That is why DCS rarely fell. A job longer than ~48 ms would lose the floor for the rest of its run. I couldn't make that longer job here: scenes of 1.15M triangles and up don't complete on G18 (host watchdog, recovery, EIO). That looks like a parameter buffer limit, unrelated to this PR, and I'm looking into it separately. 20000 triangles a frame is unchanged at 761 against 759 fps. After a run the request is released (host_gpu: active 0, vote 0), and no warnings were logged.

Checks: W=1 build of demand.o is clean, and rustfmt is clean on demand.rs.

@RyanTheTide

Copy link
Copy Markdown
Contributor

Checked 75e26d8. All three points are covered. The job guard holds the floor for the whole wait on every exit path, and the idle work drops it only with jobs == 0 under the lock, so a job that starts meanwhile keeps it. g18_demand_put() cancels the idle work before apple_clpc_gpu_put(), which clears the request itself. No further comments from me.

Assisted-by: LLM (Claude:Opus 5.5)

@sithglan

Copy link
Copy Markdown
Contributor Author

I rebased this onto integration/aurora 24dc422773c9 because it had conflicts. The new head is 700b583abf77 (was 75e26d8b92cf).

  • The one conflict was in the asahi Makefile: drm/asahi: g17: admit A18 Pro mesh renders one client at a time #2071's g17/mesh_exclusion.o sits on the line next to this PR's g18/demand.o, and both are kept.
  • Range-diff: commits 1 and 2 are identical, and commit 3 differs only in that line.
  • Build: each commit builds its directories (arm64, LLVM 22) and t8152-j873g.dtb, with no errors.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked at 700b583: range-diff against 75e26d8 shows commits 1 and 2 identical and commit 3 differing only in the Makefile line next to g17/mesh_exclusion.o. Our earlier read stands; no further comments.

Assisted-by: LLM (Claude:Opus 5.5)

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

Pre-PR checklist review at 700b583abf77 (§1–§6). The CLPC side (apple_clpc_hw_t8152.gpu_input, apple_clpc_gpu_get()), DT hook (apple,clpc = <&clpc>), and the long-job / mutex / teardown fixes from @RyanTheTide's earlier pass look good, and all 8 CI checks are green. Requesting changes for two real bugs on the G18 side, a Kconfig hazard, and a §5 evidence gap:

Blockers

  1. Rust lifetime soundness hole (drivers/gpu/drm/asahi/g18/demand.rs:35-65):
    G18Demand::job(&self) -> G18DemandJob is a safe function returning G18DemandJob(Option<NonNull<c_void>>) with no lifetime tied to &self, while G18DemandJob::drop calls unsafe { g18_demand_end(demand.as_ptr()) } relying only on a comment that no guard outlives G18Demand. Safe code can drop G18Demand before G18DemandJob, causing a use-after-free. Tie the guard to &self with a lifetime (pub(crate) struct G18DemandJob<'a>(Option<NonNull<c_void>>, PhantomData<&'a G18Demand>); and pub(crate) fn job(&self) -> G18DemandJob<'_>), matching M5ClpcBusy<'a> in drivers/gpu/drm/asahi/m5/drm.rs:137.

  2. Swallowed -EPROBE_DEFER (drivers/gpu/drm/asahi/g18/demand.c:49-59, drivers/gpu/drm/asahi/g18/boot/mod.rs:2019):
    apple_clpc_gpu_get() returns -EPROBE_DEFER when apple-clpc has not probed yet (after adding a DL_FLAG_AUTOREMOVE_CONSUMER device link if the provider device already exists in OF). g18_demand_get() swallows -EPROBE_DEFER, logs G18: no CLPC GPU input: -517, and returns NULL — permanently disabling the CLPC floor for the entire boot whenever aurora probes ahead of apple-clpc (which is non-deterministic when both are modules, as in your own test setup, or if apple-clpc defers). Because g18/boot/mod.rs:2137 (no_probe_defer) turns EPROBE_DEFER from stage_firmware() into ENODEV to avoid repeating PSD/SGX reads or stranding a session, acquire the CLPC handle before prepare_t8152_device() / firmware start and propagate -EPROBE_DEFER cleanly (matching M5ClpcInput::new() in m5/drm.rs:89 and asahi_g16_clpc_gpu_get() in g16/glue.c:346).

  3. Kconfig build-combination gap (drivers/gpu/drm/asahi/Kconfig:50):
    Unlike DRM_ASAHI_G16 (depends on APPLE_CLPC=y || APPLE_CLPC=DRM_ASAHI || APPLE_CLPC=n), DRM_ASAHI_G18 has no APPLE_CLPC reachability dependency. With CONFIG_DRM_ASAHI=y and CONFIG_APPLE_CLPC=m, IS_REACHABLE(CONFIG_APPLE_CLPC) silently compiles g18/demand.c against the -ENODEV stub and drops the floor.

Checklist summary (§1–§6)

  • §1 No model gating: Pass — uses DT apple,clpc phandle and .gpu_input = true matching T8142; no-op without a provider.
  • §2 Production-ready / code: Blocked by items 1–3 above.
  • §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass — human commits and Signed-off-by only, Assisted-by: at end of PR body.
  • §5 Evidence: Needs completion — the J873g interleaved A/B and 48 ms mid-job CLPC rows are good, but please add a §5 regression run (0 SELinux denials, 0 failed units, 0 new kernel errors) and note conformance unchanged for the +34% GPU throughput claim after the fix on the live head.
  • §6 Naming: Pass.

Assisted-by: LLM (Gemini 4 Neon)

@sithglan
sithglan force-pushed the thomas/g18-clpc-demand branch from 700b583 to 74de19f Compare November 22, 2026 08:49
@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr all three code points are fixed. New head 74de19fcca84; only the G18 commit is amended.

  1. Guard lifetime: a borrow-tied guard (G18DemandJob<'a>, as M5ClpcBusy<'a>) doesn't fit here. wait_job() holds the guard across &mut self calls (self.poll_faults(), self.recover()), and a guard borrowing self.demand would conflict with those. So the guard owns a reference instead:

    • G18Demand now holds Option<Arc<Handle>>;
    • job() returns a guard with its own Arc clone;
    • g18_demand_put() runs in Handle::drop, once the session and every guard have gone.

    Safe code can drop the two in any order without a use-after-free.

  2. -EPROBE_DEFER:

    • g18_demand_get() now returns an errno and hands the allocation through an out pointer. -EPROBE_DEFER and -ENOMEM are returned. A provider that refuses the input still logs and leaves the floor off.
    • G18Demand::new() runs at the start of prepare_t8152_device(), before any PSD or SGX access. A CLPC that hasn't probed yet defers the probe while it can still be repeated.
    • The handle travels in T8152Probe to prepare_firmware_session(), which used to create it.
  3. Kconfig: DRM_ASAHI_G18 now has depends on APPLE_CLPC=y || APPLE_CLPC=DRM_ASAHI || APPLE_CLPC=n, as DRM_ASAHI_G16 does.

Also fixed: the improper_ctypes warning on the extern declaration, which was already there before. The struct device * is now passed as *mut c_void.

Checks:

  • Each of the three commits builds drivers/gpu/drm/asahi/ and drivers/soc/apple/ (arm64, LLVM 22, W=1) with no new warnings.
  • rustfmt --check is clean on demand.rs.
  • checkpatch on demand.c reports only the existing extern warnings, for the prototypes -Wmissing-prototypes needs.

The §5 rows on this head (regression counts and conformance unchanged for the throughput claim) come with the J873g runs in progress.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Re-checked 74de19f (commit 3 only). The Arc-owned handle is the right answer to the borrow problem: each running job's guard keeps the CLPC reference alive, and g18_demand_put() runs once, when the last holder drops it. Deferring in probe before any GPU access, and the Kconfig dependency, are sensible; with APPLE_CLPC=n the stub returns -ENODEV and the GPU runs without the floor as before.

One case to confirm: a tree whose apple,clpc phandle points at a provider node that is present but status = "disabled". apple_clpc_gpu_get() starts from -EPROBE_DEFER, and if nothing ever binds that node the GPU would now defer forever instead of running without the floor. If the lookup already returns -ENODEV for an unavailable provider, a one-line comment saying so would do.

Assisted-by: LLM (Claude:Opus 5.5)

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

Pre-PR checklist re-review at 74de19fcca8484e886d743b5c0ac380b5ddc95b8 (§1–§6). All three prior code blockers are cleanly fixed with no new code bugs found; holding approval only for §5 live-head hardware rows and the 3 in-progress CI checks.

Prior Blockers Resolved

  1. Rust lifetime soundness (drivers/gpu/drm/asahi/g18/demand.rs): Fixed cleanly via Option<Arc<Handle>>. G18Demand::job() increments the active job count and clones the Arc<Handle> into G18DemandJob; G18DemandJob::drop() runs g18_demand_end() before dropping its Arc, and Handle::drop() runs g18_demand_put() (cancel_delayed_work_sync() -> apple_clpc_gpu_put() -> mutex_destroy() -> kfree()) only once the last holder drops. Safe code can drop G18Demand and G18DemandJob in any order without UAF, and a failed Arc::new() drops Handle cleanly without leaking. The improper_ctypes warning is also resolved.
  2. Swallowed -EPROBE_DEFER (g18/demand.c, g18/probe.rs): Fixed cleanly. g18_demand_get() propagates -EPROBE_DEFER and -ENOMEM directly (falling back to *out = NULL only for non-deferral refusal/absence), and G18Demand::new(pdev.as_ref())? runs at the start of prepare_t8152_device() before any PSD/SGX/DMA/firmware access or no_probe_defer, propagating cleanly out of AsahiPlatformDriver::probe_g18(). Both application graphics (boot/session.rs) and compute (boot/compute_session.rs) go through wait_job().
  3. Kconfig dependency (drivers/gpu/drm/asahi/Kconfig): DRM_ASAHI_G18 now has depends on APPLE_CLPC=y || APPLE_CLPC=DRM_ASAHI || APPLE_CLPC=n, matching DRM_ASAHI_G16.

(Non-blocking note on @RyanTheTide's disabled-node question: apple_clpc_gpu_get() in drivers/soc/apple/clpc.c indeed omits an of_device_is_available(np) check before of_find_device_by_node(np), which is pre-existing across all SoCs and &clpc is enabled on t8152-j873; not a blocker for this PR.)

Checklist & Live Status

  • §1 No model gating: Pass.
  • §2 Production-ready / code: Pass (0 code blockers).
  • §3 Safety: Pass.
  • §4 Clean-room & attribution: Pass — all 3 commits (905a71f5, a860f750, 74de19fc) carry human author/committer and human Signed-off-by: only; PR body includes Assisted-by:.
  • §5 Evidence (holding): Waiting for the J873g live-head 74de19fc regression run (0 SELinux denials, 0 failed units, 0 new kernel errors) and conformance-unchanged note for the +34% throughput claim.
  • §6 Naming: Pass.
  • CI (at 74de19fc): 5/8 SUCCESS (source, rust-build, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc); 3/8 IN_PROGRESS (dt-checks, host-tests, kunit).

Ready to approve once the remaining 3 CI checks finish green and the §5 J873g rows on 74de19fc are attached.

Assisted-by: LLM (Gemini 4 Neon)

@sithglan
sithglan force-pushed the thomas/g18-clpc-demand branch from 74de19f to e6d9b74 Compare November 22, 2026 08:59
@sithglan

Copy link
Copy Markdown
Contributor Author

@RyanTheTide Confirmed, and fixed. A provider node with status = "disabled" never gets a platform device, so of_find_device_by_node() returned NULL, ret stayed -EPROBE_DEFER, and the GPU would have deferred forever.

apple_clpc_gpu_get() now checks of_device_is_available() right after the compatible check and returns 0 for a disabled node. The GPU then runs without the floor, as it does with no apple,clpc property. A phandle to a node that isn't a CLPC still returns -EINVAL. The commit message says this too.

New head e6d9b7404891. Only the first commit changed; the other two were replayed unchanged. Each commit builds with LLVM 22 and W=1 with no new warnings, and checkpatch --strict is clean. A hardware row on the M6 with the provider node disabled will follow, together with the regression and conformance rows on this head, once the M6 is free.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Confirmed at e6d9b74: apple_clpc_gpu_get() returns 0 for a disabled provider (of_device_is_available() right after the compatible check), so the GPU runs without the floor instead of deferring, and a non-CLPC phandle still returns -EINVAL. Nothing further from us; the M6 rows are what's left.

Assisted-by: LLM (Claude:Opus 5.5)

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

Pre-PR checklist re-review at e6d9b740489191407db23031b86c2c90624a239d (§1–§6). The new disabled-provider fix in commit 1 is clean and all 8/8 CI checks are green; 0 code/policy/attribution/CI blockers. Holding APPROVE solely for the pending §5 J873g live-head hardware rows.

New Commit Delta Verified (03aecd64baba)

  • drivers/soc/apple/clpc.c:319-322 (apple_clpc_gpu_get()): Placing if (!of_device_is_available(np)) { of_node_put(np); return 0; } immediately after the compatible check cleanly prevents infinite -EPROBE_DEFER when apple,clpc points to a status = "disabled" node, preserves -EINVAL for non-CLPC phandles, releases np, and leaves *out == NULL (initialized at function entry) so callers run without the floor. Commits 2 (ef7f545f79aa) and 3 (e6d9b7404891) are unchanged.

Checklist & Live Status

  • §1–§3, §6: Pass (0 code blockers).
  • §4 Attribution: Pass — all 3 commits (03aecd64baba, ef7f545f79aa, e6d9b7404891) carry human author/committer (Thomas Glanzmann <thomas@glanzmann.de>) and human Signed-off-by: only; PR body includes Assisted-by:.
  • CI (at e6d9b7404891): 8/8 COMPLETED / SUCCESS (dt-checks, host-tests, source, rust-build, kunit, DWC3/ATC builtin-no-atc, DWC3/ATC modular-no-atc, DWC3/ATC builtin-modular-atc).
  • §5 Evidence (holding): Ready to approve once the queued J873g live-head e6d9b740 rows land (regression counts 0 SELinux denials / 0 failed units / 0 new kernel errors, conformance unchanged for the +34% GPU throughput claim, and the disabled-provider check).

Assisted-by: LLM (Gemini 4 Neon)

@sithglan

Copy link
Copy Markdown
Contributor Author

@DjDeveloperr @RyanTheTide the J873g rows at e6d9b7404891.

Build.

Regression (both boots):

  • 0 failed units and 0 AVC denials.
  • 0 GPU job failures.
  • No kernel errors during the rows. The only error lines are the same 3 from boot time as on every boot of this Mac (apple-dcpib 502e00000 set_mode failed: -5 and the two btcentauri -16 probe lines).

A: CLPC linked.

  • The CLPC is bound and the GPU probed without deferring (devices_deferred is empty).
  • During a 20k-triangle run, the CLPC status shows host_gpu: active 1, floor 0x47, DCS state 7 and fabric state 4. When idle it shows floor 0x0 and both rails at state 0.

Disabled provider (B).

  • performance-controller@1 has status = "disabled", and no CLPC device is bound.
  • The GPU probed anyway: aurora-g18 is bound and renderD128 is present. Nothing is left in devices_deferred, and no CLPC GPU input isn't logged.
  • The GPU runs without the floor; see the table.

asyncbench, frames/s, 3 rounds:

triangles A: CLPC linked B: CLPC disabled
200 2300, 2471, 2497 1604, 1629, 1619
20000 912, 910, 911 605, 609, 626
1000000 20.2, 20.1, 20.1 17.9, 17.9, 17.9

In B the whole CLPC is gone, the CPU inputs too, so B is the "no floor at all" case, not just "no GPU input".

Conformance unchanged. On boot A, with the same caselists as the base rows on this M6 earlier today (r22base, which used the older #2623 code):

suite (cases) A vs r22base
dEQP-GLES31 compute.* + draw_indirect.* (416) 398 pass, 18 skip 0 cases differ
dEQP-GLES3 fence_sync, flush_finish, occlusion_query, pbo, read_pixels, transform_feedback (1506) 1392 pass, 6 fail, 108 skip 0 cases differ

The 6 fails are the transform_feedback lines cases, which fail on every build here.

Assisted-by: LLM (Claude:Opus 5.5)

The T8152 CLPC raises the memory controller (DCS) and fabric floor only
for busy CPU clusters. GPU work alone leaves both at their lowest states,
so on the J873g (Mac mini M6) a GPU-bound render ran a third slower than
it can, and faster the more CPU time the G18 driver's own job waits used
while polling: polling made a CPU cluster busy, which raised the floor
for the GPU as a side effect.

Take GPU input on T8152 as on T8142: while the GPU driver reports work
in flight (apple_clpc_gpu_get(), apple_clpc_gpu_set_active()), both
rails go to the top of the map, DCS 7 and fabric 4. Accept the T8152
CLPC in apple_clpc_gpu_get().

A provider node the tree disables never gets a device that binds, so
apple_clpc_gpu_get() returns 0 for it (no input) rather than
-EPROBE_DEFER: a GPU that defers on the CLPC would otherwise wait
forever.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
Name the T8152 CLPC as the GPU's host performance controller
(apple,clpc), as the J813 does, so that the GPU driver can report its
work in flight and get the memory controller and fabric floor while it
has some.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
The G18 backend never told the CLPC that the GPU was busy, so on the
J873g the memory controller and fabric floor followed the CPU clusters
alone. A GPU-bound render then ran faster the more CPU time the job wait
used, and any change that made the wait cheaper made the GPU slower.

Report work in flight through the CLPC's GPU input, as the G17 backend
does. Each job wait holds the request from the job's start until it
ends, on every path out of the wait. The request is dropped 16 ms after
the last job ended (a delayed work item), so frame-paced clients keep
the floor between frames and an idle GPU releases it. A mutex orders the
request against that work, which drops it only while no job runs. The
work is cancelled and the CLPC reference put when the last holder of
the handle drops it: the session, or a job guard, which keeps its own
reference. Without an apple,clpc provider nothing changes.

The handle is taken at the start of the probe, before any GPU access. A
CLPC that has not probed yet defers the probe there (-EPROBE_DEFER),
instead of the GPU running without the floor for the whole boot; later
in the probe a deferral can no longer be repeated safely. DRM_ASAHI_G18
depends on APPLE_CLPC being reachable from the driver, as DRM_ASAHI_G16
does.

On the J873g (asyncbench, polling job waits, four interleaved rounds on
one boot), with the floor against without it:
- 20000 triangles per frame: 789 against 585 frames/s
- 200 triangles per frame: 1847 against 1636 frames/s
- 20000 triangles plus 2 ms of application CPU work: 490 against 488
  (CPU-bound, as expected)

With 48 ms jobs (1M triangles a frame) the request stays on for the
whole run, sampled every 2 ms. When it was refreshed only at a job's
start and end, it was off for 54-62% of those samples.

Signed-off-by: Thomas Glanzmann <thomas@glanzmann.de>
@sithglan
sithglan force-pushed the thomas/g18-clpc-demand branch from e6d9b74 to 3692f97 Compare November 22, 2026 20:30
@sithglan

Copy link
Copy Markdown
Contributor Author

Rebased onto integration/aurora 95a13cf. The head is 3692f97. Two conflicts, both resolved by keeping both sides:

The first two commits are identical; the third differs only by these resolutions.

Checks:

  • W=1 build of clpc.o, the GPU module and the J873g DTB: no new warnings.
  • run-host-tests.py --only clpc: 3/3.
  • DART lint: 0 new.
  • checkpatch: unchanged.

The CHANGES_REQUESTED shown on this PR is Dj's 08:38 review. e6d9b74 addressed it, and that head was approved later.

Assisted-by: LLM (Claude:Opus 5.5)

@RyanTheTide

Copy link
Copy Markdown
Contributor

Thanks for the J873g rows at e6d9b74. Boot B with the provider disabled shows the GPU binding without a defer, and the conformance subsets show 0 cases differing, which covers what was left. 3692f97 is a rebase only. Commits 1-2 are the same patches, and commit 3 differs only by the Makefile line next to g18/sync_input.o and the job guard after growth_refused = false in recovery.rs, which doesn't change when the floor is held. Our view stands.

Assisted-by: LLM (Claude:Opus 5.5)

@Acelogic

Copy link
Copy Markdown
Member

I tested head 3692f9763dad on a physical J873g Mac mini M6, merged locally onto public integration/aurora at 322eadc80921 (candidate tree 09a7dcc3011c). I booted the same kernel image, modules and Mesa userspace twice. The first boot disabled only the CLPC provider in the device tree. The second used the PR's device tree as submitted. Both brought all 12 CPUs online, bound the GPU driver and rendered the expected pixels on the Apple M6 GPU.

Rendering and clock response. Median frames per second across three 3-second runs per workload, using a 256×256 offscreen target and two frames in flight.

Triangles per frame Provider disabled Provider enabled Change
200 1,434.95 1,959.82 +36.6%
20,000 1,234.61 1,531.81 +24.1%

All six enabled runs released the GPU clock request at idle. In a separate 4-second run with 20,000 triangles per frame, all 78 active samples showed DCS state 7 and SoC fabric state 4 with a 0x47 request. Both states read zero before and after the draw. Kernel taint remained zero, lockdep stayed enabled and neither boot logged a new workload warning. The three public CLPC host checks also passed locally.

One probe error needs a fix before merge. I compiled the submitted g18_demand_get() with controlled provider return values. When apple_clpc_gpu_get() returns -ENOMEM after a failed device_link_add(), the consumer returns success with a null demand pointer. That silently disables GPU clock requests for the lifetime of that binding. The absent provider, working provider, deferred probe, and consumer allocation failure cases behaved as expected. Please propagate provider-side -ENOMEM alongside -EPROBE_DEFER. I verified that change in the host harness and all five cases passed. The physical results above used the submitted driver.

apple_clpc_gpu_get() returns -ENOMEM when it cannot create the
device link. Return that error to probe so that G18 does not bind
with clock demand permanently disabled after an allocation failure.

Assisted-by: OpenAI Codex
Signed-off-by: Acelogic <miguelc4600@gmail.com>
@sithglan

Copy link
Copy Markdown
Contributor Author

@Acelogic thanks for the row and the fix. 182b72d is right, and I'm keeping it on the branch as your commit.

The comment above g18_demand_get() already said -ENOMEM goes back to the probe; the code only checked -EPROBE_DEFER. With your change, every return of apple_clpc_gpu_get() is handled the way that comment describes:

  • 0 (no apple,clpc, a disabled provider, or the T8140 fallback while its provider is unbound): bind without the floor.
  • -EINVAL (a phandle to something that isn't a CLPC): warn and bind without the floor.
  • -EPROBE_DEFER (the provider hasn't probed, or its GPU input is held elsewhere): defer.
  • -ENOMEM (device_link_add() failed, or allocating g18_demand failed): fail the probe, before the GPU is touched.

demand.o builds clean with W=1 at 182b72d (ARCH=arm64 LLVM=-22).

Assisted-by: LLM (Claude:Opus 5.5)

@Acelogic

Copy link
Copy Markdown
Member

I fixed the provider allocation error in 182b72da0063 and retested this revision on the physical J873g Mac mini M6. The public integration base was a7638d51880c and the tested merge tree was 6b4073519f06.

The error now reaches the GPU probe as -ENOMEM. A controlled test compiled from the updated function passed all five cases, including provider allocation failure, consumer allocation failure, probe deferral, provider absence and success. The public CLPC test group passed 3/3 locally, and strict checkpatch reported zero findings on the fix.

I booted that tree twice, with identical kernels, modules and Mesa userspace. One boot disabled the clock provider in the device tree and the other used the submitted device tree. Both brought all 12 CPUs online and passed native GPU pixel checks before and after the workload. Median FPS across three 3-second offscreen runs per workload appears below.

Triangles per frame Provider disabled Provider enabled Difference
200 1,579.59 1,853.80 +17.4%
20,000 1,367.75 1,627.88 +19.0%

All six enabled workloads released their clock request at idle. In a separate 4-second draw, 79 of 79 active samples showed DCS state 7 and SoC fabric state 4. Both returned to zero after the draw. Kernel taint finished at zero on both boots, lock debugging stayed enabled and there were no new workload warnings.

@Acelogic
Acelogic merged commit 927afa8 into aurora-silicon:integration/aurora Nov 23, 2026
8 checks passed
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.

4 participants