msm: kgsl: Idle the GPU after recovery in recovery routine

Before returning from recovery routine, wait for the GPU to
become completely idle to ensure that recovery passed

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 1088bdb727a0360e0acf38b4420a259877deb125)

Change-Id: Ida471d10188f55f7a5f70bb2427fdac27c8d767d
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 776c108db6c62578a0ee618f96088649baf76bd8)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Start the sleep timer after recovery has completed

Start the sleep timer if recovery from hang is successful.
This prevents GPU from entering low power states during
recovery.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit df609308d9cdd5ebc4605d09be4fdda420e1a434)

Change-Id: I7034ad26b12175fc704656eced5ea6cf7b57413c
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit f7593196a0fb7a1563bed6b96297c3c3d1b77e68)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Always add a start identifier to a command sequence

Add command sequence start identifier for commands submitted from
kgsl as well since this will be used during recovery. We will just
try recovery and not try to differentiate between commands from
kgsl or from user space.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit c3ad5803d537142ae15841afefba0831e9ed6134)

Change-Id: Ibe363682e4ea405a81fae77d5b5bfeccbad97edc
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit b13c30dd3ad88b5a5dd128f4824876f82e695b5b)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Introduce recovery data structure for hang recovery

Create a new data structure that holds all the information required
for recovering from hangs. This data structure is initialized as soon
as hang is detected because if the GPU is under DOS attack then by
the time we start recovery the recovery data may have changed.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit ba6c70b85941267c552b154be1729aef4e944da6)

Change-Id: Idcd7de7a02b4d57735c2186db9307a22bfd1a6b6
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit a5667011435a34bedb0916abc80e3337da68f28f)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Use recovery data structure to extract valid commands

Use the data set in the recovery structure when extracting
valid commands from the ringbuffer instead of reading
it from the device/memory.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit adb1602262d7a8cf988ef1ced622ea6cc1aecc99)

Change-Id: I5b4f263c34c09bc724e875866806971931060d52
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit ae6b074d30e3d1d3cad362f80ed5eb4c84f7e001)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Create a separate function to extract valid commands

Create a separate function that extracts valid commands from good
contexts and invalid commands from bad contexts during recovery

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 1d577fe6fc5cdf768c5f3fe59b56adcd0e86db19)

Change-Id: I03e787657d37a13cf2c915677ba05b87b5a5731c
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 9790eadcb74289fe3114c8cf2ba6d4d8a4920bfd)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Separate function to detect last command in recovery

Make the code more readable by writing a separate function to
detect the end of last command that is assumed to be successfully
executed by the GPU

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit bb7b32a2cd7c42783f608fa750b7cb23821a587e)

Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 59c917c7d6e36e5daf9820dc12a3f7c5bd508e2a)

Conflicts:

	drivers/gpu/msm/adreno_ringbuffer.h

Change-Id: Ia9065c8cf83c3404d82a2cf0865e1f0398be69da
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Turn on preamble to enable replay of commands

Turn on the preamble of the IB sequence in which hang is assumed
to have happened so that the bad sequence can be replayed.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 2a85f1fb19278fa530cb31dca0198583b77fc8be)

Change-Id: Ie3f70f2c8f273f73f5ed525f911bb2914b6bebce
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 53b95e6361dc7925374d375ea83cb6f51af59282)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Do not restore per context timestamp states

We do not have to restore the per context timestamp states during
recovery as this data is irrelevant after recovery.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 1caba1c8066b77d3955300c95a9be2489418b094)

Change-Id: I2ebf10cb9fca40fdff9f02978bdcda18dd771871
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 5ef7b562609b5b1ac3159f9dfca6d9922ac66186)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Write a separate function to set the reset status

Write a separate function that sets the reset status of each
context after recovery.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 29ed38ee8491fd873b304f3d2edad2a4a0395017)

Change-Id: Ic4a70823cb35637794a281142181d93b689d3b6e
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 51d5c7fb21d7d603a085c331bf2d29b5b6754ec3)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Mark the hung context in recovery before extraction

Mark the context that has caused a hang in recovery before
calling the extraction function. This updates the context
state correctly early in recovery.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit b9f1e831b78da1192c189aab507272298ae9eb9b)

Change-Id: I8a3078ca76d7f447d5ca104ba98b34d46a4409aa
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit 790998de09e2fc4a091da9444bad52d222776390)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Expire timestamps after recovery

Expire the global timestamp and timestamps of contexts that have
cause at the end of recovery. This will prevent any users waiting
on timestamps of hung contexts to return without waiting.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 5f085f45b19b1fd209eef1cb02b2bb68ad40f505)

Change-Id: I916bf41bad7b2e33c5fe0a885c3ea4e132974541
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit c1f92ca72dc3819c93a6bbee21d0af8354919465)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: In recovery search for command stream after global eop

In recovery search for the timestamp of the command stream after
global eop instead of searching for the command stream of the
global eop and then moving the pointer forward till the start of
the command stream following global eop. This is because if the
ringbuffer is full then the global eop timestamp may have been
overwritten, so its more reliable to search for the timestamp
that occurs after global eop.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 6f6ecb3ef3eb66ef8e07ae8473682f8b36091376)

Change-Id: I21e28acade3d6f431a00b8825845dbf4b8cb7008
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit f96febefc320b9c6007f2c167428a7c85e8d56b0)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: After timeout check if timestamp has retired

When a thread times out while waiting for a timestamp, check once
whether the timestamp which it was waiting for has expired or not
before treating it as an error

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
(cherry picked from commit 54396e5406b5fecdd1a0e347dab953967d0e9318)

Change-Id: Iaf8fef4881ca0510ac44b437d82b1382ce602097
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
(cherry picked from commit cb579bd248409c6892f4eecd0bf93383b66b375d)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm_fb: display: set pipe src and dst size same in solid fill mode

When a mdp pipe is in solid fill mode, the pipe outputs constant color
and pipe itself does not fetch data from memory, so pipe src size
should not matter. However, when src size is greater than dst size in
solid mode which means downscaling, underrun happens. In this
situation, setting src size to be same as dst size can remove underrun.

CRs-fixed: 368478
Change-Id: Ie3ffc34486129cddcc872fe6e5317873db985b97
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm_fb: display: Set timing generator after register flush

Timing generator was getting started before the register flush.
Stale values were sometimes causing IOMMU page faults on bootup.

Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
Change-Id: Ia671c3603e383af94197a23a8e5e5f32274a9978
msm_fb: display: add dcs command list for dsi command mode

DSI dcs commands and mdp pixel stream share same dsi link.
Add dcs command list to serialize sending dcs command and mdp
pixel stream to avoid contention which may cause dsi controller
to stall.

Change-Id: Ia1c75ba4773f9332d897273fc1f6922c28333d3e
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: vidc: Add support for ION memory on 8x55 target

This commit will add support for ION memory on
8x55 target for video encoder and decoder.

CRs-fixed: 380463
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
(cherry picked from commit 22d1abd7eec3bdba91f31fe3d8a1ea86d35e8568)

Conflicts:

	arch/arm/mach-msm/devices-msm7x30.c

Change-Id: I9263dfd99d490508013758c30fd22606a25d4fc6
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: kgsl: Increase the virtual GPU range for the IOMMU

Instead of a fixed 256MB virtual range for both the GPUMMU and IOMMU, make
the virtual range a property of the MMU engine and set the IOMMU range to
2GB.  Technically we could go all the way up to 4G, but even 2G is far out
of the realm of possiblity in the current generation, and we wanted to
reserve some of the space for future enhancements.

Change-Id: Ic0dedbad2987beb162b6a1878dd65ffae8a78522
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 6d76c4d0dff8edb0849ec85537d7013640d7d28a)