summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/nouveau/nouveau_prime.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2024-02-27 11:14:53 +0100
committerThomas Zimmermann <tzimmermann@suse.de>2024-03-11 13:33:50 +0100
commit1a8326de8cfd76a0f825696f97b7925813e026b7 (patch)
treebff77d1711cda6626609a6ca99ad664752f94483 /drivers/gpu/drm/nouveau/nouveau_prime.c
parentdrm/nouveau: Provide nouveau_bo_{pin,unpin}_locked() (diff)
downloadlinux-1a8326de8cfd76a0f825696f97b7925813e026b7.tar.xz
linux-1a8326de8cfd76a0f825696f97b7925813e026b7.zip
drm/nouveau: Acquire reservation lock in GEM pin/unpin callbacks
Acquire the reservation lock directly in GEM pin callback. Same for unpin. Prepares for further changes. Dma-buf locking semantics require callers to hold the buffer's reservation lock when invoking the pin and unpin callbacks. Prepare nouveau accordingly by pushing locking out of the implementation. A follow-up patch will fix locking for all GEM code at once. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # virtio-gpu Acked-by: Christian König <christian.koenig@amd.com> Acked-by: Zack Rusin <zack.rusin@broadcom.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240227113853.8464-7-tzimmermann@suse.de
Diffstat (limited to '')
-rw-r--r--drivers/gpu/drm/nouveau/nouveau_prime.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/drivers/gpu/drm/nouveau/nouveau_prime.c b/drivers/gpu/drm/nouveau/nouveau_prime.c
index 1b2ff0c40fc1..774f9bd03110 100644
--- a/drivers/gpu/drm/nouveau/nouveau_prime.c
+++ b/drivers/gpu/drm/nouveau/nouveau_prime.c
@@ -86,21 +86,32 @@ unlock:
int nouveau_gem_prime_pin(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+ struct ttm_buffer_object *bo = &nvbo->bo;
int ret;
- /* pin buffer into GTT */
- ret = nouveau_bo_pin(nvbo, NOUVEAU_GEM_DOMAIN_GART, false);
+ ret = ttm_bo_reserve(bo, false, false, NULL);
if (ret)
return -EINVAL;
+ /* pin buffer into GTT */
+ ret = nouveau_bo_pin_locked(nvbo, NOUVEAU_GEM_DOMAIN_GART, false);
+ if (ret)
+ ret = -EINVAL;
+ ttm_bo_unreserve(bo);
- return 0;
+ return ret;
}
void nouveau_gem_prime_unpin(struct drm_gem_object *obj)
{
struct nouveau_bo *nvbo = nouveau_gem_object(obj);
+ struct ttm_buffer_object *bo = &nvbo->bo;
+ int ret;
- nouveau_bo_unpin(nvbo);
+ ret = ttm_bo_reserve(bo, false, false, NULL);
+ if (ret)
+ return;
+ nouveau_bo_unpin_locked(nvbo);
+ ttm_bo_unreserve(bo);
}
struct dma_buf *nouveau_gem_prime_export(struct drm_gem_object *gobj,