msm: socinfo: fix memory leak in socinfo_init_sysdev

Under certain error paths in socinfo_init_sysdev the soc_dev_attr
struct does not get freed. Fix this memory leak.

Change-Id: I22a4b60722367798dc5171fe7c00fc7c814168cb
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
msm: kgsl: Bump the frequency all the way to turbo for long ibs.

Process the enormous chunks of data faster.

Change-Id: Idf3fd0bfddc1cd1ac00f87dd72e403b81d70b170
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: reset GPU when GDSC is forced on

Sometimes for debug purposes the GPU regulators can be left
on, make sure we reset the gpu while waking up.

Change-Id: Ie18c9f45d9f5a5a7587a1bea2c7c9bb5ce000316
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm: kgsl: Do not start performance counters if not present

Certain hardware does not support performance counters and does not set
them.  Ensure the uninitialized performance counter variable does not
get dereferenced in this instance.

Change-Id: I8692090d60ff1e6a0c45b5699b90d9808ef61c5a
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: disable full cache flush if full_cache_threshold is 0

Make full_cache_threshold==0 mean never do a full cache flush,
since that is more useful than having it mean always do it.

Change-Id: I4ae46b6253f2d78a97f067b5f906637a3db1d5c8
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Restrict allocated memory alignment to a max of 2^31

The GPU memory allocation flags allow 8 bits of space to specify
a power of 2 aligment for the allocated memory block.  Cap the
actual alignment to 2^31 since any value more than that will have
unintended effects on a 32 bit system.

Change-Id: Ic0dedbadd42a9a886b8bfada0c7d415caaed65de
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add a check to free the kgsl_timeline object.

Add a check to free the kgsl_timeline object only after
destroy flag is set. This is to avoid further references to timeline
from kgsl if it is already freed and also to catch any unbalanced
kref count.

Change-Id: I8017b9a928a26b703eb92b17ab6a361e4b479e5a
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
msm: kgsl: Bypass SP counter 4 on A33x

SP performance counter 4 is broken on A33x targets so do not assign
this counter.  The counter does not reliably return correct values
which can make results misleading.

Change-Id: I87c36e021c547b630e8dfd89abbdb5c65d4b3c46
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Do not wait 100ms before checking for GPU idle

When checking for GPU idle do not wait 100ms first, this
delays detection of GPU idle by 100ms.For example in
GPU fault tolerance we check for GPU idle, this
additional 100ms wait is delaying GPU FT by 100ms in
each step.

Change-Id: I028541f6e0ef765f505a2792b0b1c313665e1ba5
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Wait for the shorter wait timeout value

If wait timeout value is lesser then the default time to wait
for then use the smaller timeout value.

CRs-Fixed: 498631
Change-Id: Ib0e37d40da09d0711a97d6a12106a5e73c23070f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Fix memory leak of DRM GEM object structure.

This changes frees the DRM GEM object structure in
kgsl_gem_free_object function. kgsl_gem_free_object is
called from DRM module after the last refrence to the
object has been lost.

Change-Id: I21d91e9706cf46909168ab99b130ef4d833886e6
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
msm: kgsl: Get an active count before snapshotting GPU

Acquire an active count before attempting to capture a snapshot.
Doing so prevents instances of not being able to snapshot because of
switched off clocks.

CRs-fixed: 511878
Change-Id: Ib80b57c127566e274d4018001561f4da7ea38265
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Remove msm-dcvs pwrscale driver

The msm-dcvs pwrscale driver is no longer in development. Remove it to
avoid bitrot and simplify future target development.

Change-Id: Ic0dedbad81c2afb4bfbb377ee1a2330e115c0e71
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Detect long IB per submission

Currently long IB is detected per GPU command, this mainly
detects infinate shaders, this policy is changed to trigger
long IB per submission. If any submission to GPU takes more
than 2 seconds of GPU time, trigger a long IB and mark the
context bad.

Change-Id: Ic6e9a677bd1e42444d38d2a859a58721345958f5
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Turn on GPU clock before setting the control flag

Make sure the GPU clocks are turned on before the control flag
is set, otherwise the clocks can never be turned on afterwards.

Change-Id: I44458e11ae09ae2499c7c2d5334e5acd43261756
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm: kgsl: Idle GPU after IOMMU V1 TLB flush

After TLB flush on IOMMU V1, stall prefetch parser until
GPU is idle, this guarantees GPU is completely idle
after executing TLB flush instructions. This prevents
prefetching GPU instructions which could trigger hardware
page table walk while TLB flush instructions are
still being executed by GPU.

CRs-Fixed: 541950
Change-Id: Iaf5e577beb640bc42b9a1e29c96d06b125629860
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Enable the shader corruption workaround for all A3XX targets

The power-on shader corruption workaround is required for all A3XX
targets.

CRs-fixed: 556872
Change-Id: Ic0dedbad5ef5a1bfec7cba148a652e1766517e57
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fix overflow check in mmap_range_valid

A eager compiler might optimize out the overflow check in
mmap_range_valid.  Add a check against ULONG_MAX to ensure
that the check is performed.

CRs-fixed: 546373
Change-Id: Ic0dedbad478cc3bd65a00a7b31d2039095c005d6
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Handle failure of find_process_private()

Handle the case of NULL return from find_process_private() upon
its failure by failing from get_process_private().

Change-Id: Id42ae795d140bd67d8a36496f840387858e5f779
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Revert "msm: kgsl: Idle GPU after IOMMU V1 TLB flush"

This reverts commit 4b4b32375892c2dbde36d301b14cc5546de68fce.