Allow the mapping code to request a specific virtual address for the gem mapping. If the virtual address is zero we fall back to the old mode of allocating a virtual address for the mapping.
Unified · Split
| @@ -308,7 +308,8 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( · 307 unmodified lines | |||
| 308 | mapping->use = 1; | 308 | mapping->use = 1; |
| 309 | 309 | ||
| 310 | ret = etnaviv_iommu_map_gem(mmu_context, etnaviv_obj, | 310 | ret = etnaviv_iommu_map_gem(mmu_context, etnaviv_obj, |
| 311 | mmu_context->global->memory_base, mapping); | 311 | mmu_context->global->memory_base, |
| 312 | mapping, 0); | ||
| 312 | if (ret < 0) { | 313 | if (ret < 0) { |
| 313 | etnaviv_iommu_context_put(mmu_context); | 314 | etnaviv_iommu_context_put(mmu_context); |
| 314 | kfree(mapping); | 315 | kfree(mapping); |
| @@ -120,7 +120,8 @@ struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj); · 119 unmodified lines | |||
| 120 | void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj); | 120 | void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj); |
| 121 | 121 | ||
| 122 | struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( | 122 | struct etnaviv_vram_mapping *etnaviv_gem_mapping_get( |
| 123 | struct drm_gem_object *obj, struct etnaviv_iommu_context *mmu_context); | 123 | struct drm_gem_object *obj, struct etnaviv_iommu_context *mmu_context, |
| 124 | u64 va); | ||
| 124 | void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping); | 125 | void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping); |
| 125 | 126 | ||
| 126 | #endif /* __ETNAVIV_GEM_H__ */ | 127 | #endif /* __ETNAVIV_GEM_H__ */ |
| @@ -220,9 +220,16 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context, · 219 unmodified lines | |||
| 220 | return ret; | 220 | return ret; |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | static int etnaviv_iommu_insert_exact(struct etnaviv_iommu_context *context, | ||
| 224 | struct drm_mm_node *node, size_t size, u64 va) | ||
| 225 | { | ||
| 226 | return drm_mm_insert_node_in_range(&context->mm, node, size, 0, 0, va, | ||
| 227 | va + size, DRM_MM_INSERT_LOWEST); | ||
| 228 | } | ||
| 229 | |||
| 223 | int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, | 230 | int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, |
| 224 | struct etnaviv_gem_object *etnaviv_obj, u32 memory_base, | 231 | struct etnaviv_gem_object *etnaviv_obj, u32 memory_base, |
| 225 | struct etnaviv_vram_mapping *mapping) | 232 | struct etnaviv_vram_mapping *mapping, u64 va) |
| 226 | { | 233 | { |
| 227 | struct sg_table *sgt = etnaviv_obj->sgt; | 234 | struct sg_table *sgt = etnaviv_obj->sgt; |
| 228 | struct drm_mm_node *node; | 235 | struct drm_mm_node *node; |
| @@ -248,7 +255,12 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, · 19 unmodified lines | |||
| 248 | 255 | ||
| 249 | node = &mapping->vram_node; | 256 | node = &mapping->vram_node; |
| 250 | 257 | ||
| 251 | ret = etnaviv_iommu_find_iova(context, node, etnaviv_obj->base.size); | 258 | if (va) |
| 259 | ret = etnaviv_iommu_insert_exact(context, node, | ||
| 260 | etnaviv_obj->base.size, va); | ||
| 261 | else | ||
| 262 | ret = etnaviv_iommu_find_iova(context, node, | ||
| 263 | etnaviv_obj->base.size); | ||
| 252 | if (ret < 0) | 264 | if (ret < 0) |
| 253 | goto unlock; | 265 | goto unlock; |
| 254 | 266 | ||
| @@ -88,7 +88,7 @@ struct etnaviv_gem_object; · 87 unmodified lines | |||
| 88 | 88 | ||
| 89 | int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, | 89 | int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context, |
| 90 | struct etnaviv_gem_object *etnaviv_obj, u32 memory_base, | 90 | struct etnaviv_gem_object *etnaviv_obj, u32 memory_base, |
| 91 | struct etnaviv_vram_mapping *mapping); | 91 | struct etnaviv_vram_mapping *mapping, u64 va); |
| 92 | void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context, | 92 | void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context, |
| 93 | struct etnaviv_vram_mapping *mapping); | 93 | struct etnaviv_vram_mapping *mapping); |
| 94 | 94 | ||