summaryrefslogtreecommitdiff
path: root/include/drm/drm_gem_shmem_helper.h
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2024-02-27 13:14:56 +0300
committerThomas Zimmermann <tzimmermann@suse.de>2024-03-11 15:33:50 +0300
commita78027847226493ea6f09a00875fa4871fd29e69 (patch)
treee03be2e5de8b4aefafcb3570eb21fb7148da1ee7 /include/drm/drm_gem_shmem_helper.h
parent94567420208600bf39ea90a9677529e3367626d3 (diff)
downloadlinux-a78027847226493ea6f09a00875fa4871fd29e69.tar.xz
drm/gem: Acquire reservation lock in drm_gem_{pin/unpin}()
Acquire the buffer object's reservation lock in drm_gem_pin() and remove locking the drivers' GEM callbacks where necessary. Same for unpin(). DRM drivers and memory managers modified by this patch will now have correct dma-buf locking semantics: the caller is responsible for holding the reservation lock when calling the pin or unpin callback. DRM drivers and memory managers that are not modified will now be protected against concurent invocation of their pin and unpin callbacks. PRIME does not implement struct dma_buf_ops.pin, which requires the caller to hold the reservation lock. It does implement struct dma_buf_ops.attach, which requires to callee to acquire the reservation lock. The PRIME code uses drm_gem_pin(), so locks are now taken as specified. Same for unpin and detach. The patch harmonizes GEM pin and unpin to have non-interruptible reservation locking across all drivers, as is already the case for vmap and vunmap. This affects gem-shmem, gem-vram, loongson, qxl and radeon. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Christian König <christian.koenig@amd.com> Reviewed-by: Zack Rusin <zack.rusin@broadcom.com> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # virtio-gpu Link: https://patchwork.freedesktop.org/patch/msgid/20240227113853.8464-10-tzimmermann@suse.de
Diffstat (limited to 'include/drm/drm_gem_shmem_helper.h')
-rw-r--r--include/drm/drm_gem_shmem_helper.h11
1 files changed, 1 insertions, 10 deletions
diff --git a/include/drm/drm_gem_shmem_helper.h b/include/drm/drm_gem_shmem_helper.h
index eb12aa9a8c55..efbc9f27312b 100644
--- a/include/drm/drm_gem_shmem_helper.h
+++ b/include/drm/drm_gem_shmem_helper.h
@@ -175,15 +175,8 @@ static inline void drm_gem_shmem_object_print_info(struct drm_printer *p, unsign
static inline int drm_gem_shmem_object_pin(struct drm_gem_object *obj)
{
struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
- int ret;
- ret = dma_resv_lock_interruptible(shmem->base.resv, NULL);
- if (ret)
- return ret;
- ret = drm_gem_shmem_pin_locked(shmem);
- dma_resv_unlock(shmem->base.resv);
-
- return ret;
+ return drm_gem_shmem_pin_locked(shmem);
}
/**
@@ -197,9 +190,7 @@ static inline void drm_gem_shmem_object_unpin(struct drm_gem_object *obj)
{
struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj);
- dma_resv_lock(shmem->base.resv, NULL);
drm_gem_shmem_unpin_locked(shmem);
- dma_resv_unlock(shmem->base.resv);
}
/**