msm: kgsl: Set sysfs max clock for devices with no power scale policy

When the sysfs entry for max clock is updated, set it immediately for the
devices that has no power scale policy. This prevents the device from
running with undesired clock.

Change-Id: I3211234f6d2afe4c2de115dace70b332d2b30f21
CRs-fixed: 408963
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
Signed-off-by: Rajeev Kulkarni <krajeev@codeaurora.org>
msm: kgsl: Make the GPU device aware of the next pending event

The adreno core needs to know what the next event pending for
any given context is so it can mark the interupt to be fired.
If this isn't done then some timestamps that don't have a
matching waittimestamp call won't fire an interrupt. This is
dangerous on the last interrupt/event before a context goes
away.

Change-Id: Ic0dedbad71f6de07b43b0656128c76509326d645
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm: kgsl: Add support for Android's sync point

The Android sync point framework will replace the synchronization
previously implemented by genlock. This change implements the KGSL
component of the sync point framework by creating a fence that is
automatically signaled by KGSL when it's timestamp expires. The
fence FD is returned to the user driver so that another process
can wait for the sync point.

Change-Id: Ifee38dfde00e551f3524f7a37833938dcdb64905
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
msm: kgsl: implement sync compare callback

The compare callback is required to test the order that
sync pts will signal. Failing to implement the compare
callback results in kernel panics for some use cases.

Change-Id: Ibea1497c12fd8cc66087ff52d3709a07793f215f
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>
(cherry picked from commit b44e3b4fb92810703ad296a5c9f829c5f86ffe4a)
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: kgsl: Idle the core before changing the gpu clock.

Idle the core before changing the gpu clock as instability
is caused on some platforms on changing the clock freq when
core is busy.

CRs-fixed: 328249
Signed-off-by: Kedar Joshi <kjoshi@codeaurora.org>
(cherry picked from commit c11d098f53dd1fb07ea03475510c29c39b9671ab)

Change-Id: I11fc58128560b131f60a84fc94b8bc48134a9eaa
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: kgsl: Detect and avoid malformed ioctl codes

Because we were using _IO_NR, one could construct a malformed ioctl
code that would avoid allocating memory yet go to a function that
expected that memory. Still use _IO_NR to index the array of ioctls,
but check that the full values match before jumping to the helper
function.

CRs-fixed: 385592
Change-Id: Ic0dedbaded469035bd0a2bb0f20fecb2a3045ca5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
(cherry picked from commit 1e76f61bb001b93795a227f8f808104b6c10b048)
msm: kgsl: In kgsl release do not idle if device is in HUNG state

When recovery fails we are in HUNG state and clocks are turned off,
If a client closes kgsl device, driver release gets called and
we will try to idle the device which leads to accessing GPU registers
without clock being on. This leads to excessive kernel logging
"kgsl_pre_hwaccess hw access while clocks off from state HUNG"
and this eventually leads to watchdog.

Change-Id: Ib15c83fa06f6d32382b20c68a3ceb5081f1cfd69
CRs-fixed: 397149
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
msm: kgsl: In kgsl release do not idle if device is in HUNG state

When recovery fails we are in HUNG state and clocks are turned off,
If a client closes kgsl device, driver release gets called and
we will try to idle the device which leads to accessing GPU registers
without clock being on. This leads to excessive kernel logging
"kgsl_pre_hwaccess hw access while clocks off from state HUNG"
and this eventually leads to watchdog.

Change-Id: Ib15c83fa06f6d32382b20c68a3ceb5081f1cfd69
CRs-fixed: 397149
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Gopal Goberu <ggober@codeaurora.org>
Signed-off-by: Subrahmanyam Uppala <csuppal@codeaurora.org>
msm: kgsl: Set requested power state to NONE after resume

When GPU resumes from suspend requested state is not cleared to NONE.
Due to this idle reporting is not done and GPU stays at MAX freq. As
a fix if the current power state is already ACTIVE and request is
made for active power state then clear the requested state immediately.

CRs-fixed: 424682
Change-Id: I7f0d7fa819308f166cbbbf30b2c20aee73644cfb
Signed-off-by: Vinay Roy <vroy@codeaurora.org>