Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs
@ 2026-11-19 19:38 Maíra Canal
  2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Maíra Canal @ 2026-11-19 19:38 UTC (permalink / raw)
  To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, Faith Ekstrand, Boris Brezillon, Rob Herring,
	Steven Price, Adrián Larumbe, Liviu Dudau, Akash Goel,
	Karunika Choo, Lukas Zapolskas, Chris Diamand, Daniel Almeida,
	Alice Ryhl
  Cc: kernel-dev, dri-devel, rust-for-linux, Maíra Canal

This series follows up on the discussion in the V3D cached maps series
[1], about how to handle CPU-cached BOs that are shared through dma-buf.

As pointed by Faith and Boris, when a buffer is shared through dma-buf,
there's no way to ensure that a client will properly bracket their CPU
accesses with DMA_BUF_IOCTL_SYNC. With WC mappings, waiting on fences is
enough to guarantee consistency. However, with WB mappings, a missed sync
can leave dirty cache lines behind, which another client can end up
writing over.

PanVK already keeps WB_MMAP BOs private, so this series only makes the
kernel enforce the same policy on Panfrost and Panthor. As WB_MMAP BOs can
no longer be exported, the custom dma_buf_ops providing begin/end_cpu_access()
are no longer needed for them and are replaced by the default PRIME ops.

- Patch 1 adds the drm_gem_shmem_sync() helper, taken from [2].
- Patches 2 and 5 refuse to export WB_MMAP BOs in Panfrost and Panthor.
- Patches 3 and 6 drop the custom dma_buf_ops from Panfrost and Panthor.
- Patch 4 converts Panfrost to drm_gem_shmem_sync(). V3D will also use it
  to implement its cached maps, which I'll send in a separate series.

Patches 3 and 6 need some extra attention as they aren't a no-op on
IO-coherent GPUs. In this case, all BOs are CPU-mapped WB, and the custom
begin/end_cpu_access() could be used to sync the mappings of non-coherent
importers.

However, I decided to send these patches either way because they only
restore the behavior prior to commits 3ae6637378e6 and 925ad0c26dd8, which
is what we discussed in [1] (IIUC). Also, Mesa writes through the GEM mmap
without DMA_BUF_IOCTL_SYNC, so it never relied on these hooks anyway.

Still, if you think this would be problematic, I can drop patches 3 and 6.

The Panthor changes were tested on hardware, but Panfrost changes were
only compile-tested.

[1] https://lore.kernel.org/dri-devel/20261030-v3d-cached-maps-v1-0-0a6a6b363382@igalia.com/T/
[2] https://lore.kernel.org/dri-devel/20251126124455.3656651-1-boris.brezillon@collabora.com/

Best regards,
- Maíra

---
Faith Ekstrand (1):
      drm/shmem: Add a drm_gem_shmem_sync() helper

Maíra Canal (5):
      drm/panfrost: Refuse to export WB_MMAP BOs
      drm/panfrost: Drop custom dma_buf_ops
      drm/panfrost: Use drm_gem_shmem_sync()
      drm/panthor: Refuse to export WB_MMAP BOs
      drm/panthor: Drop custom dma_buf_ops

 drivers/gpu/drm/drm_gem_shmem_helper.c  |  93 +++++++++++++++
 drivers/gpu/drm/panfrost/panfrost_drv.c |   1 -
 drivers/gpu/drm/panfrost/panfrost_gem.c | 194 ++------------------------------
 drivers/gpu/drm/panfrost/panfrost_gem.h |   3 -
 drivers/gpu/drm/panthor/panthor_drv.c   |   1 -
 drivers/gpu/drm/panthor/panthor_gem.c   | 120 +-------------------
 drivers/gpu/drm/panthor/panthor_gem.h   |   4 -
 include/drm/drm_gem_shmem_helper.h      |  17 +++
 include/uapi/drm/panfrost_drm.h         |   1 +
 include/uapi/drm/panthor_drm.h          |   2 +
 10 files changed, 126 insertions(+), 310 deletions(-)
---
base-commit: 8e2afcd2b57990465f132367fd8fdc2e55c1adad
change-id: 20261119-pan-drop-dma-buf-hooks-98f7f19f3b51


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-11-20  9:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-19 19:38 [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 1/6] drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal
2026-11-19 19:38 ` [PATCH 2/6] drm/panfrost: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 3/6] drm/panfrost: Drop custom dma_buf_ops Maíra Canal
2026-11-19 19:38 ` [PATCH 4/6] drm/panfrost: Use drm_gem_shmem_sync() Maíra Canal
2026-11-19 19:38 ` [PATCH 5/6] drm/panthor: Refuse to export WB_MMAP BOs Maíra Canal
2026-11-19 19:38 ` [PATCH 6/6] drm/panthor: Drop custom dma_buf_ops Maíra Canal
2026-11-20  9:56 ` [PATCH 0/6] drm/panfrost,panthor: Refuse to export WB_MMAP BOs Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox