Lines Matching refs:sw_context
140 static int vmw_resource_val_add(struct vmw_sw_context *sw_context, in vmw_resource_val_add() argument
148 if (likely(drm_ht_find_item(&sw_context->res_ht, (unsigned long) res, in vmw_resource_val_add()
165 ret = drm_ht_insert_item(&sw_context->res_ht, &node->hash); in vmw_resource_val_add()
172 list_add_tail(&node->head, &sw_context->resource_list); in vmw_resource_val_add()
194 struct vmw_sw_context *sw_context, in vmw_resource_context_res_add() argument
210 ret = vmw_resource_val_add(sw_context, entry->bi.res, NULL); in vmw_resource_context_res_add()
285 struct vmw_sw_context *sw_context, in vmw_cmd_invalid() argument
292 struct vmw_sw_context *sw_context, in vmw_cmd_ok() argument
310 static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, in vmw_bo_to_validate_list() argument
321 if (likely(drm_ht_find_item(&sw_context->res_ht, (unsigned long) bo, in vmw_bo_to_validate_list()
330 val_node = vval_buf - sw_context->val_bufs; in vmw_bo_to_validate_list()
332 val_node = sw_context->cur_val_buf; in vmw_bo_to_validate_list()
338 vval_buf = &sw_context->val_bufs[val_node]; in vmw_bo_to_validate_list()
340 ret = drm_ht_insert_item(&sw_context->res_ht, &vval_buf->hash); in vmw_bo_to_validate_list()
346 ++sw_context->cur_val_buf; in vmw_bo_to_validate_list()
350 list_add_tail(&val_buf->head, &sw_context->validate_nodes); in vmw_bo_to_validate_list()
370 static int vmw_resources_reserve(struct vmw_sw_context *sw_context) in vmw_resources_reserve() argument
375 list_for_each_entry(val, &sw_context->resource_list, head) { in vmw_resources_reserve()
386 (sw_context, bo, in vmw_resources_reserve()
405 static int vmw_resources_validate(struct vmw_sw_context *sw_context) in vmw_resources_validate() argument
410 list_for_each_entry(val, &sw_context->resource_list, head) { in vmw_resources_validate()
437 struct vmw_sw_context *sw_context, in vmw_cmd_res_reloc_add() argument
447 ret = vmw_resource_relocation_add(&sw_context->res_relocations, in vmw_cmd_res_reloc_add()
449 id_loc - sw_context->buf_start); in vmw_cmd_res_reloc_add()
453 ret = vmw_resource_val_add(sw_context, res, &node); in vmw_cmd_res_reloc_add()
465 list_add(&node->head, &sw_context->resource_list); in vmw_cmd_res_reloc_add()
467 ret = vmw_resource_context_res_add(dev_priv, sw_context, res); in vmw_cmd_res_reloc_add()
502 struct vmw_sw_context *sw_context, in vmw_cmd_res_check() argument
509 &sw_context->res_cache[res_type]; in vmw_cmd_res_check()
537 (&sw_context->res_relocations, res, in vmw_cmd_res_check()
538 id_loc - sw_context->buf_start); in vmw_cmd_res_check()
542 sw_context->fp->tfile, in vmw_cmd_res_check()
557 ret = vmw_cmd_res_reloc_add(dev_priv, sw_context, res_type, id_loc, in vmw_cmd_res_check()
569 BUG_ON(sw_context->error_resource != NULL); in vmw_cmd_res_check()
570 sw_context->error_resource = res; in vmw_cmd_res_check()
583 static int vmw_rebind_contexts(struct vmw_sw_context *sw_context) in vmw_rebind_contexts() argument
588 list_for_each_entry(val, &sw_context->resource_list, head) { in vmw_rebind_contexts()
614 struct vmw_sw_context *sw_context, in vmw_cmd_cid_check() argument
623 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_cid_check()
628 struct vmw_sw_context *sw_context, in vmw_cmd_set_render_target_check() argument
641 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_set_render_target_check()
647 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_set_render_target_check()
667 struct vmw_sw_context *sw_context, in vmw_cmd_surface_copy_check() argument
677 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_surface_copy_check()
682 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_surface_copy_check()
688 struct vmw_sw_context *sw_context, in vmw_cmd_stretch_blt_check() argument
698 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_stretch_blt_check()
703 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_stretch_blt_check()
709 struct vmw_sw_context *sw_context, in vmw_cmd_blt_surf_screen_check() argument
719 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_blt_surf_screen_check()
725 struct vmw_sw_context *sw_context, in vmw_cmd_present_check() argument
736 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_present_check()
756 struct vmw_sw_context *sw_context) in vmw_query_bo_switch_prepare() argument
759 &sw_context->res_cache[vmw_res_context]; in vmw_query_bo_switch_prepare()
763 sw_context->last_query_ctx = ctx_entry->res; in vmw_query_bo_switch_prepare()
765 if (unlikely(new_query_bo != sw_context->cur_query_bo)) { in vmw_query_bo_switch_prepare()
772 if (unlikely(sw_context->cur_query_bo != NULL)) { in vmw_query_bo_switch_prepare()
773 sw_context->needs_post_query_barrier = true; in vmw_query_bo_switch_prepare()
774 ret = vmw_bo_to_validate_list(sw_context, in vmw_query_bo_switch_prepare()
775 sw_context->cur_query_bo, in vmw_query_bo_switch_prepare()
780 sw_context->cur_query_bo = new_query_bo; in vmw_query_bo_switch_prepare()
782 ret = vmw_bo_to_validate_list(sw_context, in vmw_query_bo_switch_prepare()
812 struct vmw_sw_context *sw_context) in vmw_query_bo_switch_commit() argument
819 if (sw_context->needs_post_query_barrier) { in vmw_query_bo_switch_commit()
821 &sw_context->res_cache[vmw_res_context]; in vmw_query_bo_switch_commit()
834 if (dev_priv->pinned_bo != sw_context->cur_query_bo) { in vmw_query_bo_switch_commit()
840 if (!sw_context->needs_post_query_barrier) { in vmw_query_bo_switch_commit()
841 vmw_bo_pin(sw_context->cur_query_bo, true); in vmw_query_bo_switch_commit()
852 BUG_ON(sw_context->last_query_ctx == NULL); in vmw_query_bo_switch_commit()
853 dev_priv->query_cid = sw_context->last_query_ctx->id; in vmw_query_bo_switch_commit()
856 ttm_bo_reference(sw_context->cur_query_bo); in vmw_query_bo_switch_commit()
880 struct vmw_sw_context *sw_context, in vmw_translate_mob_ptr() argument
890 ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo, in vmw_translate_mob_ptr()
899 if (unlikely(sw_context->cur_reloc >= VMWGFX_MAX_RELOCATIONS)) { in vmw_translate_mob_ptr()
906 reloc = &sw_context->relocs[sw_context->cur_reloc++]; in vmw_translate_mob_ptr()
910 ret = vmw_bo_to_validate_list(sw_context, bo, true, &reloc->index); in vmw_translate_mob_ptr()
943 struct vmw_sw_context *sw_context, in vmw_translate_guest_ptr() argument
953 ret = vmw_user_dmabuf_lookup(sw_context->fp->tfile, handle, &vmw_bo, in vmw_translate_guest_ptr()
962 if (unlikely(sw_context->cur_reloc >= VMWGFX_MAX_RELOCATIONS)) { in vmw_translate_guest_ptr()
969 reloc = &sw_context->relocs[sw_context->cur_reloc++]; in vmw_translate_guest_ptr()
972 ret = vmw_bo_to_validate_list(sw_context, bo, false, &reloc->index); in vmw_translate_guest_ptr()
993 struct vmw_sw_context *sw_context, in vmw_cmd_begin_gb_query() argument
1004 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_begin_gb_query()
1017 struct vmw_sw_context *sw_context, in vmw_cmd_begin_query() argument
1042 return vmw_cmd_begin_gb_query(dev_priv, sw_context, header); in vmw_cmd_begin_query()
1045 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_begin_query()
1058 struct vmw_sw_context *sw_context, in vmw_cmd_end_gb_query() argument
1069 ret = vmw_cmd_cid_check(dev_priv, sw_context, header); in vmw_cmd_end_gb_query()
1073 ret = vmw_translate_mob_ptr(dev_priv, sw_context, in vmw_cmd_end_gb_query()
1079 ret = vmw_query_bo_switch_prepare(dev_priv, &vmw_bo->base, sw_context); in vmw_cmd_end_gb_query()
1093 struct vmw_sw_context *sw_context, in vmw_cmd_end_query() argument
1120 return vmw_cmd_end_gb_query(dev_priv, sw_context, header); in vmw_cmd_end_query()
1123 ret = vmw_cmd_cid_check(dev_priv, sw_context, header); in vmw_cmd_end_query()
1127 ret = vmw_translate_guest_ptr(dev_priv, sw_context, in vmw_cmd_end_query()
1133 ret = vmw_query_bo_switch_prepare(dev_priv, &vmw_bo->base, sw_context); in vmw_cmd_end_query()
1147 struct vmw_sw_context *sw_context, in vmw_cmd_wait_gb_query() argument
1158 ret = vmw_cmd_cid_check(dev_priv, sw_context, header); in vmw_cmd_wait_gb_query()
1162 ret = vmw_translate_mob_ptr(dev_priv, sw_context, in vmw_cmd_wait_gb_query()
1180 struct vmw_sw_context *sw_context, in vmw_cmd_wait_query() argument
1207 return vmw_cmd_wait_gb_query(dev_priv, sw_context, header); in vmw_cmd_wait_query()
1210 ret = vmw_cmd_cid_check(dev_priv, sw_context, header); in vmw_cmd_wait_query()
1214 ret = vmw_translate_guest_ptr(dev_priv, sw_context, in vmw_cmd_wait_query()
1225 struct vmw_sw_context *sw_context, in vmw_cmd_dma() argument
1248 ret = vmw_translate_guest_ptr(dev_priv, sw_context, in vmw_cmd_dma()
1265 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_dma()
1274 srf = vmw_res_to_srf(sw_context->res_cache[vmw_res_surface].res); in vmw_cmd_dma()
1276 vmw_kms_cursor_snoop(srf, sw_context->fp->tfile, &vmw_bo->base, in vmw_cmd_dma()
1285 struct vmw_sw_context *sw_context, in vmw_cmd_draw() argument
1299 ret = vmw_cmd_cid_check(dev_priv, sw_context, header); in vmw_cmd_draw()
1312 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_draw()
1328 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_draw()
1339 struct vmw_sw_context *sw_context, in vmw_cmd_tex_state() argument
1358 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_tex_state()
1368 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_tex_state()
1390 struct vmw_sw_context *sw_context, in vmw_cmd_check_define_gmrfb() argument
1401 ret = vmw_translate_guest_ptr(dev_priv, sw_context, in vmw_cmd_check_define_gmrfb()
1428 struct vmw_sw_context *sw_context, in vmw_cmd_switch_backup() argument
1440 ret = vmw_cmd_res_check(dev_priv, sw_context, res_type, in vmw_cmd_switch_backup()
1445 ret = vmw_translate_mob_ptr(dev_priv, sw_context, buf_id, &dma_buf); in vmw_cmd_switch_backup()
1468 struct vmw_sw_context *sw_context, in vmw_cmd_bind_gb_surface() argument
1478 return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_bind_gb_surface()
1493 struct vmw_sw_context *sw_context, in vmw_cmd_update_gb_image() argument
1503 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_update_gb_image()
1517 struct vmw_sw_context *sw_context, in vmw_cmd_update_gb_surface() argument
1527 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_update_gb_surface()
1541 struct vmw_sw_context *sw_context, in vmw_cmd_readback_gb_image() argument
1551 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_readback_gb_image()
1565 struct vmw_sw_context *sw_context, in vmw_cmd_readback_gb_surface() argument
1575 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_readback_gb_surface()
1589 struct vmw_sw_context *sw_context, in vmw_cmd_invalidate_gb_image() argument
1599 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_invalidate_gb_image()
1613 struct vmw_sw_context *sw_context, in vmw_cmd_invalidate_gb_surface() argument
1623 return vmw_cmd_res_check(dev_priv, sw_context, vmw_res_surface, in vmw_cmd_invalidate_gb_surface()
1638 struct vmw_sw_context *sw_context, in vmw_cmd_shader_define() argument
1652 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_shader_define()
1666 &sw_context->staged_cmd_res); in vmw_cmd_shader_define()
1670 return vmw_resource_relocation_add(&sw_context->res_relocations, in vmw_cmd_shader_define()
1672 sw_context->buf_start); in vmw_cmd_shader_define()
1686 struct vmw_sw_context *sw_context, in vmw_cmd_shader_destroy() argument
1699 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_shader_destroy()
1711 &sw_context->staged_cmd_res); in vmw_cmd_shader_destroy()
1715 return vmw_resource_relocation_add(&sw_context->res_relocations, in vmw_cmd_shader_destroy()
1717 sw_context->buf_start); in vmw_cmd_shader_destroy()
1731 struct vmw_sw_context *sw_context, in vmw_cmd_set_shader() argument
1746 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_set_shader()
1762 ret = vmw_cmd_res_reloc_add(dev_priv, sw_context, in vmw_cmd_set_shader()
1773 ret = vmw_cmd_res_check(dev_priv, sw_context, in vmw_cmd_set_shader()
1797 struct vmw_sw_context *sw_context, in vmw_cmd_set_shader_const() argument
1809 ret = vmw_cmd_res_check(dev_priv, sw_context, vmw_res_context, in vmw_cmd_set_shader_const()
1830 struct vmw_sw_context *sw_context, in vmw_cmd_bind_gb_shader() argument
1841 return vmw_cmd_switch_backup(dev_priv, sw_context, vmw_res_shader, in vmw_cmd_bind_gb_shader()
1848 struct vmw_sw_context *sw_context, in vmw_cmd_check_not_3d() argument
1879 if (unlikely(!sw_context->kernel)) { in vmw_cmd_check_not_3d()
1885 return vmw_cmd_check_define_gmrfb(dev_priv, sw_context, buf); in vmw_cmd_check_not_3d()
2060 struct vmw_sw_context *sw_context, in vmw_cmd_check() argument
2073 return vmw_cmd_check_not_3d(dev_priv, sw_context, buf, size); in vmw_cmd_check()
2090 if (unlikely(!entry->user_allow && !sw_context->kernel)) in vmw_cmd_check()
2099 ret = entry->func(dev_priv, sw_context, header); in vmw_cmd_check()
2123 struct vmw_sw_context *sw_context, in vmw_cmd_check_all() argument
2130 sw_context->buf_start = buf; in vmw_cmd_check_all()
2134 ret = vmw_cmd_check(dev_priv, sw_context, buf, &size); in vmw_cmd_check_all()
2149 static void vmw_free_relocations(struct vmw_sw_context *sw_context) in vmw_free_relocations() argument
2151 sw_context->cur_reloc = 0; in vmw_free_relocations()
2154 static void vmw_apply_relocations(struct vmw_sw_context *sw_context) in vmw_apply_relocations() argument
2161 for (i = 0; i < sw_context->cur_reloc; ++i) { in vmw_apply_relocations()
2162 reloc = &sw_context->relocs[i]; in vmw_apply_relocations()
2163 validate = &sw_context->val_bufs[reloc->index].base; in vmw_apply_relocations()
2180 vmw_free_relocations(sw_context); in vmw_apply_relocations()
2206 static void vmw_clear_validations(struct vmw_sw_context *sw_context) in vmw_clear_validations() argument
2214 list_for_each_entry_safe(entry, next, &sw_context->validate_nodes, in vmw_clear_validations()
2218 (void) drm_ht_remove_item(&sw_context->res_ht, &entry->hash); in vmw_clear_validations()
2219 sw_context->cur_val_buf--; in vmw_clear_validations()
2221 BUG_ON(sw_context->cur_val_buf != 0); in vmw_clear_validations()
2223 list_for_each_entry(val, &sw_context->resource_list, head) in vmw_clear_validations()
2224 (void) drm_ht_remove_item(&sw_context->res_ht, &val->hash); in vmw_clear_validations()
2268 struct vmw_sw_context *sw_context) in vmw_validate_buffers() argument
2273 list_for_each_entry(entry, &sw_context->validate_nodes, base.head) { in vmw_validate_buffers()
2282 static int vmw_resize_cmd_bounce(struct vmw_sw_context *sw_context, in vmw_resize_cmd_bounce() argument
2285 if (likely(sw_context->cmd_bounce_size >= size)) in vmw_resize_cmd_bounce()
2288 if (sw_context->cmd_bounce_size == 0) in vmw_resize_cmd_bounce()
2289 sw_context->cmd_bounce_size = VMWGFX_CMD_BOUNCE_INIT_SIZE; in vmw_resize_cmd_bounce()
2291 while (sw_context->cmd_bounce_size < size) { in vmw_resize_cmd_bounce()
2292 sw_context->cmd_bounce_size = in vmw_resize_cmd_bounce()
2293 PAGE_ALIGN(sw_context->cmd_bounce_size + in vmw_resize_cmd_bounce()
2294 (sw_context->cmd_bounce_size >> 1)); in vmw_resize_cmd_bounce()
2297 if (sw_context->cmd_bounce != NULL) in vmw_resize_cmd_bounce()
2298 vfree(sw_context->cmd_bounce); in vmw_resize_cmd_bounce()
2300 sw_context->cmd_bounce = vmalloc(sw_context->cmd_bounce_size); in vmw_resize_cmd_bounce()
2302 if (sw_context->cmd_bounce == NULL) { in vmw_resize_cmd_bounce()
2304 sw_context->cmd_bounce_size = 0; in vmw_resize_cmd_bounce()
2433 struct vmw_sw_context *sw_context = &dev_priv->ctx; in vmw_execbuf_process() local
2447 sw_context->kernel = false; in vmw_execbuf_process()
2449 ret = vmw_resize_cmd_bounce(sw_context, command_size); in vmw_execbuf_process()
2454 ret = copy_from_user(sw_context->cmd_bounce, in vmw_execbuf_process()
2462 kernel_commands = sw_context->cmd_bounce; in vmw_execbuf_process()
2464 sw_context->kernel = true; in vmw_execbuf_process()
2466 sw_context->fp = vmw_fpriv(file_priv); in vmw_execbuf_process()
2467 sw_context->cur_reloc = 0; in vmw_execbuf_process()
2468 sw_context->cur_val_buf = 0; in vmw_execbuf_process()
2469 INIT_LIST_HEAD(&sw_context->resource_list); in vmw_execbuf_process()
2470 sw_context->cur_query_bo = dev_priv->pinned_bo; in vmw_execbuf_process()
2471 sw_context->last_query_ctx = NULL; in vmw_execbuf_process()
2472 sw_context->needs_post_query_barrier = false; in vmw_execbuf_process()
2473 memset(sw_context->res_cache, 0, sizeof(sw_context->res_cache)); in vmw_execbuf_process()
2474 INIT_LIST_HEAD(&sw_context->validate_nodes); in vmw_execbuf_process()
2475 INIT_LIST_HEAD(&sw_context->res_relocations); in vmw_execbuf_process()
2476 if (!sw_context->res_ht_initialized) { in vmw_execbuf_process()
2477 ret = drm_ht_create(&sw_context->res_ht, VMW_RES_HT_ORDER); in vmw_execbuf_process()
2480 sw_context->res_ht_initialized = true; in vmw_execbuf_process()
2482 INIT_LIST_HEAD(&sw_context->staged_cmd_res); in vmw_execbuf_process()
2485 ret = vmw_cmd_check_all(dev_priv, sw_context, kernel_commands, in vmw_execbuf_process()
2490 ret = vmw_resources_reserve(sw_context); in vmw_execbuf_process()
2494 ret = ttm_eu_reserve_buffers(&ticket, &sw_context->validate_nodes, in vmw_execbuf_process()
2499 ret = vmw_validate_buffers(dev_priv, sw_context); in vmw_execbuf_process()
2503 ret = vmw_resources_validate(sw_context); in vmw_execbuf_process()
2522 ret = vmw_rebind_contexts(sw_context); in vmw_execbuf_process()
2534 vmw_apply_relocations(sw_context); in vmw_execbuf_process()
2537 vmw_resource_relocations_apply(cmd, &sw_context->res_relocations); in vmw_execbuf_process()
2538 vmw_resource_relocations_free(&sw_context->res_relocations); in vmw_execbuf_process()
2543 vmw_query_bo_switch_commit(dev_priv, sw_context); in vmw_execbuf_process()
2556 vmw_resource_list_unreserve(&sw_context->resource_list, false); in vmw_execbuf_process()
2558 ttm_eu_fence_buffer_objects(&ticket, &sw_context->validate_nodes, in vmw_execbuf_process()
2565 vmw_clear_validations(sw_context); in vmw_execbuf_process()
2577 list_splice_init(&sw_context->resource_list, &resource_list); in vmw_execbuf_process()
2578 vmw_cmdbuf_res_commit(&sw_context->staged_cmd_res); in vmw_execbuf_process()
2592 ttm_eu_backoff_reservation(&ticket, &sw_context->validate_nodes); in vmw_execbuf_process()
2594 vmw_resource_list_unreserve(&sw_context->resource_list, true); in vmw_execbuf_process()
2595 vmw_resource_relocations_free(&sw_context->res_relocations); in vmw_execbuf_process()
2596 vmw_free_relocations(sw_context); in vmw_execbuf_process()
2597 vmw_clear_validations(sw_context); in vmw_execbuf_process()
2602 list_splice_init(&sw_context->resource_list, &resource_list); in vmw_execbuf_process()
2603 error_resource = sw_context->error_resource; in vmw_execbuf_process()
2604 sw_context->error_resource = NULL; in vmw_execbuf_process()
2605 vmw_cmdbuf_res_revert(&sw_context->staged_cmd_res); in vmw_execbuf_process()