Lines Matching refs:vma

51 static inline bool i915_vma_is_active(const struct i915_vma *vma)
53 return !i915_active_is_idle(&vma->active);
60 int __must_check _i915_vma_move_to_active(struct i915_vma *vma,
65 i915_vma_move_to_active(struct i915_vma *vma, struct i915_request *rq,
68 return _i915_vma_move_to_active(vma, rq, &rq->fence, flags);
73 static inline bool i915_vma_is_ggtt(const struct i915_vma *vma)
75 return test_bit(I915_VMA_GGTT_BIT, __i915_vma_flags(vma));
78 static inline bool i915_vma_is_dpt(const struct i915_vma *vma)
80 return i915_is_dpt(vma->vm);
83 static inline bool i915_vma_has_ggtt_write(const struct i915_vma *vma)
85 return test_bit(I915_VMA_GGTT_WRITE_BIT, __i915_vma_flags(vma));
88 static inline void i915_vma_set_ggtt_write(struct i915_vma *vma)
90 GEM_BUG_ON(!i915_vma_is_ggtt(vma));
91 set_bit(I915_VMA_GGTT_WRITE_BIT, __i915_vma_flags(vma));
94 static inline bool i915_vma_unset_ggtt_write(struct i915_vma *vma)
97 __i915_vma_flags(vma));
100 void i915_vma_flush_writes(struct i915_vma *vma);
102 static inline bool i915_vma_is_map_and_fenceable(const struct i915_vma *vma)
104 return test_bit(I915_VMA_CAN_FENCE_BIT, __i915_vma_flags(vma));
107 static inline bool i915_vma_set_userfault(struct i915_vma *vma)
109 GEM_BUG_ON(!i915_vma_is_map_and_fenceable(vma));
110 return test_and_set_bit(I915_VMA_USERFAULT_BIT, __i915_vma_flags(vma));
113 static inline void i915_vma_unset_userfault(struct i915_vma *vma)
115 return clear_bit(I915_VMA_USERFAULT_BIT, __i915_vma_flags(vma));
118 static inline bool i915_vma_has_userfault(const struct i915_vma *vma)
120 return test_bit(I915_VMA_USERFAULT_BIT, __i915_vma_flags(vma));
123 static inline bool i915_vma_is_closed(const struct i915_vma *vma)
125 return !list_empty(&vma->closed_link);
129 static inline u64 __i915_vma_size(const struct i915_vma *vma)
131 return vma->node.size - 2 * vma->guard;
135 * i915_vma_size - Obtain the va range size of the vma
136 * @vma: The vma
144 static inline u64 i915_vma_size(const struct i915_vma *vma)
146 GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
147 return __i915_vma_size(vma);
151 static inline u64 __i915_vma_offset(const struct i915_vma *vma)
153 /* The actual start of the vma->pages is after the guard pages. */
154 return vma->node.start + vma->guard;
158 * i915_vma_offset - Obtain the va offset of the vma
159 * @vma: The vma
167 static inline u64 i915_vma_offset(const struct i915_vma *vma)
169 GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
170 return __i915_vma_offset(vma);
173 static inline u32 i915_ggtt_offset(const struct i915_vma *vma)
175 GEM_BUG_ON(!i915_vma_is_ggtt(vma));
176 GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
177 GEM_BUG_ON(upper_32_bits(i915_vma_offset(vma)));
178 GEM_BUG_ON(upper_32_bits(i915_vma_offset(vma) +
179 i915_vma_size(vma) - 1));
180 return lower_32_bits(i915_vma_offset(vma));
183 static inline u32 i915_ggtt_pin_bias(struct i915_vma *vma)
185 return i915_vm_to_ggtt(vma->vm)->pin_bias;
188 static inline struct i915_vma *i915_vma_get(struct i915_vma *vma)
190 i915_gem_object_get(vma->obj);
191 return vma;
194 static inline struct i915_vma *i915_vma_tryget(struct i915_vma *vma)
196 if (likely(kref_get_unless_zero(&vma->obj->base.refcount)))
197 return vma;
202 static inline void i915_vma_put(struct i915_vma *vma)
204 i915_gem_object_put(vma->obj);
208 i915_vma_compare(struct i915_vma *vma,
216 cmp = ptrdiff(vma->vm, vm);
221 cmp = vma->gtt_view.type;
248 return memcmp(&vma->gtt_view.partial, &view->partial, view->type);
252 int i915_vma_bind(struct i915_vma *vma,
258 bool i915_gem_valid_gtt_space(struct i915_vma *vma, unsigned long color);
259 bool i915_vma_misplaced(const struct i915_vma *vma,
261 void __i915_vma_set_map_and_fenceable(struct i915_vma *vma);
262 void i915_vma_revoke_mmap(struct i915_vma *vma);
264 struct dma_fence *__i915_vma_evict(struct i915_vma *vma, bool async);
265 int __i915_vma_unbind(struct i915_vma *vma);
266 int __must_check i915_vma_unbind(struct i915_vma *vma);
267 int __must_check i915_vma_unbind_async(struct i915_vma *vma, bool trylock_vm);
268 int __must_check i915_vma_unbind_unlocked(struct i915_vma *vma);
269 void i915_vma_unlink_ctx(struct i915_vma *vma);
270 void i915_vma_close(struct i915_vma *vma);
271 void i915_vma_reopen(struct i915_vma *vma);
273 void i915_vma_destroy_locked(struct i915_vma *vma);
274 void i915_vma_destroy(struct i915_vma *vma);
276 #define assert_vma_held(vma) dma_resv_assert_held((vma)->obj->base.resv)
278 static inline void i915_vma_lock(struct i915_vma *vma)
280 dma_resv_lock(vma->obj->base.resv, NULL);
283 static inline void i915_vma_unlock(struct i915_vma *vma)
285 dma_resv_unlock(vma->obj->base.resv);
289 i915_vma_pin_ww(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
293 i915_vma_pin(struct i915_vma *vma, u64 size, u64 alignment, u64 flags)
300 err = i915_gem_object_lock(vma->obj, &ww);
302 err = i915_vma_pin_ww(vma, &ww, size, alignment, flags);
313 int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
316 static inline int i915_vma_pin_count(const struct i915_vma *vma)
318 return atomic_read(&vma->flags) & I915_VMA_PIN_MASK;
321 static inline bool i915_vma_is_pinned(const struct i915_vma *vma)
323 return i915_vma_pin_count(vma);
326 static inline void __i915_vma_pin(struct i915_vma *vma)
328 atomic_inc(&vma->flags);
329 GEM_BUG_ON(!i915_vma_is_pinned(vma));
332 static inline void __i915_vma_unpin(struct i915_vma *vma)
334 GEM_BUG_ON(!i915_vma_is_pinned(vma));
335 atomic_dec(&vma->flags);
338 static inline void i915_vma_unpin(struct i915_vma *vma)
340 GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
341 __i915_vma_unpin(vma);
344 static inline bool i915_vma_is_bound(const struct i915_vma *vma,
347 return atomic_read(&vma->flags) & where;
358 * @vma: VMA to iomap
367 void __iomem *i915_vma_pin_iomap(struct i915_vma *vma);
371 * @vma: VMA to unpin
378 void i915_vma_unpin_iomap(struct i915_vma *vma);
382 * @vma: vma to pin fencing for
385 * vma (and its object) is ready to be used as a scanout target. Fencing
393 * True if the vma has a fence, false otherwise.
395 int __must_check i915_vma_pin_fence(struct i915_vma *vma);
396 void i915_vma_revoke_fence(struct i915_vma *vma);
398 int __i915_vma_pin_fence(struct i915_vma *vma);
400 static inline void __i915_vma_unpin_fence(struct i915_vma *vma)
402 GEM_BUG_ON(atomic_read(&vma->fence->pin_count) <= 0);
403 atomic_dec(&vma->fence->pin_count);
408 * @vma: vma to unpin fencing for
415 i915_vma_unpin_fence(struct i915_vma *vma)
417 if (vma->fence)
418 __i915_vma_unpin_fence(vma);
421 static inline int i915_vma_fence_id(const struct i915_vma *vma)
423 return vma->fence ? vma->fence->id : -1;
428 static inline bool i915_vma_is_scanout(const struct i915_vma *vma)
430 return test_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
433 static inline void i915_vma_mark_scanout(struct i915_vma *vma)
435 set_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
438 static inline void i915_vma_clear_scanout(struct i915_vma *vma)
440 clear_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
457 list_for_each_entry(V, &(OBJ)->vma.list, obj_link) \
460 struct i915_vma *i915_vma_make_unshrinkable(struct i915_vma *vma);
461 void i915_vma_make_shrinkable(struct i915_vma *vma);
462 void i915_vma_make_purgeable(struct i915_vma *vma);
464 int i915_vma_wait_for_bind(struct i915_vma *vma);
466 static inline int i915_vma_sync(struct i915_vma *vma)
469 return i915_active_wait(&vma->active);
473 * i915_vma_get_current_resource - Get the current resource of the vma
474 * @vma: The vma to get the current resource from.
476 * It's illegal to call this function if the vma is not bound.
478 * Return: A refcounted pointer to the current vma resource
479 * of the vma, assuming the vma is bound.
482 i915_vma_get_current_resource(struct i915_vma *vma)
484 return i915_vma_resource_get(vma->resource);
489 struct i915_vma *vma);
495 I915_SELFTEST_DECLARE(int i915_vma_get_pages(struct i915_vma *vma));
496 I915_SELFTEST_DECLARE(void i915_vma_put_pages(struct i915_vma *vma));