msm: kgsl: Make sure kmemleak tool does not report incorrect mem leak.

Certain memory allocations are not properly tracked by kmemleak tool,
which makes it to incorrectly detect memory leak. Notify the tool by using
kmemleak_not_leak() to ignore the memory allocation so that incorrect leaks
report are avoided.

Change-Id: Id3beea7d99aedc10d9d8d74e5dad384e03abf4f2
CRs-Fixed: 334294
Signed-off-by: Anshuman Dani <adani@codeaurora.org>
modified for HTC GPU by faux123 from CAF base
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.

modified for HTC GPU driver from CAF reference by faux123
msm: kgsl: set the dma_address field of scatterlists

Ion carveout and content protect heap buffers do not
have a struct page associated with them. Thus
sg_phys() will not work reliably on these buffers.
Set the dma_address field on physically contiguous
buffers.  When mapping a scatterlist to the gpummu
use sg_dma_address() first and if it returns 0
then use sg_phys().

Change-Id: Ie5f19986446be4383dfbfffa2534136b592e8e46
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
modified for HTC GPU from CAF baseline by faux123
msm: kgsl: remove readl/writel use for dma memory

For dma_alloc_coherent() you don't need writel/readl because
it's just a plain old void *. Linux tries very hard to make a
distinction between io memory (void __iomem *) and memory
(void *) so that drivers are portable to architectures that
don't have a way to access registers via pointer dereferences.
You can see http://lwn.net/Articles/102232/ and the Linus rant
http://lwn.net/Articles/102240/ here for more details behind
the motivation.

Change-Id: I3da075c30304e4adf321cfb3edb1baa4a93fc2ce
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
modified for HTC GPU from CAF reference by faux123
msm: kgsl: fix statistics for ion memory regions

The sysfs code was reading the wrong entry in the stats
array, so it printed the wrong value.

Change-Id: I26ce8bbca152a98e3dac53a9c154e52b020d5532
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: flush cache otherwise memory will be uninitialized

The memory is allocated by vmalloc_user which initializes the memory
to zero however the initialization was being discarded by the cache
invalidate before the memory was returned to userspace.

Change-Id: I4d44fb3c308bb04c6cb137f7d34cd38600980f42
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
msm: kgsl: Use highest perf level on wake-up from sleep

Allowing gpu to operate on highest perf level on
wake-up for better performance.

modified for HTC GPU from CAF baseline by faux123
msm: kgsl: Don't call through pwrscale functions when entering SLUMBER

No additional calls to pwrscale idle or busy should be allowed when
transitioning to SLUMBER state.

Change-Id: I9488569758d263752c9778b8603f8e80bbc41ea1
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
modified for HTC GPU driver from CAF baseline by faux123
kgsl: Add functions for enabling / disabling a powerscale policy

Sometimes you want to enable or disable a policy for a bit without
actually swapping out the policy.  These functions allow the kernel
to control the policy functionality.

Change-Id: Ic0dedbad4406e5fffe1ebd8e8ba4e6bf84d82203
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Remove duplicate soptimestamp memory write call

This soptimestamp write is not needed twice after hang recovery.

Change-Id: I117ecdc8651bf8b9410a245e0582c1f672d3ca6d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Add a helper function for getting device platform data

Add a simple helper function to make it easy to get the platform device
data from a kgsl_device pointer.

modified for HTC GPU from CAF baseline by faux123
msm: kgsl: Use default hardcoded value for CP's ROQ queue size

The command processor FIFO depth is different for A330 and A2xx GPUs.
It is best to let each GPU use the default value which is hardcoded in
the respective GPU.

Change-Id: I5db6a1c0671d0ad4253dcad7f386429d78a4bd62
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Create ion client in the probe function

Move the call for creating the ion client from kgsl_setup_ion to
kgsl_device_platform_probe. Keeping the create ion client call linked to
kgsl_ioctl_map_user_mem made the user process which first used this
ioctl be forever visible as an ion client in debugfs, even when the
process itself had terminated. Creating ion client in probe ensures that
kgsl appears as the ion client in debugfs and avoids confusion.

CRs-fixed: 349112
Change-Id: Ic4483224d6c48f76f85d48fa4d7768cf26920508
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Fix powerscale idle logic

Logic error was causing powerscale to get into a slightly funky state.

Change-Id: I2ff9e15180babfb07c63ab556e22f7db53f95a78
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
modified for HTC GPU driver from CAF reference by faux123