msm: kgsl: Do not take spinlock when mapping to IOMMU

The IOMMU driver takes a spinlock internally when mapping, so
do not take an additional spinlock when mapping to IOMMU table.

Change-Id: I772ffb09af95ed15dc2c3495affa9efd48e4af5b
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Increase the virtual GPU range for the IOMMU

Instead of a fixed 256MB virtual range for both the GPUMMU and IOMMU, make
the virtual range a property of the MMU engine and set the IOMMU range to
2GB.  Technically we could go all the way up to 4G, but even 2G is far out
of the realm of possiblity in the current generation, and we wanted to
reserve some of the space for future enhancements.

Change-Id: Ic0dedbad2987beb162b6a1878dd65ffae8a78522
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Use the right physical addresses in NOMMU mode

In NOMMU mode the gpuaddr was set to the physaddr
for the memdesc which worked great until the memory
wasn't allocated by KGSL, at which point it blew up.
We already went through the due dilligence to turn
all memdescs into sglists, so use the sglist to get the
physaddr (and thus the gpuaddr).  Check to make sure
that we're not trying to map a real sglist (more than one
entry) and if we are, then loudly fail.

Change-Id: Ic0dedbad5d401c505949c92d9a7795f3260dbabb
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: don't clear gpuaddr when unmapping global mappings

Memory mapped through kgsl_mmu_map_global() is supposed to have
the same gpu address in all pagetables. And the memdesc will
persist beyond the lifetime of any single pagetable.
Therefore, memdesc->gpuaddr should not be zeroed for these
memdescs.

Change-Id: I0f46aaee2b9e87f839e78b7978cdf1bb4239d6f5
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl_mmu.c
msm: kgsl: Create a separate pool for mapping kgsl allocations

Create a separate kgsl pool to map global allocations made in kgsl
when IOMMU is used. Also, set the ttbr1 to point to defaultpagetable.
This allows us to map the kgsl allocations only once to the
defaultpagetable instead of having to map it to every pagetable
created.

Change-Id: I70fc051e852bf6820e09a1113a63ac93f7e0a51b
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Properly assign the physical address

Correctly assign the physical address to be used as gpu address
when no MMU is used.

Change-Id: Ie824cadc7c8c85203f81c9c5961b6f8a5d1cd449
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Allocate setstate memory when no MMU is used

Setstate memory should be allocated even when no MMU is used
because it is used when submitting workaround commands.

Change-Id: Ia8217cec9507bff82680e737b4328c2611f5f917
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Call the function to setup global mappings

Call kgsl_setup_pt function to setup the gpuaddr mappings for
global allocations when no MMU is used

Change-Id: I062de3b52fd4d48717bd9d6b074deca9ffcb85de
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Make tlb flags common for all MMU types

Remove tlb flags variable from gpu MMU specific structure and
declare it in common MMU structure since it can be used by both
MMU types i.e GPUMMU and IOMMU

Change-Id: Ia8bea65bc9acf257dc1277c98cd358963c291fd7
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Change the prototype of MMU function pointers

Change the prototype of the MMU function pointers to take the mmu
pointer as an argument instead of the device pointer.

Change-Id: I4ecafefcc8f755c23dac6e3a15a1a74a74e3db00
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>

Conflicts:

	drivers/gpu/msm/adreno_ringbuffer.c
	drivers/gpu/msm/kgsl_iommu.c
msm: kgsl: Assign a valid context only after one has been restored

Assign a context active context only after that context has been
restored. This is required because Code section to change
pagetables or flush tlb in stream require a valid context to be
active.

Change-Id: I513cf235adf2bde04af47944950d58ba1af1f61f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>