msm: kgsl: The memory entry pending flag should be guarded

Guard the memory entry free pending flag with the process
private lock. This usage of this flag is guarded everywhere
else in the code with the same lock.

Change-Id: Iac27f08876bfe8ff6205edc8233b9c27c6e9a599
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Changing to kref_get_unless_zero for process refcount

Do not allow anything to get a refcount to the process_private
structure if its refcount has gone down to 0.

Change-Id: I7cd6f731286aebfc84c288284599b47f666dcd47
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
ion: retry during race with shrinking/allocating

There exists a race between shrinking/allocating

Thread 1:                           Thread:2
mutex_lock(&sheap->alloc_lock)
ion_secure_cma_add_to_pool()
mutex_lock(&sheap->chunk_lock)
chunk->cnt = 0
mutex_unlock(&sheap->chunk_lock)
                                    ion_secure_cma_shrinker
                                    mutex_lock(&sheap->chunk_lock)
                                    __ion_secure_cma_shrink_pool
                                    chunk->cnt == 0 for the
                                       just allocated chunk
                                    ion_secure_cma-free_chunk
ion_secure_cma_alloc_from_pool
no memory to allocate!

If this race happens, just retry adding memory to the pool instead
of BUGing out the system.

Change-Id: Ic95782db6d88a33f01dcc5248fc957ca0f378078
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: kgsl: Flush TLB when mapping to IOMMU pagetable

Flush TLB when mapping to IOMMU pagetable, this is a requirement
for current IOMMU hardware.

Change-Id: I82e766f4869c737c1f5b73934eacaada40d46e10
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl_iommu.c
msm: kgsl: Mark the IOMMU setstate memory as read only

Mark the IOMMU setstate memory as read only in the pagetable.

Change-Id: Ic0dedbadb19e499c749cd744c3e89be3bcb4c2a2
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>