Lines Matching refs:vma
98 struct i915_vma *vma; in i915_gem_get_aperture_ioctl() local
105 list_for_each_entry(vma, &ggtt->vm.bound_list, vm_link) in i915_gem_get_aperture_ioctl()
106 if (i915_vma_is_pinned(vma)) in i915_gem_get_aperture_ioctl()
107 pinned += vma->node.size; in i915_gem_get_aperture_ioctl()
124 struct i915_vma *vma; in i915_gem_object_unbind() local
129 if (list_empty(&obj->vma.list)) in i915_gem_object_unbind()
142 spin_lock(&obj->vma.lock); in i915_gem_object_unbind()
143 while (!ret && (vma = list_first_entry_or_null(&obj->vma.list, in i915_gem_object_unbind()
146 list_move_tail(&vma->obj_link, &still_in_list); in i915_gem_object_unbind()
147 if (!i915_vma_is_bound(vma, I915_VMA_BIND_MASK)) in i915_gem_object_unbind()
163 if (!i915_vm_tryget(vma->vm)) in i915_gem_object_unbind()
166 spin_unlock(&obj->vma.lock); in i915_gem_object_unbind()
176 assert_object_held(vma->obj); in i915_gem_object_unbind()
177 ret = i915_vma_unbind_async(vma, vm_trylock); in i915_gem_object_unbind()
181 !i915_vma_is_active(vma))) { in i915_gem_object_unbind()
183 if (mutex_trylock(&vma->vm->mutex)) { in i915_gem_object_unbind()
184 ret = __i915_vma_unbind(vma); in i915_gem_object_unbind()
185 mutex_unlock(&vma->vm->mutex); in i915_gem_object_unbind()
188 ret = i915_vma_unbind(vma); in i915_gem_object_unbind()
192 i915_vm_put(vma->vm); in i915_gem_object_unbind()
193 spin_lock(&obj->vma.lock); in i915_gem_object_unbind()
195 list_splice_init(&still_in_list, &obj->vma.list); in i915_gem_object_unbind()
196 spin_unlock(&obj->vma.lock); in i915_gem_object_unbind()
310 struct i915_vma *vma; in i915_gem_gtt_prepare() local
316 vma = ERR_PTR(-ENODEV); in i915_gem_gtt_prepare()
326 vma = i915_gem_object_ggtt_pin_ww(obj, &ww, NULL, 0, 0, in i915_gem_gtt_prepare()
330 if (vma == ERR_PTR(-EDEADLK)) { in i915_gem_gtt_prepare()
333 } else if (!IS_ERR(vma)) { in i915_gem_gtt_prepare()
334 node->start = i915_ggtt_offset(vma); in i915_gem_gtt_prepare()
341 vma = NULL; in i915_gem_gtt_prepare()
350 i915_vma_unpin(vma); in i915_gem_gtt_prepare()
362 return ret ? ERR_PTR(ret) : vma; in i915_gem_gtt_prepare()
367 struct i915_vma *vma) in i915_gem_gtt_cleanup() argument
377 i915_vma_unpin(vma); in i915_gem_gtt_cleanup()
391 struct i915_vma *vma; in i915_gem_gtt_pread() local
400 vma = i915_gem_gtt_prepare(obj, &node, false); in i915_gem_gtt_pread()
401 if (IS_ERR(vma)) { in i915_gem_gtt_pread()
402 ret = PTR_ERR(vma); in i915_gem_gtt_pread()
443 i915_gem_gtt_cleanup(obj, &node, vma); in i915_gem_gtt_pread()
554 struct i915_vma *vma; in i915_gem_gtt_pwrite_fast() local
578 vma = i915_gem_gtt_prepare(obj, &node, true); in i915_gem_gtt_pwrite_fast()
579 if (IS_ERR(vma)) { in i915_gem_gtt_pwrite_fast()
580 ret = PTR_ERR(vma); in i915_gem_gtt_pwrite_fast()
633 i915_gem_gtt_cleanup(obj, &node, vma); in i915_gem_gtt_pwrite_fast()
885 if (!reg->vma) in i915_gem_runtime_suspend()
888 GEM_BUG_ON(i915_vma_has_userfault(reg->vma)); in i915_gem_runtime_suspend()
893 static void discard_ggtt_vma(struct i915_vma *vma) in discard_ggtt_vma() argument
895 struct drm_i915_gem_object *obj = vma->obj; in discard_ggtt_vma()
897 spin_lock(&obj->vma.lock); in discard_ggtt_vma()
898 if (!RB_EMPTY_NODE(&vma->obj_node)) { in discard_ggtt_vma()
899 rb_erase(&vma->obj_node, &obj->vma.tree); in discard_ggtt_vma()
900 RB_CLEAR_NODE(&vma->obj_node); in discard_ggtt_vma()
902 spin_unlock(&obj->vma.lock); in discard_ggtt_vma()
913 struct i915_vma *vma; in i915_gem_object_ggtt_pin_ww() local
953 vma = i915_vma_instance(obj, &ggtt->vm, view); in i915_gem_object_ggtt_pin_ww()
954 if (IS_ERR(vma)) in i915_gem_object_ggtt_pin_ww()
955 return vma; in i915_gem_object_ggtt_pin_ww()
957 if (i915_vma_misplaced(vma, size, alignment, flags)) { in i915_gem_object_ggtt_pin_ww()
959 if (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)) in i915_gem_object_ggtt_pin_ww()
973 (vma->fence_size > ggtt->mappable_end / 2 || in i915_gem_object_ggtt_pin_ww()
974 !i915_vma_is_map_and_fenceable(vma))) in i915_gem_object_ggtt_pin_ww()
978 if (i915_vma_is_pinned(vma) || i915_vma_is_active(vma)) { in i915_gem_object_ggtt_pin_ww()
979 discard_ggtt_vma(vma); in i915_gem_object_ggtt_pin_ww()
983 ret = i915_vma_unbind(vma); in i915_gem_object_ggtt_pin_ww()
988 ret = i915_vma_pin_ww(vma, ww, size, alignment, flags | PIN_GLOBAL); in i915_gem_object_ggtt_pin_ww()
993 if (vma->fence && !i915_gem_object_is_tiled(obj)) { in i915_gem_object_ggtt_pin_ww()
995 i915_vma_revoke_fence(vma); in i915_gem_object_ggtt_pin_ww()
999 ret = i915_vma_wait_for_bind(vma); in i915_gem_object_ggtt_pin_ww()
1001 i915_vma_unpin(vma); in i915_gem_object_ggtt_pin_ww()
1005 return vma; in i915_gem_object_ggtt_pin_ww()