Lines Matching refs:context

16 static void etnaviv_context_unmap(struct etnaviv_iommu_context *context,  in etnaviv_context_unmap()  argument
29 unmapped_page = context->global->ops->unmap(context, iova, in etnaviv_context_unmap()
39 static int etnaviv_context_map(struct etnaviv_iommu_context *context, in etnaviv_context_map() argument
55 ret = context->global->ops->map(context, iova, paddr, pgsize, in etnaviv_context_map()
67 etnaviv_context_unmap(context, orig_iova, orig_size - size); in etnaviv_context_map()
72 static int etnaviv_iommu_map(struct etnaviv_iommu_context *context, u32 iova, in etnaviv_iommu_map() argument
79 if (!context || !sgt) in etnaviv_iommu_map()
88 ret = etnaviv_context_map(context, da, pa, bytes, prot); in etnaviv_iommu_map()
95 context->flush_seq++; in etnaviv_iommu_map()
100 etnaviv_context_unmap(context, iova, da - iova); in etnaviv_iommu_map()
104 static void etnaviv_iommu_unmap(struct etnaviv_iommu_context *context, u32 iova, in etnaviv_iommu_unmap() argument
114 etnaviv_context_unmap(context, da, bytes); in etnaviv_iommu_unmap()
123 context->flush_seq++; in etnaviv_iommu_unmap()
126 static void etnaviv_iommu_remove_mapping(struct etnaviv_iommu_context *context, in etnaviv_iommu_remove_mapping() argument
131 lockdep_assert_held(&context->lock); in etnaviv_iommu_remove_mapping()
133 etnaviv_iommu_unmap(context, mapping->vram_node.start, in etnaviv_iommu_remove_mapping()
140 struct etnaviv_iommu_context *context = mapping->context; in etnaviv_iommu_reap_mapping() local
142 lockdep_assert_held(&context->lock); in etnaviv_iommu_reap_mapping()
145 etnaviv_iommu_remove_mapping(context, mapping); in etnaviv_iommu_reap_mapping()
146 etnaviv_iommu_context_put(mapping->context); in etnaviv_iommu_reap_mapping()
147 mapping->context = NULL; in etnaviv_iommu_reap_mapping()
151 static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context, in etnaviv_iommu_find_iova() argument
158 lockdep_assert_held(&context->lock); in etnaviv_iommu_find_iova()
166 ret = drm_mm_insert_node_in_range(&context->mm, node, in etnaviv_iommu_find_iova()
172 drm_mm_scan_init(&scan, &context->mm, size, 0, 0, mode); in etnaviv_iommu_find_iova()
176 list_for_each_entry(free, &context->mappings, mmu_node) { in etnaviv_iommu_find_iova()
233 static int etnaviv_iommu_insert_exact(struct etnaviv_iommu_context *context, in etnaviv_iommu_insert_exact() argument
241 lockdep_assert_held(&context->lock); in etnaviv_iommu_insert_exact()
243 ret = drm_mm_insert_node_in_range(&context->mm, node, size, 0, 0, va, in etnaviv_iommu_insert_exact()
259 drm_mm_for_each_node_in_range(scan_node, &context->mm, va, va + size) { in etnaviv_iommu_insert_exact()
274 return drm_mm_insert_node_in_range(&context->mm, node, size, 0, 0, va, in etnaviv_iommu_insert_exact()
278 int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, in etnaviv_iommu_map_gem() argument
288 mutex_lock(&context->lock); in etnaviv_iommu_map_gem()
291 if (context->global->version == ETNAVIV_IOMMU_V1 && in etnaviv_iommu_map_gem()
298 mapping->context = etnaviv_iommu_context_get(context); in etnaviv_iommu_map_gem()
299 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_map_gem()
308 ret = etnaviv_iommu_insert_exact(context, node, in etnaviv_iommu_map_gem()
311 ret = etnaviv_iommu_find_iova(context, node, in etnaviv_iommu_map_gem()
317 ret = etnaviv_iommu_map(context, node->start, sgt, etnaviv_obj->base.size, in etnaviv_iommu_map_gem()
325 mapping->context = etnaviv_iommu_context_get(context); in etnaviv_iommu_map_gem()
326 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_map_gem()
328 mutex_unlock(&context->lock); in etnaviv_iommu_map_gem()
333 void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context, in etnaviv_iommu_unmap_gem() argument
338 mutex_lock(&context->lock); in etnaviv_iommu_unmap_gem()
341 if (!mapping->context) { in etnaviv_iommu_unmap_gem()
342 mutex_unlock(&context->lock); in etnaviv_iommu_unmap_gem()
347 if (mapping->vram_node.mm == &context->mm) in etnaviv_iommu_unmap_gem()
348 etnaviv_iommu_remove_mapping(context, mapping); in etnaviv_iommu_unmap_gem()
351 mutex_unlock(&context->lock); in etnaviv_iommu_unmap_gem()
352 etnaviv_iommu_context_put(context); in etnaviv_iommu_unmap_gem()
357 struct etnaviv_iommu_context *context = in etnaviv_iommu_context_free() local
360 etnaviv_cmdbuf_suballoc_unmap(context, &context->cmdbuf_mapping); in etnaviv_iommu_context_free()
362 context->global->ops->free(context); in etnaviv_iommu_context_free()
364 void etnaviv_iommu_context_put(struct etnaviv_iommu_context *context) in etnaviv_iommu_context_put() argument
366 kref_put(&context->refcount, etnaviv_iommu_context_free); in etnaviv_iommu_context_put()
406 struct etnaviv_iommu_context *context) in etnaviv_iommu_restore() argument
408 context->global->ops->restore(gpu, context); in etnaviv_iommu_restore()
411 int etnaviv_iommu_get_suballoc_va(struct etnaviv_iommu_context *context, in etnaviv_iommu_get_suballoc_va() argument
416 mutex_lock(&context->lock); in etnaviv_iommu_get_suballoc_va()
420 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
430 if (context->global->version == ETNAVIV_IOMMU_V1) { in etnaviv_iommu_get_suballoc_va()
436 ret = etnaviv_iommu_find_iova(context, node, size); in etnaviv_iommu_get_suballoc_va()
438 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
443 ret = etnaviv_context_map(context, node->start, paddr, size, in etnaviv_iommu_get_suballoc_va()
447 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
451 context->flush_seq++; in etnaviv_iommu_get_suballoc_va()
454 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_get_suballoc_va()
457 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
462 void etnaviv_iommu_put_suballoc_va(struct etnaviv_iommu_context *context, in etnaviv_iommu_put_suballoc_va() argument
467 mutex_lock(&context->lock); in etnaviv_iommu_put_suballoc_va()
470 if (mapping->use > 0 || context->global->version == ETNAVIV_IOMMU_V1) { in etnaviv_iommu_put_suballoc_va()
471 mutex_unlock(&context->lock); in etnaviv_iommu_put_suballoc_va()
475 etnaviv_context_unmap(context, node->start, node->size); in etnaviv_iommu_put_suballoc_va()
477 mutex_unlock(&context->lock); in etnaviv_iommu_put_suballoc_va()
480 size_t etnaviv_iommu_dump_size(struct etnaviv_iommu_context *context) in etnaviv_iommu_dump_size() argument
482 return context->global->ops->dump_size(context); in etnaviv_iommu_dump_size()
485 void etnaviv_iommu_dump(struct etnaviv_iommu_context *context, void *buf) in etnaviv_iommu_dump() argument
487 context->global->ops->dump(context, buf); in etnaviv_iommu_dump()