msm: kgsl: Put only critical IBs in the snapshot section

In many cases there isn't enough room in the snapshot region to
store all the IBs from the hanging context.  Only store the
last IB1 to be executed (per the CP_IB1_BASE register) and any IB2s
within that IB1 - all other IBs in the hanging context are
marked as GPU objects. The downside to this approach is that after
a system crash, only the snapshot region can be assured to be recovered
from a RAM dump; the list of GPU objects might be skipped.  This is
why the critical IBs go in the snapshot to ensure that no matter what
at least the last buffers to execute before the hang are recovered.
The upside is this reduces the pressure on the snapshot region size and
ensures that more of the state can be recovered under normal
circumstances.

Change-Id: Ic0dedbada7869c7f5cc03ed2ed58e996294c1e8c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Cleanup header file macros

Remove macro logic for macros that are always defined.

Change-Id: Iecbc8418102205559aa551af96b79579d1b3aa4d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Capture more interesting GPU buffers from a hang

Freeze more essential GPU buffers and push them into the snapshot
dump.  Add visibilty stream buffers, VBOs, index buffers and general
purpose GPU buffers to the list of frozen buffers. Parse the captured
IBs for type0 and type3 writes that indicate a buffer of interest
and add them to the dump list.

Change-Id: Ic0dedbad1ee978b951abedacb0c70481a1a7e38f
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	drivers/gpu/msm/a3xx_reg.h
	drivers/gpu/msm/adreno_pm4types.h
msm: kgsl: Remove unused debugfs files

istore, sx_debug, cp_debug and mh_debug have been deprecated. Remove
them.

Change-Id: I34364f8987a74e68244015992af39842342d0489
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno_debugfs.c
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: set state as requested state when in NAP

Fix the state to requested state so that when both ISR and
timer fire at the same time, the state is set as SLEEP

Change-Id: Ibeeaa8e586481eef0143f3cdb16bb8273ba2cc80
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>

Conflicts:
	drivers/gpu/msm/kgsl_pwrctrl.c
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.

Change-Id: I0fd678359bd29a27fb218a506d1b307544ec5aae
Signed-off-by: Nilesh Shah <nsshah@codeaurora.org>
msm: kgsl: Add markers to identify IB sequence start and end

Add nop packets in ringbuffer at the start and end of IB buffers
subnmitted by user space driver. These nop packets serve as markers
that can be used during replay, recovery, and snapshot to get valid
data for a GPU hang dump

Change-Id: Id080672b7c04a1b6cfbccbcf5d4591cb5f0b3058
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Dump the entire ringbuffer to the snapshot

Dump the entire ringbuffer to the snapshot and let the parser decide
what it wants to show.  This is a lot better then trying to make those
sorts of decisions in the kernel. Even if we are dumping the entire
ringbuffer it still only makes sense to dump the IBs for the hanging
frame so do the math to find the context switch before the
last submitted IB and dump only the IBs from there to rptr or the
next context switch whichever is first.

Change-Id: Ic0dedbad3fed6be1fca3ed8a320386f70a562d43
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Fix type0 packet parsing

The snapshot code was incorrectly parsing type0 packets in
indirect buffers which ended up with the snapshot code trying
to dump random values as valid GPU addresses.  There were other
failsafes in place to make sure we didn't actually try to read
the memory, but it still made for a incomplete snapshot and lots
of annoying error messages.

Change-Id: Ic0dedbad200ce0170a70c45a613e9717ff86658b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add KGSL_IOCTL_SETPROPERTY

Add KGSL_IOCTL_SETPROPERTY to allow certain features to be enabled in
the kernel driver via userspace.

Change-Id: Ic0dedbadcbf3bfd451db947cec5d997261b12915
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Revert "msm: kgsl: Add KGSL_IOCTL_SETPROPERTY"

This reverts commit b725d17974eb46c303d7e01862bffd1aadda2968.
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>
msm: kgsl: flush outer cache for alloc_page() pages

The outer cache needs to be flushed for these pages
after they are allocated so that the GPU and CPU
have a consistent view of them.

Change-Id: I4d6b688fc4a9f04d4bf8e3215d51bac32bf8e9fd
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Resolve conflicts in state changes

Only check requested state once, and fully transition to that
specific state.  This will resolve any conflicts arising from
changes to the requested_state as the state transition occurs.

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

Conflicts:
	drivers/gpu/msm/kgsl_pwrctrl.c
msm: kgsl: Fix when GMEM is saved for A2xx

Saving GMEM is set when doing context switching and should not
be set when creating the gmem shadow.

Change-Id: I743a7287f105dd50955727c4f0dcaf8de363a1dc
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Ensure glitch free changing of the GPU frequency

If there are requests to skip levels while the clocks are on
be sure to hit the intermediate frequencies.

Change-Id: Ib69bcbc7eb87532c090b4ede28d967e4cd0f08ec
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Search setstate memory descriptor

When searching for a memory descriptor for a given gpuaddr search
for the setstate memory descriptor as well.

Change-Id: Ib5cbc797bbfddd35b89fbba64196c226c0995fa1
Signed-off-by: Shubhraprakash Das <sadas@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: Make use of the new clock APIs.

Use the split clock APIs to do low latency actions (enable/disable)
frequently.  Use the high latency functions (prepare/unprepare)
sparingly to help performance.

CRs-fixed: 351696
Change-Id: Iaf9ed2117a1647e38be8658c60a365d377c968a4
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>