As we have some unfortunate GPUs with IOMMUv2 but broken PTA (reloading a different page table at runtime always fails), shared_context is now not a v1-only thing.
Move it out of the v1 struct in the union. Signed-off-by: Icenowy Zheng <u...@icenowy.me> --- drivers/gpu/drm/etnaviv/etnaviv_iommu.c | 8 ++++---- drivers/gpu/drm/etnaviv/etnaviv_mmu.h | 22 +++++++--------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c index afe5dd6a9925b..6fdce63b9971a 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_iommu.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_iommu.c @@ -39,7 +39,7 @@ static void etnaviv_iommuv1_free(struct etnaviv_iommu_context *context) dma_free_wc(context->global->dev, PT_SIZE, v1_context->pgtable_cpu, v1_context->pgtable_dma); - context->global->v1.shared_context = NULL; + context->global->shared_context = NULL; kfree(v1_context); } @@ -136,8 +136,8 @@ etnaviv_iommuv1_context_alloc(struct etnaviv_iommu_global *global) * a stop the world operation, so we only support a single shared * context with this version. */ - if (global->v1.shared_context) { - context = global->v1.shared_context; + if (global->shared_context) { + context = global->shared_context; etnaviv_iommu_context_get(context); mutex_unlock(&global->lock); return context; @@ -163,7 +163,7 @@ etnaviv_iommuv1_context_alloc(struct etnaviv_iommu_global *global) mutex_init(&context->lock); INIT_LIST_HEAD(&context->mappings); drm_mm_init(&context->mm, GPU_MEM_START, PT_ENTRIES * SZ_4K); - context->global->v1.shared_context = context; + context->global->shared_context = context; mutex_unlock(&global->lock); diff --git a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h index 7f8ac01785474..2ec4acda02bc6 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_mmu.h +++ b/drivers/gpu/drm/etnaviv/etnaviv_mmu.h @@ -49,21 +49,13 @@ struct etnaviv_iommu_global { u32 memory_base; - /* - * This union holds members needed by either MMUv1 or MMUv2, which - * can not exist at the same time. - */ - union { - struct { - struct etnaviv_iommu_context *shared_context; - } v1; - struct { - /* P(age) T(able) A(rray) */ - u64 *pta_cpu; - dma_addr_t pta_dma; - DECLARE_BITMAP(pta_alloc, ETNAVIV_PTA_ENTRIES); - } v2; - }; + struct etnaviv_iommu_context *shared_context; + struct { + /* P(age) T(able) A(rray) */ + u64 *pta_cpu; + dma_addr_t pta_dma; + DECLARE_BITMAP(pta_alloc, ETNAVIV_PTA_ENTRIES); + } v2; }; struct etnaviv_iommu_context { -- 2.50.1