drivers: gpu: Backport Adreno driver

Change-Id: I02fe59ebfdf27d2eb36fa8a5ed76afbb816d7df6

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>

msm: kgsl: Add support for Android's sync point framework

The Android sync point framework will replace the synchronization
previously implemented by genlock. This change implements the KGSL
component of the sync point framework by creating a fence that is
automatically signaled by KGSL when it's timestamp expires. The
fence FD is returned to the user driver so that another process
can wait for the sync point.

Change-Id: Ifee38dfde00e551f3524f7a37833938dcdb64905
Signed-off-by: Jeff Boody <jboody@codeaurora.org>

msm: kgsl: implement sync compare callback

The compare callback is required to test the order that
sync pts will signal. Failing to implement the compare
callback results in kernel panics for some use cases.

Change-Id: Ibea1497c12fd8cc66087ff52d3709a07793f215f
Signed-off-by: Jeff Boody <jboody@codeaurora.org>

msm: kgsl: remove unnecessary definitions for dup and has_signaled

The dup and has_signaled functions are not called outside kgsl_sync.c

Change-Id: I69d746f4e4acae9b4f5a3a2cac79ac812e5eff5c
Signed-off-by: Jeff Boody <jboody@codeaurora.org>

msm: kgsl: Add GPU clock statistics.

The GPU clock statistics show the amount of time the
GPU was busy in the last one second and the time spent
at each individual clock level while it was busy.

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

msm: kgsl: Fix conditional GPU interrupts to fire only for waiting context

Conditional interrupts were not getting fired at the correct time when
using per context timestamps.  When a context was waiting on a timestamp,
the interrupt was being fired on the global timestamp rather than the per
context timestamp.  Now the interrupt is fired on the per context
timestamp.

Change-Id: Ib683c846f0639a1e44f5b39bb81ca2751b306ea1
CRs-Fixed: 340620
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

msm: kgsl: fix idle reporting for the msm pwrscale policy

Report idle whenever we go to nap and sleep for the msm policy

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

msm: kgsl: No need to write registers on _stop

After a _stop, _start must be called to write the correct
values to these registers before the device can be used
again.  No reason to write an additional value on _stop.

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

msm: kgsl: Don't use 'wait_timeout' in the idle functions

There are two distinct parts of the code that may need to loop waiting
for the GPU to complete a task: waiting for a timestamp and waiting
for the entire core to go idle. Waiting for a timestamp technically
doesn't need a timeout since the only downside is a process that sleeps
forever with an interruptible timeout. Waiting for the core to go idle
is more problematic because it is a busy wait and it is the last point
we can safely detect a GPU hang.

Beacuse we can (and will) not use a timeout in wait for timestamp, we
need to institute a new timeout value to be used in idle. Nowhere the
idle function is called uses a custom value for the timeout, so remove
that parameter from the calls and use a static timeout value in the
core specific functions.

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

msm: kgsl: Allow the wait_timeout to be disabled

With the improved hang detection we don't technically need a upper
timeout bound for a process to wait in waitfortimestamp().  Allow
for a idle_timestamp of '0' to allow the loop to wait for ever.
The infrastructure for changing the idle_timeout still exists
so it can be changed to whatever value is appropriate for debugging
or testing.

CRs-fixed: 382366
CRs-fixed: 383999
Change-Id: Ic0dedbadf2c100eb56ed2338914575061776e725
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

msm: kgsl: Fix address range checking with no MMU

Fix the address range checked with no MMU by always
returning true for no MMU as there is no particular
address range when MMU is not used

Change-Id: I522681d13b2281d482bad91dd00d34ec0f440a1f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Alex Wong <waiw@codeaurora.org>

msm: kgsl: Map ebi memory to kernel

Implement the function to map ebi memory to the kernel.
This function is used when from postmortem or snapshot
when there is a hang and we are allocating memory from
kernel ebi space

Change-Id: I4f3e8b3fcb8c0107599ce3d3636c0ed33ace725a
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>

msm: kgsl: improved bounds checking on user-specified parameters

Verify that the user specified length for a PMEM region is smaller than the
size of the entire region as reported by the kernel APIs.

Change-Id: Ic0dedbad0127bdaed70eafc00238b44f982b093b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

Conflicts:

	drivers/gpu/msm/adreno.c
	drivers/gpu/msm/adreno_debugfs.c
	drivers/gpu/msm/kgsl.c
	drivers/gpu/msm/kgsl_gpummu.c
	drivers/gpu/msm/kgsl_iommu.c
	drivers/gpu/msm/kgsl_mmu.c
	drivers/gpu/msm/kgsl_pwrctrl.c
	drivers/gpu/msm/kgsl_pwrctrl.h
	drivers/gpu/msm/kgsl_pwrscale_trustzone.c
	drivers/gpu/msm/kgsl_sharedmem.c