From 8a706cbc3d9ede07d39b9d715cc4b195f54b8e96 Mon Sep 17 00:00:00 2001 From: Rajesh Kemisetti Date: Sat, 12 Nov 2016 00:43:22 +0530 Subject: [PATCH] msm: kgsl: Check MMU type for memory and pagetable operations Check MMU type for below operations to make NOMMU functional: - adreno_iommu_set_pt_ctx() tries to set pagetable during context switch without really checking on type of MMU. - skip tracking of gpuaddr in case of NoMMU during kgsl_mem_entry_track_gpuaddr(). - In case of nommu the function kgsl_allocate_global() should always allocate contiguous memory from CMA. Change-Id: I8cb59e1475376167c7a8a60c54df0939597f5083 Signed-off-by: Rajesh Kemisetti --- drivers/gpu/msm/adreno_iommu.c | 11 +++++++++++ drivers/gpu/msm/kgsl.c | 4 +++- drivers/gpu/msm/kgsl_sharedmem.h | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/msm/adreno_iommu.c b/drivers/gpu/msm/adreno_iommu.c index aa00dcb84185..4bb7f6286664 100644 --- a/drivers/gpu/msm/adreno_iommu.c +++ b/drivers/gpu/msm/adreno_iommu.c @@ -856,6 +856,17 @@ int adreno_iommu_set_pt_ctx(struct adreno_ringbuffer *rb, int result = 0; int cpu_path = 0; + /* Just do the context switch incase of NOMMU */ + if (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_NONE) { + if ((!(flags & ADRENO_CONTEXT_SWITCH_FORCE_GPU)) && + adreno_isidle(device)) + _set_ctxt_cpu(rb, drawctxt); + else + result = _set_ctxt_gpu(rb, drawctxt); + + return result; + } + if (rb->drawctxt_active) cur_pt = rb->drawctxt_active->base.proc_priv->pagetable; diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 699d99651f2c..6ef542416959 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -353,8 +353,10 @@ static int kgsl_mem_entry_track_gpuaddr(struct kgsl_device *device, /* * If SVM is enabled for this object then the address needs to be * assigned elsewhere + * Also do not proceed further in case of NoMMU. */ - if (kgsl_memdesc_use_cpu_map(&entry->memdesc)) + if (kgsl_memdesc_use_cpu_map(&entry->memdesc) || + (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_NONE)) return 0; pagetable = kgsl_memdesc_is_secured(&entry->memdesc) ? diff --git a/drivers/gpu/msm/kgsl_sharedmem.h b/drivers/gpu/msm/kgsl_sharedmem.h index 03f278ead20f..c1c2afa68756 100644 --- a/drivers/gpu/msm/kgsl_sharedmem.h +++ b/drivers/gpu/msm/kgsl_sharedmem.h @@ -284,7 +284,8 @@ static inline int kgsl_allocate_global(struct kgsl_device *device, memdesc->flags = flags; memdesc->priv = priv; - if ((memdesc->priv & KGSL_MEMDESC_CONTIG) != 0) + if (((memdesc->priv & KGSL_MEMDESC_CONTIG) != 0) || + (kgsl_mmu_get_mmutype(device) == KGSL_MMU_TYPE_NONE)) ret = kgsl_sharedmem_alloc_contig(device, memdesc, (size_t) size); else {