Commit b170783a authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/qxl: Provide qxl_bo_{pin,unpin}_locked()

Rename __qxl_bo_pin() to qxl_bo_pin_locked() and update all callers.
The function will be helpful for implementing the GEM pin callback
with correct semantics. Same for __qxl_bo_unpin().
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDmitry Osipenko <dmitry.osipenko@collabora.com>
Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> # virtio-gpu
Acked-by: default avatarChristian König <christian.koenig@amd.com>
Acked-by: default avatarZack Rusin <zack.rusin@broadcom.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240227113853.8464-8-tzimmermann@suse.de
parent 1a8326de
...@@ -29,9 +29,6 @@ ...@@ -29,9 +29,6 @@
#include "qxl_drv.h" #include "qxl_drv.h"
#include "qxl_object.h" #include "qxl_object.h"
static int __qxl_bo_pin(struct qxl_bo *bo);
static void __qxl_bo_unpin(struct qxl_bo *bo);
static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo) static void qxl_ttm_bo_destroy(struct ttm_buffer_object *tbo)
{ {
struct qxl_bo *bo; struct qxl_bo *bo;
...@@ -167,13 +164,13 @@ int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map) ...@@ -167,13 +164,13 @@ int qxl_bo_vmap_locked(struct qxl_bo *bo, struct iosys_map *map)
goto out; goto out;
} }
r = __qxl_bo_pin(bo); r = qxl_bo_pin_locked(bo);
if (r) if (r)
return r; return r;
r = ttm_bo_vmap(&bo->tbo, &bo->map); r = ttm_bo_vmap(&bo->tbo, &bo->map);
if (r) { if (r) {
__qxl_bo_unpin(bo); qxl_bo_unpin_locked(bo);
return r; return r;
} }
bo->map_count = 1; bo->map_count = 1;
...@@ -246,7 +243,7 @@ void qxl_bo_vunmap_locked(struct qxl_bo *bo) ...@@ -246,7 +243,7 @@ void qxl_bo_vunmap_locked(struct qxl_bo *bo)
return; return;
bo->kptr = NULL; bo->kptr = NULL;
ttm_bo_vunmap(&bo->tbo, &bo->map); ttm_bo_vunmap(&bo->tbo, &bo->map);
__qxl_bo_unpin(bo); qxl_bo_unpin_locked(bo);
} }
int qxl_bo_vunmap(struct qxl_bo *bo) int qxl_bo_vunmap(struct qxl_bo *bo)
...@@ -290,12 +287,14 @@ struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo) ...@@ -290,12 +287,14 @@ struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo)
return bo; return bo;
} }
static int __qxl_bo_pin(struct qxl_bo *bo) int qxl_bo_pin_locked(struct qxl_bo *bo)
{ {
struct ttm_operation_ctx ctx = { false, false }; struct ttm_operation_ctx ctx = { false, false };
struct drm_device *ddev = bo->tbo.base.dev; struct drm_device *ddev = bo->tbo.base.dev;
int r; int r;
dma_resv_assert_held(bo->tbo.base.resv);
if (bo->tbo.pin_count) { if (bo->tbo.pin_count) {
ttm_bo_pin(&bo->tbo); ttm_bo_pin(&bo->tbo);
return 0; return 0;
...@@ -309,14 +308,16 @@ static int __qxl_bo_pin(struct qxl_bo *bo) ...@@ -309,14 +308,16 @@ static int __qxl_bo_pin(struct qxl_bo *bo)
return r; return r;
} }
static void __qxl_bo_unpin(struct qxl_bo *bo) void qxl_bo_unpin_locked(struct qxl_bo *bo)
{ {
dma_resv_assert_held(bo->tbo.base.resv);
ttm_bo_unpin(&bo->tbo); ttm_bo_unpin(&bo->tbo);
} }
/* /*
* Reserve the BO before pinning the object. If the BO was reserved * Reserve the BO before pinning the object. If the BO was reserved
* beforehand, use the internal version directly __qxl_bo_pin. * beforehand, use the internal version directly qxl_bo_pin_locked.
* *
*/ */
int qxl_bo_pin(struct qxl_bo *bo) int qxl_bo_pin(struct qxl_bo *bo)
...@@ -327,14 +328,14 @@ int qxl_bo_pin(struct qxl_bo *bo) ...@@ -327,14 +328,14 @@ int qxl_bo_pin(struct qxl_bo *bo)
if (r) if (r)
return r; return r;
r = __qxl_bo_pin(bo); r = qxl_bo_pin_locked(bo);
qxl_bo_unreserve(bo); qxl_bo_unreserve(bo);
return r; return r;
} }
/* /*
* Reserve the BO before pinning the object. If the BO was reserved * Reserve the BO before pinning the object. If the BO was reserved
* beforehand, use the internal version directly __qxl_bo_unpin. * beforehand, use the internal version directly qxl_bo_unpin_locked.
* *
*/ */
int qxl_bo_unpin(struct qxl_bo *bo) int qxl_bo_unpin(struct qxl_bo *bo)
...@@ -345,7 +346,7 @@ int qxl_bo_unpin(struct qxl_bo *bo) ...@@ -345,7 +346,7 @@ int qxl_bo_unpin(struct qxl_bo *bo)
if (r) if (r)
return r; return r;
__qxl_bo_unpin(bo); qxl_bo_unpin_locked(bo);
qxl_bo_unreserve(bo); qxl_bo_unreserve(bo);
return 0; return 0;
} }
......
...@@ -67,6 +67,8 @@ void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int pa ...@@ -67,6 +67,8 @@ void *qxl_bo_kmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, int pa
void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, void *map); void qxl_bo_kunmap_atomic_page(struct qxl_device *qdev, struct qxl_bo *bo, void *map);
extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo); extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
extern void qxl_bo_unref(struct qxl_bo **bo); extern void qxl_bo_unref(struct qxl_bo **bo);
extern int qxl_bo_pin_locked(struct qxl_bo *bo);
extern void qxl_bo_unpin_locked(struct qxl_bo *bo);
extern int qxl_bo_pin(struct qxl_bo *bo); extern int qxl_bo_pin(struct qxl_bo *bo);
extern int qxl_bo_unpin(struct qxl_bo *bo); extern int qxl_bo_unpin(struct qxl_bo *bo);
extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain); extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment