Commit 27072152 authored by Thomas Zimmermann's avatar Thomas Zimmermann

drm/ast: Pin and map cursor source BO during update

The ast driver used to lock the cursor source BO during updates. Locking
should be done internally by the BO's implementation, so we pin it instead
to system memory. The mapping information is also stored in the BO. No
need to have an extra argument to the kmap function.

v2:
	* pin cursor BOs to current location
Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190613073041.29350-5-tzimmermann@suse.de
parent ff771bb1
...@@ -1183,9 +1183,8 @@ static int ast_cursor_set(struct drm_crtc *crtc, ...@@ -1183,9 +1183,8 @@ static int ast_cursor_set(struct drm_crtc *crtc,
u64 gpu_addr; u64 gpu_addr;
u32 csum; u32 csum;
int ret; int ret;
struct ttm_bo_kmap_obj uobj_map;
u8 *src, *dst; u8 *src, *dst;
bool src_isiomem, dst_isiomem;
if (!handle) { if (!handle) {
ast_hide_cursor(crtc); ast_hide_cursor(crtc);
return 0; return 0;
...@@ -1201,31 +1200,25 @@ static int ast_cursor_set(struct drm_crtc *crtc, ...@@ -1201,31 +1200,25 @@ static int ast_cursor_set(struct drm_crtc *crtc,
} }
gbo = drm_gem_vram_of_gem(obj); gbo = drm_gem_vram_of_gem(obj);
ret = drm_gem_vram_lock(gbo, false); ret = drm_gem_vram_pin(gbo, 0);
if (ret) if (ret)
goto fail; goto err_drm_gem_object_put_unlocked;
src = drm_gem_vram_kmap(gbo, true, NULL);
memset(&uobj_map, 0, sizeof(uobj_map));
src = drm_gem_vram_kmap_at(gbo, true, &src_isiomem, &uobj_map);
if (IS_ERR(src)) { if (IS_ERR(src)) {
ret = PTR_ERR(src); ret = PTR_ERR(src);
goto fail_unlock; goto err_drm_gem_vram_unpin;
} }
if (src_isiomem == true)
DRM_ERROR("src cursor bo should be in main memory\n");
dst = drm_gem_vram_kmap(drm_gem_vram_of_gem(ast->cursor_cache), dst = drm_gem_vram_kmap(drm_gem_vram_of_gem(ast->cursor_cache),
false, &dst_isiomem); false, NULL);
if (IS_ERR(dst)) { if (IS_ERR(dst)) {
ret = PTR_ERR(dst); ret = PTR_ERR(dst);
goto fail_unlock; goto err_drm_gem_vram_kunmap;
} }
if (dst_isiomem == false)
DRM_ERROR("dst bo should be in VRAM\n");
dst_gpu = drm_gem_vram_offset(drm_gem_vram_of_gem(ast->cursor_cache)); dst_gpu = drm_gem_vram_offset(drm_gem_vram_of_gem(ast->cursor_cache));
if (dst_gpu < 0) { if (dst_gpu < 0) {
ret = (int)dst_gpu; ret = (int)dst_gpu;
goto fail_unlock; goto err_drm_gem_vram_kunmap;
} }
dst += (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor; dst += (AST_HWC_SIZE + AST_HWC_SIGNATURE_SIZE)*ast->next_cursor;
...@@ -1233,9 +1226,6 @@ static int ast_cursor_set(struct drm_crtc *crtc, ...@@ -1233,9 +1226,6 @@ static int ast_cursor_set(struct drm_crtc *crtc,
/* do data transfer to cursor cache */ /* do data transfer to cursor cache */
csum = copy_cursor_image(src, dst, width, height); csum = copy_cursor_image(src, dst, width, height);
drm_gem_vram_kunmap_at(gbo, &uobj_map);
drm_gem_vram_unlock(gbo);
/* write checksum + signature */ /* write checksum + signature */
{ {
struct drm_gem_vram_object *dst_gbo = struct drm_gem_vram_object *dst_gbo =
...@@ -1263,12 +1253,17 @@ static int ast_cursor_set(struct drm_crtc *crtc, ...@@ -1263,12 +1253,17 @@ static int ast_cursor_set(struct drm_crtc *crtc,
ast_show_cursor(crtc); ast_show_cursor(crtc);
drm_gem_vram_kunmap(gbo);
drm_gem_vram_unpin(gbo);
drm_gem_object_put_unlocked(obj); drm_gem_object_put_unlocked(obj);
return 0; return 0;
fail_unlock: err_drm_gem_vram_kunmap:
drm_gem_vram_unlock(gbo); drm_gem_vram_kunmap(gbo);
fail: err_drm_gem_vram_unpin:
drm_gem_vram_unpin(gbo);
err_drm_gem_object_put_unlocked:
drm_gem_object_put_unlocked(obj); drm_gem_object_put_unlocked(obj);
return ret; return ret;
} }
......
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