Skip to content

drm/imagination: apple: let any A9 VM take a second PM scene while sets remain (on #121) - #127

Open
brkosebay wants to merge 3 commits into
OrchardLinux:mainfrom
brkosebay:a9/pm-scene2
Open

brkosebay wants to merge 3 commits into
OrchardLinux:mainfrom
brkosebay:a9/pm-scene2

Conversation

@brkosebay

Copy link
Copy Markdown

Depends on #121 (shared S8003 PM pools). This branch is #121's two commits plus one new commit. Please review only the last commit, drm/imagination: apple: let any VM take a second PM scene while sets remain.

What

With shared PM pools (apple_pm_shared, from #121), a PM set costs no pool memory. This PR lets a VM reserve its second PM set on demand: when its first scene is still in flight at its next geometry job, as long as at least 2 of the 12 sets stay free for new VMs' first scene.

The old rule gave a second set only while fewer than half of the sets were taken. It still applies with powervr.apple_pm_scene2=0, and whenever the pools are private, where a set can cost up to 16 MiB.

Why

A second set gives a VM a second scene, so its next geometry job no longer waits for its last fragment job to finish. Apple keeps many scenes per work queue: one PM pool per queue and a 256-entry TA ring.

Result (iPad 5, j71t)

Carbon (a WebGPU game in Firefox), garage menu, 10 s per arm, same boot:

apple_pm_scene2 Carbon VM PM sets Carbon renders/s Presents/s All GPU jobs/s
0 (old rule) 1 244.5 10.8 744
1 (this PR) 2 257.3 11.3 902

That is +5 %. With the second scene, 75 % of Carbon's geometry jobs start before the previous fragment job is done. These runs used our integration kernel, which carries this commit together with other work that is not upstream yet. This head is the same change, rebased onto #121 and build-tested only: drivers/gpu/drm/imagination/ compiles with W=1 under the 16k and 4k defconfigs.

A10 and A8

This change is A9-only: S8003 PM set reservation. The A8, A7 and A10 (G9P) paths are untouched.

How to test

On an iPad 5 running a GPU-heavy browser page, such as a WebGPU demo:

  1. echo 0 | sudo tee /sys/module/powervr/parameters/apple_pm_scene2 switches to the old rule. Measure frame rate or renders.
  2. echo 1 | sudo tee /sys/module/powervr/parameters/apple_pm_scene2 switches to this PR's rule. Measure again.

The parameter is read whenever a VM reserves its sets, so no reboot is needed. Expected A9 result: a few percent more frames, and no GPU faults.

🤖 Generated with Claude Code

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>
…remain

A VM's second PM set gives it a second scene: its next geometry job no
longer waits for its last fragment job to finish. Apple keeps many
scenes per work queue (one PM pool per queue, a 256-entry TA ring). The
A9 path gave a VM its second set only while fewer than half of the 12
sets were taken, so with a desktop and a browser open a new VM got one.

With the shared PM pools (apple_pm_shared) a set costs no pool memory.
Reserve a VM's second set on demand, when its first scene is still in
flight at the next geometry job, while at least S8003_PM_SPARE_SETS (2)
sets stay free for new VMs' first scene. The apple_pm_scene2 module
parameter (default 1) selects this; 0 keeps the half rule, which also
stays in force when the pools are private (up to 16 MiB per set).

On an iPad 5, a WebGPU game in Firefox goes from one set to two, 75 % of
its geometry jobs start before the previous fragment job is done, and
its render rate rises by 5 % (244.5 to 257.3 per second).

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

Copy link
Copy Markdown

Thank you Berkay, giving any VM a second scene while it has one in flight is a nice win (your +5 % on the WebGPU game). We'd like to merge it, with one change to how many apps can draw at once.

What's wrong now: a VM keeps its PM sets until it closes. With "second set on demand while 2 stay free", five VMs can end up with two sets each, and then only two more VMs get a set: 7 apps can draw at once. The half rule this replaces guaranteed at least 9, because a second set was only given while fewer than 6 sets were taken. The 8th app would fail its geometry jobs with "no PM set".

The rework is on pr127-rework in OrchardLinux/linux, on top of current main:

  • Your commit, rebased onto drm/imagination: apple: land #122, drop A9 debug switches from #121 and #126 #141 (apple_pm_shared is gone), with you as author and an [Orchard: …] note.
  • drm/imagination: apple: keep a first PM set for nine A9 VMs: at most S8003_PM_SETS / 4 (3) VMs hold a second set at once, still on demand. Every other set stays free for a new app's first set, so at least 9 apps can draw at once, as before. The second sets go to the VMs that have a scene in flight. Taking an idle second set back from another VM would keep all 12 usable, but the PM may still write a returned set, so a fixed cap is the simpler correct choice for now.
  • apple_pm_scene2 and S8003_PM_SPARE_SETS are gone, and so is the stray double blank line. Debug switches stay on your fork (CONTRIBUTING, "Bring-up material").

Your fork doesn't accept maintainer pushes (it's a fork of HoolockLinux/linux), so please reset your branch to it:

git fetch https://github.com/OrchardLinux/linux pr127-rework
git checkout a9/pm-scene2
git reset --hard FETCH_HEAD
git push --force origin a9/pm-scene2

Once CI is green we merge. If you'd rather solve it another way, say so and we'll review that with you. A run on your iPad 5 with several apps open would be very welcome too.

henrikklee pushed a commit to ricktav/linux that referenced this pull request Dec 4, 2026
…attachment

USB data stays off from attach until the source is identified, at most
TRISTAR_HOLD_MS; only the first attachment since probe got that bound.
The PMIC can stay in a transitional state (e.g. 0x62) for any later
attachment too, and then USB data stayed off for good: no USB serial
and no USB network until a reboot. Release the hold for every
attachment, at the fallback limit, and start the hold when input
returns after an unplug, not when it went away, so a cable reinserted
after a long unplug is still identified first.

The charger's queue asked for neither WQ_PERCPU nor WQ_UNBOUND, so every
boot warned in alloc_workqueue(). The poll sleeps on I2C and the HDQ
gauge and keeps no per-CPU state: make the queue unbound.

[Orchard: from orchard PR OrchardLinux#127 (commits 339bd296; patches 0031-0033
 there), folded into one patch that extends the existing hold instead
 of adding a second timer]

Assisted-by: LLM
Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Link: OrchardLinux/orchard#231 (comment)
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