msm: kgsl: remove kgsl_mem_entry.flags

The two flags fields in kgsl_memdesc should be enough for
anyone.  Move the only flag using kgsl_mem_entry, the
FROZEN flag for snapshot procesing, to use kgsl_memdesc.priv.

Change-Id: Ia12b9a6e6c1f5b5e57fa461b04ecc3d1705f2eaf
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: snapshot: Don't keep parsing indirect buffers on failure

Stop parsing an indirect buffer if an error is encountered (such as
a missing buffer). This is a pretty good indication that the buffers
are not reliable and the further the parser goes with a unreliable
buffer the more likely it is to get confused.

Change-Id: Ic0dedbadf28ef374c9afe70613048d3c31078ec6
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: snapshot: Only push the last IB1 and IB2 in the static space

Some IB1 buffers have hundreds of little IB2 buffers and only one of them
will actually be interesting enough to push into the static space.  Only
push the last executed IB1 and IB2 into the static space.

Change-Id: Ic0dedbad26fb30fb5bf90c37c29061fd962dd746
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Save the last active context in snapshot

Save the last active context that was executing when the hang happened
in snapshot.

Change-Id: I2d32de6873154ec6c200268844fee7f3947b7395
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: In snapshot track a larger object size if address is same

If the object being tracked has the same address as a previously
tracked object then only track a single object with larger size
as the smaller object will be a part of the larger one anyway.

Change-Id: I0e33bbaf267bc0ec580865b133917b3253f9e504
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Loop till correct index on type0 packets

When searching for memory addresses in type0 packet we were looping
from start of the type0 packet till it's end, but the first DWORD
is a header so we only need to loop till packet_size - 1. Fix this.

Change-Id: I278446c6ab380cf8ebb18d5f3ae192d3d7e7db62
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Add global timestamp information to snapshot

Make sure that we always add global timestamp information to
snapshot. This is needed in playbacks for searching whereabouts
of last executed IB.

Change-Id: Ica5b3b2ddff6fd45dbc5a911f42271ad5855a86a
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Skip cff dump for certain functions when its disabled

Certain functions were generating CFF when CFF was disabled. Make
sure these functions do not dump CFF when it is disabled.

Change-Id: Ib5485b03b8a4d12f190f188b80c11ec6f552731d
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Fix searching of memory object

Make sure that at least a size of 1 byte is searched when locating
the memory entry of a region. If size is 0 then a memory region
whose last address is equal to the start address of the memory being
searched will be returned which is wrong.

Change-Id: I643185d1fdd17296bd70fea483aa3c365e691bc5
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
 msm: kgsl: If adreno start fails then restore state of device

Restore the state of the device back to what it was at the
start of the adreno_start function if this function fails to
execute successfully.

Change-Id: I5b279e5186b164d3361fba7c8f8d864395b794c8
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Fix early exit condition in ringbuffer drain

The ringbuffer drain function can be called when the ringbuffer
start flag is not set. This happens on startup. Hence,
exiting the function early based on start flag is incorrect.
Simply execute this function regardless of the start flag.

Change-Id: Ibf2075847f8bb1a760bc1550309efb3c7aa1ca49
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Do not return an error on NULL gpu address

If a NULL gpu address is passed to snapshot object tracking
function then do not treat this as an error and return 0. NULL
objects may be present in an IB so just skip over these objects
instead of exiting due to an error.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Change-Id: Ic253722c58b41f41d03f83c77017e58365da01a7
msm: kgsl: Use CPU path to program pagetable when active count is 0

When active count is 0 then we should use the CPU path to program
pagetables because the GPU path requires event registration. Events
can only be queued when active count is valid. Hence, if the active
count is NULL then use the CPU path.

Change-Id: I70f5894d20796bdc0f592db7dc2731195c0f7a82
CRs-fixed: 481887
Signed-off-by: Shubhrapralash Das <sadas@codeaurora.org>
msm: kgsl: Only initialize process structure once

If the debug root of the process structure is initialized
then it means that the remaining fields will also be
initialized. Check this field at the beginning of the
initialization routine and skip to end of the function. This
also by-passes the reinitialization of some fields because
of errorneous NULL pointer check of rb node. The rb node is
always initialized to NULL so checking if it is NULL to
determine whether the pointer is initialized or not is wrong.

CRs-Fixed: 498014
Change-Id: I73b2124c037187bc96942714dac62c0a72c26372
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Do not hold memory spinlock when calling find
 region function

The function kgsl_sharedmem_find_region holds the memory spinlock
at the beginning of the function so we do not need to hold the lock
before calling the function

Change-Id: I20ee32e0ed6aee6ed61cdd4fb7a9cc08a876fc84
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Skip perf counters and Sync lock for A2xx.

Fix includes two changes:

- Skip Perf counters for A2xx since these are intended only for A3xx.
- Don't use GPU-CPU sync lock for A2xx to avoid bootup failure.

Change-Id: I9e1d349b95dd0f6470ab507167b53540f1f1acf7
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
msm: kgsl: Add a section to list memory entries in snapshot

Add a section that lists all memory entries of a process
in which the hang has supposedly occurred. The entries are
of (gpuaddr, size, memtype) tuples.

Change-Id: I981d2325346455a6775af1691474c02422581b4f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>