History

drm/etnaviv: allow to request specific virtual address for gem mapping

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.

Lucas Stach committed 7 years ago

Commit 17eae231 parent edb5ff04 files · +19 −5Browse files

Unified · Split

4 files
  1. drivers/gpu/drm/etnaviv/etnaviv_gem.c +2 −1
  2. drivers/gpu/drm/etnaviv/etnaviv_gem.h +2 −1
  3. drivers/gpu/drm/etnaviv/etnaviv_mmu.c +14 −2
  4. drivers/gpu/drm/etnaviv/etnaviv_mmu.h +1 −1
drivers/gpu/drm/etnaviv/etnaviv_gem.c+2−1
@@ -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);
drivers/gpu/drm/etnaviv/etnaviv_gem.h+2−1
@@ -120,7 +120,8 @@ struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj); · 119 unmodified lines
120void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);120void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);
121 121
122struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(122struct 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);
124void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping);125void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping);
125 126
126#endif /* __ETNAVIV_GEM_H__ */127#endif /* __ETNAVIV_GEM_H__ */
drivers/gpu/drm/etnaviv/etnaviv_mmu.c+14−2
@@ -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
223static 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
223int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,230int 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
drivers/gpu/drm/etnaviv/etnaviv_mmu.h+1−1
@@ -88,7 +88,7 @@ struct etnaviv_gem_object; · 87 unmodified lines
88 88
89int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,89int 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);
92void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context,92void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context,
93 struct etnaviv_vram_mapping *mapping);93 struct etnaviv_vram_mapping *mapping);
94 94

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t