This series aims to implement cached maps and explicit flushing for the V3D driver, which is mostly motivated by Vulkan's host cached memory.
V3D's implementation of cached maps is quite similar to Panfrost's and therefore, I decided to revamp Panthor/Panfrost's efforts [1] to implement common shmem helpers for CPU cache maintenance. The other option would be copying the same code in V3D, so I preferred to retake the discussion and see if we can reach some consensus. The most controversial part of this series are the first three patches, which were extensively discussed in Boris' series. Patch 1 lets the PRIME helpers work with custom dma_buf_ops, following Thomas' feedback on [1]: drm_gem_prime_export_with_ops() exports with driver-provided ops, and gem_prime_is_exporter() lets a driver recognize its own DMA-BUFs on import, without adding buffer callbacks to struct drm_driver, as requested by Thomas. Patches 2-3 are taken from [1], rebased on top of drm-misc-next with some minor kernel-doc fixes. Patches 4-8 convert Panfrost, Panthor and amdgpu to the new helpers. Note that I didn't use the new helpers from patches 2-3 in Panthor, as they recently parted ways with DRM GEM shmem. Finally, patches 9-12 add v3d support to cacheable BOs and the new ioctl DRM_IOCTL_V3D_SYNC_BO. About the userspace implementation, I tested this implementation using a hack implementation (based in PanVK), as I preferred to leave the userspace implementation to be finished by JaeHoon Lee, which is already working on it on [2]. [1] https://lore.kernel.org/dri-devel/[email protected]/ [2] https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/42974 Best regards, - Maíra --- Boris Brezillon (1): drm/shmem: Provide a generic {begin, end}_cpu_access() implementation Faith Ekstrand (1): drm/shmem: Add a drm_gem_shmem_sync() helper Maíra Canal (10): drm/prime: Allow custom dma_buf_ops in PRIME helpers drm/panfrost: Use PRIME helpers with custom dma_buf_ops drm/panfrost: Use common shmem helpers for dma_buf CPU access drm/panfrost: Use drm_gem_shmem_sync() drm/panthor: Use PRIME helpers with custom dma_buf_ops drm/amdgpu: Use drm_gem_prime_export_with_ops() drm/v3d: Provide a custom dma_buf implementation drm/v3d: Add flag to map BOs write-back cacheable drm/v3d: Add a DRM_IOCTL_V3D_SYNC_BO ioctl drm/v3d: Advertise support for write-back cacheable BOs drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c | 9 +- drivers/gpu/drm/drm_gem_shmem_helper.c | 208 ++++++++++++++++++++++++++++ drivers/gpu/drm/drm_prime.c | 47 +++++-- drivers/gpu/drm/panfrost/panfrost_drv.c | 2 +- drivers/gpu/drm/panfrost/panfrost_gem.c | 185 ++----------------------- drivers/gpu/drm/panfrost/panfrost_gem.h | 5 +- drivers/gpu/drm/panthor/panthor_drv.c | 2 +- drivers/gpu/drm/panthor/panthor_gem.c | 28 +--- drivers/gpu/drm/panthor/panthor_gem.h | 5 +- drivers/gpu/drm/v3d/v3d_bo.c | 101 +++++++++++++- drivers/gpu/drm/v3d/v3d_drv.c | 5 + drivers/gpu/drm/v3d/v3d_drv.h | 6 +- drivers/gpu/drm/v3d/v3d_irq.c | 2 +- include/drm/drm_drv.h | 11 ++ include/drm/drm_gem_shmem_helper.h | 27 ++++ include/drm/drm_prime.h | 4 + include/uapi/drm/v3d_drm.h | 58 +++++++- 17 files changed, 474 insertions(+), 231 deletions(-) --- base-commit: a1e63ab695ad76850ab9787b9eb6aab695dc2965 change-id: 20261028-v3d-cached-maps-faae3ba95e11
