Skip to content

Commit 17eae23

Browse files
committed
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. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de> Reviewed-by: Guido Günther <agx@sigxcpu.org>
1 parent edb5ff0 commit 17eae23

4 files changed

Lines changed: 19 additions & 5 deletions

File tree

‎drivers/gpu/drm/etnaviv/etnaviv_gem.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,8 @@ struct etnaviv_vram_mapping *etnaviv_gem_mapping_get(
308308
mapping->use = 1;
309309

310310
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);
312313
if (ret < 0) {
313314
etnaviv_iommu_context_put(mmu_context);
314315
kfree(mapping);

‎drivers/gpu/drm/etnaviv/etnaviv_gem.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ struct page **etnaviv_gem_get_pages(struct etnaviv_gem_object *obj);
120120
void etnaviv_gem_put_pages(struct etnaviv_gem_object *obj);
121121

122122
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);
124125
void etnaviv_gem_mapping_unreference(struct etnaviv_vram_mapping *mapping);
125126

126127
#endif /* __ETNAVIV_GEM_H__ */

‎drivers/gpu/drm/etnaviv/etnaviv_mmu.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,16 @@ static int etnaviv_iommu_find_iova(struct etnaviv_iommu_context *context,
220220
return ret;
221221
}
222222

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+
223230
int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,
224231
struct etnaviv_gem_object *etnaviv_obj, u32 memory_base,
225-
struct etnaviv_vram_mapping *mapping)
232+
struct etnaviv_vram_mapping *mapping, u64 va)
226233
{
227234
struct sg_table *sgt = etnaviv_obj->sgt;
228235
struct drm_mm_node *node;
@@ -248,7 +255,12 @@ int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,
248255

249256
node = &mapping->vram_node;
250257

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);
252264
if (ret < 0)
253265
goto unlock;
254266

‎drivers/gpu/drm/etnaviv/etnaviv_mmu.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct etnaviv_gem_object;
8888

8989
int etnaviv_iommu_map_gem(struct etnaviv_iommu_context *context,
9090
struct etnaviv_gem_object *etnaviv_obj, u32 memory_base,
91-
struct etnaviv_vram_mapping *mapping);
91+
struct etnaviv_vram_mapping *mapping, u64 va);
9292
void etnaviv_iommu_unmap_gem(struct etnaviv_iommu_context *context,
9393
struct etnaviv_vram_mapping *mapping);
9494

0 commit comments

Comments
 (0)