Skip to content

drm/imagination: apple: account S8003 firmware phase time in apple_jobs - #122

Merged
3 commits merged into
OrchardLinux:mainfrom
brkosebay:submit/s8003-fw-timestamps
Dec 4, 2026
Merged

3 commits merged into
OrchardLinux:mainfrom
brkosebay:submit/s8003-fw-timestamps

Conversation

@brkosebay

Copy link
Copy Markdown

Depends on #121 (shared PM pools). This branch carries its two commits; only the last commit is new here.

apple_jobs showed the host's view of a job (submit to done), which includes queueing and kernel time. This adds the firmware's own retired geometry and fragment phase times, in 24 MHz ticks, as a gpu_ns geometry … fragment … jobs … zero … line, so the GPU's execution time can be told apart from the per-job overhead around it.

The two W records alternate by sequence parity. Both submit paths wait for last_seq - 1 before writing seq = last_seq + 1, so the previous job in that slot has retired. Its phase times are read (after dma_rmb()) before fill_ta/fill_3d clear the record and are added in s8003_job_write. A rejected fill cannot count an old result twice. Firmware records, submission order and clock policy are unchanged: this only measures.

Tested on the iPad 5 (j71t), 2026-12-03, in a kernel with this commit: Firefox scroll profiles read it to split GPU busy time into execution and overhead. On YouTube home, GPU execution was 37 % of busy time (Reddit 50 %, Wikipedia 51 %), i.e. about 0.7 ms of fixed non-execution time per geometry+fragment pair.

Built for j71t with Orchard's kernel/build --kernel-tree on this head.

How to test

On a stock Orchard install with this kernel:

sudo grep '^gpu_ns' /sys/kernel/debug/dri/*/apple_jobs; glmark2-es2-wayland --off-screen -b build:duration=10
sudo grep '^gpu_ns' /sys/kernel/debug/dri/*/apple_jobs   # geometry/fragment ns and job counts grow

Expected on the iPad 5: the counters grow with the work, and zero stays small (jobs without a firmware time). A10: unchanged, because this is the S8003 (A9) path.

Account for live PM pool objects, including replacements prepared for a
later geometry job. Expose that total and each reserved set's capacity,
last firmware feedback and control words through apple_jobs.

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
The A9 firmware runs one scene at a time per VM. The job dependency
code orders a VM's geometry after the previous VM's fragment work, so
up to two scenes can be live on the two sets of one VM. Each set's
free list names the PM pages directly.

Share one pool per set index between VMs, as the A10 shares free-list
pages. This keeps 128 blocks per scene and limits pinned PM pool memory
to 32 MiB, down from 16 MiB per allocated set. Count any wait for a
previous user of a shared pool and retain per-set allocation behind
apple_pm_shared=0.

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
…euse

Expose the firmware's retired geometry and fragment phase times, in
24 MHz ticks, alongside the existing host in-flight counters.

The two W records alternate by sequence parity. Both submit paths wait
for last_seq - 1 before writing seq = last_seq + 1, so the prior job in
that slot has retired. dma_rmb() orders the same coherent CPU mapping
used by the done stamp. Preserve W+0x550/0x8ac before fill_ta/fill_3d
memsets W, then count it in s8003_job_write before the result is zeroed.
A rejected fill cannot double-count an old result. No firmware record,
submission ordering or clock policy changes.

Affects: Apple A9 (S8003); measurement only
Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
@henrikklee

Copy link
Copy Markdown

Merged, thank you Berkay! Having the firmware's own geometry and fragment phase times in apple_jobs, next to the host counters, makes the A9 timing work much easier to read.

How it landed: after #126 your branch conflicted on one call in s8003_submit_frag(), and your fork doesn't accept maintainer pushes. So #141 carries a merge of your branch as it is, with that one call resolved (#126's PM set address plus your gpu_ticks). Your commit is unchanged in the history, and GitHub marks this PR as merged. Nothing was left out.

Follow-up: the device numbers came from your integration kernel. A run of the merged main on an A9 device would be very welcome.

henrikklee pushed a commit to ricktav/linux that referenced this pull request Dec 4, 2026
The S8000 and S8003 (A9) select their combined SoC and memory
performance state in one PMGR register, as the T8010 does: describe it
as a single "soc-ps" region.

[Orchard: from orchard PR OrchardLinux#122, commit 5775e3ed; unchanged]

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Link: OrchardLinux/orchard#231 (comment)
henrikklee pushed a commit to ricktav/linux that referenced this pull request Dec 4, 2026
The S8000 and S8003 (A9) boot with SoC and memory in their low
performance state: memory at 800 of 1200 MHz. Nothing on Linux raises
it, so CPU and GPU run on two thirds of the memory bandwidth. On a J71t
the high state takes CPU read bandwidth from 8.8 to 15.1 GB/s and
glmark2 scenes 13-64 % faster at the same GPU clock.

The register, the two states (0xd low, 0xc high) and the pending bit are
the T8010's, so the A9 and A10 share one description: high at probe, low
on suspend. iOS's PMGR driver waits up to 8 ms for the change; it takes
0.5-0.7 ms on the J71t, close to the 1 ms the T8010 waited, so both wait
up to iOS's 8 ms.

[Orchard: from orchard PR OrchardLinux#122, commit 5775e3ed; reworked so the A9 and
 A10 share one description and timeout instead of a second variant]

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Link: OrchardLinux/orchard#231 (comment)
henrikklee pushed a commit to ricktav/linux that referenced this pull request Dec 4, 2026
The PMGR register that selects the SoC and memory performance states,
for apple-pmgr-misc, at the same address and with the same layout as
on the T8010.

[Orchard: from orchard PR OrchardLinux#122, commit 5775e3ed; unchanged]

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Link: OrchardLinux/orchard#231 (comment)
henrikklee added a commit to theChristopher16/linux that referenced this pull request Dec 4, 2026
…mestamps

drm/imagination: apple: account S8003 firmware phase time in apple_jobs

Resolve the conflict with OrchardLinux#126 in s8003_submit_frag(): keep the
per-device PM set address from OrchardLinux#126 and pass OrchardLinux#122's gpu_ticks.
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