Commit 0bcdda5e authored by Gerd Hoffmann's avatar Gerd Hoffmann

drm/bochs: move ttm_bo_(un)reserve calls into bochs_bo_{pin, unpin}

Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Acked-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20190111053752.4004-13-kraxel@redhat.com
parent dde8fb55
...@@ -77,14 +77,9 @@ static int bochsfb_create(struct drm_fb_helper *helper, ...@@ -77,14 +77,9 @@ static int bochsfb_create(struct drm_fb_helper *helper,
bo = gem_to_bochs_bo(gobj); bo = gem_to_bochs_bo(gobj);
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return ret;
ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM); ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
if (ret) { if (ret) {
DRM_ERROR("failed to pin fbcon\n"); DRM_ERROR("failed to pin fbcon\n");
ttm_bo_unreserve(&bo->bo);
return ret; return ret;
} }
...@@ -92,12 +87,9 @@ static int bochsfb_create(struct drm_fb_helper *helper, ...@@ -92,12 +87,9 @@ static int bochsfb_create(struct drm_fb_helper *helper,
&bo->kmap); &bo->kmap);
if (ret) { if (ret) {
DRM_ERROR("failed to kmap fbcon\n"); DRM_ERROR("failed to kmap fbcon\n");
ttm_bo_unreserve(&bo->bo);
return ret; return ret;
} }
ttm_bo_unreserve(&bo->bo);
/* init fb device */ /* init fb device */
info = drm_fb_helper_alloc_fbi(helper); info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) { if (IS_ERR(info)) {
......
...@@ -92,34 +92,22 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane, ...@@ -92,34 +92,22 @@ static int bochs_plane_prepare_fb(struct drm_plane *plane,
struct drm_plane_state *new_state) struct drm_plane_state *new_state)
{ {
struct bochs_bo *bo; struct bochs_bo *bo;
int ret;
if (!new_state->fb) if (!new_state->fb)
return 0; return 0;
bo = gem_to_bochs_bo(new_state->fb->obj[0]); bo = gem_to_bochs_bo(new_state->fb->obj[0]);
return bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return ret;
ret = bochs_bo_pin(bo, TTM_PL_FLAG_VRAM);
ttm_bo_unreserve(&bo->bo);
return ret;
} }
static void bochs_plane_cleanup_fb(struct drm_plane *plane, static void bochs_plane_cleanup_fb(struct drm_plane *plane,
struct drm_plane_state *old_state) struct drm_plane_state *old_state)
{ {
struct bochs_bo *bo; struct bochs_bo *bo;
int ret;
if (!old_state->fb) if (!old_state->fb)
return; return;
bo = gem_to_bochs_bo(old_state->fb->obj[0]); bo = gem_to_bochs_bo(old_state->fb->obj[0]);
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return;
bochs_bo_unpin(bo); bochs_bo_unpin(bo);
ttm_bo_unreserve(&bo->bo);
} }
static const struct drm_plane_helper_funcs bochs_plane_helper_funcs = { static const struct drm_plane_helper_funcs bochs_plane_helper_funcs = {
......
...@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag) ...@@ -223,7 +223,11 @@ int bochs_bo_pin(struct bochs_bo *bo, u32 pl_flag)
bochs_ttm_placement(bo, pl_flag); bochs_ttm_placement(bo, pl_flag);
for (i = 0; i < bo->placement.num_placement; i++) for (i = 0; i < bo->placement.num_placement; i++)
bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT; bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return ret;
ret = ttm_bo_validate(&bo->bo, &bo->placement, &ctx); ret = ttm_bo_validate(&bo->bo, &bo->placement, &ctx);
ttm_bo_unreserve(&bo->bo);
if (ret) if (ret)
return ret; return ret;
...@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo) ...@@ -247,7 +251,11 @@ int bochs_bo_unpin(struct bochs_bo *bo)
for (i = 0; i < bo->placement.num_placement; i++) for (i = 0; i < bo->placement.num_placement; i++)
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT; bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
ret = ttm_bo_reserve(&bo->bo, true, false, NULL);
if (ret)
return ret;
ret = ttm_bo_validate(&bo->bo, &bo->placement, &ctx); ret = ttm_bo_validate(&bo->bo, &bo->placement, &ctx);
ttm_bo_unreserve(&bo->bo);
if (ret) if (ret)
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