msm: kgsl: create singlethread wq instead of per-cpu wq

There doesn't seem to be a need for a per-CPU workqueue - kgsl can
make do with a singlethread workqueue which consumes less resources
and does not pin work to specific CPUs.

Change-Id: I6f9bd368434797a05497be88c24a5b1645d2f221
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: fix error handling in adreno_waittimestamp()

This function was incorrectly reporting hangs when an
error such as ERESTARTSYS was returned by
__wait_event_interruptible_timeout().

Change-Id: I9139b03c4b417d135663729c763343382328da77
CRs-Fixed: 321490
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: fix adreno225 register ranges

There is a gap between GRAS_UCP5W and GRAS_UCP_ENABLED.
Trying to save and restore these registers with shadow writes off
results in rbbm read errors.

Change-Id: I4c99d9e23cae81315418f33aa656117303f990f2
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Enable adreno225 firmware for 8960v3

There is a hardware fix between 8960v2 and 8960v3 that affects which
version of adreno225 firmware is used.  There is no difference in
the chipid in adreno225 so do a runtime check to determine the
firmware to load.

Change-Id: Id4b8025c04c154550c4dc52df0011aa4e8ffa799
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: add tracepoints

Add tracepoint instrumentation to a2xx irqs, z180 irqs, command
buffer issues, timestamp checks, and timestamp waits.

Change-Id: Ib8763a4ff408c448b5b984d80f66b0c77268d9cf
Signed-off-by: Norman Gee <jgee@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
Fix-up
msm: kgsl: don not hardcode SQ_INST_STORE_MANAGMENT

This value is different on adreno225, so rather than
hardcoding it use pix_shader_start instead.

Change-Id: I805647f440a7385cf10ba8bec2cb7ce0b517ad1f
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: _timestamp ioctl should be locked.

The call touches too many general resourses to remain unlocked.

Change-Id: Ie5b36757d611750dda82f67b5579c85b1226b767
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: make cffdump work with the MMU enabled

The tools that process cff dumps expect a linear
memory region, but the start address of that region can
be configured. As long as there is only a single
pagetable (so that there aren't duplicate virtual
addresses in the dump), dumps captured with the
mmu on are easier to deal with than reconfiguring
to turn the mmu off.

Change-Id: If4070e60de50387dd12454b98e982b6713eeac42
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: remove ib_dump debugfs file

This has not been found to be useful for hang debugging.

Change-Id: Ie8cfb6bcbb8f81d8da903d5062bc75fcc4c3bee4
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: No need to set the graphics mmu type twice

Remove a second redundant call to kgsl_mmu_set_mmutype

Change-Id: I9d98a242952ac5738c260df84896c2b0f76b12d3
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: improve postmortem and cff bounds checking

Some hangs are fooling the postmortem dump code into
running off the end of a buffer. Fix this by making
its bounds check logic work better by reusing the
logic from kgsl_find_region().

CRs-Fixed: 319312
Change-Id: If6cc01369f4b0634d7e19494b8d021643abb8a39
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: let postmortem dump find context switch IBs

Because the IBs used for context switching are not allocated
by userspace, a separate search is needed to find them
in adreno_find_region.

Change-Id: I4c2a180333ae54ecbf257fd8c90ec2e3f748ad95
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Allow userspace processes to turn off/on power features.

Primarily intended to allow Adreno Profiler to turn off the features
that confuse some of its metrics.

Change-Id: I22e0bd68147ef1631e3bd3f579e777866fb894c4
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Make sure the local directory is put in the CFLAGS

Some compilers struggle to find local includes that are referenced from
external headers.  Add the driver path to ccflags-y.

Change-Id: Ic0dedbad2744e7350b19b97dc0b84cd49c070b95
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Establish a standard GPU ID scheme for the KGSL core

Establish a standard generic format for a GPU ID in the KGSL core:

[0:15] - GPU specific identifier
[16:31] - 0x0002 for 2D or 0x0003 for 3D

Add a KGSL core function to get the GPU ID from the devices and
GPU specific functions to return them.  For Z180, the ID will be
0x0002000B4 (0xB4 = 180).  For 3D, the ID will be 0x00030000 ORed
with the GPU identifier (anywhere from 205 to 225).

Change-Id: Ic0dedbadddb3f587121913b9c226e2bda466f84e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Move a #define to a centralized header

ADRENO_ISTORE_START is valuable information for
a number of functions, so move it from within
adreno_debugfs.c to adreno.h.

Change-Id: Ic0dedbad41445fad2130b7cb28d706283f59b4c2
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: Allow device attributes to be re-created

Leave the attributes initialized so that removing and
restoring policies doesn't result in a kernel panic.

Change-Id: I9724ebf94e3845b6cbaea18abf49d1813043eb52
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: fix infinite loop in adreno_find_region()

If postmortem dump tried to parse a context switch
buffer for any context except the current context
this function would never return.

Change-Id: I19f2fe7afda5796180cdf5f81c17fad960e84f05
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
msm: kgsl: adreno_isidle shouldn't BUG()

If the ringbuffer isn't idle, the GPU is probably in
SLUMBER or SUSPEND which are very idle states. This
function probably still shouldn't be called, so WARN
instead.

Change-Id: Ia49a819d935d6dce9cae2c193aff8e9de87d8af6
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>