Commit d582723d authored by Christian König's avatar Christian König

drm/vram-helper: 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>
Acked-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarDave Airlie <airlied@redhat.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Link: https://patchwork.freedesktop.org/patch/391603/?series=81973&rev=1
parent 6797cea1
...@@ -301,7 +301,7 @@ static u64 drm_gem_vram_pg_offset(struct drm_gem_vram_object *gbo) ...@@ -301,7 +301,7 @@ static u64 drm_gem_vram_pg_offset(struct drm_gem_vram_object *gbo)
*/ */
s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo) s64 drm_gem_vram_offset(struct drm_gem_vram_object *gbo)
{ {
if (WARN_ON_ONCE(!gbo->pin_count)) if (WARN_ON_ONCE(!gbo->bo.pin_count))
return (s64)-ENODEV; return (s64)-ENODEV;
return drm_gem_vram_pg_offset(gbo) << PAGE_SHIFT; return drm_gem_vram_pg_offset(gbo) << PAGE_SHIFT;
} }
...@@ -310,24 +310,21 @@ EXPORT_SYMBOL(drm_gem_vram_offset); ...@@ -310,24 +310,21 @@ EXPORT_SYMBOL(drm_gem_vram_offset);
static int drm_gem_vram_pin_locked(struct drm_gem_vram_object *gbo, static int drm_gem_vram_pin_locked(struct drm_gem_vram_object *gbo,
unsigned long pl_flag) unsigned long pl_flag)
{ {
int i, ret;
struct ttm_operation_ctx ctx = { false, false }; struct ttm_operation_ctx ctx = { false, false };
int ret;
if (gbo->pin_count) if (gbo->bo.pin_count)
goto out; goto out;
if (pl_flag) if (pl_flag)
drm_gem_vram_placement(gbo, pl_flag); drm_gem_vram_placement(gbo, pl_flag);
for (i = 0; i < gbo->placement.num_placement; ++i)
gbo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx); ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
if (ret < 0) if (ret < 0)
return ret; return ret;
out: out:
++gbo->pin_count; ttm_bo_pin(&gbo->bo);
return 0; return 0;
} }
...@@ -369,26 +366,9 @@ int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag) ...@@ -369,26 +366,9 @@ int drm_gem_vram_pin(struct drm_gem_vram_object *gbo, unsigned long pl_flag)
} }
EXPORT_SYMBOL(drm_gem_vram_pin); EXPORT_SYMBOL(drm_gem_vram_pin);
static int drm_gem_vram_unpin_locked(struct drm_gem_vram_object *gbo) static void drm_gem_vram_unpin_locked(struct drm_gem_vram_object *gbo)
{ {
int i, ret; ttm_bo_unpin(&gbo->bo);
struct ttm_operation_ctx ctx = { false, false };
if (WARN_ON_ONCE(!gbo->pin_count))
return 0;
--gbo->pin_count;
if (gbo->pin_count)
return 0;
for (i = 0; i < gbo->placement.num_placement ; ++i)
gbo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
if (ret < 0)
return ret;
return 0;
} }
/** /**
...@@ -406,10 +386,11 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo) ...@@ -406,10 +386,11 @@ int drm_gem_vram_unpin(struct drm_gem_vram_object *gbo)
ret = ttm_bo_reserve(&gbo->bo, true, false, NULL); ret = ttm_bo_reserve(&gbo->bo, true, false, NULL);
if (ret) if (ret)
return ret; return ret;
ret = drm_gem_vram_unpin_locked(gbo);
drm_gem_vram_unpin_locked(gbo);
ttm_bo_unreserve(&gbo->bo); ttm_bo_unreserve(&gbo->bo);
return ret; return 0;
} }
EXPORT_SYMBOL(drm_gem_vram_unpin); EXPORT_SYMBOL(drm_gem_vram_unpin);
......
...@@ -35,7 +35,6 @@ struct vm_area_struct; ...@@ -35,7 +35,6 @@ struct vm_area_struct;
* @placement: TTM placement information. Supported placements are \ * @placement: TTM placement information. Supported placements are \
%TTM_PL_VRAM and %TTM_PL_SYSTEM %TTM_PL_VRAM and %TTM_PL_SYSTEM
* @placements: TTM placement information. * @placements: TTM placement information.
* @pin_count: Pin counter
* *
* The type struct drm_gem_vram_object represents a GEM object that is * The type struct drm_gem_vram_object represents a GEM object that is
* backed by VRAM. It can be used for simple framebuffer devices with * backed by VRAM. It can be used for simple framebuffer devices with
...@@ -64,8 +63,6 @@ struct drm_gem_vram_object { ...@@ -64,8 +63,6 @@ struct drm_gem_vram_object {
/* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */ /* Supported placements are %TTM_PL_VRAM and %TTM_PL_SYSTEM */
struct ttm_placement placement; struct ttm_placement placement;
struct ttm_place placements[2]; struct ttm_place placements[2];
int pin_count;
}; };
/** /**
......
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