Revert "gpu driver"

This reverts commit 575ae9395e1ea2e4a9e0e861774ff761afe55ecd.
redo gpu
msm: kgsl: Hold the pm_qos vote at all times when ACTIVE

The GPU needs access to the L2 cache while running.  If the
CPU is not also active using the cache can lead to stability
issues.  Keep the CPU out of idle power collapse at all times
while the GPU is running.

CRs-Fixed: 397489

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

Conflicts:
	drivers/gpu/msm/kgsl_pwrctrl.c

Conflicts:
	drivers/gpu/msm/kgsl_pwrctrl.c
msm: kgsl: Use the correct units for ADRENO_IDLE_TIMEOUT

In a few spots the ADRENO_IDLE_TIMEOUT value (measured in milliseconds)
was used directly for jiffy calculations resulting in timeouts that were
1000/HZ times longer than they should have been.  Use msecs_to_jiffies
for these situations.

CRs-Fixed: 448226
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 0bcdb735fb0ffa524638ab75acf76d3ddfe38616)

Change-Id: Ic2cd7eaf949d5c69c803fd109f206629de56ef9f
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: kgsl: Increase REG_RBBM_CNTL value to 0xFFFF for A20X

Increase number of clocks that RBBM will wait before de-asserting
the Register Clock Active signal. This fixes kernel panics during
stability tests on multiple devices

Change-Id: I6f7f8bb17cfd9c5beed0fd21d56ab6ab9fd40195
Signed-off-by: Rammohan Basavaraju <rammoh@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
msm: kgsl: Turn off the CP_DEBUG dynamic clock

The CP dynamic clock seems to be glitchy when the CP clocks are turned
back on after a power event. Turn off said dynamic clock control at
init time. The impact of leaving the dynamic clock control off is
negligible since the CP clock is only on when the CP is actually in
use.

CRs-fixed: 402119
CRs-fixed: 409253
CRs-fixed: 413224
Change-Id: Ic0dedbad783f8b911d9b57d1602d9b3976af1b3b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add cache flush for A20x

Adding extra cache flush command to make sure that CP block
gets event from RB all the time to avoid race conditions because of
clock switches. this is to improve stability on 8x25 target.

(cherry picked from commit fd5f8a4e3dc902d32f5b37de67555e56b887f759)

Change-Id: I32063b1d4ab6180159f868b47c7e0fd79d7b12b3
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno_ringbuffer.c
msm: kgsl: Always submit an interrupt request to the GPU

A context does not have to be present to send an internal dummy
command to the GPU.  Remove BUG() in this case and instead send
a NULL context which will still cause the interrupt to get submitted
to the GPU.

CRs-fixed: 392688
Change-Id: I66b6eebe899ab09e6615d08faddea7ea73de5c6d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

Conflicts:
	drivers/gpu/msm/adreno.c
msm: kgsl: Check for valid pointer before dereferencing

Check to make sure that there is a valid context pointer before
dereferencing it when adding commands to the ringbuffer.

Change-Id: Icf9824de8f62a28cdeeef4378246d9fb334d39fa
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Revert "msm: kgsl: Update pagetable on context destruction for A20x"

This reverts commit f0d1c9b79e05972816b92bd43b29e98f764826ea.

Reverting this change since it corrupts Bin Base Offset between
two draws of a Binning pass, resulting in GPU hang.

(cherry picked from commit 3ec5d2db139d0941ec8360f6cc399223b18469e5)

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

Conflicts:
	drivers/gpu/msm/adreno_drawctxt.c
msm: kgsl: Check the current interrupt status before power operations

Sometimes the core will go idle before the interrupt can be handled on
the GPU. If that happens then we could go to a lower power state before
cleaning up the pending interrupt and various entities that might be
waiting for it. Consider the current interrupt status when checking
for idle.

Change-Id: Idd43e56e0162a522e0929df83531aff94beadc19
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Don't consider active count if not in active state

Don't consider active_cnt variable if not already in ACTIVE state.
The active count variable does not necessarily exactly indicate the
number of open handles to GPU for switching power state. Hence,
only wait for active count to reach zero before switching to SUSPEND
state if, the current state is ACTIVE.

CRs-fixed: 483154
Change-Id: Ie025a1873cfb9237bdfba89204f4c2116549eba4
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Always resume the GPU regardless of its state

Make sure we resume the GPU regardless of its current
state. If the device is not in suspend state restart the
device and  print an error message.

Change-Id: I9e71cbe27d360dc06513c54f3a734aaea5b10d2b
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm: kgsl: Protect the mem_entry list during deletion

Use the spinlock to prevent corruption of the mem_entry list during
deletion. Otherwise the mem_entry list may be modified by another
thread at the same time resulting in memory corruption.

Change-Id: I5728a8b925753d5fda82413615e5ebaf0366dfd8
CRs-fixed: 489224
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Lower bounds check the number of power levels

A misconfigured board file could cause an out-of-bounds
array access through this value.

Change-Id: I64bbad0c096a2efe65376991537d810141370d72
CRs-Fixed: 439230
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Do not try to resume the device from INIT state

If the device is still in INIT state there are no open instances
of it running.  Resume calls should be no-ops.  Do not attempt
to start the device at this point.

Change-Id: I1cb6d60581b0b5b0a2ab1b13418adc4ae3983c5e
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
msm: kgsl: Avoid turning on GPU clock if already off

In adreno_idle(), check if the GPU clock is already
turned off. If so, the GPU is already idle,
so don't turn on the clocks again.

Change-Id: I27ae939253ee71830466e3117bed0230d7ff67d5
Signed-off-by: Ananta Kishore K <akollipa@codeaurora.org>