Lines Matching full:vm
15 struct drm_i915_gem_object *alloc_pt_lmem(struct i915_address_space *vm, int sz) in alloc_pt_lmem() argument
31 obj = __i915_gem_object_create_lmem_with_ps(vm->i915, sz, sz, 0); in alloc_pt_lmem()
33 * Ensure all paging structures for this vm share the same dma-resv in alloc_pt_lmem()
38 obj->base.resv = i915_vm_resv_get(vm); in alloc_pt_lmem()
39 obj->shares_resv_from = vm; in alloc_pt_lmem()
45 struct drm_i915_gem_object *alloc_pt_dma(struct i915_address_space *vm, int sz) in alloc_pt_dma() argument
49 if (I915_SELFTEST_ONLY(should_fail(&vm->fault_attr, 1))) in alloc_pt_dma()
50 i915_gem_shrink_all(vm->i915); in alloc_pt_dma()
52 obj = i915_gem_object_create_internal(vm->i915, sz); in alloc_pt_dma()
54 * Ensure all paging structures for this vm share the same dma-resv in alloc_pt_dma()
59 obj->base.resv = i915_vm_resv_get(vm); in alloc_pt_dma()
60 obj->shares_resv_from = vm; in alloc_pt_dma()
66 int map_pt_dma(struct i915_address_space *vm, struct drm_i915_gem_object *obj) in map_pt_dma() argument
71 type = i915_coherent_map_type(vm->i915, obj, true); in map_pt_dma()
80 int map_pt_dma_locked(struct i915_address_space *vm, struct drm_i915_gem_object *obj) in map_pt_dma_locked() argument
85 type = i915_coherent_map_type(vm->i915, obj, true); in map_pt_dma_locked()
94 void __i915_vm_close(struct i915_address_space *vm) in __i915_vm_close() argument
98 if (!atomic_dec_and_mutex_lock(&vm->open, &vm->mutex)) in __i915_vm_close()
101 list_for_each_entry_safe(vma, vn, &vm->bound_list, vm_link) { in __i915_vm_close()
114 GEM_BUG_ON(!list_empty(&vm->bound_list)); in __i915_vm_close()
116 mutex_unlock(&vm->mutex); in __i915_vm_close()
119 /* lock the vm into the current ww, if we lock one, we lock all */
120 int i915_vm_lock_objects(struct i915_address_space *vm, in i915_vm_lock_objects() argument
123 if (vm->scratch[0]->base.resv == &vm->_resv) { in i915_vm_lock_objects()
124 return i915_gem_object_lock(vm->scratch[0], ww); in i915_vm_lock_objects()
126 struct i915_ppgtt *ppgtt = i915_vm_to_ppgtt(vm); in i915_vm_lock_objects()
133 void i915_address_space_fini(struct i915_address_space *vm) in i915_address_space_fini() argument
135 drm_mm_takedown(&vm->mm); in i915_address_space_fini()
136 mutex_destroy(&vm->mutex); in i915_address_space_fini()
148 struct i915_address_space *vm = in i915_vm_resv_release() local
149 container_of(kref, typeof(*vm), resv_ref); in i915_vm_resv_release()
151 dma_resv_fini(&vm->_resv); in i915_vm_resv_release()
152 kfree(vm); in i915_vm_resv_release()
157 struct i915_address_space *vm = in __i915_vm_release() local
160 vm->cleanup(vm); in __i915_vm_release()
161 i915_address_space_fini(vm); in __i915_vm_release()
163 i915_vm_resv_put(vm); in __i915_vm_release()
168 struct i915_address_space *vm = in i915_vm_release() local
171 GEM_BUG_ON(i915_is_ggtt(vm)); in i915_vm_release()
172 trace_i915_ppgtt_release(vm); in i915_vm_release()
174 queue_rcu_work(vm->i915->wq, &vm->rcu); in i915_vm_release()
177 void i915_address_space_init(struct i915_address_space *vm, int subclass) in i915_address_space_init() argument
179 kref_init(&vm->ref); in i915_address_space_init()
185 if (!kref_read(&vm->resv_ref)) in i915_address_space_init()
186 kref_init(&vm->resv_ref); in i915_address_space_init()
188 INIT_RCU_WORK(&vm->rcu, __i915_vm_release); in i915_address_space_init()
189 atomic_set(&vm->open, 1); in i915_address_space_init()
192 * The vm->mutex must be reclaim safe (for use in the shrinker). in i915_address_space_init()
196 mutex_init(&vm->mutex); in i915_address_space_init()
197 lockdep_set_subclass(&vm->mutex, subclass); in i915_address_space_init()
199 if (!intel_vm_no_concurrent_access_wa(vm->i915)) { in i915_address_space_init()
200 i915_gem_shrinker_taints_mutex(vm->i915, &vm->mutex); in i915_address_space_init()
204 * which is allowed to allocate memory. This means &vm->mutex in i915_address_space_init()
210 mutex_acquire(&vm->mutex.dep_map, 0, 0, _THIS_IP_); in i915_address_space_init()
212 mutex_release(&vm->mutex.dep_map, _THIS_IP_); in i915_address_space_init()
214 dma_resv_init(&vm->_resv); in i915_address_space_init()
216 GEM_BUG_ON(!vm->total); in i915_address_space_init()
217 drm_mm_init(&vm->mm, 0, vm->total); in i915_address_space_init()
218 vm->mm.head_node.color = I915_COLOR_UNEVICTABLE; in i915_address_space_init()
220 INIT_LIST_HEAD(&vm->bound_list); in i915_address_space_init()
277 int setup_scratch_page(struct i915_address_space *vm) in setup_scratch_page() argument
289 * scratch (read-only) between all vm, we create one 64k scratch page in setup_scratch_page()
293 if (i915_vm_is_4lvl(vm) && in setup_scratch_page()
294 HAS_PAGE_SIZES(vm->i915, I915_GTT_PAGE_SIZE_64K)) in setup_scratch_page()
300 obj = vm->alloc_pt_dma(vm, size); in setup_scratch_page()
304 if (map_pt_dma(vm, obj)) in setup_scratch_page()
326 vm->scratch[0] = obj; in setup_scratch_page()
327 vm->scratch_order = get_order(size); in setup_scratch_page()
340 void free_scratch(struct i915_address_space *vm) in free_scratch() argument
344 for (i = 0; i <= vm->top; i++) in free_scratch()
345 i915_gem_object_put(vm->scratch[i]); in free_scratch()
538 __vm_create_scratch_for_read(struct i915_address_space *vm, unsigned long size) in __vm_create_scratch_for_read() argument
543 obj = i915_gem_object_create_internal(vm->i915, PAGE_ALIGN(size)); in __vm_create_scratch_for_read()
549 vma = i915_vma_instance(obj, vm, NULL); in __vm_create_scratch_for_read()
559 __vm_create_scratch_for_read_pinned(struct i915_address_space *vm, unsigned long size) in __vm_create_scratch_for_read_pinned() argument
564 vma = __vm_create_scratch_for_read(vm, size); in __vm_create_scratch_for_read_pinned()