ARM: 7880/1: Clear the IT state independent of the Thumb-2 mode

The ARM architecture reference specifies that the IT state bits in the
PSR must be all zeros in ARM mode or behavior is unspecified.  On the
Qualcomm Snapdragon S4/Krait architecture CPUs the processor continues
to consider the IT state bits while in ARM mode.  This makes it so
that some instructions are skipped by the CPU.

Signed-off-by: T.J. Purtell <tj@mobisocial.us>
[rmk+kernel@arm.linux.org.uk: fixed whitespace formatting in patch]
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Git-commit: 6ecf830e5029598732e04067e325d946097519cb
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
Change-Id: I74275a3d98aef291d6f41b1905acc3aeecb50b47
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Merge branch 'test' of https://github.com/xboxfanj/kernel_msm into android-4.4
msm: kgsl: remove or fix badly formated printk messages

Remove allocation failure errors, since we'll already get
plenty of notice from the kernel when this happens.

Use %zu when printing size_t values for portability.

Change-Id: I746043bd12116066e6b3c07a5fcabcbc9b00dba9
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl_iommu.c
msm: kgsl: fix build when dma-buf, ashmem and fbdev are not enabled

All of these features can be disabled in the kernel config.
Add appropriate idefs so that the build isn't broken in
this case.

Change-Id: Ife3283c40a87012ab58a679a911090a00e627a61
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Interpret the AHB bus error correctly for A4XX

On a AHB bus error interrupt the incorrect registers were read for
A4XX.

Change-Id: Iace2ef619423dc3b0bef9faf5517150f5dd111f3
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Change readl to readll for reading 64bit registers

The macro KGSL_IOMMU_GET_CTX_REG_LL  was incorrectly using
readl_relaxed() instead of the correct readll_relaxed().

Change-Id: Ie811161a31257eb58b82d38503c3790528eb8333
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: Add caching support for DRM GEM allocations

This change adds 3 KGSL DRM ioctls:

DRM_IOCTL_KGSL_GEM_SET_USERDATA
DRM_IOCTL_KGSL_GEM_SET_USERDATA
DRM_IOCTL_KGSL_GEM_CACHE_OPS

Get and set userdata ioctls are used by userspace to
store information like last operation (Read/Write) done
on this DRM object and last mapping (CPU/GPU) done for
this DRM object. This is required to optimize number of
cache operations on DRM GEM objects.

DRM_IOCTL_KGSL_GEM_CACHE_OPS is used by userspace to
perform cache operations on DRM GEM objects.

Change-Id: Id228a52da90cafed6a2b9e0b000117ad7aa8e366
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
msm: kgsl: Set CP_DEBUG in GPU cores start routine

The CP_DEBUG register needs to be programmed with values that
depend on the GPU core. Set this register in the core specific
start routine.

Change-Id: I5fa3813fa4b98efa8c73e1fc00b61f3cc3745b2f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: Bootstrap GPU microcode

When doing a GPU cold start after power collapse, load microcode
booter+dispatcher using AHB writes and setup a CP type3 bootstrap
packet in ringbuffer, this bootstrap packet loads the rest
of the microcode.

When doing a warm start after GPU soft reset, bootstrap microcode
jump tables.

Change-Id: I9ed07c6a428fdeed33650fa22d1b3317ea587189
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>

Conflicts:

	drivers/gpu/msm/adreno.h
	drivers/gpu/msm/adreno_ringbuffer.c
msm: kgsl: Fix overlap checking of address range

While checking if an address range can be merged or is contained within
a different address range also check if the type of the ranges are same.
If they are not same then do not merge them. Also, when checking for
overlap condition reduce the size of range by 1 since the last byte
till the size of the range is not a part of the range.

Change-Id: I721e5ee218d9222575516a188b6fc1e8649ecc10
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Pass an actual pointer to a snapshot callback

Pass an actual pointer to the snapshot_os callback from
kgsl_device_snapshot in lieu of playing a dangerous dereferencing
trick.

Change-Id: Ic0dedbaddbae90f18953582d113170d316a9b7f4
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: Fix several possible problem spots in the dispatcher

Fix a few spots that the compiler warnings missed. Avoid
dereferencing a pointer that may have returned ERR_PTR() without
first checking to see that if it did return ERR_PTR() and correct
an egregious signed / unsigned mixup. Not sure why the compiler
didn't yell at me for that one.

Change-Id: Ic0dedbadf075b34e51a89ce625d2308c5171a58d
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Avoid a possible pointer deference in __force_on_show

Make sure the device pointer is a thing before using it in
__force_on_show().

Change-Id: Ic0dedbad2e47f3bfb22daf43a910ab886200c03c
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Use the standard functions to read the queued timestamp

Use the standard KGSL functions to access the queued timestamp in the
generic event code rather than directly dereference the adreno_device.

Change-Id: Ic0dedbadfc3004ba9bb26dc6bda82dfe61663106
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Change prev_padding type in subbuf_start_handler

The .subbuf_start callback expects the prev_padding type to be
size_t. Change the definition of subbuf_start_handler to use
size_t instead of uint.

Change-Id: I572ccf7adceb0c7f1fd24c01ff09abc111981016
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>
msm: kgsl: Do not take active_cnt for events and waittimestamp

In the mists of time it was nessesary to take an active count
for waittimestamp and events because we did not want to run
the risk of suspending while the GPU was active.  Now that we
have the dispatcher we have much better control over the GPU
so the original risk is diminished.

The problem is that holding active_cnt prevents us from going
into nap and suspend and with server-side-sync a lot of the
events we are waiting for might take a very long time before
they even get dispatched on the GPU so we are essentially
keeping the clocks on waiting for other people.

z180 must take active count on its own.

Change-Id: Ic0dedbadcb608115938b198faebe333d19c6a8f6
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: manage active count in adreno_ioctl()

Most of the adreno specific ioctls do not need the hardware
on. The few that do are perfcounter related, it may be
better at some point to optimize them further to shadow
the counters when the hardware is not on rather than
forcing the power on.

Change-Id: I9ea83106e0aaf3d3ac8d261bdec4e4c2e21c4659
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: remove KGSL_IOCTL_WAKE from context destruction

Adreno context destruction never needs the hardware on
to destroy the current context.

For z180, always take an active count while destroying.

Since this is the last ioctl to use KGSL_IOCTL_WAKE, remove
it entirely.

Change-Id: I97368c7f3c28f16538cc5f48b802b681d7af96ef
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl.c
msm: kgsl: Fix the trace output for kgsl_issueibcmds

the ib= field in the kgsl_issueibcmds ftrace event is be the GPU
address of the first indirect buffer. Output it in hex, not decimal.

Change-Id: Ic0dedbad2fab5f280f71c819cdaac03789d90288
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Protect against a potential overflow in kgsl_sg_alloc

Avoid allocating a scatterlist so large that it overflows the size
passed to the memory allocators.

CRs-fixed: 564448
Change-Id: Ic0dedbad2ab421ddec8f3be38d61c9bdf9ae5bd4
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>