Lines Matching +full:resource +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0 OR MIT
4 * Copyright (c) 2009-2024 Broadcom. All Rights Reserved. The term
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
39 * vmw_resource_mob_attach - Mark a resource as attached to its backing mob
40 * @res: The resource
44 struct vmw_bo *gbo = res->guest_memory_bo; in vmw_resource_mob_attach()
45 struct rb_node **new = &gbo->res_tree.rb_node, *parent = NULL; in vmw_resource_mob_attach()
47 dma_resv_assert_held(gbo->tbo.base.resv); in vmw_resource_mob_attach()
48 res->used_prio = (res->res_dirty) ? res->func->dirty_prio : in vmw_resource_mob_attach()
49 res->func->prio; in vmw_resource_mob_attach()
56 new = (res->guest_memory_offset < this->guest_memory_offset) ? in vmw_resource_mob_attach()
57 &((*new)->rb_left) : &((*new)->rb_right); in vmw_resource_mob_attach()
60 rb_link_node(&res->mob_node, parent, new); in vmw_resource_mob_attach()
61 rb_insert_color(&res->mob_node, &gbo->res_tree); in vmw_resource_mob_attach()
64 vmw_bo_prio_add(gbo, res->used_prio); in vmw_resource_mob_attach()
68 * vmw_resource_mob_detach - Mark a resource as detached from its backing mob
69 * @res: The resource
73 struct vmw_bo *gbo = res->guest_memory_bo; in vmw_resource_mob_detach()
75 dma_resv_assert_held(gbo->tbo.base.resv); in vmw_resource_mob_detach()
77 rb_erase(&res->mob_node, &gbo->res_tree); in vmw_resource_mob_detach()
78 RB_CLEAR_NODE(&res->mob_node); in vmw_resource_mob_detach()
79 vmw_bo_prio_del(gbo, res->used_prio); in vmw_resource_mob_detach()
85 kref_get(&res->kref); in vmw_resource_reference()
92 return kref_get_unless_zero(&res->kref) ? res : NULL; in vmw_resource_reference_unless_doomed()
96 * vmw_resource_release_id - release a resource id to the id manager.
98 * @res: Pointer to the resource.
100 * Release the resource id to the resource id manager and set it to -1
104 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_release_id()
105 struct idr *idr = &dev_priv->res_idr[res->func->res_type]; in vmw_resource_release_id()
107 spin_lock(&dev_priv->resource_lock); in vmw_resource_release_id()
108 if (res->id != -1) in vmw_resource_release_id()
109 idr_remove(idr, res->id); in vmw_resource_release_id()
110 res->id = -1; in vmw_resource_release_id()
111 spin_unlock(&dev_priv->resource_lock); in vmw_resource_release_id()
118 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_release()
119 int id; in vmw_resource_release() local
121 struct idr *idr = &dev_priv->res_idr[res->func->res_type]; in vmw_resource_release()
123 spin_lock(&dev_priv->resource_lock); in vmw_resource_release()
124 list_del_init(&res->lru_head); in vmw_resource_release()
125 spin_unlock(&dev_priv->resource_lock); in vmw_resource_release()
126 if (res->guest_memory_bo) { in vmw_resource_release()
127 struct ttm_buffer_object *bo = &res->guest_memory_bo->tbo; in vmw_resource_release()
132 res->func->unbind != NULL) { in vmw_resource_release()
137 res->func->unbind(res, false, &val_buf); in vmw_resource_release()
139 res->guest_memory_size = false; in vmw_resource_release()
141 if (res->dirty) in vmw_resource_release()
142 res->func->dirty_free(res); in vmw_resource_release()
143 if (res->coherent) in vmw_resource_release()
144 vmw_bo_dirty_release(res->guest_memory_bo); in vmw_resource_release()
146 vmw_user_bo_unref(&res->guest_memory_bo); in vmw_resource_release()
149 if (likely(res->hw_destroy != NULL)) { in vmw_resource_release()
150 mutex_lock(&dev_priv->binding_mutex); in vmw_resource_release()
151 vmw_binding_res_list_kill(&res->binding_head); in vmw_resource_release()
152 mutex_unlock(&dev_priv->binding_mutex); in vmw_resource_release()
153 res->hw_destroy(res); in vmw_resource_release()
156 id = res->id; in vmw_resource_release()
157 if (res->res_free != NULL) in vmw_resource_release()
158 res->res_free(res); in vmw_resource_release()
162 spin_lock(&dev_priv->resource_lock); in vmw_resource_release()
163 if (id != -1) in vmw_resource_release()
164 idr_remove(idr, id); in vmw_resource_release()
165 spin_unlock(&dev_priv->resource_lock); in vmw_resource_release()
173 kref_put(&res->kref, vmw_resource_release); in vmw_resource_unreference()
178 * vmw_resource_alloc_id - release a resource id to the id manager.
180 * @res: Pointer to the resource.
182 * Allocate the lowest free resource from the resource manager, and set
183 * @res->id to that id. Returns 0 on success and -ENOMEM on failure.
187 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_alloc_id()
189 struct idr *idr = &dev_priv->res_idr[res->func->res_type]; in vmw_resource_alloc_id()
191 BUG_ON(res->id != -1); in vmw_resource_alloc_id()
194 spin_lock(&dev_priv->resource_lock); in vmw_resource_alloc_id()
198 res->id = ret; in vmw_resource_alloc_id()
200 spin_unlock(&dev_priv->resource_lock); in vmw_resource_alloc_id()
206 * vmw_resource_init - initialize a struct vmw_resource
210 * @delay_id: Boolean whether to defer device id allocation until
212 * @res_free: Resource destructor.
213 * @func: Resource function table.
220 kref_init(&res->kref); in vmw_resource_init()
221 res->hw_destroy = NULL; in vmw_resource_init()
222 res->res_free = res_free; in vmw_resource_init()
223 res->dev_priv = dev_priv; in vmw_resource_init()
224 res->func = func; in vmw_resource_init()
225 RB_CLEAR_NODE(&res->mob_node); in vmw_resource_init()
226 INIT_LIST_HEAD(&res->lru_head); in vmw_resource_init()
227 INIT_LIST_HEAD(&res->binding_head); in vmw_resource_init()
228 res->id = -1; in vmw_resource_init()
229 res->guest_memory_bo = NULL; in vmw_resource_init()
230 res->guest_memory_offset = 0; in vmw_resource_init()
231 res->guest_memory_dirty = false; in vmw_resource_init()
232 res->res_dirty = false; in vmw_resource_init()
233 res->coherent = false; in vmw_resource_init()
234 res->used_prio = 3; in vmw_resource_init()
235 res->dirty = NULL; in vmw_resource_init()
244 * vmw_user_resource_lookup_handle - lookup a struct resource from a
245 * TTM user-space handle and perform basic type checks
249 * @handle: The TTM user-space handle
250 * @converter: Pointer to an object describing the resource type
254 * If the handle can't be found or is associated with an incorrect resource
255 * type, -EINVAL will be returned.
266 int ret = -EINVAL; in vmw_user_resource_lookup_handle()
270 return -EINVAL; in vmw_user_resource_lookup_handle()
272 if (unlikely(ttm_base_object_type(base) != converter->object_type)) in vmw_user_resource_lookup_handle()
275 res = converter->base_obj_to_res(base); in vmw_user_resource_lookup_handle()
276 kref_get(&res->kref); in vmw_user_resource_lookup_handle()
297 struct ttm_object_file *tfile = vmw_fpriv(filp)->tfile; in vmw_user_object_lookup()
301 WARN_ON(uo->surface || uo->buffer); in vmw_user_object_lookup()
307 uo->surface = vmw_res_to_srf(res); in vmw_user_object_lookup()
311 uo->surface = NULL; in vmw_user_object_lookup()
312 ret = vmw_user_bo_lookup(filp, handle, &uo->buffer); in vmw_user_object_lookup()
313 if (!ret && !uo->buffer->is_dumb) { in vmw_user_object_lookup()
314 uo->surface = vmw_lookup_surface_for_buffer(dev_priv, in vmw_user_object_lookup()
315 uo->buffer, in vmw_user_object_lookup()
317 if (uo->surface) in vmw_user_object_lookup()
318 vmw_user_bo_unref(&uo->buffer); in vmw_user_object_lookup()
325 * vmw_resource_buf_alloc - Allocate a guest memory buffer for a resource.
327 * @res: The resource for which to allocate a gbo buffer.
334 unsigned long size = PFN_ALIGN(res->guest_memory_size); in vmw_resource_buf_alloc()
337 .domain = res->func->domain, in vmw_resource_buf_alloc()
338 .busy_domain = res->func->busy_domain, in vmw_resource_buf_alloc()
340 .size = res->guest_memory_size, in vmw_resource_buf_alloc()
345 if (likely(res->guest_memory_bo)) { in vmw_resource_buf_alloc()
346 BUG_ON(res->guest_memory_bo->tbo.base.size < size); in vmw_resource_buf_alloc()
350 ret = vmw_gem_object_create(res->dev_priv, &bo_params, &gbo); in vmw_resource_buf_alloc()
354 res->guest_memory_bo = gbo; in vmw_resource_buf_alloc()
361 * vmw_resource_do_validate - Make a resource up-to-date and visible
364 * @res: The resource to make visible to the device.
369 * On hardware resource shortage, this function returns -EBUSY and
377 const struct vmw_res_func *func = res->func; in vmw_resource_do_validate()
379 if (unlikely(res->id == -1)) { in vmw_resource_do_validate()
380 ret = func->create(res); in vmw_resource_do_validate()
385 if (func->bind && in vmw_resource_do_validate()
386 ((func->needs_guest_memory && !vmw_resource_mob_attached(res) && in vmw_resource_do_validate()
387 val_buf->bo) || in vmw_resource_do_validate()
388 (!func->needs_guest_memory && val_buf->bo))) { in vmw_resource_do_validate()
389 ret = func->bind(res, val_buf); in vmw_resource_do_validate()
392 if (func->needs_guest_memory) in vmw_resource_do_validate()
398 * the resource isn't. in vmw_resource_do_validate()
400 if (func->dirty_alloc && vmw_resource_mob_attached(res) && in vmw_resource_do_validate()
401 !res->coherent) { in vmw_resource_do_validate()
402 if (res->guest_memory_bo->dirty && !res->dirty) { in vmw_resource_do_validate()
403 ret = func->dirty_alloc(res); in vmw_resource_do_validate()
406 } else if (!res->guest_memory_bo->dirty && res->dirty) { in vmw_resource_do_validate()
407 func->dirty_free(res); in vmw_resource_do_validate()
412 * Transfer the dirty regions to the resource and update in vmw_resource_do_validate()
413 * the resource. in vmw_resource_do_validate()
415 if (res->dirty) { in vmw_resource_do_validate()
416 if (dirtying && !res->res_dirty) { in vmw_resource_do_validate()
417 pgoff_t start = res->guest_memory_offset >> PAGE_SHIFT; in vmw_resource_do_validate()
419 (res->guest_memory_offset + res->guest_memory_size, in vmw_resource_do_validate()
422 vmw_bo_dirty_unmap(res->guest_memory_bo, start, end); in vmw_resource_do_validate()
426 return func->dirty_sync(res); in vmw_resource_do_validate()
432 func->destroy(res); in vmw_resource_do_validate()
438 * vmw_resource_unreserve - Unreserve a resource previously reserved for
442 * @dirty_set: Change dirty status of the resource.
449 * Currently unreserving a resource means putting it back on the device's
450 * resource lru list, so that it can be evicted if necessary.
459 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_unreserve()
461 if (!list_empty(&res->lru_head)) in vmw_resource_unreserve()
464 if (switch_guest_memory && new_guest_memory_bo != res->guest_memory_bo) { in vmw_resource_unreserve()
465 if (res->guest_memory_bo) { in vmw_resource_unreserve()
467 if (res->coherent) in vmw_resource_unreserve()
468 vmw_bo_dirty_release(res->guest_memory_bo); in vmw_resource_unreserve()
469 vmw_user_bo_unref(&res->guest_memory_bo); in vmw_resource_unreserve()
473 res->guest_memory_bo = vmw_user_bo_ref(new_guest_memory_bo); in vmw_resource_unreserve()
479 WARN_ON(res->coherent && !new_guest_memory_bo->dirty); in vmw_resource_unreserve()
483 res->guest_memory_bo = NULL; in vmw_resource_unreserve()
485 } else if (switch_guest_memory && res->coherent) { in vmw_resource_unreserve()
486 vmw_bo_dirty_release(res->guest_memory_bo); in vmw_resource_unreserve()
490 res->guest_memory_offset = new_guest_memory_offset; in vmw_resource_unreserve()
493 res->res_dirty = dirty; in vmw_resource_unreserve()
495 if (!res->func->may_evict || res->id == -1 || res->pin_count) in vmw_resource_unreserve()
498 spin_lock(&dev_priv->resource_lock); in vmw_resource_unreserve()
499 list_add_tail(&res->lru_head, in vmw_resource_unreserve()
500 &res->dev_priv->res_lru[res->func->res_type]); in vmw_resource_unreserve()
501 spin_unlock(&dev_priv->resource_lock); in vmw_resource_unreserve()
505 * vmw_resource_check_buffer - Check whether a backup buffer is needed
506 * for a resource and in that case, allocate
510 * @res: The resource for which to allocate a backup buffer.
527 if (unlikely(!res->guest_memory_bo)) { in vmw_resource_check_buffer()
534 ttm_bo_get(&res->guest_memory_bo->tbo); in vmw_resource_check_buffer()
535 val_buf->bo = &res->guest_memory_bo->tbo; in vmw_resource_check_buffer()
536 val_buf->num_shared = 0; in vmw_resource_check_buffer()
537 list_add_tail(&val_buf->head, &val_list); in vmw_resource_check_buffer()
542 if (res->func->needs_guest_memory && !vmw_resource_mob_attached(res)) in vmw_resource_check_buffer()
545 guest_memory_dirty = res->guest_memory_dirty; in vmw_resource_check_buffer()
546 vmw_bo_placement_set(res->guest_memory_bo, res->func->domain, in vmw_resource_check_buffer()
547 res->func->busy_domain); in vmw_resource_check_buffer()
548 ret = ttm_bo_validate(&res->guest_memory_bo->tbo, in vmw_resource_check_buffer()
549 &res->guest_memory_bo->placement, in vmw_resource_check_buffer()
560 ttm_bo_put(val_buf->bo); in vmw_resource_check_buffer()
561 val_buf->bo = NULL; in vmw_resource_check_buffer()
563 vmw_user_bo_unref(&res->guest_memory_bo); in vmw_resource_check_buffer()
569 * vmw_resource_reserve - Reserve a resource for command submission
571 * @res: The resource to reserve.
573 * This function takes the resource off the LRU list and make sure
574 * a guest memory buffer is present for guest-backed resources.
575 * However, the buffer may not be bound to the resource at this
582 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_reserve()
585 spin_lock(&dev_priv->resource_lock); in vmw_resource_reserve()
586 list_del_init(&res->lru_head); in vmw_resource_reserve()
587 spin_unlock(&dev_priv->resource_lock); in vmw_resource_reserve()
589 if (res->func->needs_guest_memory && !res->guest_memory_bo && in vmw_resource_reserve()
595 (unsigned long) res->guest_memory_size); in vmw_resource_reserve()
604 * vmw_resource_backoff_reservation - Unreserve and unreference a
616 if (likely(val_buf->bo == NULL)) in vmw_resource_backoff_reservation()
620 list_add_tail(&val_buf->head, &val_list); in vmw_resource_backoff_reservation()
622 ttm_bo_put(val_buf->bo); in vmw_resource_backoff_reservation()
623 val_buf->bo = NULL; in vmw_resource_backoff_reservation()
627 * vmw_resource_do_evict - Evict a resource, and transfer its data
631 * @res: The resource to evict.
638 const struct vmw_res_func *func = res->func; in vmw_resource_do_evict()
641 BUG_ON(!func->may_evict); in vmw_resource_do_evict()
649 if (unlikely(func->unbind != NULL && in vmw_resource_do_evict()
650 (!func->needs_guest_memory || vmw_resource_mob_attached(res)))) { in vmw_resource_do_evict()
651 ret = func->unbind(res, res->res_dirty, &val_buf); in vmw_resource_do_evict()
656 ret = func->destroy(res); in vmw_resource_do_evict()
657 res->guest_memory_dirty = true; in vmw_resource_do_evict()
658 res->res_dirty = false; in vmw_resource_do_evict()
667 * vmw_resource_validate - Make a resource up-to-date and visible
669 * @res: The resource to make visible to the device.
671 * @dirtying: Pending GPU operation will dirty the resource
673 * On successful return, any backup DMA buffer pointed to by @res->backup will
675 * On hardware resource shortage, this function will repeatedly evict
678 * Return: Zero on success, -ERESTARTSYS if interrupted, negative error code
686 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_validate()
687 struct list_head *lru_list = &dev_priv->res_lru[res->func->res_type]; in vmw_resource_validate()
691 if (!res->func->create) in vmw_resource_validate()
696 if (res->guest_memory_bo) in vmw_resource_validate()
697 val_buf.bo = &res->guest_memory_bo->tbo; in vmw_resource_validate()
700 if (likely(ret != -EBUSY)) in vmw_resource_validate()
703 spin_lock(&dev_priv->resource_lock); in vmw_resource_validate()
704 if (list_empty(lru_list) || !res->func->may_evict) { in vmw_resource_validate()
706 "for %s.\n", res->func->type_name); in vmw_resource_validate()
707 ret = -EBUSY; in vmw_resource_validate()
708 spin_unlock(&dev_priv->resource_lock); in vmw_resource_validate()
715 list_del_init(&evict_res->lru_head); in vmw_resource_validate()
717 spin_unlock(&dev_priv->resource_lock); in vmw_resource_validate()
722 spin_lock(&dev_priv->resource_lock); in vmw_resource_validate()
723 list_add_tail(&evict_res->lru_head, lru_list); in vmw_resource_validate()
724 spin_unlock(&dev_priv->resource_lock); in vmw_resource_validate()
725 if (ret == -ERESTARTSYS || in vmw_resource_validate()
737 else if (!res->func->needs_guest_memory && res->guest_memory_bo) { in vmw_resource_validate()
739 vmw_user_bo_unref(&res->guest_memory_bo); in vmw_resource_validate()
754 * Evicts the Guest Backed hardware resource if the backup
756 * Note that this function will not race with the resource
757 * validation code, since resource validation and eviction
763 .bo = &vbo->tbo, in vmw_resource_unbind_list()
767 dma_resv_assert_held(vbo->tbo.base.resv); in vmw_resource_unbind_list()
768 while (!RB_EMPTY_ROOT(&vbo->res_tree)) { in vmw_resource_unbind_list()
769 struct rb_node *node = vbo->res_tree.rb_node; in vmw_resource_unbind_list()
773 if (!WARN_ON_ONCE(!res->func->unbind)) in vmw_resource_unbind_list()
774 (void) res->func->unbind(res, res->res_dirty, &val_buf); in vmw_resource_unbind_list()
776 res->guest_memory_size = true; in vmw_resource_unbind_list()
777 res->res_dirty = false; in vmw_resource_unbind_list()
781 (void) ttm_bo_wait(&vbo->tbo, false, false); in vmw_resource_unbind_list()
786 * vmw_query_readback_all - Read back cached query states
804 if (!dx_query_mob || !dx_query_mob->dx_query_ctx) in vmw_query_readback_all()
807 dx_query_ctx = dx_query_mob->dx_query_ctx; in vmw_query_readback_all()
808 dev_priv = dx_query_ctx->dev_priv; in vmw_query_readback_all()
810 cmd = VMW_CMD_CTX_RESERVE(dev_priv, sizeof(*cmd), dx_query_ctx->id); in vmw_query_readback_all()
812 return -ENOMEM; in vmw_query_readback_all()
814 cmd->header.id = SVGA_3D_CMD_DX_READBACK_ALL_QUERY; in vmw_query_readback_all()
815 cmd->header.size = sizeof(cmd->body); in vmw_query_readback_all()
816 cmd->body.cid = dx_query_ctx->id; in vmw_query_readback_all()
821 dx_query_mob->dx_query_ctx = NULL; in vmw_query_readback_all()
829 * vmw_query_move_notify - Read back cached query states
843 struct ttm_device *bdev = bo->bdev; in vmw_query_move_notify()
846 mutex_lock(&dev_priv->binding_mutex); in vmw_query_move_notify()
850 new_mem->mem_type == TTM_PL_SYSTEM && in vmw_query_move_notify()
851 old_mem->mem_type == VMW_PL_MOB) { in vmw_query_move_notify()
854 dx_query_mob = to_vmw_bo(&bo->base); in vmw_query_move_notify()
855 if (!dx_query_mob || !dx_query_mob->dx_query_ctx) { in vmw_query_move_notify()
856 mutex_unlock(&dev_priv->binding_mutex); in vmw_query_move_notify()
861 mutex_unlock(&dev_priv->binding_mutex); in vmw_query_move_notify()
872 mutex_unlock(&dev_priv->binding_mutex); in vmw_query_move_notify()
876 * vmw_resource_needs_backup - Return whether a resource needs a backup buffer.
878 * @res: The resource being queried.
882 return res->func->needs_guest_memory; in vmw_resource_needs_backup()
886 * vmw_resource_evict_type - Evict all resources of a specific type
889 * @type: The resource type to evict
897 struct list_head *lru_list = &dev_priv->res_lru[type]; in vmw_resource_evict_type()
904 spin_lock(&dev_priv->resource_lock); in vmw_resource_evict_type()
912 list_del_init(&evict_res->lru_head); in vmw_resource_evict_type()
913 spin_unlock(&dev_priv->resource_lock); in vmw_resource_evict_type()
918 spin_lock(&dev_priv->resource_lock); in vmw_resource_evict_type()
919 list_add_tail(&evict_res->lru_head, lru_list); in vmw_resource_evict_type()
920 spin_unlock(&dev_priv->resource_lock); in vmw_resource_evict_type()
931 spin_unlock(&dev_priv->resource_lock); in vmw_resource_evict_type()
935 * vmw_resource_evict_all - Evict all evictable resources
941 * guest-backed resources that are registered with the device are
948 mutex_lock(&dev_priv->cmdbuf_mutex); in vmw_resource_evict_all()
953 mutex_unlock(&dev_priv->cmdbuf_mutex); in vmw_resource_evict_all()
957 * vmw_resource_pin - Add a pin reference on a resource
959 * @res: The resource to add a pin reference on
961 * This function adds a pin reference, and if needed validates the resource.
962 * Having a pin reference means that the resource can never be evicted, and
963 * its id will never change as long as there is a pin reference.
969 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_pin()
972 mutex_lock(&dev_priv->cmdbuf_mutex); in vmw_resource_pin()
977 if (res->pin_count == 0) { in vmw_resource_pin()
980 if (res->guest_memory_bo) { in vmw_resource_pin()
981 vbo = res->guest_memory_bo; in vmw_resource_pin()
983 ret = ttm_bo_reserve(&vbo->tbo, interruptible, false, NULL); in vmw_resource_pin()
986 if (!vbo->tbo.pin_count) { in vmw_resource_pin()
988 res->func->domain, in vmw_resource_pin()
989 res->func->busy_domain); in vmw_resource_pin()
991 (&vbo->tbo, in vmw_resource_pin()
992 &vbo->placement, in vmw_resource_pin()
995 ttm_bo_unreserve(&vbo->tbo); in vmw_resource_pin()
1005 ttm_bo_unreserve(&vbo->tbo); in vmw_resource_pin()
1009 res->pin_count++; in vmw_resource_pin()
1014 mutex_unlock(&dev_priv->cmdbuf_mutex); in vmw_resource_pin()
1020 * vmw_resource_unpin - Remove a pin reference from a resource
1022 * @res: The resource to remove a pin reference from
1024 * Having a pin reference means that the resource can never be evicted, and
1025 * its id will never change as long as there is a pin reference.
1029 struct vmw_private *dev_priv = res->dev_priv; in vmw_resource_unpin()
1032 mutex_lock(&dev_priv->cmdbuf_mutex); in vmw_resource_unpin()
1037 WARN_ON(res->pin_count == 0); in vmw_resource_unpin()
1038 if (--res->pin_count == 0 && res->guest_memory_bo) { in vmw_resource_unpin()
1039 struct vmw_bo *vbo = res->guest_memory_bo; in vmw_resource_unpin()
1041 (void) ttm_bo_reserve(&vbo->tbo, false, false, NULL); in vmw_resource_unpin()
1043 ttm_bo_unreserve(&vbo->tbo); in vmw_resource_unpin()
1048 mutex_unlock(&dev_priv->cmdbuf_mutex); in vmw_resource_unpin()
1052 * vmw_res_type - Return the resource type
1054 * @res: Pointer to the resource
1058 return res->func->res_type; in vmw_res_type()
1062 * vmw_resource_dirty_update - Update a resource's dirty tracker with a
1064 * @res: The resource.
1071 if (res->dirty) in vmw_resource_dirty_update()
1072 res->func->dirty_range_add(res, start << PAGE_SHIFT, in vmw_resource_dirty_update()
1080 if (res->res_dirty) { in vmw_resource_clean()
1081 if (!res->func->clean) in vmw_resource_clean()
1082 return -EINVAL; in vmw_resource_clean()
1084 ret = res->func->clean(res); in vmw_resource_clean()
1087 res->res_dirty = false; in vmw_resource_clean()
1093 * vmw_resources_clean - Clean resources intersecting a mob range
1103 struct rb_node *cur = vbo->res_tree.rb_node; in vmw_resources_clean()
1111 * Find the resource with lowest backup_offset that intersects the in vmw_resources_clean()
1118 if (cur_res->guest_memory_offset >= res_end) { in vmw_resources_clean()
1119 cur = cur->rb_left; in vmw_resources_clean()
1120 } else if (cur_res->guest_memory_offset + cur_res->guest_memory_size <= in vmw_resources_clean()
1122 cur = cur->rb_right; in vmw_resources_clean()
1125 cur = cur->rb_left; in vmw_resources_clean()
1138 last_cleaned = found->guest_memory_offset + found->guest_memory_size; in vmw_resources_clean()
1139 cur = rb_next(&found->mob_node); in vmw_resources_clean()
1144 if (found->guest_memory_offset >= res_end) in vmw_resources_clean()
1153 struct ttm_buffer_object *bo = &vbo->tbo; in vmw_resources_clean()
1155 *num_prefault = __KERNEL_DIV_ROUND_UP(last_cleaned - res_start, in vmw_resources_clean()