Lines Matching full: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()
138 static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context, in etnaviv_iommu_find_iova() argument
145 lockdep_assert_held(&context->lock); in etnaviv_iommu_find_iova()
153 ret = drm_mm_insert_node_in_range(&context->mm, node, in etnaviv_iommu_find_iova()
159 drm_mm_scan_init(&scan, &context->mm, size, 0, 0, mode); in etnaviv_iommu_find_iova()
163 list_for_each_entry(free, &context->mappings, mmu_node) { in etnaviv_iommu_find_iova()
205 etnaviv_iommu_remove_mapping(context, m); in etnaviv_iommu_find_iova()
206 etnaviv_iommu_context_put(m->context); in etnaviv_iommu_find_iova()
207 m->context = NULL; in etnaviv_iommu_find_iova()
223 static int etnaviv_iommu_insert_exact(struct etnaviv_iommu_context *context, in etnaviv_iommu_insert_exact() argument
231 lockdep_assert_held(&context->lock); in etnaviv_iommu_insert_exact()
233 ret = drm_mm_insert_node_in_range(&context->mm, node, size, 0, 0, va, in etnaviv_iommu_insert_exact()
244 * destroyed yet (likely due to being referenced by another context) in in etnaviv_iommu_insert_exact()
249 drm_mm_for_each_node_in_range(scan_node, &context->mm, va, va + size) { in etnaviv_iommu_insert_exact()
260 etnaviv_iommu_remove_mapping(context, m); in etnaviv_iommu_insert_exact()
261 etnaviv_iommu_context_put(m->context); in etnaviv_iommu_insert_exact()
262 m->context = NULL; in etnaviv_iommu_insert_exact()
267 return drm_mm_insert_node_in_range(&context->mm, node, size, 0, 0, va, in etnaviv_iommu_insert_exact()
271 int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, in etnaviv_iommu_map_gem() argument
281 mutex_lock(&context->lock); in etnaviv_iommu_map_gem()
284 if (context->global->version == ETNAVIV_IOMMU_V1 && in etnaviv_iommu_map_gem()
291 mapping->context = etnaviv_iommu_context_get(context); in etnaviv_iommu_map_gem()
292 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_map_gem()
301 ret = etnaviv_iommu_insert_exact(context, node, in etnaviv_iommu_map_gem()
304 ret = etnaviv_iommu_find_iova(context, node, in etnaviv_iommu_map_gem()
310 ret = etnaviv_iommu_map(context, node->start, sgt, etnaviv_obj->base.size, in etnaviv_iommu_map_gem()
318 mapping->context = etnaviv_iommu_context_get(context); in etnaviv_iommu_map_gem()
319 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_map_gem()
321 mutex_unlock(&context->lock); in etnaviv_iommu_map_gem()
326 void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context, in etnaviv_iommu_unmap_gem() argument
331 mutex_lock(&context->lock); in etnaviv_iommu_unmap_gem()
334 if (!mapping->context) { in etnaviv_iommu_unmap_gem()
335 mutex_unlock(&context->lock); in etnaviv_iommu_unmap_gem()
340 if (mapping->vram_node.mm == &context->mm) in etnaviv_iommu_unmap_gem()
341 etnaviv_iommu_remove_mapping(context, mapping); in etnaviv_iommu_unmap_gem()
344 mutex_unlock(&context->lock); in etnaviv_iommu_unmap_gem()
345 etnaviv_iommu_context_put(context); in etnaviv_iommu_unmap_gem()
350 struct etnaviv_iommu_context *context = in etnaviv_iommu_context_free() local
353 etnaviv_cmdbuf_suballoc_unmap(context, &context->cmdbuf_mapping); in etnaviv_iommu_context_free()
355 context->global->ops->free(context); in etnaviv_iommu_context_free()
357 void etnaviv_iommu_context_put(struct etnaviv_iommu_context *context) in etnaviv_iommu_context_put() argument
359 kref_put(&context->refcount, etnaviv_iommu_context_free); in etnaviv_iommu_context_put()
399 struct etnaviv_iommu_context *context) in etnaviv_iommu_restore() argument
401 context->global->ops->restore(gpu, context); in etnaviv_iommu_restore()
404 int etnaviv_iommu_get_suballoc_va(struct etnaviv_iommu_context *context, in etnaviv_iommu_get_suballoc_va() argument
409 mutex_lock(&context->lock); in etnaviv_iommu_get_suballoc_va()
413 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
423 if (context->global->version == ETNAVIV_IOMMU_V1) { in etnaviv_iommu_get_suballoc_va()
429 ret = etnaviv_iommu_find_iova(context, node, size); in etnaviv_iommu_get_suballoc_va()
431 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
436 ret = etnaviv_context_map(context, node->start, paddr, size, in etnaviv_iommu_get_suballoc_va()
440 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
444 context->flush_seq++; in etnaviv_iommu_get_suballoc_va()
447 list_add_tail(&mapping->mmu_node, &context->mappings); in etnaviv_iommu_get_suballoc_va()
450 mutex_unlock(&context->lock); in etnaviv_iommu_get_suballoc_va()
455 void etnaviv_iommu_put_suballoc_va(struct etnaviv_iommu_context *context, in etnaviv_iommu_put_suballoc_va() argument
460 mutex_lock(&context->lock); in etnaviv_iommu_put_suballoc_va()
463 if (mapping->use > 0 || context->global->version == ETNAVIV_IOMMU_V1) { in etnaviv_iommu_put_suballoc_va()
464 mutex_unlock(&context->lock); in etnaviv_iommu_put_suballoc_va()
468 etnaviv_context_unmap(context, node->start, node->size); in etnaviv_iommu_put_suballoc_va()
470 mutex_unlock(&context->lock); in etnaviv_iommu_put_suballoc_va()
473 size_t etnaviv_iommu_dump_size(struct etnaviv_iommu_context *context) in etnaviv_iommu_dump_size() argument
475 return context->global->ops->dump_size(context); in etnaviv_iommu_dump_size()
478 void etnaviv_iommu_dump(struct etnaviv_iommu_context *context, void *buf) in etnaviv_iommu_dump() argument
480 context->global->ops->dump(context, buf); in etnaviv_iommu_dump()