Lines Matching refs:vma_res
53 struct i915_vma_resource *vma_res = in i915_vma_resource_alloc() local
56 return vma_res ? vma_res : ERR_PTR(-ENOMEM); in i915_vma_resource_alloc()
63 void i915_vma_resource_free(struct i915_vma_resource *vma_res) in i915_vma_resource_free() argument
65 if (vma_res) in i915_vma_resource_free()
66 kmem_cache_free(slab_vma_resources, vma_res); in i915_vma_resource_free()
81 struct i915_vma_resource *vma_res = in unbind_fence_free_rcu() local
82 container_of(head, typeof(*vma_res), unbind_fence.rcu); in unbind_fence_free_rcu()
84 i915_vma_resource_free(vma_res); in unbind_fence_free_rcu()
89 struct i915_vma_resource *vma_res = in unbind_fence_release() local
90 container_of(fence, typeof(*vma_res), unbind_fence); in unbind_fence_release()
92 i915_sw_fence_fini(&vma_res->chain); in unbind_fence_release()
103 static void __i915_vma_resource_unhold(struct i915_vma_resource *vma_res) in __i915_vma_resource_unhold() argument
107 if (!refcount_dec_and_test(&vma_res->hold_count)) in __i915_vma_resource_unhold()
110 dma_fence_signal(&vma_res->unbind_fence); in __i915_vma_resource_unhold()
112 vm = vma_res->vm; in __i915_vma_resource_unhold()
113 if (vma_res->wakeref) in __i915_vma_resource_unhold()
114 intel_runtime_pm_put(&vm->i915->runtime_pm, vma_res->wakeref); in __i915_vma_resource_unhold()
116 vma_res->vm = NULL; in __i915_vma_resource_unhold()
117 if (!RB_EMPTY_NODE(&vma_res->rb)) { in __i915_vma_resource_unhold()
119 vma_res_itree_remove(vma_res, &vm->pending_unbind); in __i915_vma_resource_unhold()
123 if (vma_res->bi.pages_rsgt) in __i915_vma_resource_unhold()
124 i915_refct_sgt_put(vma_res->bi.pages_rsgt); in __i915_vma_resource_unhold()
135 void i915_vma_resource_unhold(struct i915_vma_resource *vma_res, in i915_vma_resource_unhold() argument
144 spin_lock_irqsave(&vma_res->lock, irq_flags); in i915_vma_resource_unhold()
145 spin_unlock_irqrestore(&vma_res->lock, irq_flags); in i915_vma_resource_unhold()
148 __i915_vma_resource_unhold(vma_res); in i915_vma_resource_unhold()
162 bool i915_vma_resource_hold(struct i915_vma_resource *vma_res, in i915_vma_resource_hold() argument
165 bool held = refcount_inc_not_zero(&vma_res->hold_count); in i915_vma_resource_hold()
175 struct i915_vma_resource *vma_res = in i915_vma_resource_unbind_work() local
176 container_of(work, typeof(*vma_res), work); in i915_vma_resource_unbind_work()
177 struct i915_address_space *vm = vma_res->vm; in i915_vma_resource_unbind_work()
181 if (likely(!vma_res->skip_pte_rewrite)) in i915_vma_resource_unbind_work()
182 vma_res->ops->unbind_vma(vm, vma_res); in i915_vma_resource_unbind_work()
185 __i915_vma_resource_unhold(vma_res); in i915_vma_resource_unbind_work()
186 i915_vma_resource_put(vma_res); in i915_vma_resource_unbind_work()
193 struct i915_vma_resource *vma_res = in i915_vma_resource_fence_notify() local
194 container_of(fence, typeof(*vma_res), chain); in i915_vma_resource_fence_notify()
196 &vma_res->unbind_fence; in i915_vma_resource_fence_notify()
201 if (vma_res->immediate_unbind) { in i915_vma_resource_fence_notify()
202 i915_vma_resource_unbind_work(&vma_res->work); in i915_vma_resource_fence_notify()
204 INIT_WORK(&vma_res->work, i915_vma_resource_unbind_work); in i915_vma_resource_fence_notify()
205 queue_work(system_unbound_wq, &vma_res->work); in i915_vma_resource_fence_notify()
209 i915_vma_resource_put(vma_res); in i915_vma_resource_fence_notify()
230 struct dma_fence *i915_vma_resource_unbind(struct i915_vma_resource *vma_res, in i915_vma_resource_unbind() argument
233 struct i915_address_space *vm = vma_res->vm; in i915_vma_resource_unbind()
235 vma_res->tlb = tlb; in i915_vma_resource_unbind()
238 i915_vma_resource_get(vma_res); in i915_vma_resource_unbind()
241 if (vma_res->needs_wakeref) in i915_vma_resource_unbind()
242 vma_res->wakeref = intel_runtime_pm_get_if_in_use(&vm->i915->runtime_pm); in i915_vma_resource_unbind()
244 if (atomic_read(&vma_res->chain.pending) <= 1) { in i915_vma_resource_unbind()
245 RB_CLEAR_NODE(&vma_res->rb); in i915_vma_resource_unbind()
246 vma_res->immediate_unbind = 1; in i915_vma_resource_unbind()
248 vma_res_itree_insert(vma_res, &vma_res->vm->pending_unbind); in i915_vma_resource_unbind()
251 i915_sw_fence_commit(&vma_res->chain); in i915_vma_resource_unbind()
253 return &vma_res->unbind_fence; in i915_vma_resource_unbind()
262 void __i915_vma_resource_init(struct i915_vma_resource *vma_res) in __i915_vma_resource_init() argument
264 spin_lock_init(&vma_res->lock); in __i915_vma_resource_init()
265 dma_fence_init(&vma_res->unbind_fence, &unbind_fence_ops, in __i915_vma_resource_init()
266 &vma_res->lock, 0, 0); in __i915_vma_resource_init()
267 refcount_set(&vma_res->hold_count, 1); in __i915_vma_resource_init()
268 i915_sw_fence_init(&vma_res->chain, i915_vma_resource_fence_notify); in __i915_vma_resource_init()