ast_fb = to_ast_framebuffer(fb);
obj = ast_fb->obj;
gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return ret;
drm_gem_vram_push_to_system(gbo);
- drm_gem_vram_unreserve(gbo);
}
ast_fb = to_ast_framebuffer(crtc->primary->fb);
obj = ast_fb->obj;
gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return ret;
-
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
if (ret)
- goto err_drm_gem_vram_unreserve;
+ return ret;
gpu_addr = drm_gem_vram_offset(gbo);
if (gpu_addr < 0) {
ret = (int)gpu_addr;
ast_fbdev_set_base(ast, gpu_addr);
}
}
- drm_gem_vram_unreserve(gbo);
ast_set_offset_reg(crtc);
ast_set_start_address_crt1(crtc, (u32)gpu_addr);
err_drm_gem_vram_unpin:
drm_gem_vram_unpin(gbo);
-err_drm_gem_vram_unreserve:
- drm_gem_vram_unreserve(gbo);
return ret;
}
static void ast_crtc_disable(struct drm_crtc *crtc)
{
- int ret;
-
DRM_DEBUG_KMS("\n");
ast_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
if (crtc->primary->fb) {
struct drm_gem_object *obj = ast_fb->obj;
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return;
drm_gem_vram_push_to_system(gbo);
- drm_gem_vram_unreserve(gbo);
}
crtc->primary->fb = NULL;
}
if (ret)
return ret;
gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (unlikely(ret != 0))
- goto fail;
-
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
- drm_gem_vram_unreserve(gbo);
if (ret)
goto fail;
gpu_addr = drm_gem_vram_offset(gbo);
int i, ret;
struct ttm_operation_ctx ctx = { false, false };
- if (gbo->pin_count) {
- ++gbo->pin_count;
- return 0;
- }
+ ret = ttm_bo_reserve(&gbo->bo, true, false, NULL);
+ if (ret < 0)
+ return ret;
+
+ if (gbo->pin_count)
+ goto out;
drm_gem_vram_placement(gbo, pl_flag);
for (i = 0; i < gbo->placement.num_placement; ++i)
ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
if (ret < 0)
- return ret;
+ goto err_ttm_bo_unreserve;
- gbo->pin_count = 1;
+out:
+ ++gbo->pin_count;
+ ttm_bo_unreserve(&gbo->bo);
return 0;
+
+err_ttm_bo_unreserve:
+ ttm_bo_unreserve(&gbo->bo);
+ return ret;
}
EXPORT_SYMBOL(drm_gem_vram_pin);
int i, ret;
struct ttm_operation_ctx ctx = { false, false };
+ ret = ttm_bo_reserve(&gbo->bo, true, false, NULL);
+ if (ret < 0)
+ return ret;
+
if (WARN_ON_ONCE(!gbo->pin_count))
- return 0;
+ goto out;
--gbo->pin_count;
if (gbo->pin_count)
- return 0;
+ goto out;
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;
+ goto err_ttm_bo_unreserve;
+
+out:
+ ttm_bo_unreserve(&gbo->bo);
return 0;
+
+err_ttm_bo_unreserve:
+ ttm_bo_unreserve(&gbo->bo);
+ return ret;
}
EXPORT_SYMBOL(drm_gem_vram_unpin);
int i, ret;
struct ttm_operation_ctx ctx = { false, false };
+ ret = ttm_bo_reserve(&gbo->bo, true, false, NULL);
+ if (ret < 0)
+ return ret;
+
if (WARN_ON_ONCE(!gbo->pin_count))
- return 0;
+ goto out;
--gbo->pin_count;
if (gbo->pin_count)
- return 0;
+ goto out;
if (gbo->kmap.virtual)
ttm_bo_kunmap(&gbo->kmap);
ret = ttm_bo_validate(&gbo->bo, &gbo->placement, &ctx);
if (ret)
- return ret;
+ goto err_ttm_bo_unreserve;
+
+out:
+ ttm_bo_unreserve(&gbo->bo);
return 0;
+
+err_ttm_bo_unreserve:
+ ttm_bo_unreserve(&gbo->bo);
+ return ret;
}
EXPORT_SYMBOL(drm_gem_vram_push_to_system);
hibmc_fb = to_hibmc_framebuffer(state->fb);
gbo = drm_gem_vram_of_gem(hibmc_fb->obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret) {
- DRM_ERROR("failed to reserve BO: %d", ret);
- return;
- }
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
- drm_gem_vram_unreserve(gbo);
if (ret) {
DRM_ERROR("failed to pin bo: %d", ret);
return;
struct drm_mode_fb_cmd2 mode_cmd;
struct drm_gem_object *gobj = NULL;
int ret = 0;
- int ret1;
size_t size;
unsigned int bytes_per_pixel;
struct drm_gem_vram_object *gbo = NULL;
gbo = drm_gem_vram_of_gem(gobj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret) {
- DRM_ERROR("failed to reserve bo: %d\n", ret);
- goto out_unref_gem;
- }
-
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
if (ret) {
DRM_ERROR("failed to pin fbcon: %d\n", ret);
- goto out_unreserve_ttm_bo;
+ goto out_unref_gem;
}
base = drm_gem_vram_kmap(gbo, true, NULL);
DRM_ERROR("failed to kmap fbcon: %d\n", ret);
goto out_unpin_bo;
}
- drm_gem_vram_unreserve(gbo);
info = drm_fb_helper_alloc_fbi(helper);
if (IS_ERR(info)) {
return 0;
out_release_fbi:
- ret1 = drm_gem_vram_reserve(gbo, false);
- if (ret1) {
- DRM_ERROR("failed to rsv ttm_bo when release fbi: %d\n", ret1);
- goto out_unref_gem;
- }
drm_gem_vram_kunmap(gbo);
out_unpin_bo:
drm_gem_vram_unpin(gbo);
-out_unreserve_ttm_bo:
- drm_gem_vram_unreserve(gbo);
out_unref_gem:
drm_gem_object_put_unlocked(gobj);
mga_fb = to_mga_framebuffer(fb);
obj = mga_fb->obj;
gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return ret;
drm_gem_vram_push_to_system(gbo);
- drm_gem_vram_unreserve(gbo);
}
mga_fb = to_mga_framebuffer(crtc->primary->fb);
obj = mga_fb->obj;
gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return ret;
-
ret = drm_gem_vram_pin(gbo, DRM_GEM_VRAM_PL_FLAG_VRAM);
if (ret)
- goto err_drm_gem_vram_unreserve;
+ return ret;
gpu_addr = drm_gem_vram_offset(gbo);
if (gpu_addr < 0) {
ret = (int)gpu_addr;
}
}
- drm_gem_vram_unreserve(gbo);
-
mga_set_start_address(crtc, (u32)gpu_addr);
return 0;
err_drm_gem_vram_unpin:
drm_gem_vram_unpin(gbo);
-err_drm_gem_vram_unreserve:
- drm_gem_vram_unreserve(gbo);
return ret;
}
static void mga_crtc_disable(struct drm_crtc *crtc)
{
- int ret;
DRM_DEBUG_KMS("\n");
mga_crtc_dpms(crtc, DRM_MODE_DPMS_OFF);
if (crtc->primary->fb) {
struct drm_gem_object *obj = mga_fb->obj;
struct drm_gem_vram_object *gbo = drm_gem_vram_of_gem(obj);
- ret = drm_gem_vram_reserve(gbo, false);
- if (ret)
- return;
drm_gem_vram_push_to_system(gbo);
- drm_gem_vram_unreserve(gbo);
}
crtc->primary->fb = NULL;
}