msm: kgsl: Add new sysfs node to list GPU clock frequencies

Add a new sysfs node to communicate available GPU clock frequencies
to userspace for the power daemons.

Signed-off-by: Anshuman Dani <adani@codeaurora.org>
(cherry picked from commit 0e80b365d2b6e15344a774667a1e273edb2d64ff)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
(cherry picked from commit 9ca738c3c746017e5a4c8d5fe64e1ed3e6128cc1)

Change-Id: I623a36148ae86a9a527f28e7d768535f67ceaa01
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: Detect and avoid malformed ioctl codes

Because we were using _IO_NR, one could construct a malformed ioctl
code that would avoid allocating memory yet go to a function that
expected that memory. Still use _IO_NR to index the array of ioctls,
but check that the full values match before jumping to the helper
function.

CRs-fixed: 385592
Change-Id: Ic0dedbaded469035bd0a2bb0f20fecb2a3045ca5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 1e76f61bb001b93795a227f8f808104b6c10b048)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
msm: kgsl: Use the gpuaddr to decide whether to map memstore

Use the gpuaddr to determine whether memstore is being mapped in
mmap or a normal memory allocation is mapped instead of physical
address. gpuaddr of the memstore will always be unique but the
physaddr may be equal to the gpuaddr of another memory allocation
and that will cause the memory allocation to be mapped as memstore
which is wrong.

Change-Id: I6a803e82e0a9d3713ebb3f15ea46d450f69d8ac7
CRs-fixed: 379019
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: Limit the number of indirect buffers per submission

Put a reasonable upper limit on the number of indirect buffers allowed
per submission via IOCTL_KGSL_RINGBUFFER_ISSUEIBCMDS.

CRs-Fixed: 380267
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 834c8594c0583d779cb6a8eb3fca3ebc714d87d0)

Change-Id: I95d1035448f8367ab2faadd9f11b589b7efdf11a
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: kgsl: Optimize page_alloc allocations

User memory needs to be zeroed out before it is sent to the user.
To do this, the kernel maps the page, memsets it to zero and then
unmaps it.  By virtue of mapping it, this forces us to flush the
dcache to ensure cache coherency between kernel and user mappings.
Originally, the page_alloc loop was using GFP_ZERO (which does a
map, memset, and unmap for each individual page) and then we were
additionally calling flush_dcache_page() for each page killing us
on performance.  It is far more efficient, especially for large
allocations (> 1MB), to allocate the pages without GFP_ZERO and
then to vmap the entire allocation, memset it to zero, flush the
cache and then unmap. This process is slightly slower for very
small allocations, but only by a few microseconds, and is well
within the margin of acceptability. In all, the new scheme is
faster than the default for all sizes greater than 16k, and is
almost 4X faster for 2MB and 4MB allocations which are common for
textures and very large buffer objects.

The downside is that if there isn't enough vmalloc room for the
allocation that we are forced to fallback to a slow page by
page memset/flush, but this should happen rarely (if at all) and
is only included for completeness.

CRs-Fixed: 372638
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 89bd323f4b9c4c2382e5361c52f25f86db330583)

Change-Id: I160d23c25d7cae7b9d432f9f79945e01bcbe89e9
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl_sharedmem.c
msm: kgsl: remove slow path
to fix the build. Seems it was only a fallback path for completeness.
(Will look into this if bugs/errors occur)