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);
295 int i915_ggtt_pin(struct i915_vma *vma, struct i915_gem_ww_ctx *ww,
298 static inline int i915_vma_pin_count(const struct i915_vma *vma)
300 return atomic_read(&vma->flags) & I915_VMA_PIN_MASK;
303 static inline bool i915_vma_is_pinned(const struct i915_vma *vma)
305 return i915_vma_pin_count(vma);
308 static inline void __i915_vma_pin(struct i915_vma *vma)
310 atomic_inc(&vma->flags);
311 GEM_BUG_ON(!i915_vma_is_pinned(vma));
314 static inline void __i915_vma_unpin(struct i915_vma *vma)
316 GEM_BUG_ON(!i915_vma_is_pinned(vma));
317 atomic_dec(&vma->flags);
320 static inline void i915_vma_unpin(struct i915_vma *vma)
322 GEM_BUG_ON(!drm_mm_node_allocated(&vma->node));
323 __i915_vma_unpin(vma);
326 static inline bool i915_vma_is_bound(const struct i915_vma *vma,
329 return atomic_read(&vma->flags) & where;
338 static inline void __iomem *i915_vma_get_iomap(struct i915_vma *vma)
340 return READ_ONCE(vma->iomap);
345 * @vma: VMA to iomap
354 void __iomem *i915_vma_pin_iomap(struct i915_vma *vma);
358 * @vma: VMA to unpin
365 void i915_vma_unpin_iomap(struct i915_vma *vma);
369 * @vma: vma to pin fencing for
372 * vma (and its object) is ready to be used as a scanout target. Fencing
379 * True if the vma has a fence, false otherwise.
381 int __must_check i915_vma_pin_fence(struct i915_vma *vma);
382 void i915_vma_revoke_fence(struct i915_vma *vma);
384 int __i915_vma_pin_fence(struct i915_vma *vma);
386 static inline void __i915_vma_unpin_fence(struct i915_vma *vma)
388 GEM_BUG_ON(atomic_read(&vma->fence->pin_count) <= 0);
389 atomic_dec(&vma->fence->pin_count);
394 * @vma: vma to unpin fencing for
401 i915_vma_unpin_fence(struct i915_vma *vma)
403 if (vma->fence)
404 __i915_vma_unpin_fence(vma);
407 static inline int i915_vma_fence_id(const struct i915_vma *vma)
409 return vma->fence ? vma->fence->id : -1;
414 static inline bool i915_vma_is_scanout(const struct i915_vma *vma)
416 return test_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
419 static inline void i915_vma_mark_scanout(struct i915_vma *vma)
421 set_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
424 static inline void i915_vma_clear_scanout(struct i915_vma *vma)
426 clear_bit(I915_VMA_SCANOUT_BIT, __i915_vma_flags(vma));
443 list_for_each_entry(V, &(OBJ)->vma.list, obj_link) \
446 struct i915_vma *i915_vma_make_unshrinkable(struct i915_vma *vma);
447 void i915_vma_make_shrinkable(struct i915_vma *vma);
448 void i915_vma_make_purgeable(struct i915_vma *vma);
450 int i915_vma_wait_for_bind(struct i915_vma *vma);
452 static inline int i915_vma_sync(struct i915_vma *vma)
455 return i915_active_wait(&vma->active);
459 * i915_vma_get_current_resource - Get the current resource of the vma
460 * @vma: The vma to get the current resource from.
462 * It's illegal to call this function if the vma is not bound.
464 * Return: A refcounted pointer to the current vma resource
465 * of the vma, assuming the vma is bound.
468 i915_vma_get_current_resource(struct i915_vma *vma)
470 return i915_vma_resource_get(vma->resource);
475 struct i915_vma *vma);
481 I915_SELFTEST_DECLARE(int i915_vma_get_pages(struct i915_vma *vma));
482 I915_SELFTEST_DECLARE(void i915_vma_put_pages(struct i915_vma *vma));