Skip to content

A9 GPU follow-ups: render fixes, recovery, eviction, PM, direct scanout - #159

Merged
henrikklee merged 57 commits into
mainfrom
a9-gpu-integration
Nov 17, 2026
Merged

henrikklee merged 57 commits into
mainfrom
a9-gpu-integration

Conversation

@henrikklee

Copy link
Copy Markdown
Contributor

Lands the iPad 5 (A9) GPU follow-ups by brkosebay, #150, #151, #152, #153, #154, #156, #157 and #158, as one stack. Each PR's head is merged unchanged, so the PRs show as merged. Integration commits on top:

Tested:

  • Builds: apple-16k and apple-4k with no warnings; unit tests pass.
  • J71b (iPad 6), installed desktop on the GPU with the matching Mesa stack (OrchardLinux/mesa Cache root images on the existing Linux-data partition #9-Allow explicitly confirmed resets of existing ext4 filesystems #14):
    • about 42k GPU jobs, 0 faults, no kernel warnings
    • 6 min suspend and wake
    • no touch stalls
  • The display DART self-check fails on the A10 (SMMU fault on stream 1 at 0xc4b4a80 during the translated step; the translated and permuted CRCs were correct) and falls back to bypass as designed. Follow-up: find what stream 1 reads on the T8010.
  • The A9 parts were tested by brkosebay on the iPad 5; he confirms on the nightly.

Assisted-by: LLM

…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
Firmware stops processing jobs after a fault, but internal record and
PM waits spent five seconds polling an unreachable stamp. End waits on
the existing fault latch and return -EIO unless the requested stamp
actually arrived. Keep the latch until a new boot.

Affects: Apple A9 (S8003); A10 unchanged
Assisted-by: LLM
A texture read at VA 0xffffffc0 stopped rendering on the iPad 5. Share
the decoder and once-per-boot report so the VA, access, requester and
context are captured before reset. Read only e150/e158 after checking
Fender state, transition bits and an optional chip-supplied highest
state. Refuse capture without a licence. Both fault edges and internal
wait failures use this path.

Affects: Apple A9 (S8003); chips without a licence callback do not read RGX
Assisted-by: LLM
A VM_BIND client supplies no per-job buffer list. Its VM reservation must
therefore retain every queued job before idle mappings can be reclaimed.
Prepare the VM reservation in the existing drm_exec pass, reserving space
for the whole submission even when several jobs share it. Add each armed
finished fence with BOOKKEEP usage before queueing.

Track the latest finished-fence retirement timestamp under the VM lock.
Reclaim skips a signalled fence until its timestamp is published, and
requires a full quiet period after the latest retirement. No job lifetime
is extended into a fence-signalling callback.

Affects: every PowerVR device

Assisted-by: LLM
A quick idle suspend and resume can restart firmware before the chip's
minimum gate-off interval expires. Record successful power-off time and
wait only its remaining interval before powering up. Retain reset's
existing delay. Chips with no minimum are unaffected.

Affects: Apple A9 (S8003); A10 has no gate-off minimum
Assisted-by: LLM
A large storage buffer consumes unswappable memory at CREATE_BO even if
it is never used. Leave userspace shmem unbacked until VM_MAP, vmap or a
CPU fault. Shmem supplies zero-filled pages. Keep the internal create
entry point eager and explicitly mark all its objects kernel-pinned.

Audit of sgt readers: VM map acquires residency; GEM vmap now does too;
vmap/vunmap cache sync already tolerates NULL; get_dma_addr now returns
-EINVAL when unbacked. Its Apple boot, PM pool and VM reserved-page
callers use eager kernel BOs. The free-list page writer obtains an sgt
for its eager internal BO. Firmware, HWRT sync objects and both Apple
backends retain the internal create entry point.

The shmem locked page-in helper is private. Transfer a temporary explicit
pin's page reference to our DMA-mapped sgt under the reservation instead.

Affects: every PowerVR device

Assisted-by: LLM
A slot tag can wrap onto firmware's cached value, making a page-table
change invisible and retaining stale translations. Share the helper
that skips zero and the cached tag, retaining unsigned wrap and the
steps-past counter. Leave A10's generation bump unchanged until its
cached-generation offset is known.

Affects: Apple A9 (S8003); A10 unchanged
Assisted-by: LLM
Mesa maps its buffers on the CPU for their whole lifetime. The shmem
mmap helper holds page references for every such VMA, defeating reclaim.
Keep only GEM references in native VMAs and obtain DMA-mapped pages in
the fault handler under the BO reservation. Use PFN mappings with the
existing write-combining policy. A later eviction can zap those PFNs
under the same reservation before dropping pages. Mark pages dirty to
preserve CPU stores across swap. Imported mappings stay with exporters.

Affects: every PowerVR device

Assisted-by: LLM
Native creation pins all backing pages, so a client can exhaust memory
needed to recover. Charge before taking pages and refuse above device
and per-TGID budgets with -ENOMEM and a ratelimited diagnostic. Share
accounting across the creator's DRM files, uncharge at free and exclude
imports. Defaults are 50 percent of RAM and 75 percent of that device
budget per client. Create-time charging counts real backing here; it
can move to residency when eviction becomes available.

Affects: every PowerVR device
Assisted-by: LLM
Idle clients keep every mapped BO unswappable on small-memory systems.
Use the GEM LRUs and shrinker to release native shmem backing while
preserving GPU virtual addresses. Require all mapping VMs to be idle,
with published retirement timestamps, for a one-second quiet period.

Trylock every VM under the BO reservation before editing any PTE. Mark
each cleared VA and vm_bo evicted, publish the MMU invalidation, then zap
CPU mappings, DMA-unmap and release the sole sgt page reference. Keep
pages on any partial unmap or flush failure for submit-time repair.

Never reclaim imports, exports (including export publication), kernel
BOs, PM/FW-protected BOs, vmaps, explicit pins or additional page users.
The Apple veto trylocks submit_lock and S8003 checks pm_last/pm_prev,
attached versus firmware gen, fault/booted, and each pm[].scene/td_seq
through s8003_pm_idle(). Track the last two geometry VM targets; no new
register access is introduced. T8010 keeps its generation invalidation.

Use base.gem_lru_mutex, required by drm_gem_lru, rather than a private LRU
lock. Reclaim edits use GFP_NOWAIT cursors. IMG KCCB flushing can acquire
power/CCB locks and reset firmware: schedule its scan in ordinary work
context rather than invoke it from direct reclaim. Eviction is enabled
on every device. Apple scans publish RAM-only tags directly in reclaim.

Expose controls and resident/evicted bytes, counters and skip reasons in
gem_evict; writing a MiB limit requests one pass. No swap, no eviction.

Affects: every PowerVR device

Assisted-by: LLM
Pool-limit failures cannot be attributed without the sizes real scenes
ask the PM to hold. Log VM, blocks, clamp, tiles and initial free-list
pages once per VM when its first pool is built. Reuse existing values
and add no register access.

Affects: Apple A9 (S8003); A10 unchanged
Assisted-by: LLM
A faultless GPU must never start work with a hole left by reclaim.
The first render on the iPad 5 hung before firmware boot when the HWRT
dependency walk reacquired a reservation already owned by drm_exec.
Assert ownership there instead of taking a NULL-ticket recursive lock.
Lock each distinct submission VM before taking any reservation, validate
the GPUVM evict list, and retain VM locks through arming, VM fence
publication and queueing. Serialize submissions with the existing order
mutex, now common, as the nesting anchor for multiple VM locks. Map and
unmap only take one VM lock, then reservations; reclaim only trylocks.

PowerVR uses GPUVM flags zero and does not populate its extobj list.
Keep the internally spinlocked evict list, add vm_bo_validate, and use
drm_gpuvm_prepare_range over the actual VA tree in the drm_exec retry
pass. Restore every marked VA from its new DMA-mapped sgt, publish the
flush, clear eviction and refresh LRU recency. Keep prior restores on a
failure and return -ENOMEM before prepare_job_syncs can arm anything.

Track eviction per VA for mixed resident/evicted mappings and splits.
Unmap skips cleared PTEs. Repair a partial eviction by clearing its full
range before remapping. Move VM_MAP's page acquisition and MMU cursor
creation under the VM and BO locks: a bare sgt obtained before either
lock could otherwise be freed by reclaim before MAP uses it.

Native validation defers context and HWRT reservations until its MMU
flush completes: the flush error path resets and vmaps firmware objects.
Reinitialize exec for the full reservation pass before dependencies; VM
mutexes keep residency protected across both passes. Apple uses its
RAM-only invalidation with the complete reservation set held.

Affects: every PowerVR device

Assisted-by: LLM
A firmware fault stopped the iPad 5 GPU, but submitted jobs waited for
the five-second scheduler timeout. Fault the one scheduler owning the
oldest bound hardware fence; its reset cancels all pending engines.
Bind scheduler metadata under the fence lock and retain normal timeout
coverage for unbound fences. Mark the selected fence so the timeout
handler says the job was lost to a firmware fault. Keep context failure,
stop, reset and restart unchanged. A10 can opt in once its fault event
types are confirmed.

Affects: Apple A9 (S8003); A10 event policy unchanged
Assisted-by: LLM
Memory pressure can stall a scheduler worker while its job fence is
needed to make memory reclaimable. Prepare S8003 PM resources in submit
ioctl context, before VM locks and arming. Take scene sets there, allocate
and persistently vmap aux buffers and pending pool growth outside the
worker's submit_lock, then publish pointers under that lock. Keep an
active set's old pool until the worker selects the idle set. The worker
only installs pre-reserved capacity and writes the existing records.
Missing capacity fails cleanly instead of allocating in the worker.

Allocation audit of run_job through chip submission:
- Shared submit_compute_job: fence allocation becomes GFP_NOWAIT.
- Shared submit_render_job (T8010): fence and translated command buffer
  become GFP_NOWAIT, retaining existing -ENOMEM cleanup.
- Shared submit_job (S8003): fence allocation becomes GFP_NOWAIT.
- S8003 pm_build: aux GEM creation, reserved VM mapping, pool creation
  and pool/aux vmaps move to prepare_job. Persistent maps make zeroing
  allocation-free. Replaced pools are released only when their set idles.
- S8003 job_write/fill and T8010 write_compute/write_geom/write_frag
  allocate nothing. Firmware restart reuses the initialized image/pages;
  the T8010 coherent window/heap and S8003 image are init-time allocations.

Publish PM set readiness only after aux mappings and pool resources exist.
Arming counts ready sets under set_lock and the worker selects them under
submit_lock; both locks protect readiness publication.

Only ioctl preparers take prepare_lock. No worker lock is held while
allocating the new resources. PM record format and sizing are unchanged.

Affects: Apple A9 and A10

Assisted-by: LLM
Driver removal freed firmware storage while the DMA writer still ran.
Stop firmware and pollers before releasing pages, and defer an idle
firmware restart until a job needs it. A blocked submit ioctl also held
reboot in DRM unplug SRCU for minutes. Quiesce hardware in shutdown
without unplug or scheduler flush. Bound submit locking and engine waits,
cancel fences with -ESHUTDOWN, and use terminal-only non-joining work,
mailbox and runtime-PM operations. Preserve the existing power requests
and force-stop writes. Retain callback storage until CPUs stop; ordinary
teardown still joins workers.

Affects: Apple A9 and A10 firmware teardown and reboot
Assisted-by: LLM
Keep S8003 eviction and require a chip hook before reclaim on other Apple GPUs. T8010 remains excluded until its pressure test is validated; non-Apple PowerVR retains the common default.

Affects: Apple A9 (S8003); other Apple chips opt in per chip

Assisted-by: LLM
Keep the native BO cap at S8003 50/75 defaults and off on other chips unless explicitly configured. Track one devfreq suspend reference across lazy runtime resumes, failed starts and system sleep on both Apple chips.

Assisted-by: LLM
Keep the branch based on the updated A9 render series.

Assisted-by: LLM
Keep the branch based on the updated A9 render series.

Assisted-by: LLM
A 1 MiB buffer at BO offset zero can cross a 2 MiB device-VA boundary.
Sizing the table reserve from the BO offset leaves it one table short,
so mapping fails with ENOMEM on every retry despite available memory.
Masked indices can also wrap across a parent boundary and underflow the
allocation count. Count absolute regions through the inclusive last VA;
retain the BO offset only for the scatter-gather cursor.

Fixes: ff5f643de0bf ("drm/imagination: Add GEM and VM related code")
Affects: every PowerVR device
Assisted-by: LLM
…M memory

The S8003 event callback reads firmware and PM cache lines before completed
job fences are signalled. That host work delays the next scheduled job even
though completion stamps are already visible through coherent mappings.

Signal the fences and retire their runtime-PM references first, then run
the chip event callback. Keep the A10 event acknowledgement before its
retirement-watermark check, as before. No submission dependency changes.

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

Assisted-by: LLM
…pletion

The poll work re-arms a 100 us timer for as long as any job is pending:
about 10,000 wakeups a second whenever the GPU is busy, and a finished
job is seen up to 100 us late.

Let a chip hand the backend its firmware's interrupt. The hard IRQ handler
acknowledges it at the source through the new irq_ack() op and kicks the
poll work, which drains the firmware's rings and signals fences as
before. The interrupt is requested with IRQF_NO_AUTOEN and enabled only
while fences are pending, because firmware that is up but idle raises it
as well. While it is enabled the poll work re-checks every irq_poll_us,
except for PVR_APPLE_FAST_US after a chip reported a finished job
(pvr_apple_firmware_progress()). The stamps and ring watermarks that
make a job done do not all reach memory at the same moment, so those
re-checks keep apple_poll_us.

pvr_apple_firmware_event() is the one place that kicks the poll work for
the firmware. The A10's RTKit receive callback now calls it as well,
with the same behaviour as before. The A10 takes no interrupt here and
keeps polling, because none of its firmware messages is known to mean
completion.

Affects: Apple A9 (S8003) and A10 (T8010); the A10 keeps polling, no behaviour change

Assisted-by: LLM
The A9's firmware raises AIC interrupt 174, the node's fifth, by writing
its bit to the AIC's software-set register (AIC+0x4014, bit 14). The
apple-aic driver never clears a software-set interrupt, so taking it
without help would fire again as soon as it is unmasked. That is why the
backend polled for finished jobs every 100 us.

Apple's kext clears the bit itself at the software-clear register
(AIC+0x4094 for interrupt 174) before it reads the rings, and so does
this. irq_ack() writes the bit to that word, which init() maps from the
AIC's address in the device tree, and the shared code then takes the
interrupt while jobs are pending. A stamp event read from the event ring
marks progress, so completion is checked again at 100 us steps for a
millisecond while the job's watermarks reach memory. Otherwise the
backstop period is 1 ms, the period of s8003_touch() that the firmware
needs to make progress at all.

If the interrupt or its register cannot be had, the backend logs a
warning and polls as before.

Affects: Apple A9 (S8003)

Assisted-by: LLM
brkosebay and others added 26 commits November 16, 2026 17:49
…is not clean

Every geometry job starts with the PM record command {6, slot, PM id,
set}. It has the firmware take the PM state from the set and rebuild
the set's free list from its block list, which is per-job firmware
time. Earlier hardware measurements sent it only when the set was not known to be
clean, and otherwise {4, the geometry channel's stamp, seq - 1}, a wait
that is already satisfied. On the iPad 5 that cut a small render pass
by a third and raised glmark2 by 6 to 35 % per scene, with no fault,
timeout or free-list drift. It let the next geometry job run under the
previous fragment job, as on iOS.

Do the same. A set is clean for a geometry job when:
- it is not built anew for the job (same firmware start, pool large
  enough);
- its last scene ran to its end in this firmware start: geometry and
  fragment job both handed over, the fragment job done, no fault
  latched.

A scene without a fragment job gave no pages back and leaves the set
dirty. So does a job that failed before it reached the firmware. A
firmware start (every runtime resume, every reset) builds the sets anew.

Unlike in earlier hardware measurements, a geometry job here can be written while the
one before it still runs. The {4} form would then make the firmware
wait on its own stamp, which it sees late without the host's reads. So
the record is skipped only when job seq - 1 is already done.

Affects: Apple A9 (S8003)

Assisted-by: LLM
An S8003 scene that exhausts its PM pool stops the firmware. Dataset
sizing alone does not incorporate what previous scenes actually used.

Read the firmware high-water mark, margin and bounded growth request from
the completed set's list page, following its taken-flag protocol. At most
every 167 ms per VM, grow to three times high-water or one block plus the
margin, otherwise by the request (at most eight blocks). Ignore impossible
values and retain the existing pool cap.

Take feedback in the geometry submission's process context, under the
existing submit lock, just before the existing idle-set pool allocator.
No reclaim or prepared-pool infrastructure is needed by this change.

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

Assisted-by: LLM
…bugfs

Host in-flight durations include queueing and firmware overhead, so they
cannot show how long the GPU geometry and fragment phases actually ran.

Read the retired phase-time u64 at W+0x550 or W+0x8ac before the record is
cleared. Both submission paths wait for last_seq - 1 before writing the
two-slot ring's next record, so its previous occupant has retired. Order
that shared-memory read with dma_rmb(), preserve it across the fill, and
account only successful fills before the result word is cleared.

Expose accumulated geometry and fragment time, jobs and zero samples in
apple_jobs, converting 24 MHz ticks by ticks * 125 / 3. Add only the small
chip debugfs callback needed by that line; no timing parameters, phase-gap
attribution or memory census. Submission ordering and power policy stay
unchanged.

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

Assisted-by: LLM
Composited S8003 workloads serialize one client's geometry behind another
client's fragment, even though their PM sets are private to their VMs.

Keep each VM's last two fragment fences and add apple_vm_overlap, default
off. When enabled on a chip with per-VM scenes, geometry waits on its own
VM's previous fragment (or last fragment for one scene). Keep the global
scene dependencies with the option off and for chips without per-VM sets.
Reference and release the per-VM history with the existing VM lifetime.

Affects: Apple A9 (S8003). T8010 has no per-VM scene hook and keeps its
global dependencies regardless of the parameter.

Assisted-by: LLM
…ugfs

Runtime suspend stops the firmware and the next job starts it again, but
host in-flight durations do not show that cycle's cost or the work spent
checking for completion.

Expose a read-only apple_jobs file and snapshot job progress without
powering up the GPU. Report firmware starts and failures, gate-off waits,
boot/resume/first-job latency, suspend duration, IRQs and poll iterations.
Let each chip add its own measurements; S8003 reports cache-line read time,
PM record use, pool feedback and its wait loops. Keep the existing power
policy, submission order and completion criteria unchanged.

Affects: Apple A9 (S8003) and A10 (T8010), debugfs measurements only.

Assisted-by: LLM
…ady state

The clean-set path waits on the immediately preceding geometry job. When
that job is still running it falls back to a full PM record, rebuilding
the free list even though this set has not changed.

Follow AGXTACommandDescriptor_preparePMAndWork: remember the geometry job
that last carried each set's PM record and wait only on that stamp for a
clean set. A newer ordinary geometry job does not force a rebuild. Reset
the remembered stamp when backing is rebuilt or firmware restarts, and
fall back to a record if the rebuild stamp has not been reached.

Make this the single behavior. No always-rebuild or legacy-wait mode and
no module parameter are added. Keep the existing clean-set bookkeeping
in the prerequisite series; report clean queued and unreached stamps.

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

Assisted-by: LLM
The boot loader leaves display scanout fetching its framebuffer through a
bypassed DART. Attaching an empty DMA domain under those reads can blank
or corrupt the display before its driver has mapped the live addresses.

Let a DMA master request apple,dart-deferred-attach and export the existing
iommu_deferred_attach() helper. The display driver can populate its default
domain before enabling translation. Other masters keep their attach policy.

Affects: Apple display DMA masters left running by the boot loader.

Assisted-by: LLM
The display fetch path has a DART and a second SMMU front end. Describe
both named register windows and fault interrupts for the S5L8960X layout,
and the display pipe's optional deferred-attach scanout DMA master.
Existing single-window IOMMUs and display pipes remain valid.

Affects: Apple S5L8960X display DART and scanout device trees.

Assisted-by: LLM
Translated display fetches can read unrelated DRAM without a DART fault
when the second front end remains in bypass. Mirror stream translation in
DART then SMMU order and program the second error reflector and diagnostic
word, following AppleS5L8960XDART enableStream and hardware initialization.
Only the primary DART owns page tables and invalidation commands.

Handle both fault interrupts, expose their combined count for the display
self-check, and mask each faulting line after 16 faults until translation
or bypass setup rearms it. This path requires an explicitly described
second window; existing single-window DARTs retain their setup.

Affects: S5L8960X display DARTs with an SMMU window.

Assisted-by: LLM
An unmap walk does not create page tables. When it loads a level 1
table that is absent, pvr_mmu_op_context_load_tables() leaves
curr_page.l1_table NULL and returns success. Removing the last level 0
table of a level 1 table also frees that level 1 table and clears
curr_page.l1_table. In both cases, the next page that crosses only a
level 0 boundary asks for a level 0 reload, and
pvr_page_table_l0_get_or_insert() reads the level 1 entry through the
NULL table:

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000001008
  pc : pvr_mmu_op_context_load_tables+0xd8/0x1dc [powervr]
  lr : pvr_mmu_op_context_next_page+0xbc/0xd4 [powervr]
   pvr_mmu_op_context_unmap_curr_page+0x48/0x68 [powervr]
   pvr_mmu_unmap+0x2c/0x38 [powervr]

0x1008 is the backing page's host_ptr behind the 512-entry mirror
array. Unmapping a range only after it was mapped never reaches this,
but an unmap of a range that is already partly or fully unmapped does,
for example when restoring an evicted mapping first clears whatever an
interrupted eviction left behind.

Without a level 1 table there is no level 0 table either. Report
-ENXIO like any other absent table when not inserting, so the walk
treats the range as unmapped. A walk that inserts tables always loads
the level 1 table first, so warn if it ever gets here.

Assisted-by: LLM
pvr_mmu_op_context_unmap_curr_page() advances one device page at a
time, even through a range whose page tables are absent. Unmapping a
range that is already unmapped, such as clearing what an interrupted
eviction may have left before restoring a mapping, then walks every
page of it: 16384 steps for 256 MiB with 16 KiB pages, 65536 with
4 KiB pages.

Do what the FIXME suggested. When the current page has no level 0
table, no page up to the end of that table's span can be mapped; with
no level 1 table, the same holds up to the end of the level 1 span.
Move the cursor to the last page of that span, so the next advance
crosses the boundary and loads the following tables through the usual
path, which also syncs the tables being left. Never move past the last
page of the range.

The check runs after each page is destroyed, so a level 0 or level 1
table freed by removing its last entry also ends the walk through its
span.

The -ENXIO this loop skipped on never reached it:
pvr_mmu_op_context_load_tables() reports an absent table as success
with a NULL table pointer, which is what the loop now checks.

Assisted-by: LLM
Fullscreen client buffers cannot scan out directly while the display
fetches physically contiguous memory in bypass, adding a compositor pass.
Map scanout buffers through the display DART so imported dma-bufs form a
single device-address range. Preserve the boot framebuffer mapping before
deferred attachment and hold each displayed buffer through its last fetch.

Require a live pipe-CRC self-check before using translated planes. Scan out
an owned asymmetric pattern in bypass, through a nonidentity mapping, and
through an alias with two 16 KiB pages swapped. Enable blend CRC directly at
ADP +0x1074, restore its previous value, and require stable nonzero reference
CRCs, matching translated CRCs, a different permuted CRC and no DART/SMMU
faults. Report per-step pipe errors; output underrun alone is diagnostic.

Always restore the previous framebuffer after the check. On failure or an
inconclusive result, restore bypass and verify both translation controls.
Retain live mappings if the previous framebuffer or rollback cannot be
confirmed. Shutdown parks on the boot framebuffer before disabling both
front ends. There is no option to bypass verification; the existing
read-only dart_scanout parameter remains a boot-time disable switch.

Only a display pipe with a scanout DMA child takes the new path. Both SoCs
use the same mapping-before-attach and mandatory CRC check. If the CRC enable
does not read back, restore its control without flipping or attaching. A
zero or unstable reference, or an ineffective page permutation, also returns
to bypass. Restore the prior image before returning from any displayed test.

Affects: Apple A9 and A10 display scanout.

Assisted-by: LLM
The display pipe fetches through two translation front ends. Describe
the DART and SMMU windows, both fault interrupts, and the deferred-attach
scanout master so the boot framebuffer can be mapped before attachment.
Keep the IOMMU disabled until the display driver prepares the live mapping.
Only S8003 gets this node; T8010 scanout is unchanged.
Record the supplied J71t display proof in the hardware catalog and
regenerate its support matrix; other boards retain their recorded status.

Affects: Apple A9 S8003 display DART.

Assisted-by: LLM
Fullscreen imported buffers otherwise require a compositor pass on the
1536x2048 iPad 6 panel. Describe the display DART and SMMU with their ADT
windows, reflector, configuration and fault interrupts, and give disp0 a
deferred-attach scanout master. Reuse the same map-before-attach and mandatory
pipe-CRC gate as S8003; no unchecked T8010 translation path is introduced.

Use the display back-end domain, which keeps its front end powered, because
there is no separate DISP0_DART domain in the current PMGR description.
The ADT's smmu-options=2 and dart-options=5 are noted for hardware testers;
no speculative properties or register writes are added for them.
disp0 is enabled on the iPad 6 and, through the shared iPad 6 include, on
the iPad 7. On the iPad 7 the display driver rejects the boot framebuffer
size at probe, before any DART code runs, so it stays on simpledrm and the
scanout master is never attached there. Translated scanout is untested on
A10 hardware.

Affects: Apple A10 iPad 6 display scanout; the iPad 7 stays on simpledrm.

Assisted-by: LLM
#151, #152, #156 and #157 each numbered their patches after #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
#151, #152, #153 and #157 were each written on #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 (#156; belongs in per-client fdinfo
accounting) and the default-off scene overlap switch (#157's second
patch). The s8003 display DART patch becomes devices/s8000/0017; main
took 0016 meanwhile.

Assisted-by: LLM
- gpu/0061: the T8010's RTKit crash callback latches the same shared
  fault as the S8003's fault event: waits end at once and the GPU resets
  within milliseconds instead of after the 5 s job timeout.
- gpu/0038 (BO memory cap) goes. It charged a BO's full size at creation,
  which no longer measures memory now that userspace BOs are backed on
  first use and idle ones are evicted to swap (zram on every install).
  It refused legitimate large buffers (GravityMark) and put a chip check
  into common code.
- gpu/0062: apple_jobs keeps the hang state; runtime PM timings, poll,
  interrupt, cache-touch and PM record counters and the per-VM pool log
  line go.

Assisted-by: LLM
Pull request checks never compiled a kernel, so a green check said
nothing about kernel patches, configs or build scripts.

On a pull request the changed job now compares each platform's kernel
between the merge commit and the branch it merges into
(ci/changed_kernels.py): its source key, computed by each side's own
code, and the build scripts ci/reuse_kernel.py guards. The kernel job
runs for the platforms that differ and leaves the others out of its
matrix. A change to a shared patch layer (hoolock, pauli1go, drivers,
devices) changes both apple-16k and apple-4k, which compile the same
patches with different page sizes and configs, so both are built; a
config change builds only its platform; apple-armv7 builds when its own
layers change; documentation builds nothing.

A pull request reads the compiler cache of the last main build but
saves none, and archives and uploads nothing; assets, draft and nightly
still never run for it.

Assisted-by: LLM
@henrikklee
henrikklee merged commit 15b8d09 into main Nov 17, 2026
12 checks passed
@henrikklee
henrikklee deleted the a9-gpu-integration branch November 17, 2026 11:21
@brkosebay

Copy link
Copy Markdown
Contributor

Tested merged main on the iPad 5 (J71t, A9): kernel 46fc6bb with main's own J71t series and apple-16k config, Mesa 5e7a998 (#15) built with the packages repo's PKGBUILD options. The only addition was the warm-restart hand-over set our test setup needs to kexec in (gated by apple_warm_restart=1; it touches ADBE and the DART only on their shutdown/hand-over path). The GPU driver is main's, unchanged. Mac USB cable connected throughout.

Test Result
Boot, display warm boot; display DART self-check passed, 0 faults; scanout through the DART
Desktop Labwc on Zink/PowerVR; idle 0 % GPU busy; Firefox scrolling 60 fps at 17.5 % busy, direct scanout
glmark2 --fullscreen, all scenes, portrait 520 (91 % busy), direct scanout. Same as before the merge (522)
glmark2, landscape 461, composited by Labwc as expected for GL clients (466 before the merge)
vkmark --fullscreen 300 (92 % busy)
Eviction stress, 300 s 67 MiB evicted and restored; 370/370 alternating cycles fully evicted and restored; 28,156 checksummed frames, 0 mismatches, 0 restore failures
Firefox WebGPU textured page, 60 fps for 30 s
GPU faults 0 for the whole boot, 0 resets
Suspend (s2idle, RTC wake) not entered: see below

Suspend. All three attempts were refused by the charger, not the GPU: apple-tristar-charger: PM: failed to suspend: error -16. tristar_suspend() returns -EBUSY while the charger is in TRISTAR_SETTLING or TRISTAR_RAMPING (drivers/power/0024), and with the Mac cable in the input current was still in one of those phases at each attempt (limit 2400 mA, 99 % Charging just after). I'll check it again with the cable out, and against the charging changes I'm about to send, which move the ramp to iOS's sequence.

GPU busy here is apple_jobs busy_ns over wall time, since the per-engine GPU time is no longer exposed.

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