Lines Matching refs:res
51 struct vmw_resource res; member
107 static int vmw_cotable_bind(struct vmw_resource *res,
109 static int vmw_cotable_unbind(struct vmw_resource *res,
112 static int vmw_cotable_create(struct vmw_resource *res);
113 static int vmw_cotable_destroy(struct vmw_resource *res);
133 static struct vmw_cotable *vmw_cotable(struct vmw_resource *res) in vmw_cotable() argument
135 return container_of(res, struct vmw_cotable, res); in vmw_cotable()
146 static int vmw_cotable_destroy(struct vmw_resource *res) in vmw_cotable_destroy() argument
148 res->id = -1; in vmw_cotable_destroy()
161 static int vmw_cotable_unscrub(struct vmw_resource *res) in vmw_cotable_unscrub() argument
163 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_unscrub()
164 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_unscrub()
165 struct ttm_buffer_object *bo = &res->backup->base; in vmw_cotable_unscrub()
206 static int vmw_cotable_bind(struct vmw_resource *res, in vmw_cotable_bind() argument
216 val_buf->bo = &res->backup->base; in vmw_cotable_bind()
218 return vmw_cotable_unscrub(res); in vmw_cotable_bind()
239 int vmw_cotable_scrub(struct vmw_resource *res, bool readback) in vmw_cotable_scrub() argument
241 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_scrub()
242 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_scrub()
280 vcotbl->size_read_back = res->backup_size; in vmw_cotable_scrub()
292 res->id = -1; in vmw_cotable_scrub()
307 static int vmw_cotable_unbind(struct vmw_resource *res, in vmw_cotable_unbind() argument
311 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_unbind()
312 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_unbind()
316 if (list_empty(&res->mob_head)) in vmw_cotable_unbind()
342 static int vmw_cotable_readback(struct vmw_resource *res) in vmw_cotable_readback() argument
344 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_readback()
345 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_readback()
365 vcotbl->size_read_back = res->backup_size; in vmw_cotable_readback()
370 vmw_bo_fence_single(&res->backup->base, fence); in vmw_cotable_readback()
388 static int vmw_cotable_resize(struct vmw_resource *res, size_t new_size) in vmw_cotable_resize() argument
391 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_resize()
392 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_resize()
393 struct vmw_buffer_object *buf, *old_buf = res->backup; in vmw_cotable_resize()
394 struct ttm_buffer_object *bo, *old_bo = &res->backup->base; in vmw_cotable_resize()
395 size_t old_size = res->backup_size; in vmw_cotable_resize()
402 ret = vmw_cotable_readback(res); in vmw_cotable_resize()
465 res->backup = buf; in vmw_cotable_resize()
466 res->backup_size = new_size; in vmw_cotable_resize()
473 ret = vmw_cotable_unscrub(res); in vmw_cotable_resize()
476 res->backup = old_buf; in vmw_cotable_resize()
477 res->backup_size = old_size; in vmw_cotable_resize()
483 list_del(&res->mob_head); in vmw_cotable_resize()
484 list_add_tail(&res->mob_head, &buf->res_list); in vmw_cotable_resize()
486 res->id = vcotbl->type; in vmw_cotable_resize()
511 static int vmw_cotable_create(struct vmw_resource *res) in vmw_cotable_create() argument
513 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_create()
514 size_t new_size = res->backup_size; in vmw_cotable_create()
523 if (likely(new_size <= res->backup_size)) { in vmw_cotable_create()
524 if (vcotbl->scrubbed && !list_empty(&res->mob_head)) { in vmw_cotable_create()
525 ret = vmw_cotable_unscrub(res); in vmw_cotable_create()
529 res->id = vcotbl->type; in vmw_cotable_create()
533 return vmw_cotable_resize(res, new_size); in vmw_cotable_create()
543 static void vmw_hw_cotable_destroy(struct vmw_resource *res) in vmw_hw_cotable_destroy() argument
545 (void) vmw_cotable_destroy(res); in vmw_hw_cotable_destroy()
555 static void vmw_cotable_free(struct vmw_resource *res) in vmw_cotable_free() argument
557 struct vmw_private *dev_priv = res->dev_priv; in vmw_cotable_free()
559 kfree(res); in vmw_cotable_free()
597 ret = vmw_resource_init(dev_priv, &vcotbl->res, true, in vmw_cotable_alloc()
603 vcotbl->res.id = type; in vmw_cotable_alloc()
604 vcotbl->res.backup_size = PAGE_SIZE; in vmw_cotable_alloc()
607 vcotbl->res.backup_size = co_info[type].min_initial_entries * in vmw_cotable_alloc()
609 vcotbl->res.backup_size = in vmw_cotable_alloc()
610 (vcotbl->res.backup_size + PAGE_SIZE - 1) & PAGE_MASK; in vmw_cotable_alloc()
618 vmw_resource_activate(&vcotbl->res, vmw_hw_cotable_destroy); in vmw_cotable_alloc()
620 return &vcotbl->res; in vmw_cotable_alloc()
635 int vmw_cotable_notify(struct vmw_resource *res, int id) in vmw_cotable_notify() argument
637 struct vmw_cotable *vcotbl = vmw_cotable(res); in vmw_cotable_notify()
647 res->id = -1; in vmw_cotable_notify()
661 void vmw_cotable_add_resource(struct vmw_resource *res, struct list_head *head) in vmw_cotable_add_resource() argument
664 container_of(res, struct vmw_cotable, res); in vmw_cotable_add_resource()