Merge pull request #9 from mifl/cm-11.0

presto: add specific drivers for bluesleep & bcmdhd
msm: kgsl: GPU fault tolerance timer

GPU fault tolerance timer with a 50ms interval is introduced to detect
the condition where GPU is stalled, when GPU state is active we check
for GPU stall and if a stall is detected fault tolerance is triggered.
Using a timer is a better design because this removes dependency
on userspace to call waittimestamp.

Conflicts:

    drivers/gpu/msm/adreno.c
    drivers/gpu/msm/kgsl_pwrctrl.c

CRs-Fixed: 477979
Change-Id: I22b1316ad3edb271c1241b93e7a36373dfc70234
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Check long IB only for valid context

Do not check for long IB if the hang is detected in a NULL context,
hang in NULL context can happen when we are switching from NULL to
active context and hang is detected in commands that write an
active context to memstore, long IB in this scenario is not possible.

Change-Id: I7711c86b91c6c2ce0b4aa0543572c26d10c83030
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Fix long IB time calculation problem.

Remove unnecessary addition of GPU used time to calculate
IB duration.

Change-Id: Ic7e18882038f21a087a2348d6f4fab5aed2bb8cf
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
msm: kgsl: Set alignment to 0 when low on mapped memory

If CPU map returns error due to low memory then we need to set
the alignment to 0 and instead of setting it to PAGE_OFFSET. This
is because we then simply search of a free memory gap at page
boundary and disrerard alignment requirement since memory is
low.

Change-Id: I828f5d0120d6d530e0e8857bcd96c9d5f266da10
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Set proper pagetable address immediately after recovery

Update the MMU with proper pagetable address immediately after
recovery to avoid any translations with old pagetable.

Change-Id: Ib929598363e48a42b8ae174ed9718402541f5b09
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
msm: kgsl: Don't refer the NULL context

This fix ensure the BIRT test case will not
cause any device crash.

Change-Id: Ibbcdca293f4da05b21d16674f605aac729905959
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Always Signal event time timeline for every event type

Fence sync seems to react badly when it gets a unexpected timestamp
on a timeline.  When a event expires always send the expected timestamp
even if the event expired because the context was destroyed.

Change-Id: Id1bc18220223c665012df1db21eea78af78d9288
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: display: Handle mixer stage commit for wfd correctly

If no dequeue buffer is present, do not return early as commit
call still needs to take care of  mixer staging and stage commit.
Early return of commit, results in pipe still staged errors since,
mixer stage and commit gets bypass.

Change-Id: I1aa7dc9e95d183b22739daae123cf7818afbeadd
CRs-Fixed:523959
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm_fb:hdmi:Video playback failure issue

OEM reported Video playback failure
(before Video, Audio fails actually) issue,
because hdmi_msm_power_off() skips
SWITCH_SET_HDMI_AUDIO, hdmi_msm_audio_off()

Change-Id: I4db61a62217bc49741571f23703361d273648fee
Signed-off-by: Nirmal Abraham <nabrah@codeaurora.org>
msm: hdmi-cec: bounds check cec frame size

Ensure that the frame size for the HDMI-CEC message
frame size doesn't exceed the maximum size when
reading message from userspace through sysfs interface.
This avoids potential overflow in cec send msg routine.

Change-Id: I09eb8f7a6dee64be2b504c6448b49e1da902aa47
CRs-Fixed: 520140
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
Revert "Revert "msm: kgsl: Prevent race conditions when freeing memory""

This reverts commit 31641ba74b0f4b1373fc1d3eae7ba668d85fa536.

Change-Id: Ic6ad47ed199bf598f6357d48ab220cf790d4440c
msm: kgsl: Configure FT behaviour from sysfs instead of debugfs

FT behaviour is changed to be configured from sysfs
instead of debugfs. Sysfs control gives us the advantage
of configuring FT at bootup and also across bootups.
Persistant configuration across bootups helps
testing by configuring FT once and testing the FT
config across bootups.

Conflicts:

	drivers/gpu/msm/adreno.h
	drivers/gpu/msm/adreno_debugfs.c

Change-Id: Ia3378f214371a6a4b9f205f9f884976f58585971
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Allocate space in ringbuffer for EOF commands

When userspace passes end of frame (EOF) flag, ringbuffer is
inserted with EOF marker commands. Allocate ringbuffer space
for EOF marker commands.

CRs-Fixed: 469807
Change-Id: I7de8d1b81d358a8d8753ac84fbdceddad27bb17d
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
msm: kgsl: use the same logic in adreno_idle and adreno_isidle

These two functions need to agree on the meaning of "idle",
so that calling adreno_isidle() right after an adreno_idle()
will always return true.

Change-Id: I7cddf73773186c3ec8b56c111affacac3b07fcc7
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 5365240cf0abf2d799dd849abca0dc5b46d4b784)
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>

Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
msm: kgsl: fix NULL check in kgsl_mem_entry_set_pend()

Checking NULL before derefencing usually works better.

Change-Id: I2e2936eb9532dae4b0ef471b5cb2dd1c3a8f0975
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
msm: kgsl: Avoid dereferencing NULL pointers

It is possible to drop to the bottom of adreno_ringbuffer_issuecmds
with either context or drawctxt set to NULL. Avoid dereferencing these
variables in the trace call at the bottom of the function.

Change-Id: Ic0dedbadbc7e2c0c4ef85e0d7103e04485ed3e69
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: An error condition could cause an array overflow

In kgsl_setup_pt() if the MMU specific setup_pt function fails
the code will attempt to unwind the setup but it will use an
out of bounds index to do so.

Change-Id: Ic0dedbad8b23f65d4b52cb5ba01810ff26b19b89
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl Check NULL return from kgsl_get_device_from_dev

The function kgsl_get_device_from_dev() might return NULL, which
was not checked in a few places. Check the return value wherever
it is called.

Change-Id: I764b23a7b13acd692ce0e1bf4bd040c7e180c7d8
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Init log levels in device init

Device log levels should be initialized during device initialization,
removing this from debugfs init because customer could disable
debugfs.

Conflicts:

	drivers/gpu/msm/adreno.c
	drivers/gpu/msm/kgsl_debugfs.c

Change-Id: Ie1222be1d421405e0d7481c799045cb9876c2a91
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>