mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
drm/qxl: use ttm bo priorities
commit 4fff19ae42 upstream.
Allow to set priorities for buffer objects. Use priority 1 for surface
and cursor command releases. Use priority 0 for drawing command
releases. That way the short-living drawing commands are first in line
when it comes to eviction, making it *much* less likely that
ttm_bo_mem_force_space() picks something which can't be evicted and
throws an error after waiting a while without success.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: http://patchwork.freedesktop.org/patch/msgid/20210217123213.2199186-4-kraxel@redhat.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
f6c5cc6feb
commit
08f6e8a753
|
|
@ -268,7 +268,7 @@ int qxl_alloc_bo_reserved(struct qxl_device *qdev,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = qxl_bo_create(qdev, size, false /* not kernel - device */,
|
ret = qxl_bo_create(qdev, size, false /* not kernel - device */,
|
||||||
false, QXL_GEM_DOMAIN_VRAM, NULL, &bo);
|
false, QXL_GEM_DOMAIN_VRAM, 0, NULL, &bo);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_ERROR("failed to allocate VRAM BO\n");
|
DRM_ERROR("failed to allocate VRAM BO\n");
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
||||||
|
|
@ -791,8 +791,8 @@ static int qxl_plane_prepare_fb(struct drm_plane *plane,
|
||||||
qdev->dumb_shadow_bo = NULL;
|
qdev->dumb_shadow_bo = NULL;
|
||||||
}
|
}
|
||||||
qxl_bo_create(qdev, surf.height * surf.stride,
|
qxl_bo_create(qdev, surf.height * surf.stride,
|
||||||
true, true, QXL_GEM_DOMAIN_SURFACE, &surf,
|
true, true, QXL_GEM_DOMAIN_SURFACE, 0,
|
||||||
&qdev->dumb_shadow_bo);
|
&surf, &qdev->dumb_shadow_bo);
|
||||||
}
|
}
|
||||||
if (user_bo->shadow != qdev->dumb_shadow_bo) {
|
if (user_bo->shadow != qdev->dumb_shadow_bo) {
|
||||||
if (user_bo->shadow) {
|
if (user_bo->shadow) {
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ int qxl_gem_object_create(struct qxl_device *qdev, int size,
|
||||||
/* At least align on page size */
|
/* At least align on page size */
|
||||||
if (alignment < PAGE_SIZE)
|
if (alignment < PAGE_SIZE)
|
||||||
alignment = PAGE_SIZE;
|
alignment = PAGE_SIZE;
|
||||||
r = qxl_bo_create(qdev, size, kernel, false, initial_domain, surf, &qbo);
|
r = qxl_bo_create(qdev, size, kernel, false, initial_domain, 0, surf, &qbo);
|
||||||
if (r) {
|
if (r) {
|
||||||
if (r != -ERESTARTSYS)
|
if (r != -ERESTARTSYS)
|
||||||
DRM_ERROR(
|
DRM_ERROR(
|
||||||
|
|
|
||||||
|
|
@ -103,8 +103,8 @@ static const struct drm_gem_object_funcs qxl_object_funcs = {
|
||||||
.print_info = drm_gem_ttm_print_info,
|
.print_info = drm_gem_ttm_print_info,
|
||||||
};
|
};
|
||||||
|
|
||||||
int qxl_bo_create(struct qxl_device *qdev,
|
int qxl_bo_create(struct qxl_device *qdev, unsigned long size,
|
||||||
unsigned long size, bool kernel, bool pinned, u32 domain,
|
bool kernel, bool pinned, u32 domain, u32 priority,
|
||||||
struct qxl_surface *surf,
|
struct qxl_surface *surf,
|
||||||
struct qxl_bo **bo_ptr)
|
struct qxl_bo **bo_ptr)
|
||||||
{
|
{
|
||||||
|
|
@ -137,6 +137,7 @@ int qxl_bo_create(struct qxl_device *qdev,
|
||||||
|
|
||||||
qxl_ttm_placement_from_domain(bo, domain, pinned);
|
qxl_ttm_placement_from_domain(bo, domain, pinned);
|
||||||
|
|
||||||
|
bo->tbo.priority = priority;
|
||||||
r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
|
r = ttm_bo_init(&qdev->mman.bdev, &bo->tbo, size, type,
|
||||||
&bo->placement, 0, !kernel, size,
|
&bo->placement, 0, !kernel, size,
|
||||||
NULL, NULL, &qxl_ttm_bo_destroy);
|
NULL, NULL, &qxl_ttm_bo_destroy);
|
||||||
|
|
|
||||||
|
|
@ -84,6 +84,7 @@ static inline int qxl_bo_wait(struct qxl_bo *bo, u32 *mem_type,
|
||||||
extern int qxl_bo_create(struct qxl_device *qdev,
|
extern int qxl_bo_create(struct qxl_device *qdev,
|
||||||
unsigned long size,
|
unsigned long size,
|
||||||
bool kernel, bool pinned, u32 domain,
|
bool kernel, bool pinned, u32 domain,
|
||||||
|
u32 priority,
|
||||||
struct qxl_surface *surf,
|
struct qxl_surface *surf,
|
||||||
struct qxl_bo **bo_ptr);
|
struct qxl_bo **bo_ptr);
|
||||||
extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
|
extern int qxl_bo_kmap(struct qxl_bo *bo, void **ptr);
|
||||||
|
|
|
||||||
|
|
@ -199,11 +199,12 @@ qxl_release_free(struct qxl_device *qdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qxl_release_bo_alloc(struct qxl_device *qdev,
|
static int qxl_release_bo_alloc(struct qxl_device *qdev,
|
||||||
struct qxl_bo **bo)
|
struct qxl_bo **bo,
|
||||||
|
u32 priority)
|
||||||
{
|
{
|
||||||
/* pin releases bo's they are too messy to evict */
|
/* pin releases bo's they are too messy to evict */
|
||||||
return qxl_bo_create(qdev, PAGE_SIZE, false, true,
|
return qxl_bo_create(qdev, PAGE_SIZE, false, true,
|
||||||
QXL_GEM_DOMAIN_VRAM, NULL, bo);
|
QXL_GEM_DOMAIN_VRAM, priority, NULL, bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
|
int qxl_release_list_add(struct qxl_release *release, struct qxl_bo *bo)
|
||||||
|
|
@ -326,13 +327,18 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
union qxl_release_info *info;
|
union qxl_release_info *info;
|
||||||
int cur_idx;
|
int cur_idx;
|
||||||
|
u32 priority;
|
||||||
|
|
||||||
if (type == QXL_RELEASE_DRAWABLE)
|
if (type == QXL_RELEASE_DRAWABLE) {
|
||||||
cur_idx = 0;
|
cur_idx = 0;
|
||||||
else if (type == QXL_RELEASE_SURFACE_CMD)
|
priority = 0;
|
||||||
|
} else if (type == QXL_RELEASE_SURFACE_CMD) {
|
||||||
cur_idx = 1;
|
cur_idx = 1;
|
||||||
else if (type == QXL_RELEASE_CURSOR_CMD)
|
priority = 1;
|
||||||
|
} else if (type == QXL_RELEASE_CURSOR_CMD) {
|
||||||
cur_idx = 2;
|
cur_idx = 2;
|
||||||
|
priority = 1;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
DRM_ERROR("got illegal type: %d\n", type);
|
DRM_ERROR("got illegal type: %d\n", type);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
@ -352,7 +358,7 @@ int qxl_alloc_release_reserved(struct qxl_device *qdev, unsigned long size,
|
||||||
qdev->current_release_bo[cur_idx] = NULL;
|
qdev->current_release_bo[cur_idx] = NULL;
|
||||||
}
|
}
|
||||||
if (!qdev->current_release_bo[cur_idx]) {
|
if (!qdev->current_release_bo[cur_idx]) {
|
||||||
ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx]);
|
ret = qxl_release_bo_alloc(qdev, &qdev->current_release_bo[cur_idx], priority);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
mutex_unlock(&qdev->release_mutex);
|
mutex_unlock(&qdev->release_mutex);
|
||||||
qxl_release_free(qdev, *release);
|
qxl_release_free(qdev, *release);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user