Commit 9d36d432 authored by Christian König's avatar Christian König

drm/qxl: switch over to the new pin interface

Stop using TTM_PL_FLAG_NO_EVICT.
Signed-off-by: default avatarChristian König <christian.koenig@amd.com>
Reviewed-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Tested-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Link: https://patchwork.freedesktop.org/patch/391607/?series=81973&rev=1
parent d582723d
......@@ -67,7 +67,7 @@ qxl_debugfs_buffers_info(struct seq_file *m, void *data)
seq_printf(m, "size %ld, pc %d, num releases %d\n",
(unsigned long)bo->tbo.base.size,
bo->pin_count, rel);
bo->tbo.pin_count, rel);
}
return 0;
}
......
......@@ -80,7 +80,6 @@ struct qxl_bo {
struct ttm_place placements[3];
struct ttm_placement placement;
struct ttm_bo_kmap_obj kmap;
unsigned int pin_count;
void *kptr;
unsigned int map_count;
int type;
......
......@@ -326,8 +326,8 @@ static int qxl_update_area_ioctl(struct drm_device *dev, void *data,
if (ret)
goto out;
if (!qobj->pin_count) {
qxl_ttm_placement_from_domain(qobj, qobj->type, false);
if (!qobj->tbo.pin_count) {
qxl_ttm_placement_from_domain(qobj, qobj->type);
ret = ttm_bo_validate(&qobj->tbo, &qobj->placement, &ctx);
if (unlikely(ret))
goto out;
......
......@@ -51,14 +51,12 @@ bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo)
return false;
}
void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain, bool pinned)
void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain)
{
u32 c = 0;
u32 pflag = 0;
unsigned int i;
if (pinned)
pflag |= TTM_PL_FLAG_NO_EVICT;
if (qbo->tbo.base.size <= PAGE_SIZE)
pflag |= TTM_PL_FLAG_TOPDOWN;
......@@ -128,14 +126,13 @@ int qxl_bo_create(struct qxl_device *qdev,
}
bo->tbo.base.funcs = &qxl_object_funcs;
bo->type = domain;
bo->pin_count = pinned ? 1 : 0;
bo->surface_id = 0;
INIT_LIST_HEAD(&bo->list);
if (surf)
bo->surf = *surf;
qxl_ttm_placement_from_domain(bo, domain, pinned);
qxl_ttm_placement_from_domain(bo, domain);
r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
&bo->placement, 0, !kernel, size,
......@@ -147,6 +144,8 @@ int qxl_bo_create(struct qxl_device *qdev,
size, domain);
return r;
}
if (pinned)
ttm_bo_pin(&bo->tbo);
*bo_ptr = bo;
return 0;
}
......@@ -248,39 +247,22 @@ static int __qxl_bo_pin(struct qxl_bo *bo)
struct drm_device *ddev = bo->tbo.base.dev;
int r;
if (bo->pin_count) {
bo->pin_count++;
if (bo->tbo.pin_count) {
ttm_bo_pin(&bo->tbo);
return 0;
}
qxl_ttm_placement_from_domain(bo, bo->type, true);
qxl_ttm_placement_from_domain(bo, bo->type);
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (likely(r == 0)) {
bo->pin_count = 1;
}
if (likely(r == 0))
ttm_bo_pin(&bo->tbo);
if (unlikely(r != 0))
dev_err(ddev->dev, "%p pin failed\n", bo);
return r;
}
static int __qxl_bo_unpin(struct qxl_bo *bo)
static void __qxl_bo_unpin(struct qxl_bo *bo)
{
struct ttm_operation_ctx ctx = { false, false };
struct drm_device *ddev = bo->tbo.base.dev;
int r, i;
if (!bo->pin_count) {
dev_warn(ddev->dev, "%p unpin not necessary\n", bo);
return 0;
}
bo->pin_count--;
if (bo->pin_count)
return 0;
for (i = 0; i < bo->placement.num_placement; i++)
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
r = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (unlikely(r != 0))
dev_err(ddev->dev, "%p validate failed for unpin\n", bo);
return r;
ttm_bo_unpin(&bo->tbo);
}
/*
......@@ -314,9 +296,9 @@ int qxl_bo_unpin(struct qxl_bo *bo)
if (r)
return r;
r = __qxl_bo_unpin(bo);
__qxl_bo_unpin(bo);
qxl_bo_unreserve(bo);
return r;
return 0;
}
void qxl_bo_force_delete(struct qxl_device *qdev)
......
......@@ -71,7 +71,7 @@ extern struct qxl_bo *qxl_bo_ref(struct qxl_bo *bo);
extern void qxl_bo_unref(struct qxl_bo **bo);
extern int qxl_bo_pin(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, bool pinned);
extern void qxl_ttm_placement_from_domain(struct qxl_bo *qbo, u32 domain);
extern bool qxl_ttm_bo_is_qxl_bo(struct ttm_buffer_object *bo);
#endif
......@@ -231,8 +231,8 @@ static int qxl_release_validate_bo(struct qxl_bo *bo)
struct ttm_operation_ctx ctx = { true, false };
int ret;
if (!bo->pin_count) {
qxl_ttm_placement_from_domain(bo, bo->type, false);
if (!bo->tbo.pin_count) {
qxl_ttm_placement_from_domain(bo, bo->type);
ret = ttm_bo_validate(&bo->tbo, &bo->placement, &ctx);
if (ret)
return ret;
......
......@@ -67,7 +67,7 @@ static void qxl_evict_flags(struct ttm_buffer_object *bo,
return;
}
qbo = to_qxl_bo(bo);
qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU, false);
qxl_ttm_placement_from_domain(qbo, QXL_GEM_DOMAIN_CPU);
*placement = qbo->placement;
}
......
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