[PATCH v4 03/17] drm/panfrost: Refuse to sync the CPU caches of a heap BO
From: Arun Iyengar via B4 Relay
Date: Thu Nov 26 2026 - 04:37:34 EST
From: Arun Iyengar <aiyengar1990@xxxxxxxxx>
On a coherent GPU, PANFROST_SYNC_BO on a heap BO dereferences the NULL
entries of its sparse page array. Heap BOs cannot be CPU-mapped:
return -EINVAL. Not tested on a coherent GPU.
Fixes: 7be45f548976 ("drm/panfrost: Add a PANFROST_SYNC_BO ioctl")
Cc: stable@xxxxxxxxxxxxxxx
Reported-by: Sashiko <sashiko-bot@xxxxxxxxxx>
Closes: https://lore.kernel.org/all/sashiko-outbox-206561@xxxxxxxxxx/
Signed-off-by: Arun Iyengar <aiyengar1990@xxxxxxxxx>
---
v4: shorter commit message.
---
drivers/gpu/drm/panfrost/panfrost_gem.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/panfrost/panfrost_gem.c b/drivers/gpu/drm/panfrost/panfrost_gem.c
index 518f24549..8067c5533 100644
--- a/drivers/gpu/drm/panfrost/panfrost_gem.c
+++ b/drivers/gpu/drm/panfrost/panfrost_gem.c
@@ -569,6 +569,9 @@ panfrost_gem_sync(struct drm_gem_object *obj, u32 type, u32 offset, u32 size)
if (drm_gem_is_imported(&shmem->base))
return -EINVAL;
+ if (bo->is_heap)
+ return -EINVAL;
+
switch (type) {
case PANFROST_BO_SYNC_CPU_CACHE_FLUSH:
case PANFROST_BO_SYNC_CPU_CACHE_FLUSH_AND_INVALIDATE:
--
2.55.0