base: genlock: protect kref counting with spinlock

A race condition exists where the attach may not kref_get
before the kref_put finished. The genlock_file_lock was
originally added to protect against this case however it
was not protecting the kref.

CRs-fixed: 359649
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
(cherry picked from commit d6f534fc51eb5fc23d08dacceecd42a4b98747a6)

Change-Id: I4115ea1cc39ebe38ad0032ebf86871ac9d23a312
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
base: genlock: add magic to protect attach from non-genlock file

It is possible for user space to attempt to attach a valid fd that
does not correspond to a genlock file. This change adds a magic to
the kernel private data that is used for validation.

CRs-fixed: 359649
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
(cherry picked from commit 507a9d3354b24e7cc7f22e9695339de6df317fc1)

Change-Id: Ice93bfc904f61431688f03027a4090ceb7b9289a
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
base: genlock: remove BIT macro usage

The BIT macro is not defined for !_KERNEL_ resulting in compile errors.

CRs-fixed: 356263
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
(cherry picked from commit 0977510e0f72b2f1a24f41d5154c2f1b80c96d9a)

Change-Id: Iaf188a1af838c98ca30ce216d7be8ddf85db700c
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: Only return tlb flush flag if bit is set for given device

We should only return the tlb flush flag if the bit corresponding
to the given device is set in the tlb flags. Earlier we were returning
the flush flag always if the tlb flags had the flush bit set for any
device.

Change-Id: Ia598694b295e650ce97dde83ccd89c99e5811d06
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: kgsl: Report error if regulator enable fails

In function kgsl_pwrctrl_pwrrail check if call to enable the
regulator fails or not and report an error message on failure.

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

Change-Id: Id77422bd73c6a0f5f8106834419cfa13e8e807bd
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
msm: kgsl: Check whether the ops pointer is valid.

Check that the ops pointer is valid before using it, otherwise we
may fault.

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

Conflicts:

	drivers/gpu/msm/kgsl.h

Change-Id: I59d5ee123c66b044e8d9c502ed6e641e51bf62fa
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: kgsl: Pass correct datatype to kgsl_mmu_ptpool_destroy()

This fixes a crash due to NULL pointer access when allocation of DMA
Coherent memory fails.

Change-Id: I7ea7405713682aaa7cd660ef341a968342dc0880
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
msm: kgsl: Follow reverse sequence of init procedure during exit

Fixes kernel warnings about sysfs entries being unavailable when they
are removed during exit.

Change-Id: I6caaaff935b31d3f39a3610cdd2b048baf2f1a97
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
msm: kgsl: Modify kgsl_core_exit to release resources carefully.

kgsl_core_exit() should not call kgsl_sharedmem_uninit_sysfs() and
device_unregister() if those resources have not been allocated.
We check this by seeing if kgsl_driver.virtdev has been
populated or not.

CRs-fixed: 359477
Change-Id: Ic040667b29bd4e006e6f29a50809d94a2bb4b469
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: Add draw workaround commands after every 50 context switches

We need to add a draw workaround command sequence after every 50 context
switches if the gmem has not been saved in those 50 switches. This
workaround is required to prevent the GPU from deadlocking. Since gmem
save commands have draw calls in them we only need to execute this
workaround if the gmem has not been saved. The number 50 was chosen
empirically.

CRs-fixed: 362302
Change-Id: I1a659c85736c47fe6f45030b20ce7a12851b0815
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>

Conflicts:

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

Signed-off-by: Anshuman Dani <adani@codeaurora.org>
msm: kgsl: Issue packet to set shader bases on A20x/220 GPU

When GMEM save is not performed, the events to reuse shader space
can get dropped. This make the CP block to wait indefinitely
causing a hang. To unblock this, issue a packet to set shader bases.
This applies only to A20x/220 GPU.

CRs-fixed: 365465
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
(cherry picked from commit d71cfd6ee15626dfd66e2b94ed524fbd2488fe91)

Change-Id: I9a4bb72de7922e22f5c9a2d7972062e5ec15a187
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: kgsl: Add TLB flush for each submit in case of 8x25/7x2xa

Add TLB flush for each submit to prevent target freeze
in case of 8x25/7x27a/7x25a targets.

CRs-fixed: 379991
Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>
(cherry picked from commit 22a06d18c6eb100419616ddf7a2c4ac403420a9e)

Change-Id: I7c34660128c791c9329b41246af39879625d64d3
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Revert "msm: vidc: fix klockwork issue from HTC"

This reverts commit 6f9bb0d59cd73786842ea104957737128355e5bc.
Revert "msm: vidc: missing ifdef"

This reverts commit 67816e934ec98ac4c9bfd7696f528e8725248f92.
Revert "msm_fb: display: add YUV444 MDP format support"

This reverts commit 9a1c543fbe8b02c484e1f929932baf5c6d27bb0b.
Revert "msm_fb: display: fix incorrect MDP formats components unpack pattern"

This reverts commit 36444714483a71c18eb731ba8aa4f954e05d55c4.
Revert "msm: rotator: codes clean up"

This reverts commit 78b10bb47ef40e6c4d266c801e26107b7c32c3f5.
Revert "msm: rotator: update user session parameters for all rotator start calls"

This reverts commit 78b475ab0f1340c60fb99602eca94732c10e5ecf.
Revert "msm_rotator: add rotator ref count to cleanup code"

This reverts commit 56b940fbf8e27dea1efd4dd3e680479e61dd242c.
Revert "semaphore: fix compiling error"

This reverts commit aef4145bd657081e5df04b36a4e40dd8c093f1fe.