Skip to content

kernel: The A9 GPU (iPad 5) renders: fixes from the first hardware runs - #150

Merged
henrikklee merged 8 commits into
OrchardLinux:mainfrom
brkosebay:a9-gpu-renders
Nov 17, 2026
Merged

henrikklee merged 8 commits into
OrchardLinux:mainfrom
brkosebay:a9-gpu-renders

Conversation

@brkosebay

Copy link
Copy Markdown
Contributor

These eight patches follow gpu/0025. They come from the first iPad 5 hardware runs: without them the A9 GPU does not render on main.

Fixes

0026: size an S8003 dataset's free list by its initial pages.
vkCreateDevice() failed with VK_ERROR_INITIALIZATION_FAILED because CREATE_HWRT_DATASET returned -EINVAL, without a log line. The A9 owns its PM pages, so a free list's current_pages stays zero. The fix checks initial_num_pages instead, which the backend uses to size the pool. A9 only.

0027: don't free a job's command twice when its stream is rejected.
After a rejected stream, the next exec in another process oopsed in free_bprm with a bad rss-counter. slub_debug reported "Object already free" on kmalloc-512: the object was allocated in pvr_fw_cmd_init(), freed on the error path, and freed again from pvr_job_put(). The fix clears the command pointer and length after the first free. Upstream has the same code, so this affects every PowerVR device.

0028: require each chip's own register extension.
Every A9 geometry and fragment stream was refused with -EINVAL, without a log line, because the parser required the A10's type-1 extension. The A9 carries its registers in type 2. The required type and mask now sit in each chip's definition.

0029: drop a fragment job's reference on its geometry job.
Every fragment job warned at WARN_ON(job->paired_job) in pvr_job.c, thousands of times a minute. Geometry jobs were never freed, and glmark2 and vkcube hung on render-target destruction until killed. The fix follows IMG's queue free path: drop the paired reference and clear it before releasing the job. The A9 and A10 share this queue.

0030: let every geometry job take its VM's scene first.
A client's first render could fail silently when another client had rendered last. Geometry returned -EBUSY, then the fragment job was refused with "fragment job without a geometry job". The fix calls vm_scenes before choosing the geometry dependency, so the VM has a PM set. A9 only.

0031: say why a command stream is rejected.
The stream failures above were silent. This adds one rate-limited warning per rejected stream, naming the failed check and its values. Parsing and error returns are unchanged. This covers every PowerVR device.

0032: say why an S8003 job was not submitted.
This adds one rate-limited warning per failed submission, naming the engine, error, VM and failing stage. A fragment without its geometry scene is still refused. Submission and recovery behaviour are unchanged. A9 only.

0033: keep VM tag bumps off an S8003 slot pair while it loads.
The PR 1 hardware gate lost Firefox's WebGL context three times in about ten minutes with Aquarium and other GPU clients; single-client runs did not fail. The kernel reported GFX firmware did not load slots 181 and 180: -5, followed by a refused fragment job because its geometry job failed. Concurrent VM map/unmap flushes could bump a slot's host tag while firmware loaded its root and copied the tag, so an intermediate tag falsely failed the load check. Loading slots now defer tag bumps until the exact loaded tag is verified. The pending bump lands before the VM's job under submit_lock; a mismatch reports the slot and loaded, firmware and current tags. A9 only.

iPad 6 / 7 (A10)

  • 0028: the T8010 entry carries the same extension type and mask the parser used before, so A10 stream validation is unchanged.
  • 0029: this changes the A10 too. Whenever a submission carries an explicit geometry→fragment dependency, pvr_jobs_link_geom_frag() pairs the jobs and the A10's Apple queue leaked the geometry job's reference. The fix is IMG's free path. The fragment job keeps its own HWRT and context references, so nothing the firmware uses is freed early.
  • 0027 and 0031: common PowerVR fixes, which also apply to the A10.
  • 0026, 0030, 0032, 0033: these sit behind own_pm_pages, vm_scenes and the S8003 file, none of which the T8010 sets or uses.

The A10 configuration builds (j171, apple-16k, all A10 device trees). It was not run on an A10.

Hardware

iPad 5 (J71t), cold boot, Orchard main plus exactly this series. Mesa: OrchardLinux/mesa main with the pending A9 fixes (27.0.0-devel), Zink on the PowerVR Vulkan driver, Labwc on the A9 display.

Two kernels were run. The first carried 0026-0032 only (7.3.0-rc1-orchard-apple-16k-topic-main-50d3172-pr1). Its multi-client part exposed the slot-tag race that 0033 fixes. The second is this series as posted (...-50d3172-pr1-slotload).

First kernel (0026-0032):

  • smoke: pass. glmark2 800x600 score 1171, vkcube 600 frames. faults 0, rejects 0, warns 0.
  • panel-perf: pass. glmark2-es2-wayland fullscreen 2048x1536 score 386, vkcube 600 frames. faults 0, rejects 0, warns 0.
  • soak30: pass. glmark2 loop for 1800 s: 177 iterations, 0 client failures. faults 0, rejects 0.
  • multi-client: Firefox Aquarium with 500 fish rendered correctly at about 24 fps next to the glmark2 loop (59 iterations, 0 client failures, 0 faults). The kernel logged GFX firmware did not load slots N and N-1: -5 three times in about ten minutes, and one fragment job was refused. Starting a short-lived Vulkan client every few seconds alongside raised that to 21 times in 631 s (248 extra clients, 13 refused fragment jobs).

Second kernel (this series):

  • smoke: pass. glmark2 800x600 FPS 1235/1121/1141 on the first scenes. faults 0, rejects 0, warns 0.
  • multi-client with the same extra-client loop (Firefox Aquarium 500 fish, the glmark2 loop and 116 short-lived Vulkan clients, about ten minutes): no slot load failures, no refused jobs, no faults.
  • The Labwc desktop then ran on the GPU (wlroots GLES2 renderer through Zink on the PowerVR render node, presenting on the A9 display) with no faults.

panel-perf and soak30 were not repeated on the second kernel, which differs from the first only by 0033.

Earlier development runs, on main plus later local patches, answer some of the "Open on hardware" questions in docs/bring-up/gpu/a9-g5p.md:

  • Boot with kernel VM page tables, shmem pages and polling: yes.
  • Stop, gate off and boot again under runtime PM: yes. After 1.19 million jobs on one boot the firmware was stopped, runtime PM reported suspended, and the firmware booted again for the next client.
  • A render completes with the PM tables mapped protected (bit 62): yes.
  • The firmware accepts different PDS and USC code bases (0x2a00000000, 0x2c00000000): yes.
  • {6, ...} on every geometry job, with stamps alone as completion: yes.
  • Not measured yet: firmware boot duration, the unacknowledged interrupt, which interrupts fire, data addresses up to 2^38, the compute doorbell, two scenes of one VM in flight, the 3 MiB PM-set limit, recovery during a held power domain, and the cost of s8003_touch().

Build

The apple-16k (j71t, j171) and apple-4k configurations build with no new warnings in drivers/gpu/drm/imagination. Platform configs are unchanged.

…ial pages

On the iPad 5, vkCreateDevice() fails with VK_ERROR_INITIALIZATION_FAILED.
CREATE_HWRT_DATASET returns -EINVAL without a log line when Mesa creates
the dummy render target used during device creation.

The A9 allocates the parameter manager's pages itself. Its free list is
not grown by pvr_free_list_create(), so current_pages stays zero, but
hwrt_init_kernel_structure() still checks it against the minimum.

For chips with own_pm_pages, check initial_num_pages instead. This is
the limit used to size the S8003 parameter manager's render blocks.

Affects the Apple A9 (S8003). The A10 is unchanged.

Assisted-by: LLM
…rejected

After a rejected command stream on the iPad 5, the next exec in another
process oopses in free_bprm with a bad rss-counter. slub_debug reports
"Object already free" on kmalloc-512: the object was allocated and freed
in pvr_fw_cmd_init(), then freed again from pvr_job_put().

When stream parsing fails, pvr_job_process_stream() frees the command.
The caller then releases the job, whose release path frees it again.
Clear the command pointer and length after freeing the rejected command.

Upstream has the same code. Affects every PowerVR device.

Fixes: eaf01ee5ba28 ("drm/imagination: Implement job submission and scheduling")

Assisted-by: LLM
Every geometry and fragment job on the iPad 5 is refused with -EINVAL,
without a log line. The stream parser requires the A10's type-1 register
extension on every Apple chip, while the A9 supplies its registers in
extension type 2.

Put each chip's required extension type and mask beside its stream
definitions and obtain them through an Apple accessor. Keep the A10's
values and leave compute without an Apple must-have entry.

Affects the Apple A9 (S8003). The A10's validation values are unchanged.

Assisted-by: LLM
…ry job

Once rendering works on the iPad 5, every fragment job warns at
WARN_ON(job->paired_job) in pvr_job.c, thousands of times a minute.
Geometry jobs are never freed, and clients hang when destroying a
render target: glmark2 and vkcube run until killed.

Apple queues receive jobs linked by pvr_jobs_link_geom_frag(), but their
free path does not drop the fragment job's paired geometry reference.
That reference also keeps the geometry job's HWRT and context alive.

Follow pvr_queue_free_job(): drop the paired geometry reference and
clear paired_job before dropping the scheduler's reference.

Affects the shared Apple queue used by the A9 (S8003) and A10 (T8010).
The A10 has been build-tested only.

Assisted-by: LLM
A client's first render on the iPad 5 fails without a log line when
another client rendered last. Its geometry job returns -EBUSY, then
its fragment job is refused with "fragment job without a geometry job".

The call that takes a VM's PM sets is inside the dependency choice for
consecutive jobs of the same VM. A new VM can therefore reach submission
without a PM set when the previous fragment belonged to another VM.

Call vm_scenes for every geometry job before selecting its dependency.
Keep the existing prev_frag/last_frag choice and locking context.

Affects the Apple A9 (S8003). The A10 has no vm_scenes callback and is
unchanged.

Assisted-by: LLM
The iPad 5's rejected geometry and fragment streams return -EINVAL
without explaining which check failed. Applications fail to render,
and the kernel gives no values with which to diagnose the rejection.

Report malformed headers, invalid destination entries, short input,
unsupported extensions and missing must-have bits at the rejecting
check. Include the command type, entry or extension, and checked values.
Use one rate-limited warning per rejected stream; callers log short
reads so that propagated errors do not produce duplicate messages.

Keep successful parsing and error returns unchanged. Affects every
PowerVR device.

Assisted-by: LLM
Render failures on the iPad 5 can leave a fragment job without its
geometry job. S8003 submission errors otherwise return silently, so
the kernel does not say which engine or stage failed.

Add one rate-limited warning at each failing submission stage with the
engine, error, VM and reason. Separate the PM pool build and record
slot wait checks so that their errors can be distinguished.

Keep submission and recovery behaviour unchanged. A fragment without
its geometry scene is still refused.

Affects the Apple A9 (S8003). The A10 is unchanged.

Assisted-by: LLM
…e it loads

The iPad 5 loses Firefox's WebGL context under multiple GPU clients.
Firmware slot loads return -EIO, geometry jobs fail, and their fragment
jobs are refused. Single-client runs do not hit the failure.

VM map and unmap flushes take tag_lock but not submit_lock. They can
bump a slot's host tag while DC_SLOT loads its root. With two or more
bumps, firmware can copy an intermediate tag that matches neither the
loaded tag nor the current host tag, falsely failing the load check.

Mark each slot as loading under tag_lock while publishing its root and
tag. Defer flushes on those slots, verify the exact loaded tag, then
clear loading and apply any pending bump through the shared helper on
both success and failure. submit_lock keeps the VM's job behind the
pending bump, so firmware still invalidates stale translations before
using the slot. Report the slot, loaded, firmware and current tags on
a mismatch.

Affects: Apple A9 (S8003). The A10 is unchanged.

Assisted-by: LLM
@brkosebay

Copy link
Copy Markdown
Contributor Author

Review order for the open iPad 5 (A9) GPU work, since there are a lot of pull requests now. Everything below is green in CI and mergeable. The kernel PRs that share code with the A10 have it enabled. Please test it there and tell us what breaks; each PR has a "How to test" section.

Kernel (orchard)

  1. kernel: The A9 GPU (iPad 5) renders: fixes from the first hardware runs #150 renders: the base for everything else. Without it the A9 GPU does not render on main.
  2. kernel: Recover promptly from Apple GPU faults and bound firmware shutdown #151 stability: fault recovery and bounded firmware shutdown. Stacked on kernel: The A9 GPU (iPad 5) renders: fixes from the first hardware runs #150.
  3. kernel: Reclaim idle PowerVR buffer backing and restore it before submission #152 eviction: idle GPU buffers can be swapped. Stacked on kernel: The A9 GPU (iPad 5) renders: fixes from the first hardware runs #150, independent of kernel: Recover promptly from Apple GPU faults and bound firmware shutdown #151. Updated today with two pvr_mmu.c fixes for a NULL dereference the restore path could reach under heavy memory pressure (details in the comment there). Please review it at the current head.
  4. Performance, after the above:

Mesa

  1. Cache root images on the existing Linux-data partition #9 → Add experimental P105 iPad mini 1 hardware and recovery support #10 → Move to a torvalds-based kernel stack, device-generic tooling and iPad 6 charging #11 → Allow resetting an existing Linux filesystem #12 are one stack: device-loss reporting, A9 correctness, memory, then Zink/common fixes.
  2. Select m1n1 Rust installer for the host architecture #13 two frames in flight in Zink (on Allow resetting an existing Linux filesystem #12).
  3. Allow explicitly confirmed resets of existing ext4 filesystems #14 Wayland WSI pre-rotated swapchains and 8-bit formats first. Based on main, independent of the stack. Where it touches zink_kopper.c next to Select m1n1 Rust installer for the host architecture #13, whichever merges second needs a trivial rebase.

A follow-up for #10 is coming: two vertex-shader register fixes that NFS Carbon (WebGPU) needed. With them, a character vertex shader that used to be refused now compiles, and the faces render.

Packages / omarchy-a

@henrikklee
henrikklee merged commit 31aa327 into OrchardLinux:main Nov 17, 2026
11 checks passed
shaynelegault pushed a commit to shaynelegault/hardware that referenced this pull request Nov 19, 2026
OrchardLinux#151, OrchardLinux#152, OrchardLinux#156 and OrchardLinux#157 each numbered their patches after OrchardLinux#150 as if
they were the only follow-up. Number them in merge order: stability
(0034-0042), firmware interrupt and PM (0043-0049), eviction (0050-0057),
GPU time (0058), scene overlap (0059-0060).

Assisted-by: LLM
shaynelegault pushed a commit to shaynelegault/hardware that referenced this pull request Nov 19, 2026
OrchardLinux#151, OrchardLinux#152, OrchardLinux#153 and OrchardLinux#157 were each written on OrchardLinux#150 alone. Combined:

- gpu/0051: the BO memory cap charges a native BO at creation, also when
  its pages come later.
- gpu/0053: one record of the last two PM scenes, shared by the cache-line
  touch mask and the eviction veto.
- gpu/0054: the restore path and VM_MAP size their page tables from the
  device address, as gpu/0042 made VM_MAP do.
- gpu/0055: pools are prepared in the submit ioctl and sized for the
  firmware's feedback too; the job worker only switches to a prepared
  pool, between scenes, and never allocates.
- gpu/0058: completions are signalled before the S8003 rings are
  touched, in the poll worker of gpu/0041 and gpu/0043.

Two fixes on top: one submission order lock per device instead of one
for every PowerVR device (gpu/0059), and the job worker allocates as
before on chips that cannot evict (gpu/0060), so the A10 is unchanged.

Left out: GPU time in debugfs (OrchardLinux#156; belongs in per-client fdinfo
accounting) and the default-off scene overlap switch (OrchardLinux#157's second
patch). The s8003 display DART patch becomes devices/s8000/0017; main
took 0016 meanwhile.

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