• Home
  • Raw
  • Download

Lines Matching refs:ctx

99 void *vmw_validation_mem_alloc(struct vmw_validation_context *ctx,  in vmw_validation_mem_alloc()  argument
108 if (ctx->mem_size_left < size) { in vmw_validation_mem_alloc()
111 if (ctx->vm && ctx->vm_size_left < PAGE_SIZE) { in vmw_validation_mem_alloc()
112 int ret = ctx->vm->reserve_mem(ctx->vm, ctx->vm->gran); in vmw_validation_mem_alloc()
117 ctx->vm_size_left += ctx->vm->gran; in vmw_validation_mem_alloc()
118 ctx->total_mem += ctx->vm->gran; in vmw_validation_mem_alloc()
125 if (ctx->vm) in vmw_validation_mem_alloc()
126 ctx->vm_size_left -= PAGE_SIZE; in vmw_validation_mem_alloc()
128 list_add_tail(&page->lru, &ctx->page_list); in vmw_validation_mem_alloc()
129 ctx->page_address = page_address(page); in vmw_validation_mem_alloc()
130 ctx->mem_size_left = PAGE_SIZE; in vmw_validation_mem_alloc()
133 addr = (void *) (ctx->page_address + (PAGE_SIZE - ctx->mem_size_left)); in vmw_validation_mem_alloc()
134 ctx->mem_size_left -= size; in vmw_validation_mem_alloc()
147 static void vmw_validation_mem_free(struct vmw_validation_context *ctx) in vmw_validation_mem_free() argument
151 list_for_each_entry_safe(entry, next, &ctx->page_list, lru) { in vmw_validation_mem_free()
156 ctx->mem_size_left = 0; in vmw_validation_mem_free()
157 if (ctx->vm && ctx->total_mem) { in vmw_validation_mem_free()
158 ctx->vm->unreserve_mem(ctx->vm, ctx->total_mem); in vmw_validation_mem_free()
159 ctx->total_mem = 0; in vmw_validation_mem_free()
160 ctx->vm_size_left = 0; in vmw_validation_mem_free()
174 vmw_validation_find_bo_dup(struct vmw_validation_context *ctx, in vmw_validation_find_bo_dup() argument
179 if (!ctx->merge_dups) in vmw_validation_find_bo_dup()
182 if (ctx->ht) { in vmw_validation_find_bo_dup()
185 if (!drm_ht_find_item(ctx->ht, (unsigned long) vbo, &hash)) in vmw_validation_find_bo_dup()
190 list_for_each_entry(entry, &ctx->bo_list, base.head) { in vmw_validation_find_bo_dup()
211 vmw_validation_find_res_dup(struct vmw_validation_context *ctx, in vmw_validation_find_res_dup() argument
216 if (!ctx->merge_dups) in vmw_validation_find_res_dup()
219 if (ctx->ht) { in vmw_validation_find_res_dup()
222 if (!drm_ht_find_item(ctx->ht, (unsigned long) res, &hash)) in vmw_validation_find_res_dup()
227 list_for_each_entry(entry, &ctx->resource_ctx_list, head) { in vmw_validation_find_res_dup()
234 list_for_each_entry(entry, &ctx->resource_list, head) { in vmw_validation_find_res_dup()
255 int vmw_validation_add_bo(struct vmw_validation_context *ctx, in vmw_validation_add_bo() argument
262 bo_node = vmw_validation_find_bo_dup(ctx, vbo); in vmw_validation_add_bo()
273 bo_node = vmw_validation_mem_alloc(ctx, sizeof(*bo_node)); in vmw_validation_add_bo()
277 if (ctx->ht) { in vmw_validation_add_bo()
279 ret = drm_ht_insert_item(ctx->ht, &bo_node->hash); in vmw_validation_add_bo()
291 list_add_tail(&val_buf->head, &ctx->bo_list); in vmw_validation_add_bo()
310 int vmw_validation_add_resource(struct vmw_validation_context *ctx, in vmw_validation_add_resource() argument
320 node = vmw_validation_find_res_dup(ctx, res); in vmw_validation_add_resource()
326 node = vmw_validation_mem_alloc(ctx, sizeof(*node) + priv_size); in vmw_validation_add_resource()
332 if (ctx->ht) { in vmw_validation_add_resource()
334 ret = drm_ht_insert_item(ctx->ht, &node->hash); in vmw_validation_add_resource()
347 list_add_tail(&node->head, &ctx->resource_list); in vmw_validation_add_resource()
352 list_add(&node->head, &ctx->resource_ctx_list); in vmw_validation_add_resource()
355 list_add_tail(&node->head, &ctx->resource_ctx_list); in vmw_validation_add_resource()
358 list_add_tail(&node->head, &ctx->resource_list); in vmw_validation_add_resource()
386 void vmw_validation_res_set_dirty(struct vmw_validation_context *ctx, in vmw_validation_res_set_dirty() argument
411 void vmw_validation_res_switch_backup(struct vmw_validation_context *ctx, in vmw_validation_res_switch_backup() argument
437 int vmw_validation_res_reserve(struct vmw_validation_context *ctx, in vmw_validation_res_reserve() argument
443 list_splice_init(&ctx->resource_ctx_list, &ctx->resource_list); in vmw_validation_res_reserve()
445 list_for_each_entry(val, &ctx->resource_list, head) { in vmw_validation_res_reserve()
457 (ctx, vbo, vmw_resource_needs_backup(res), in vmw_validation_res_reserve()
467 vmw_validation_res_unreserve(ctx, true); in vmw_validation_res_reserve()
478 void vmw_validation_res_unreserve(struct vmw_validation_context *ctx, in vmw_validation_res_unreserve() argument
483 list_splice_init(&ctx->resource_ctx_list, &ctx->resource_list); in vmw_validation_res_unreserve()
485 list_for_each_entry(val, &ctx->resource_list, head) { in vmw_validation_res_unreserve()
492 list_for_each_entry(val, &ctx->resource_list, head) { in vmw_validation_res_unreserve()
518 struct ttm_operation_ctx ctx = { in vmw_validation_bo_validate_single() local
528 return ttm_bo_validate(bo, &vmw_mob_placement, &ctx); in vmw_validation_bo_validate_single()
537 ret = ttm_bo_validate(bo, &vmw_vram_gmr_placement, &ctx); in vmw_validation_bo_validate_single()
546 ret = ttm_bo_validate(bo, &vmw_vram_placement, &ctx); in vmw_validation_bo_validate_single()
559 int vmw_validation_bo_validate(struct vmw_validation_context *ctx, bool intr) in vmw_validation_bo_validate() argument
564 list_for_each_entry(entry, &ctx->bo_list, base.head) { in vmw_validation_bo_validate()
566 struct ttm_operation_ctx ctx = { in vmw_validation_bo_validate() local
572 &vmw_nonfixed_placement, &ctx); in vmw_validation_bo_validate()
595 int vmw_validation_res_validate(struct vmw_validation_context *ctx, bool intr) in vmw_validation_res_validate() argument
600 list_for_each_entry(val, &ctx->resource_list, head) { in vmw_validation_res_validate()
616 (ctx, vbo, vmw_resource_needs_backup(res), in vmw_validation_res_validate()
637 void vmw_validation_drop_ht(struct vmw_validation_context *ctx) in vmw_validation_drop_ht() argument
642 if (!ctx->ht) in vmw_validation_drop_ht()
645 list_for_each_entry(entry, &ctx->bo_list, base.head) in vmw_validation_drop_ht()
646 (void) drm_ht_remove_item(ctx->ht, &entry->hash); in vmw_validation_drop_ht()
648 list_for_each_entry(val, &ctx->resource_list, head) in vmw_validation_drop_ht()
649 (void) drm_ht_remove_item(ctx->ht, &val->hash); in vmw_validation_drop_ht()
651 list_for_each_entry(val, &ctx->resource_ctx_list, head) in vmw_validation_drop_ht()
652 (void) drm_ht_remove_item(ctx->ht, &val->hash); in vmw_validation_drop_ht()
654 ctx->ht = NULL; in vmw_validation_drop_ht()
665 void vmw_validation_unref_lists(struct vmw_validation_context *ctx) in vmw_validation_unref_lists() argument
670 list_for_each_entry(entry, &ctx->bo_list, base.head) { in vmw_validation_unref_lists()
675 list_splice_init(&ctx->resource_ctx_list, &ctx->resource_list); in vmw_validation_unref_lists()
676 list_for_each_entry(val, &ctx->resource_list, head) in vmw_validation_unref_lists()
683 INIT_LIST_HEAD(&ctx->bo_list); in vmw_validation_unref_lists()
684 INIT_LIST_HEAD(&ctx->resource_list); in vmw_validation_unref_lists()
686 vmw_validation_mem_free(ctx); in vmw_validation_unref_lists()
704 int vmw_validation_prepare(struct vmw_validation_context *ctx, in vmw_validation_prepare() argument
719 ctx->res_mutex = mutex; in vmw_validation_prepare()
720 ret = vmw_validation_res_reserve(ctx, intr); in vmw_validation_prepare()
724 ret = vmw_validation_bo_reserve(ctx, intr); in vmw_validation_prepare()
728 ret = vmw_validation_bo_validate(ctx, intr); in vmw_validation_prepare()
732 ret = vmw_validation_res_validate(ctx, intr); in vmw_validation_prepare()
739 vmw_validation_bo_backoff(ctx); in vmw_validation_prepare()
741 vmw_validation_res_unreserve(ctx, true); in vmw_validation_prepare()
757 void vmw_validation_revert(struct vmw_validation_context *ctx) in vmw_validation_revert() argument
759 vmw_validation_bo_backoff(ctx); in vmw_validation_revert()
760 vmw_validation_res_unreserve(ctx, true); in vmw_validation_revert()
761 if (ctx->res_mutex) in vmw_validation_revert()
762 mutex_unlock(ctx->res_mutex); in vmw_validation_revert()
763 vmw_validation_unref_lists(ctx); in vmw_validation_revert()
775 void vmw_validation_done(struct vmw_validation_context *ctx, in vmw_validation_done() argument
778 vmw_validation_bo_fence(ctx, fence); in vmw_validation_done()
779 vmw_validation_res_unreserve(ctx, false); in vmw_validation_done()
780 if (ctx->res_mutex) in vmw_validation_done()
781 mutex_unlock(ctx->res_mutex); in vmw_validation_done()
782 vmw_validation_unref_lists(ctx); in vmw_validation_done()
796 int vmw_validation_preload_bo(struct vmw_validation_context *ctx) in vmw_validation_preload_bo() argument
800 if (!vmw_validation_mem_alloc(ctx, size)) in vmw_validation_preload_bo()
803 ctx->mem_size_left += size; in vmw_validation_preload_bo()
819 int vmw_validation_preload_res(struct vmw_validation_context *ctx, in vmw_validation_preload_res() argument
825 if (!vmw_validation_mem_alloc(ctx, size)) in vmw_validation_preload_res()
828 ctx->mem_size_left += size; in vmw_validation_preload_res()