Lines Matching refs:vma

41 static bool dying_vma(struct i915_vma *vma)
43 return !kref_read(&vma->obj->base.refcount);
54 * Not everything in the GGTT is tracked via vma (otherwise we
67 static bool grab_vma(struct i915_vma *vma, struct i915_gem_ww_ctx *ww)
73 if (i915_gem_object_get_rcu(vma->obj)) {
74 if (!i915_gem_object_trylock(vma->obj, ww)) {
75 i915_gem_object_put(vma->obj);
80 atomic_and(~I915_VMA_PIN_MASK, &vma->flags);
86 static void ungrab_vma(struct i915_vma *vma)
88 if (dying_vma(vma))
91 i915_gem_object_unlock(vma->obj);
92 i915_gem_object_put(vma->obj);
98 struct i915_vma *vma,
102 if (i915_vma_is_pinned(vma))
105 if (!grab_vma(vma, ww))
108 list_add(&vma->evict_link, unwind);
109 return drm_mm_scan_add_block(scan, &vma->node);
112 static bool defer_evict(struct i915_vma *vma)
114 if (i915_vma_is_active(vma))
117 if (i915_vma_is_scanout(vma))
138 * This function is used by the object/vma binding code.
157 struct i915_vma *vma, *next;
199 list_for_each_entry_safe(vma, next, &vm->bound_list, vm_link) {
200 if (vma == active) { /* now seen this vma twice */
222 if (active != ERR_PTR(-EAGAIN) && defer_evict(vma)) {
224 active = vma;
226 list_move_tail(&vma->vm_link, &vm->bound_list);
230 if (mark_free(&scan, ww, vma, flags, &eviction_list))
235 list_for_each_entry_safe(vma, next, &eviction_list, evict_link) {
236 ret = drm_mm_scan_remove_block(&scan, &vma->node);
238 ungrab_vma(vma);
282 list_for_each_entry_safe(vma, next, &eviction_list, evict_link) {
283 if (drm_mm_scan_remove_block(&scan, &vma->node)) {
284 __i915_vma_pin(vma);
286 list_del(&vma->evict_link);
287 ungrab_vma(vma);
293 list_for_each_entry_safe(vma, next, &eviction_list, evict_link) {
294 __i915_vma_unpin(vma);
296 ret = __i915_vma_unbind(vma);
297 ungrab_vma(vma);
301 vma = container_of(node, struct i915_vma, node);
303 /* If we find any non-objects (!vma), we cannot evict them */
304 if (vma->node.color != I915_COLOR_UNEVICTABLE &&
305 grab_vma(vma, ww)) {
306 ret = __i915_vma_unbind(vma);
307 ungrab_vma(vma);
337 struct i915_vma *vma, *next;
373 /* If we find any non-objects (!vma), we cannot evict them */
380 vma = container_of(node, typeof(*vma), node);
400 if (i915_vma_is_pinned(vma)) {
405 if (flags & PIN_NONBLOCK && i915_vma_is_active(vma)) {
410 if (!grab_vma(vma, ww)) {
420 * the vma pin_count in order to prevent the action of
421 * unbinding one vma from freeing (by dropping its active
424 __i915_vma_pin(vma);
425 list_add(&vma->evict_link, &eviction_list);
428 list_for_each_entry_safe(vma, next, &eviction_list, evict_link) {
429 __i915_vma_unpin(vma);
431 ret = __i915_vma_unbind(vma);
433 ungrab_vma(vma);
443 * will be able to evict vma's locked by the ww as well.
478 struct i915_vma *vma, *vn;
482 list_for_each_entry(vma, &vm->bound_list, vm_link) {
483 if (i915_vma_is_pinned(vma))
491 if (!i915_gem_object_get_rcu(vma->obj) ||
492 (ww && (dma_resv_locking_ctx(vma->obj->base.resv) == &ww->ctx))) {
493 __i915_vma_pin(vma);
494 list_add(&vma->evict_link, &locked_eviction_list);
498 if (!i915_gem_object_trylock(vma->obj, ww)) {
500 *busy_bo = vma->obj; /* holds ref */
504 i915_gem_object_put(vma->obj);
508 __i915_vma_pin(vma);
509 list_add(&vma->evict_link, &eviction_list);
515 list_for_each_entry_safe(vma, vn, &locked_eviction_list, evict_link) {
516 __i915_vma_unpin(vma);
519 ret = __i915_vma_unbind(vma);
523 if (!dying_vma(vma))
524 i915_gem_object_put(vma->obj);
527 list_for_each_entry_safe(vma, vn, &eviction_list, evict_link) {
528 __i915_vma_unpin(vma);
530 ret = __i915_vma_unbind(vma);
535 i915_gem_object_unlock(vma->obj);
536 i915_gem_object_put(vma->obj);