Lines Matching refs:res
36 struct vmw_resource res; member
44 static void vmw_user_context_free(struct vmw_resource *res);
48 static int vmw_gb_context_create(struct vmw_resource *res);
49 static int vmw_gb_context_bind(struct vmw_resource *res,
51 static int vmw_gb_context_unbind(struct vmw_resource *res,
54 static int vmw_gb_context_destroy(struct vmw_resource *res);
55 static int vmw_dx_context_create(struct vmw_resource *res);
56 static int vmw_dx_context_bind(struct vmw_resource *res,
58 static int vmw_dx_context_unbind(struct vmw_resource *res,
61 static int vmw_dx_context_destroy(struct vmw_resource *res);
117 struct vmw_resource *res; in vmw_context_cotables_unref() local
122 res = uctx->cotables[i]; in vmw_context_cotables_unref()
126 if (res) in vmw_context_cotables_unref()
127 vmw_resource_unreference(&res); in vmw_context_cotables_unref()
131 static void vmw_hw_context_destroy(struct vmw_resource *res) in vmw_hw_context_destroy() argument
134 container_of(res, struct vmw_user_context, res); in vmw_hw_context_destroy()
135 struct vmw_private *dev_priv = res->dev_priv; in vmw_hw_context_destroy()
142 if (res->func->destroy == vmw_gb_context_destroy || in vmw_hw_context_destroy()
143 res->func->destroy == vmw_dx_context_destroy) { in vmw_hw_context_destroy()
148 (void) res->func->destroy(res); in vmw_hw_context_destroy()
168 cmd->body.cid = res->id; in vmw_hw_context_destroy()
176 struct vmw_resource *res, in vmw_gb_context_init() argument
177 void (*res_free)(struct vmw_resource *res)) in vmw_gb_context_init() argument
181 container_of(res, struct vmw_user_context, res); in vmw_gb_context_init()
183 res->backup_size = (dx ? sizeof(SVGADXContextMobFormat) : in vmw_gb_context_init()
185 ret = vmw_resource_init(dev_priv, res, true, in vmw_gb_context_init()
212 &uctx->res, i); in vmw_gb_context_init()
222 vmw_resource_activate(res, vmw_hw_context_destroy); in vmw_gb_context_init()
229 res_free(res); in vmw_gb_context_init()
231 kfree(res); in vmw_gb_context_init()
236 struct vmw_resource *res, in vmw_context_init() argument
237 void (*res_free)(struct vmw_resource *res), in vmw_context_init() argument
248 return vmw_gb_context_init(dev_priv, dx, res, res_free); in vmw_context_init()
250 ret = vmw_resource_init(dev_priv, res, false, in vmw_context_init()
258 if (unlikely(res->id >= SVGA3D_MAX_CONTEXT_IDS)) { in vmw_context_init()
260 vmw_resource_unreference(&res); in vmw_context_init()
267 vmw_resource_unreference(&res); in vmw_context_init()
273 cmd->body.cid = res->id; in vmw_context_init()
277 vmw_resource_activate(res, vmw_hw_context_destroy); in vmw_context_init()
282 kfree(res); in vmw_context_init()
284 res_free(res); in vmw_context_init()
293 static int vmw_gb_context_create(struct vmw_resource *res) in vmw_gb_context_create() argument
295 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_context_create()
302 if (likely(res->id != -1)) in vmw_gb_context_create()
305 ret = vmw_resource_alloc_id(res); in vmw_gb_context_create()
311 if (unlikely(res->id >= VMWGFX_NUM_GB_CONTEXT)) { in vmw_gb_context_create()
326 cmd->body.cid = res->id; in vmw_gb_context_create()
333 vmw_resource_release_id(res); in vmw_gb_context_create()
338 static int vmw_gb_context_bind(struct vmw_resource *res, in vmw_gb_context_bind() argument
341 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_context_bind()
358 cmd->body.cid = res->id; in vmw_gb_context_bind()
360 cmd->body.validContents = res->backup_dirty; in vmw_gb_context_bind()
361 res->backup_dirty = false; in vmw_gb_context_bind()
367 static int vmw_gb_context_unbind(struct vmw_resource *res, in vmw_gb_context_unbind() argument
371 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_context_unbind()
375 container_of(res, struct vmw_user_context, res); in vmw_gb_context_unbind()
409 cmd1->body.cid = res->id; in vmw_gb_context_unbind()
414 cmd2->body.cid = res->id; in vmw_gb_context_unbind()
435 static int vmw_gb_context_destroy(struct vmw_resource *res) in vmw_gb_context_destroy() argument
437 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_context_destroy()
443 if (likely(res->id == -1)) in vmw_gb_context_destroy()
455 cmd->body.cid = res->id; in vmw_gb_context_destroy()
457 if (dev_priv->query_cid == res->id) in vmw_gb_context_destroy()
459 vmw_resource_release_id(res); in vmw_gb_context_destroy()
469 static int vmw_dx_context_create(struct vmw_resource *res) in vmw_dx_context_create() argument
471 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_context_create()
478 if (likely(res->id != -1)) in vmw_dx_context_create()
481 ret = vmw_resource_alloc_id(res); in vmw_dx_context_create()
487 if (unlikely(res->id >= VMWGFX_NUM_DXCONTEXT)) { in vmw_dx_context_create()
502 cmd->body.cid = res->id; in vmw_dx_context_create()
509 vmw_resource_release_id(res); in vmw_dx_context_create()
514 static int vmw_dx_context_bind(struct vmw_resource *res, in vmw_dx_context_bind() argument
517 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_context_bind()
535 cmd->body.cid = res->id; in vmw_dx_context_bind()
537 cmd->body.validContents = res->backup_dirty; in vmw_dx_context_bind()
538 res->backup_dirty = false; in vmw_dx_context_bind()
563 container_of(ctx, struct vmw_user_context, res); in vmw_dx_context_scrub_cotables()
568 struct vmw_resource *res; in vmw_dx_context_scrub_cotables() local
572 res = uctx->cotables[vmw_cotable_scrub_order[i]]; in vmw_dx_context_scrub_cotables()
573 if (res) in vmw_dx_context_scrub_cotables()
574 res = vmw_resource_reference_unless_doomed(res); in vmw_dx_context_scrub_cotables()
576 if (!res) in vmw_dx_context_scrub_cotables()
579 WARN_ON(vmw_cotable_scrub(res, readback)); in vmw_dx_context_scrub_cotables()
580 vmw_resource_unreference(&res); in vmw_dx_context_scrub_cotables()
584 static int vmw_dx_context_unbind(struct vmw_resource *res, in vmw_dx_context_unbind() argument
588 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_context_unbind()
592 container_of(res, struct vmw_user_context, res); in vmw_dx_context_unbind()
609 vmw_dx_context_scrub_cotables(res, readback); in vmw_dx_context_unbind()
613 WARN_ON(uctx->dx_query_mob->dx_query_ctx != res); in vmw_dx_context_unbind()
633 cmd1->body.cid = res->id; in vmw_dx_context_unbind()
638 cmd2->body.cid = res->id; in vmw_dx_context_unbind()
659 static int vmw_dx_context_destroy(struct vmw_resource *res) in vmw_dx_context_destroy() argument
661 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_context_destroy()
667 if (likely(res->id == -1)) in vmw_dx_context_destroy()
679 cmd->body.cid = res->id; in vmw_dx_context_destroy()
681 if (dev_priv->query_cid == res->id) in vmw_dx_context_destroy()
683 vmw_resource_release_id(res); in vmw_dx_context_destroy()
696 return &(container_of(base, struct vmw_user_context, base)->res); in vmw_user_context_base_to_res()
699 static void vmw_user_context_free(struct vmw_resource *res) in vmw_user_context_free() argument
702 container_of(res, struct vmw_user_context, res); in vmw_user_context_free()
703 struct vmw_private *dev_priv = res->dev_priv; in vmw_user_context_free()
708 (void) vmw_context_bind_dx_query(res, NULL); in vmw_user_context_free()
725 struct vmw_resource *res = &ctx->res; in vmw_user_context_base_release() local
728 vmw_resource_unreference(&res); in vmw_user_context_base_release()
745 struct vmw_resource *res; in vmw_context_define() local
791 res = &ctx->res; in vmw_context_define()
799 ret = vmw_context_init(dev_priv, res, vmw_user_context_free, dx); in vmw_context_define()
803 tmp = vmw_resource_reference(&ctx->res); in vmw_context_define()
814 vmw_resource_unreference(&res); in vmw_context_define()
854 container_of(ctx, struct vmw_user_context, res); in vmw_context_binding_list()
861 return container_of(ctx, struct vmw_user_context, res)->man; in vmw_context_res_man()
871 (container_of(ctx, struct vmw_user_context, res)-> in vmw_context_cotable()
887 return container_of(ctx, struct vmw_user_context, res)->cbs; in vmw_context_binding_state()
906 container_of(ctx_res, struct vmw_user_context, res); in vmw_context_bind_dx_query()
939 container_of(ctx_res, struct vmw_user_context, res); in vmw_context_get_dx_query_mob()