Lines Matching refs:vm

41 struct drm_i915_gem_object *alloc_pt_lmem(struct i915_address_space *vm, int sz)
57 obj = __i915_gem_object_create_lmem_with_ps(vm->i915, sz, sz,
58 vm->lmem_pt_obj_flags);
60 * Ensure all paging structures for this vm share the same dma-resv
65 obj->base.resv = i915_vm_resv_get(vm);
66 obj->shares_resv_from = vm;
68 if (vm->fpriv)
69 i915_drm_client_add_object(vm->fpriv->client, obj);
75 struct drm_i915_gem_object *alloc_pt_dma(struct i915_address_space *vm, int sz)
79 if (I915_SELFTEST_ONLY(should_fail(&vm->fault_attr, 1)))
80 i915_gem_shrink_all(vm->i915);
82 obj = i915_gem_object_create_internal(vm->i915, sz);
84 * Ensure all paging structures for this vm share the same dma-resv
89 obj->base.resv = i915_vm_resv_get(vm);
90 obj->shares_resv_from = vm;
92 if (vm->fpriv)
93 i915_drm_client_add_object(vm->fpriv->client, obj);
99 int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
104 type = intel_gt_coherent_map_type(vm->gt, obj, true);
112 if (IS_METEORLAKE(vm->i915))
123 int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object *obj)
128 type = intel_gt_coherent_map_type(vm->gt, obj, true);
136 if (IS_METEORLAKE(vm->i915))
170 * Delay the vm and vm mutex freeing until the
173 i915_vm_resv_get(vma->vm);
183 static void __i915_vm_close(struct i915_address_space *vm)
185 mutex_lock(&vm->mutex);
187 clear_vm_list(&vm->bound_list);
188 clear_vm_list(&vm->unbound_list);
191 GEM_BUG_ON(!list_empty(&vm->bound_list));
192 GEM_BUG_ON(!list_empty(&vm->unbound_list));
194 mutex_unlock(&vm->mutex);
197 /* lock the vm into the current ww, if we lock one, we lock all */
198 int i915_vm_lock_objects(struct i915_address_space *vm,
201 if (vm->scratch[0]->base.resv == &vm->_resv) {
202 return i915_gem_object_lock(vm->scratch[0], ww);
204 struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm);
211 void i915_address_space_fini(struct i915_address_space *vm)
213 drm_mm_takedown(&vm->mm);
226 struct i915_address_space *vm =
227 container_of(kref, typeof(*vm), resv_ref);
229 dma_resv_fini(&vm->_resv);
230 mutex_destroy(&vm->mutex);
232 kfree(vm);
237 struct i915_address_space *vm =
240 __i915_vm_close(vm);
243 i915_vma_resource_bind_dep_sync_all(vm);
245 vm->cleanup(vm);
246 i915_address_space_fini(vm);
248 i915_vm_resv_put(vm);
253 struct i915_address_space *vm =
256 GEM_BUG_ON(i915_is_ggtt(vm));
257 trace_i915_ppgtt_release(vm);
259 queue_work(vm->i915->wq, &vm->release_work);
262 void i915_address_space_init(struct i915_address_space *vm, int subclass)
264 kref_init(&vm->ref);
270 if (!kref_read(&vm->resv_ref))
271 kref_init(&vm->resv_ref);
273 vm->pending_unbind = RB_ROOT_CACHED;
274 INIT_WORK(&vm->release_work, __i915_vm_release);
277 * The vm->mutex must be reclaim safe (for use in the shrinker).
281 mutex_init(&vm->mutex);
282 lockdep_set_subclass(&vm->mutex, subclass);
284 if (!intel_vm_no_concurrent_access_wa(vm->i915)) {
285 i915_gem_shrinker_taints_mutex(vm->i915, &vm->mutex);
289 * which is allowed to allocate memory. This means &vm->mutex
295 mutex_acquire(&vm->mutex.dep_map, 0, 0, _THIS_IP_);
297 mutex_release(&vm->mutex.dep_map, _THIS_IP_);
299 dma_resv_init(&vm->_resv);
301 GEM_BUG_ON(!vm->total);
302 drm_mm_init(&vm->mm, 0, vm->total);
304 memset64(vm->min_alignment, I915_GTT_MIN_ALIGNMENT,
305 ARRAY_SIZE(vm->min_alignment));
307 if (HAS_64K_PAGES(vm->i915)) {
308 vm->min_alignment[INTEL_MEMORY_LOCAL] = I915_GTT_PAGE_SIZE_64K;
309 vm->min_alignment[INTEL_MEMORY_STOLEN_LOCAL] = I915_GTT_PAGE_SIZE_64K;
312 vm->mm.head_node.color = I915_COLOR_UNEVICTABLE;
314 INIT_LIST_HEAD(&vm->bound_list);
315 INIT_LIST_HEAD(&vm->unbound_list);
360 int setup_scratch_page(struct i915_address_space *vm)
372 * scratch (read-only) between all vm, we create one 64k scratch page
376 if (i915_vm_is_4lvl(vm) &&
377 HAS_PAGE_SIZES(vm->i915, I915_GTT_PAGE_SIZE_64K) &&
378 !HAS_64K_PAGES(vm->i915))
384 obj = vm->alloc_scratch_dma(vm, size);
388 if (map_pt_dma(vm, obj))
410 vm->scratch[0] = obj;
411 vm->scratch_order = get_order(size);
424 void free_scratch(struct i915_address_space *vm)
428 if (!vm->scratch[0])
431 for (i = 0; i <= vm->top; i++)
432 i915_gem_object_put(vm->scratch[i]);
696 __vm_create_scratch_for_read(struct i915_address_space *vm, unsigned long size)
701 obj = i915_gem_object_create_internal(vm->i915, PAGE_ALIGN(size));
707 vma = i915_vma_instance(obj, vm, NULL);
717 __vm_create_scratch_for_read_pinned(struct i915_address_space *vm, unsigned long size)
722 vma = __vm_create_scratch_for_read(vm, size);