msm: kgsl: Add check for NULL value from dev_get_drvdata

Check to see if dev_get_drvdata returns NULL and handle it.

CRs-Fixed: 552580
Change-Id: Ic0dedbad426dbbe15896608213067ee7337f3b34
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Don't block on detach if the context is invalid

An invalidated context means that something pretty nasty happened and
likely there was an unrecovered GPU fault along the way. If this is
the case then the GPU is likely not processing commands for the context
anymore. Don't block for the last retired global if the context was
invalidated.

Change-Id: Ic0dedbad22a22b704baf14557d7e18cc4cf1044a
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fix the api type in adreno drawctxt flags

Adding the missed type field in adreno draw ctxt create
which was giving incorrect data type.

CRs-Fixed: 590103

Signed-off-by: Anoop Kumar Yerukala <ayeruk@codeaurora.org>
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
Change-Id: I6f464a3b6cc1fec3891d1189f85c7fe9ac65764e
msm: kgsl: Panic if global timestamp wait fails in context detach.

If we timeout while waiting for the last issued global timestamp for
a detaching context to expire (10 seconds!) then we are on a fast
train to crashville.  BUG_ON() so we can stand a chance of debugging
this very rare issue.

Change-Id: I3bd4cffe05127b07ede06a29b1701b65b8923706
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Panwar Vivek <vpanwa@codeaurora.org>
msm: kgsl: Flush the UCHE when context changes

Add commands to flush the GPU UCHE when a new context submits
commands to GPU. The ensures that the new context does not use
stale data present in UCHE.

CRs-Fixed: 607976
Change-Id: I123a323be5f3fb9d1f9f96fed5bb68b8d0d27d76
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Fix range checking for profile wrapping

There is a chance that the profile code will not wrap correctly.
This can cause the in stream profiling to cause buffer pre-run
or undershoot (accessing data before the buffer). Fix logic to
cause the correct wrapping.

Change-Id: I9aa68228ff5be1bd26ee1cf1a486859346a8027f
CRs-Fixed: 585754
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Add arch_mmap_check() stub definition

Add a stub definition for arch_mmap_check() in kgsl.c for
situations where the function is not defined, similar to the
stub definition in mm/mmap.c

Change-Id: I2d0f7f8c76f35cbec1554893433199e256f76df4
Signed-off-by: Shrenuj Bansal <shrenujb@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>
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: Don't open kgsl device in erroneous case

If kgsl_get_process_private() returns NULL, it goes to
err_stop with result = -ENOMEM. If open_count is 0,
adreno_stop() overwrites the result variable with 0.
This leads to kgsl_open() to be successful while it
shouldn't.

Change-Id: Ic12d92a099280e4d958fa192fa5128211120d361
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
msm: kgsl: protect syncpoint events with a reference count

Replace the event spinlock with krefs to avoid the possiblity
of calling a sleeping function while holding the spinlock and
to generally make the whole cmdbatch cancel loop a lot more
stable.

Change-Id: I08ba54fa4c5a11c05e3503dfc6a4ee040733e5a6
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: allow creation of events from the future

For contexts created with the KGSL_CONTEXT_USER_GENERATED_TS,
allow events to be created for timestamps that have not
been issued yet. Presumably these contexts know what they
are doing.

Change-Id: Iccf2e549b38e1a11850d26ee64b7279ab0b8a1ae
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Fix the NULL context submission size

When submitting commands with a NULL context the size may not be
calculated properly. Fix this calculation.

Change-Id: Idcc37772349673da8a9b9d5127f88946ced8fff6
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
Enable GPU CONSERVATIVE GOV.
BLOCK: do not CREATE_TRACE_POINTS for BLOCK code.
Revert USB CABLE Hack, it's not working as needed.
FORCE FAST CHARGE: bump to v1.5 Cleanups + FIX, now it's WORKS
Intelli Thermal Control: Tuning and corrections to TEMP and controls.

We cant wait 10ms in queue_delayed_work CPU letancy is 0, we must react.

or cpu overheat fast and panic.

now we can go up to 80c and stable.
msm_rq_stats: Removed useless cur_iowait_time references.
PM / devfreq: Make target flags unique

Overlapping target flags cause both to be set
rather than the intended one.  Make sure the flags
have different values.

Change-Id: Ia4fb9566be7284e57e67be78c32de05cbd11d6f8
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>