]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/shmem-helper: Add lockdep asserts to vmap/vunmap
authorAsahi Lina <lina@asahilina.net>
Tue, 18 Mar 2025 19:22:35 +0000 (16:22 -0300)
committerLyude Paul <lyude@redhat.com>
Tue, 13 May 2025 20:27:51 +0000 (16:27 -0400)
Since commit 21aa27ddc582 ("drm/shmem-helper: Switch to reservation
lock"), the drm_gem_shmem_vmap and drm_gem_shmem_vunmap functions
require that the caller holds the DMA reservation lock for the object.
Add lockdep assertions to help validate this.

Signed-off-by: Asahi Lina <lina@asahilina.net>
Signed-off-by: Daniel Almeida <daniel.almeida@collabora.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Lyude Paul <lyude@redhat.com>
Link: https://lore.kernel.org/r/20250318-drm-gem-shmem-v1-1-64b96511a84f@collabora.com
drivers/gpu/drm/drm_gem_shmem_helper.c

index aa43265f4f4f61dda92d306111e860dce4d48ff8..0b41f0346bad159252980a9545cd643a79e7bf41 100644 (file)
@@ -348,6 +348,8 @@ int drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem,
        struct drm_gem_object *obj = &shmem->base;
        int ret = 0;
 
+       dma_resv_assert_held(obj->resv);
+
        if (drm_gem_is_imported(obj)) {
                ret = dma_buf_vmap(obj->dma_buf, map);
        } else {
@@ -408,6 +410,8 @@ void drm_gem_shmem_vunmap_locked(struct drm_gem_shmem_object *shmem,
 {
        struct drm_gem_object *obj = &shmem->base;
 
+       dma_resv_assert_held(obj->resv);
+
        if (drm_gem_is_imported(obj)) {
                dma_buf_vunmap(obj->dma_buf, map);
        } else {