Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= <brkosebay@users.noreply.github.com>
Date: Sun, 15 Nov 2026 12:45:47 +0100
Subject: [PATCH] drm/imagination: apple: Size an S8003 dataset's free list by
its initial 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
---
drivers/gpu/drm/imagination/pvr_hwrt.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_hwrt.c b/drivers/gpu/drm/imagination/pvr_hwrt.c
index ec50237..dd91ed9 100644
--- a/drivers/gpu/drm/imagination/pvr_hwrt.c
+++ b/drivers/gpu/drm/imagination/pvr_hwrt.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/* Copyright (c) 2023 Imagination Technologies Ltd. */

+#include "pvr_apple.h"
#include "pvr_free_list.h"
#include "pvr_hwrt.h"
#include "pvr_gem.h"
@@ -45,6 +46,7 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,
struct pvr_hwrt_dataset *hwrt)
{
struct pvr_device *pvr_dev = pvr_file->pvr_dev;
+ u32 local_pages;
int err;

hwrt->pvr_dev = pvr_dev;
@@ -62,8 +64,16 @@ hwrt_init_kernel_structure(struct pvr_file *pvr_file,
}
}

- if (hwrt->free_lists[ROGUE_FW_LOCAL_FREELIST]->current_pages <
- pvr_get_free_list_min_pages(pvr_dev)) {
+ /*
+ * On a chip that allocates the parameter manager's pages itself, a
+ * free list never holds pages (pvr_apple_free_list_has_pages()); its
+ * initial size is how many a render may take.
+ */
+ local_pages = hwrt->free_lists[ROGUE_FW_LOCAL_FREELIST]->current_pages;
+ if (pvr_device_is_apple(pvr_dev) && !pvr_apple_free_list_has_pages(pvr_dev))
+ local_pages = hwrt->free_lists[ROGUE_FW_LOCAL_FREELIST]->initial_num_pages;
+
+ if (local_pages < pvr_get_free_list_min_pages(pvr_dev)) {
err = -EINVAL;
goto err_put_free_lists;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= <brkosebay@users.noreply.github.com>
Date: Sun, 15 Nov 2026 18:28:34 +0100
Subject: [PATCH] drm/imagination: Don't free a job's command twice when its
stream is 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
---
drivers/gpu/drm/imagination/pvr_job.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imagination/pvr_job.c b/drivers/gpu/drm/imagination/pvr_job.c
index 95c5d2e..48a1cbc 100644
--- a/drivers/gpu/drm/imagination/pvr_job.c
+++ b/drivers/gpu/drm/imagination/pvr_job.c
@@ -79,8 +79,11 @@ pvr_job_process_stream(struct pvr_device *pvr_dev, const struct pvr_stream_cmd_d
job->cmd_len = cmd_defs->dest_size;

err = pvr_stream_process(pvr_dev, cmd_defs, stream, stream_size, job->cmd);
- if (err)
+ if (err) {
kfree(job->cmd);
+ job->cmd = NULL;
+ job->cmd_len = 0;
+ }

return err;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= <brkosebay@users.noreply.github.com>
Date: Sun, 15 Nov 2026 18:28:34 +0100
Subject: [PATCH] drm/imagination: apple: Require each chip's own register
extension

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
---
drivers/gpu/drm/imagination/pvr_apple.c | 26 +++++++++++++++++++
drivers/gpu/drm/imagination/pvr_apple.h | 9 +++++++
drivers/gpu/drm/imagination/pvr_apple_chip.h | 8 ++++++
drivers/gpu/drm/imagination/pvr_apple_s8003.c | 4 +++
drivers/gpu/drm/imagination/pvr_apple_t8010.c | 4 +++
drivers/gpu/drm/imagination/pvr_stream.c | 11 +++++---
6 files changed, 58 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/imagination/pvr_apple.c b/drivers/gpu/drm/imagination/pvr_apple.c
index e147626..b0505a2 100644
--- a/drivers/gpu/drm/imagination/pvr_apple.c
+++ b/drivers/gpu/drm/imagination/pvr_apple.c
@@ -1636,3 +1636,29 @@ const struct pvr_stream_cmd_defs *pvr_apple_cmd_stream(struct pvr_device *pvr_de
return chip->compute_stream ?: &pvr_cmd_compute_stream;
return type == DRM_PVR_JOB_TYPE_GEOMETRY ? chip->geom_stream : chip->frag_stream;
}
+
+/**
+ * pvr_apple_stream_musthave() - Required register extension for a chip's stream
+ * @pvr_dev: Target device.
+ * @type: Geometry or fragment stream type.
+ * @ext_type: Extension header type to which the returned mask applies.
+ *
+ * Return: the chip's required register bits, or zero for other stream types.
+ */
+u32 pvr_apple_stream_musthave(struct pvr_device *pvr_dev, enum pvr_stream_type type,
+ u32 *ext_type)
+{
+ const struct pvr_apple_chip *chip = pvr_dev->device_data->apple_chip;
+
+ if (type == PVR_STREAM_TYPE_GEOM) {
+ *ext_type = chip->geom_ext_type;
+ return chip->geom_ext_mask;
+ }
+ if (type == PVR_STREAM_TYPE_FRAG) {
+ *ext_type = chip->frag_ext_type;
+ return chip->frag_ext_mask;
+ }
+
+ *ext_type = 0;
+ return 0;
+}
diff --git a/drivers/gpu/drm/imagination/pvr_apple.h b/drivers/gpu/drm/imagination/pvr_apple.h
index cdc8e96..d1de0ad 100644
--- a/drivers/gpu/drm/imagination/pvr_apple.h
+++ b/drivers/gpu/drm/imagination/pvr_apple.h
@@ -10,6 +10,7 @@
#include <uapi/drm/pvr_drm.h>

#include "pvr_rogue_fwif_client.h"
+#include "pvr_stream.h"

struct dma_fence;
struct pvr_apple_chip;
@@ -167,6 +168,8 @@ int pvr_apple_resume(struct pvr_device *pvr_dev);
void pvr_apple_device_info_init(struct pvr_device *pvr_dev);
bool pvr_apple_takes_jobs(struct pvr_device *pvr_dev);
bool pvr_apple_free_list_has_pages(struct pvr_device *pvr_dev);
+u32 pvr_apple_stream_musthave(struct pvr_device *pvr_dev, enum pvr_stream_type type,
+ u32 *ext_type);
struct dma_fence *pvr_apple_submit_job(struct pvr_job *job);
struct dma_fence *pvr_apple_submit_compute_job(struct pvr_device *pvr_dev,
struct pvr_vm_context *vm_ctx, u64 stream,
@@ -200,6 +203,12 @@ static inline int pvr_apple_resume(struct pvr_device *pvr_dev) { return 0; }
static inline void pvr_apple_device_info_init(struct pvr_device *pvr_dev) {}
static inline bool pvr_apple_takes_jobs(struct pvr_device *pvr_dev) { return false; }
static inline bool pvr_apple_free_list_has_pages(struct pvr_device *pvr_dev) { return true; }
+static inline u32 pvr_apple_stream_musthave(struct pvr_device *pvr_dev,
+ enum pvr_stream_type type, u32 *ext_type)
+{
+ *ext_type = 0;
+ return 0;
+}
static inline int pvr_apple_vm_init(struct pvr_device *pvr_dev, struct pvr_vm_context *vm_ctx)
{
return -ENODEV;
diff --git a/drivers/gpu/drm/imagination/pvr_apple_chip.h b/drivers/gpu/drm/imagination/pvr_apple_chip.h
index 201d72a..d524415 100644
--- a/drivers/gpu/drm/imagination/pvr_apple_chip.h
+++ b/drivers/gpu/drm/imagination/pvr_apple_chip.h
@@ -164,6 +164,10 @@ struct pvr_apple {
* @render_job_size: Bytes @prepare_geom and @prepare_frag fill.
* @geom_stream: How a geometry job's command stream from userspace is decoded.
* @frag_stream: The same for a fragment job.
+ * @geom_ext_type: Required geometry register extension header type.
+ * @geom_ext_mask: Required bits within that geometry extension header.
+ * @frag_ext_type: Required fragment register extension header type.
+ * @frag_ext_mask: Required bits within that fragment extension header.
* @init: At probe, with Fender mapped: map and allocate what the chip needs,
* load the firmware (pvr_apple_fw_load()), set &pvr_apple.heap,
* &pvr_apple.layout and &pvr_apple.chip_data. Device-managed.
@@ -238,6 +242,10 @@ struct pvr_apple_chip {
size_t render_job_size;
const struct pvr_stream_cmd_defs *geom_stream;
const struct pvr_stream_cmd_defs *frag_stream;
+ u32 geom_ext_type;
+ u32 geom_ext_mask;
+ u32 frag_ext_type;
+ u32 frag_ext_mask;
const struct pvr_stream_cmd_defs *compute_stream;
unsigned int scenes;
bool own_pm_pages;
diff --git a/drivers/gpu/drm/imagination/pvr_apple_s8003.c b/drivers/gpu/drm/imagination/pvr_apple_s8003.c
index 468dd71..8115176 100644
--- a/drivers/gpu/drm/imagination/pvr_apple_s8003.c
+++ b/drivers/gpu/drm/imagination/pvr_apple_s8003.c
@@ -2550,6 +2550,10 @@ const struct pvr_apple_chip pvr_apple_chip_s8003 = {
.perf_state_max = S8003_PERF_STATE_MAX,
.geom_stream = &pvr_apple_g5p_cmd_geom_stream,
.frag_stream = &pvr_apple_g5p_cmd_frag_stream,
+ .geom_ext_type = PVR_STREAM_EXTHDR_TYPE_GEOM_G5P,
+ .geom_ext_mask = PVR_STREAM_EXTHDR_GEOM_G5P_REGS,
+ .frag_ext_type = PVR_STREAM_EXTHDR_TYPE_FRAG_G5P,
+ .frag_ext_mask = PVR_STREAM_EXTHDR_FRAG_G5P_REGS,
.compute_stream = &pvr_apple_g5p_cmd_compute_stream,
.scenes = 2,
.own_pm_pages = true,
diff --git a/drivers/gpu/drm/imagination/pvr_apple_t8010.c b/drivers/gpu/drm/imagination/pvr_apple_t8010.c
index f3ee833..5c62c13 100644
--- a/drivers/gpu/drm/imagination/pvr_apple_t8010.c
+++ b/drivers/gpu/drm/imagination/pvr_apple_t8010.c
@@ -461,6 +461,10 @@ const struct pvr_apple_chip pvr_apple_chip_t8010 = {
.render_job_size = sizeof(union pvr_apple_t8010_render_job),
.geom_stream = &pvr_apple_cmd_geom_stream,
.frag_stream = &pvr_apple_cmd_frag_stream,
+ .geom_ext_type = PVR_STREAM_EXTHDR_TYPE_GEOM_APPLE,
+ .geom_ext_mask = PVR_STREAM_EXTHDR_GEOM_APPLE_REGS,
+ .frag_ext_type = PVR_STREAM_EXTHDR_TYPE_FRAG_APPLE,
+ .frag_ext_mask = PVR_STREAM_EXTHDR_FRAG_APPLE_REGS,
.init = pvr_apple_t8010_init,
.boot = pvr_apple_t8010_boot,
.start = pvr_apple_t8010_start,
diff --git a/drivers/gpu/drm/imagination/pvr_stream.c b/drivers/gpu/drm/imagination/pvr_stream.c
index 7db6eb1..d83b7db 100644
--- a/drivers/gpu/drm/imagination/pvr_stream.c
+++ b/drivers/gpu/drm/imagination/pvr_stream.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-only OR MIT
/* Copyright (c) 2023 Imagination Technologies Ltd. */

+#include "pvr_apple.h"
#include "pvr_device.h"
#include "pvr_rogue_fwif_stream.h"
#include "pvr_stream.h"
@@ -272,10 +273,12 @@ pvr_stream_create_musthave_masks(struct pvr_device *pvr_dev)
PVR_STREAM_EXTHDR_FRAG0_BRN47217;

if (pvr_device_is_apple(pvr_dev)) {
- pvr_dev->stream_musthave_quirks[PVR_STREAM_TYPE_GEOM][PVR_STREAM_EXTHDR_TYPE_GEOM_APPLE] |=
- PVR_STREAM_EXTHDR_GEOM_APPLE_REGS;
- pvr_dev->stream_musthave_quirks[PVR_STREAM_TYPE_FRAG][PVR_STREAM_EXTHDR_TYPE_FRAG_APPLE] |=
- PVR_STREAM_EXTHDR_FRAG_APPLE_REGS;
+ u32 ext_type, mask;
+
+ mask = pvr_apple_stream_musthave(pvr_dev, PVR_STREAM_TYPE_GEOM, &ext_type);
+ pvr_dev->stream_musthave_quirks[PVR_STREAM_TYPE_GEOM][ext_type] |= mask;
+ mask = pvr_apple_stream_musthave(pvr_dev, PVR_STREAM_TYPE_FRAG, &ext_type);
+ pvr_dev->stream_musthave_quirks[PVR_STREAM_TYPE_FRAG][ext_type] |= mask;
}

if (pvr_device_has_uapi_quirk(pvr_dev, 49927)) {

Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= <brkosebay@users.noreply.github.com>
Date: Sun, 15 Nov 2026 19:08:29 +0100
Subject: [PATCH] drm/imagination: apple: Drop a fragment job's reference on
its geometry 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
---
drivers/gpu/drm/imagination/pvr_apple_queue.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/imagination/pvr_apple_queue.c b/drivers/gpu/drm/imagination/pvr_apple_queue.c
index 80bc17b..d176fe6 100644
--- a/drivers/gpu/drm/imagination/pvr_apple_queue.c
+++ b/drivers/gpu/drm/imagination/pvr_apple_queue.c
@@ -89,6 +89,11 @@ static void pvr_apple_free_job(struct drm_sched_job *sched_job)
struct pvr_job *job = container_of(sched_job, struct pvr_job, base);

drm_sched_job_cleanup(sched_job);
+
+ if (job->type == DRM_PVR_JOB_TYPE_FRAGMENT && job->paired_job)
+ pvr_job_put(job->paired_job);
+
+ job->paired_job = NULL;
pvr_job_put(job);
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Berkay=20K=C3=B6sebay?= <brkosebay@users.noreply.github.com>
Date: Sun, 15 Nov 2026 19:32:10 +0100
Subject: [PATCH] drm/imagination: apple: Let every geometry job take its VM's
scene first

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
---
drivers/gpu/drm/imagination/pvr_apple.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imagination/pvr_apple.c b/drivers/gpu/drm/imagination/pvr_apple.c
index b0505a2..5a43e3f 100644
--- a/drivers/gpu/drm/imagination/pvr_apple.c
+++ b/drivers/gpu/drm/imagination/pvr_apple.c
@@ -1229,14 +1229,18 @@ int pvr_apple_job_add_deps(struct pvr_job *job)
{
struct pvr_apple *apple = to_apple(job->pvr_dev);
struct dma_fence *last;
+ unsigned int scenes = 1;

if (job->type != DRM_PVR_JOB_TYPE_GEOMETRY && job->type != DRM_PVR_JOB_TYPE_FRAGMENT)
return 0;
spin_lock_irq(&apple->fence_lock);
+ /* Take this VM's first scene even when another VM rendered last. */
+ if (job->type == DRM_PVR_JOB_TYPE_GEOMETRY && apple->chip->vm_scenes)
+ scenes = apple->chip->vm_scenes(apple, job->ctx->vm_ctx);
if (job->type == DRM_PVR_JOB_TYPE_FRAGMENT)
last = apple->last_geom;
else if (apple->chip->scenes > 1 && apple->last_frag_vm == job->ctx->vm_ctx &&
- apple->chip->vm_scenes(apple, job->ctx->vm_ctx) > 1)
+ scenes > 1)
last = apple->prev_frag;
else
last = apple->last_frag;

Loading
Loading