Lines Matching refs:vm
18 struct lima_vm *vm; member
35 static void lima_vm_unmap_range(struct lima_vm *vm, u32 start, u32 end) in lima_vm_unmap_range() argument
43 vm->bts[pbe].cpu[bte] = 0; in lima_vm_unmap_range()
47 static int lima_vm_map_page(struct lima_vm *vm, dma_addr_t pa, u32 va) in lima_vm_map_page() argument
52 if (!vm->bts[pbe].cpu) { in lima_vm_map_page()
57 vm->bts[pbe].cpu = dma_alloc_wc( in lima_vm_map_page()
58 vm->dev->dev, LIMA_PAGE_SIZE << LIMA_VM_NUM_PT_PER_BT_SHIFT, in lima_vm_map_page()
59 &vm->bts[pbe].dma, GFP_KERNEL | __GFP_NOWARN | __GFP_ZERO); in lima_vm_map_page()
60 if (!vm->bts[pbe].cpu) in lima_vm_map_page()
63 pts = vm->bts[pbe].dma; in lima_vm_map_page()
64 pd = vm->pd.cpu + (pbe << LIMA_VM_NUM_PT_PER_BT_SHIFT); in lima_vm_map_page()
71 vm->bts[pbe].cpu[bte] = pa | LIMA_VM_FLAGS_CACHE; in lima_vm_map_page()
77 lima_vm_bo_find(struct lima_vm *vm, struct lima_bo *bo) in lima_vm_bo_find() argument
82 if (bo_va->vm == vm) { in lima_vm_bo_find()
91 int lima_vm_bo_add(struct lima_vm *vm, struct lima_bo *bo, bool create) in lima_vm_bo_add() argument
99 bo_va = lima_vm_bo_find(vm, bo); in lima_vm_bo_add()
118 bo_va->vm = vm; in lima_vm_bo_add()
121 mutex_lock(&vm->lock); in lima_vm_bo_add()
123 err = drm_mm_insert_node(&vm->mm, &bo_va->node, lima_bo_size(bo)); in lima_vm_bo_add()
128 err = lima_vm_map_page(vm, sg_page_iter_dma_address(&sg_iter), in lima_vm_bo_add()
136 mutex_unlock(&vm->lock); in lima_vm_bo_add()
145 lima_vm_unmap_range(vm, bo_va->node.start, bo_va->node.start + offset - 1); in lima_vm_bo_add()
148 mutex_unlock(&vm->lock); in lima_vm_bo_add()
155 void lima_vm_bo_del(struct lima_vm *vm, struct lima_bo *bo) in lima_vm_bo_del() argument
162 bo_va = lima_vm_bo_find(vm, bo); in lima_vm_bo_del()
168 mutex_lock(&vm->lock); in lima_vm_bo_del()
171 lima_vm_unmap_range(vm, bo_va->node.start, in lima_vm_bo_del()
176 mutex_unlock(&vm->lock); in lima_vm_bo_del()
185 u32 lima_vm_get_va(struct lima_vm *vm, struct lima_bo *bo) in lima_vm_get_va() argument
192 bo_va = lima_vm_bo_find(vm, bo); in lima_vm_get_va()
202 struct lima_vm *vm; in lima_vm_create() local
204 vm = kzalloc(sizeof(*vm), GFP_KERNEL); in lima_vm_create()
205 if (!vm) in lima_vm_create()
208 vm->dev = dev; in lima_vm_create()
209 mutex_init(&vm->lock); in lima_vm_create()
210 kref_init(&vm->refcount); in lima_vm_create()
212 vm->pd.cpu = dma_alloc_wc(dev->dev, LIMA_PAGE_SIZE, &vm->pd.dma, in lima_vm_create()
214 if (!vm->pd.cpu) in lima_vm_create()
219 vm, dev->dlbu_dma, LIMA_VA_RESERVE_DLBU); in lima_vm_create()
224 drm_mm_init(&vm->mm, dev->va_start, dev->va_end - dev->va_start); in lima_vm_create()
226 return vm; in lima_vm_create()
229 dma_free_wc(dev->dev, LIMA_PAGE_SIZE, vm->pd.cpu, vm->pd.dma); in lima_vm_create()
231 kfree(vm); in lima_vm_create()
237 struct lima_vm *vm = container_of(kref, struct lima_vm, refcount); in lima_vm_release() local
240 drm_mm_takedown(&vm->mm); in lima_vm_release()
243 if (vm->bts[i].cpu) in lima_vm_release()
244 dma_free_wc(vm->dev->dev, LIMA_PAGE_SIZE << LIMA_VM_NUM_PT_PER_BT_SHIFT, in lima_vm_release()
245 vm->bts[i].cpu, vm->bts[i].dma); in lima_vm_release()
248 if (vm->pd.cpu) in lima_vm_release()
249 dma_free_wc(vm->dev->dev, LIMA_PAGE_SIZE, vm->pd.cpu, vm->pd.dma); in lima_vm_release()
251 kfree(vm); in lima_vm_release()
254 void lima_vm_print(struct lima_vm *vm) in lima_vm_print() argument
259 if (!vm->pd.cpu) in lima_vm_print()
262 pd = vm->pd.cpu; in lima_vm_print()
264 if (!vm->bts[i].cpu) in lima_vm_print()
267 pt = vm->bts[i].cpu; in lima_vm_print()
283 int lima_vm_map_bo(struct lima_vm *vm, struct lima_bo *bo, int pageoff) in lima_vm_map_bo() argument
292 bo_va = lima_vm_bo_find(vm, bo); in lima_vm_map_bo()
298 mutex_lock(&vm->lock); in lima_vm_map_bo()
302 err = lima_vm_map_page(vm, sg_page_iter_dma_address(&sg_iter), in lima_vm_map_bo()
310 mutex_unlock(&vm->lock); in lima_vm_map_bo()
317 lima_vm_unmap_range(vm, base, base + offset - 1); in lima_vm_map_bo()
318 mutex_unlock(&vm->lock); in lima_vm_map_bo()