msm: kgsl: Add a new API to allow sharing of GPU performance
 counters

Adreno uses programmable performance counters, meaning that while there
are a limited number of physical counters each counter can be programmed
to count a vast number of different measurements (we refer to these as
countables).  This could cause problems if multiple apps want to use
the performance counters, so this API and infrastructure allows the
counters to be safely shared.

The kernel tracks which countable is selected for each of the physical
counters for each counter group (where groups closely match hardware
blocks). If the desired countable is already in use, or there is an
open physical counter, then the process is allowed to use the counter.

The get ioctl reserves the counter and returns the dword offset of the
register associated with that physical counter.  The put ioctl
releases the physical counter.  The query ioctl gets the countables
used for all of the counters in the block - up to 8 values can be
returned.  The read ioctl gets the current hardware value in the counter

Change-Id: Ic0dedbadae1dedadba60f8a3e685e2ce7d84fb33
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno_a3xx.c
msm: kgsl: Add support for VBIF and VBIF_PWR performance
 counters

These 2 counter groups are also "special cases" that require
different programming sequences.

Change-Id: I73e3e76b340e6c5867c0909b3e0edc78aa62b9ee
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Only allow two counters for VBIF performance
 counters

There are only two VBIF counter groups so validate that the user
doesn't pass in > 1 and clean up the if/else clause.

Change-Id: Ic0dedbad3d5a54e4ceb1a7302762d6bf13b25da1
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Avoid an array overrun in the perfcounter API

Make sure the passed group is less than the size of the list of
performance counters.

Change-Id: Ic0dedbadf77edf35db78939d1b55a05830979f85
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Enable HLSQ registers in snapshot when available

Reading the HLSQ registers during a GPU hang recovery might cause
the device to hang depending on the state of the HLSQ block.
Enable the HLSQ register reads when we know that they will
succeed.

Change-Id: I69f498e6f67a15328d1d41cc64c43d6c44c54bad
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Track memory address from 2 additional registers

Add tracking of memory referenced by VS_OBJ_START_REG and FS_OBJ_START_REG
registers in snapshot. This makes snapshot more complete in terms of
tracking data that is used by the GPU at the time of hang.

Change-Id: I7e5f3c94f0d6744cd6f2c6413bf7b7fac4a5a069
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: Fix the extra draw packet on resume for A305

The extra draw command on resume was missing some state. Add the missing
state registers, to avoid stability issues.

Change-Id: Iad51cbe3be7b2951563c989625a690178491e0c8
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
Revert "msm: kgsl: Fix the extra draw packet on resume for A305"

This reverts commit 2496352fc24df20c8cea498a72249eadc835e67d.
msm: kgsl: Make use of performance counter for A2xx.

Add new performance counter for a2xx to track number
of ALU instructions executed. This will help fault tolerance
detection logic to get more accurate data about the GPU.

Change-Id: I4a1afcfa12fd55a8ca1c4827f1fa7ee8e322e9c5
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>