[PATCH 08/13] drm/qxl: Acquire reservation lock in GEM pin/unpin callbacks
Zack Rusin
zack.rusin at broadcom.com
Wed Feb 28 03:47:37 UTC 2024
On Tue, Feb 27, 2024 at 6:39 AM Thomas Zimmermann <tzimmermann at suse.de> wrote:
>
> 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
> qxl 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 at suse.de>
> ---
> drivers/gpu/drm/qxl/qxl_prime.c | 16 ++++++++++++++--
> 1 file changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/qxl/qxl_prime.c b/drivers/gpu/drm/qxl/qxl_prime.c
> index 9169c26357d36..f2646603e12eb 100644
> --- a/drivers/gpu/drm/qxl/qxl_prime.c
> +++ b/drivers/gpu/drm/qxl/qxl_prime.c
> @@ -31,15 +31,27 @@
> int qxl_gem_prime_pin(struct drm_gem_object *obj)
> {
> struct qxl_bo *bo = gem_to_qxl_bo(obj);
> + int r;
>
> - return qxl_bo_pin(bo);
> + r = qxl_bo_reserve(bo);
> + if (r)
> + return r;
> + r = qxl_bo_pin_locked(bo);
> + qxl_bo_unreserve(bo);
> +
> + return r;
> }
>
> void qxl_gem_prime_unpin(struct drm_gem_object *obj)
> {
> struct qxl_bo *bo = gem_to_qxl_bo(obj);
> + int r;
>
> - qxl_bo_unpin(bo);
> + r = qxl_bo_reserve(bo);
> + if (r)
> + return;
> + qxl_bo_unpin_locked(bo);
> + qxl_bo_unreserve(bo);
> }
It looks like gem_prime_pin/unpin is largely the same between a lot of
drivers now. That might be a nice cleanup in the future.
z
More information about the amd-gfx
mailing list