msm: kgsl: Add support for Android's sync point framework

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>
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>
msm: kgsl: remove unnecessary definitions for dup and has_signaled

The dup and has_signaled functions are not called outside kgsl_sync.c

Change-Id: I69d746f4e4acae9b4f5a3a2cac79ac812e5eff5c
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
msm: kgsl: Hold the pm_qos vote at all times when ACTIVE

The GPU needs access to the L2 cache while running.  If the
CPU is not also active using the cache can lead to stability
issues.  Keep the CPU out of idle power collapse at all times
while the GPU is running.

CRs-Fixed: 397489
Change-Id: Iab2d8c601e903aadc4060f7c6d67bc128840edbf
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c
msm: kgsl: improved bounds checking on user-specified parameters

Verify that the user specified length for a PMEM region is smaller than the
size of the entire region as reported by the kernel APIs.

Change-Id: Ic0dedbad0127bdaed70eafc00238b44f982b093b
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>
msm: mpdecision: Add mpdecision driver code.

This driver is mainly responsible to convey the runqueue average and
iowait average values to the TZ periodically. The TZ returns the mask
of the cpu's that should be online and the slack timer.

The mpdecision code brings cpus up or down to match the online mask
from TZ. Also starts the slack timer as specified by TZ.

Upon expiry of the slack timer mpdecision calls TZ to get a new
mask and a new slack timer.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit a599de41a47b0b1a9f81a77227e16aff5a16a072)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit d2cf2db9632c3c2a33bc66ff61b2c2b758c10c86)

Change-Id: I30020fade79b61f86cbec52c90a1f5861a673a4c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: rearrange platform data.

This change
-removes the use of group id and instead introduces core type
-rearranges platform data, adds energy curve coefficients and power
 parameters
-allow for the energy params to be -ve numbers

The change also mandates updates to the msm8974-gpu.dtsi and the
associated binding documentation.

Also take this opportunity to remove devices for unsupported platform
- 8930 and 8960

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 4445166ad16be0c45b077bfb10487de355ed2e05)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 24d2351f6a5e7069e5d554dbc999280a69288c5d)

Change-Id: I5c65c0e65cc7652eee72c525f0db10e128061cf9
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:

	Documentation/devicetree/bindings/arm/msm/dcvs-core-info.txt
	arch/arm/boot/dts/msm8974-gpu.dtsi
msm: dcvs: Add thermal interfaces.

The algorithm needs thermal inputs for all the cores. Create members in
the internal core_info strucutre and platform data/device tree to pass
in the sensors they use.

Update the dcvs code to notify the temperature to TZ.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit fc7dca4c325725492af997fa282e07b9d03154d1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit eb478c5b7b55ea8a57e0336e4cf9979be935b289)

Change-Id: I505903eb8b9779f2065aebfab5b3f2aefc874200
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: update the event enum in preparation for mpdecision.

The event numbers used to communicate with TZ have changed. Update
them here in preparation of mpdecision.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 0db555f69e8e5b5237f2c053fffeeec3926084a1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit deda7f0ef23aea568975ec73d4f54022f468adef)

Change-Id: I8a0bd62d06135714ce954c4cf6083523f5c1ca84
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: hide -13 errors when communicating with the secure side.

-13 errors from the secure side are benign, dont print an error when
that happens.

Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
(cherry picked from commit 3cb914d56d65b9ad1dea8d186f74d3a1bc760769)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit dee3d749bbf60315080a2fb455bf8b2bd0640f36)

Change-Id: Id22bad3f3ee88e4292b3155014e43aa043a5df12
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: prevent thread creations upon cpu hotplug insertions.

Numerous threads were seen created and left idle as cpu's were
hotplugged in and out. Avoid creating new threads unnecessarily.

Instead create just one thread when a core is registered and use
it later.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit e039aac0c0be7c0d914055224103e8f41821320d)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit dbbe1e71a6f1be2dee99104281ad47e6884891bc)

Change-Id: Ib1255f9df5b41fbb49d25fdd6d661ebfa7f7642b
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: get rid of the pending freq array.

Only one pending frequency should be set, there is no need to
maintain an array of intermediate requests.

Cleanup the code and remove new_freq[] array and the index to
it. Introduce pending_freq a single entity that carries the
latest frequency request. Use the core's cpu_lock to protect
it.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit bea1b7628356bd953a88596c556373a6ec355f94)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 32f01b8af255b565d5bcf1496a1aaea77250e205)

Change-Id: Ie939700f7f62e453638e73f489e729105e363d29
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: dcvs: use wait_q.

It is cleaner to use wait_q mechanism instead of waking up the thread
and managing the scheduling flag ourselves.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
(cherry picked from commit 33bf417160e9340f2dd5f9f275e7e6021987bfe1)

Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit de943e4aff2a26e0d21b208d85b5876c31bfda85)

Change-Id: I4316ee58633f7353197654074263466cdaa25778
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>