genlock: backport from CAF @dc6023bfefe994703
timed_gpio: backport from CAF @5d92f71e687e4e1a0
msm: kgsl: Use the right physical addresses in NOMMU mode

In NOMMU mode the gpuaddr was set to the physaddr
for the memdesc which worked great until the memory
wasn't allocated by KGSL, at which point it blew up.
We already went through the due dilligence to turn
all memdescs into sglists, so use the sglist to get the
physaddr (and thus the gpuaddr).  Check to make sure
that we're not trying to map a real sglist (more than one
entry) and if we are, then loudly fail.

Change-Id: Ic0dedbad5d401c505949c92d9a7795f3260dbabb
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: return correct error code for unknown ioctls

Unknown ioctl code errors are supposed to be ENOIOCTLCMD,
not EINVAL.

Change-Id: Id38529e4ec70d63091a9273a780585aea6ae9d9a
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Cleanup header file macros

Remove macro logic for macros that are always defined.

Change-Id: Iecbc8418102205559aa551af96b79579d1b3aa4d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Do not take spinlock when mapping to IOMMU

The IOMMU driver takes a spinlock internally when mapping, so
do not take an additional spinlock when mapping to IOMMU table.

Change-Id: I772ffb09af95ed15dc2c3495affa9efd48e4af5b
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: flush cache otherwise memory will be uninitialized

The memory is allocated by vmalloc_user which initializes the memory
to zero however the initialization was being discarded by the cache
invalidate before the memory was returned to userspace.

Change-Id: I4d44fb3c308bb04c6cb137f7d34cd38600980f42
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Add KGSL_DEV_ERR_ONCE helper macro for logging

Add KGSL_DEV_ERR_ONCE macro to kgsl_log.h, with functionality
similar to pr_err_once() but output format of dev_err(). Add logging
for deprecated code usage, to kgsl_ioctl_sharedmem_from_vmalloc()
and KGSL_USER_MEM_TYPE_ADDR switch case from kgsl_ioctl_map_user_mem()

Change-Id: I43bbd5acfb4630b88170034d61f1d099fbe3f118
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Do not dereference pointer before checking against NULL

The pagetable pointer was checked against NULL after being used.
Check against NULL first and then dereference it.

Change-Id: I714de9e3b153f212cb92502a21c7d720dd4e1e37
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Don't call through pwrscale functions when entering SLUMBER

No additional calls to pwrscale idle or busy should be allowed when
transitioning to SLUMBER state.

Change-Id: I9488569758d263752c9778b8603f8e80bbc41ea1
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: flush outer cache for alloc_page() pages

The outer cache needs to be flushed for these pages
after they are allocated so that the GPU and CPU
have a consistent view of them.

Change-Id: I4d6b688fc4a9f04d4bf8e3215d51bac32bf8e9fd
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Write the retired timestamp on resume

Write the retired timestamp into the expected location. This fixes
userspace crashes after resume when the retired timestamp is read
as 0 instead of the expected last timestamp.

CRs-Fixed: 350556
Change-Id: Iaa487ba8be427c29b9f7e9b30b251cf26fcff95a
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Add functions for enabling / disabling a powerscale policy

Sometimes you want to enable or disable a policy for a bit without
actually swapping out the policy.  These functions allow the kernel
to control the policy functionality.

Change-Id: Ic0dedbad4406e5fffe1ebd8e8ba4e6bf84d82203
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Remove duplicate soptimestamp memory write call

This soptimestamp write is not needed twice after hang recovery.

Change-Id: I117ecdc8651bf8b9410a245e0582c1f672d3ca6d
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>

Conflicts:

	drivers/gpu/msm/adreno.c
msm: kgsl: Use default hardcoded value for CP's ROQ queue size

The command processor FIFO depth is different for A330 and A2xx GPUs.
It is best to let each GPU use the default value which is hardcoded in
the respective GPU.

Change-Id: I5db6a1c0671d0ad4253dcad7f386429d78a4bd62
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Improve the notification timing of idle events

Use the ringbuffer read and write pointers to determine if the
GPU is almost done processing a command sequence.

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

Conflicts:

	drivers/gpu/msm/kgsl_pwrscale_msm.c
msm: kgsl: Properly assign the physical address

Correctly assign the physical address to be used as gpu address
when no MMU is used.

Change-Id: Ie824cadc7c8c85203f81c9c5961b6f8a5d1cd449
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Fix powerscale idle logic

Logic error was causing powerscale to get into a slightly funky state.

Change-Id: I2ff9e15180babfb07c63ab556e22f7db53f95a78
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: Fix when GMEM is saved for A2xx

Saving GMEM is set when doing context switching and should not
be set when creating the gmem shadow.

Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>
msm: kgsl: fix format of the rbbm read error message

It is much more useful to get the dword offset of the
failing register than the byte offset because it is
consistent with the #defines and other register
logging in postmortem dump and snapshot.

Change-Id: Ie257475a8e2224729e4d1ac14af13a8027974027
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: nobodyAtall <tsogkas@ceid.upatras.gr>