msm8x60: sqaushed update to DCVS updates

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)

old-changeid: I30020fade79b61f86cbec52c90a1f5861a673a4c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: 8064: add board file structures for mpdecision and msm governor.

Add device structures in the board file for mpdecision and the msm
governor. This essentially probes mpdecision driver and the msm
governor driver. When enabled mpdecision communicates the run queue
average with TZ and obtains back a mask of which cpus should be
online. The msm governor communicates the frequencies of the cpus
with TZ and obtains newer frequency for that cpu.

Both combined they govern which cpus stay online and how fast they
run.

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

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

Conflicts:

	arch/arm/mach-msm/board-8064.c

old-changeid: Ic720e88e110b320ef3ce1ae35901411202066951
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/devices.h

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)

old-changeid: I8a0bd62d06135714ce954c4cf6083523f5c1ca84
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)

old-changeid: 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
	arch/arm/mach-msm/devices-8960.c

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)

old-changeid: I505903eb8b9779f2065aebfab5b3f2aefc874200
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

cpufreq: msm: remove gov_mutex from stop.

The stop could end up calling set_frequency callback. The set_frequency
callback takes the same gov_mutex lock and we end up in a deadlock.

Fix this by removing the locks around stop.

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

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

old-changeid: I306f9cd2c05ce1e9c4c36d22d16b775a42881f0d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

cpufreq: msm: fix race in cpufreq.

__cpufreq_driver_target expects to be called with the rw semaphore
held. We are not doing this when the frequency is asked to be changed
by dcvs.

Use cpufreq_driver_target variant of that function which gets the
rw semaphore before setting the frequency.

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

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

old-changeid: I33cdac0aaac7fb44acf6f9eb451a80ff94175c46
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)

old-changeid: 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)

old-changeid: 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)

old-changeid: 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)

old-changeid: I4316ee58633f7353197654074263466cdaa25778
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: update dcvs if the governor limits change.

We had seen issues where dcvs goes out of sync with the actual
freq the cpu is running at. The root cause was if the userspace
changes the limits on the governor, the governor ends up changing
the frequency without notifying dcvs.

Provide an api for the governor to call dcvs when a frequency change
happens.

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

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

old-changeid: I3f321df0270e997531d1a4cf3ee2251f86aef0bc
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: provide frequency set/get callbacks at registration.

There is no need to register a separate structure for setting and
getting frequency.

Simply pass function pointers to set and get callbacks when a
core is registered.

While at it rename the msm_dcvs_freq_sink_register/unregister to
msm_dcvs_freq_sink_start/stop to better reflect that those
apis are meant to do.

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

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

old-changeid: Iee7aee1cbb2f33ed2852f1816ab62416b96fa7e6
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: remove idle notification registration.

Register the idle enable callback along with the core. The code
becomes cleaner and easy to update.

Importantly, the msm_dcvs_idle driver becomes useless. Remove it
and instead let the msm governor handle idle enabling and disabling.

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

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

old-changeid: Ice039e608d45bdeb9b8b718e5fbbf82a698d584d
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-8064.c

msm: dcvs: split get_core in add/get_core.

There is currently only one function to add and get a core. Clean this
up by splitting that in two functions one for adding core and the other
for getting one.

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

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

old-changeid: Ieefc853f1b3e1c4dd84e253ccc0d54cf4d1fdb24
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: remove core name.

Currently core_name is used to identify which core the dcvs operates on.
Instead use a type and the type num while registration with dcvs and
return an id (dcvs_core_id) upon successfull registration.

The dcvs_core_id is used by the clients of msm_dcvs to call upon its
apis viz. freq_start, freq_stop, msm_dcvs_idle etc.

The dcvs inturn uses the type num passed in at registration time to
invoke apis on the clients viz. set_freq, get_freq, idle_enable.

This further cleans up the internal dcvs add_core and get_core
implementation. One need not pass around the core_name and use the type
instead.

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

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

old-changeid: Id27751a8ec8f5d3d386bbe7c7625ed56757b8bd7
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: cleanup debug prints.

The debug print mechanism is not much useful. Remove that code.

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

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

old-changeid: I5b574aa4bf2784f8cdfe065bb17ab8246d0d9e73
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: functions to start/stop/restart hrtimer.

The slack timer is supposed to be activated only when the core
is out of idle and that the governor for that core has started.
If any of the conditions is not met one should not activate
the slack timer.

To implement such a scheme, create two variables idle_entered,
and pending freq protected by their respective spinlocks
idle_state change_lock and pending_freq_lock. Whenever the
idle is entered or exited stop/start_slack_timer is called
which grabs the appropriate spinlocks and udpates the idle_entered
variable and starts and stops the hrtimer.

Moreover there are situations when a activated timer needs to
be restarted. This happens when a frequency is updated and a new
slack timer is received. We provide restart_slack_timer() callback
which cancels the hrtimer and restarts it only if the conditions
mentioned above are met.

There is also a situation when one has to forcefully cancel the timer
when the governor stops. Provide an api for that too. Note that one
cannot use stop_slack_timer becuase stop_slack_timer manipulates
idle_entered flag.

Also on related note, cleanup the code that handles pending_freq.
We get a new freq to set for a core when
- the slack timer expires
- when the governor starts when the cpu is brought back online
- when the cpu comes out of idle

Use pending_freq_lock to serialize updates to pending_freq.

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

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

old-changeid: I4db5b4de0c02bef62749c9e727a59171ae3f4ac0
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: change tz buffer to 32KB.

Only around 32K of buffer is required for normal operation.
Request the scm buffer of 32kb from the contiguous area.

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

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

old-changeid: Ie1c9997fdf79796458aacaa5d3169e24666fcac4
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: add thermal control.

Add capability to read the sensor data and report the temperature of
a core to the TZ.

Note that this was done earlier whenever a frequency update was done,
instead create a delayed workqueue per core. Also create a attribute
that controls the rate of thermal update per core.

If that attribute is not set use 60seconds as the default update rate.
If it is less than one second, default to using one second.

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

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

old-changeid: If91343b975d490c05ea63c9977d81f9572072773
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: get rid of unused attributes.

There are certain attributes that are not used. Get rid of them.

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

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

old-changeid: Ia666e025aae47918471a55575646455764ca42f8
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: force on the slack timer,

For performance reasons the kernel should execute
a ONLINE call on TZ when the governor starts. The return
 values from ONLINE call are a new frequency and a new
 slack timer.

This new frequency would be queued up for the thread to set it up
on that core.

The way we handle the new slack timer is interesting. When the
governor starts we really dont know what the state of idle pulses
is, this is indicated by setting idle_entered = -1.  However we
want to start the slack timer. To handle this situation create
a function to force on the hrtimer without checking idle_entered or
pending_freq.

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

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

old-changeid: I7f6cd678323588f6d411c17526dc04a5748ed9b4
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: mpdcvs: add ftrace events.

Add ftrace events at interesting points in the dcvs and mpdecision code.

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

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

old-changeid: Ic5cc00539b837090010627f364428c157137f052
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: allow re-registration of cores.

If a core has already been registered with dcvs, just
return the previous dcvs core id if it is registered
again.

Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit b162e2b79d36fb7cb870b7b7184ed52ecafbf849)

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

old-changeid: I03b3519f4659e1c3adfee99f0b361b233fa2a918
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>

msm: dcvs: add frequency transient control to sysfs

It is useful to be able to toggle at runtime whether
particular DCVS points are used as transient levels. This
adds a sysfs node per core which when read returns a list
of the currently enabled DCVS transient levels. Writing
the frequency of a DCVS transient level toggles whether it
is enabled or not.

old-changeid: I69ebb6974e97efa832798047259b9acdfd08aa7c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 2f6db34b3216695d4f624d2204d5e1356e62c3d5)

msm: dcvs: run dcvs, mpdecision threads at default priority

It is not necessary to run these threads at a realtime
priority level.

old-changeid: I8c6492f22e803811db5757c51beeeb81f93f32b6
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 8862f41f1c632ba84f0a21e8045d70278fd67fd3)

msm: dcvs: create cpu freq table dynamically

CPU frequencies can differ between different revisions, so create
the table of cpu frequencies dynamically based on data from
acpuclock rather than using a fixed table.

Some of the data in the table comes from sync points that will be
implemented between CPU and GPU frequencies. The sync points are
defined here, but the sync implementation itself will come in a
subsequent commit.

old-changeid: I24cf17b199df1e5d064c1894b269e49118b39ac7
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit f9a8749b17961be653e9cbb426b1b72cada7f61c)

msm: dcvs: gpu minimum frequency levels

System performance is enhanced if the gpu frequency is given a
minimum corresponding to various frequency levels of CPU 0.

old-changeid: Iba168d708524fc8ef164428bb5f4e0631a499342
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 682c7a01c1d86518cdc7bec25cb413498811137b)

Conflicts:
	drivers/gpu/msm/kgsl_pwrscale_msm.c

msm: dcvs: start and stop temp updates with core sink

Temperature updates should not be sent continuously just
because a core has registered with dcvs. Instead, start
and stop the updates when the core starts and stops as a
dcvs frequency sink.

old-changeid: If7721f523eb44026c421dd7ec4fa3975bc65cd09
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 4eb5d7cf22bbea963251ff70a7b4e28a2d883b77)

msm: dcvs: drop pending frequency update on stop sink

If there is a pending frequency update when a core stops
acting as a dcvs sink, it should just be dropped, rather
than trying to honor that last frequency request.

old-changeid: Iac30cc7e06a8a70eecc4da712fdf160b788a7c2c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 016af00bf66bb267cab573131598edbf83204f3f)

msm: dcvs: do not run gpu set_floor_frequency callbacks after stop_sink

Once a gpu calls stop_sink and is no longer participating in dcvs, we
should not call set_floor_frequency callbacks for that gpu.

old-changeid: I3cde82dc9975bcb37f065ea7ab8eb88a8f7fc933
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 77c66a3c6c27729aa0594b2f1b140aaf8f556b67)

msm: dcvs: set gpu frequency floor when multiple CPUs online

Performance is enhanced if the GPU frequency is floored at its
maximum nominal frequency when multiple CPUs are online.

old-changeid: Ib6bfd5007d660064844876b06f552f4d8c84865c
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 749f301c94312d2ec827c67cecb858e02383c8ab)

msm: dcvs: set algo params according to number of online CPUs

It is desirable for performance reasons to be able to run dcvs
with different algorithm parameters depending on the number of
CPUs that are online. The algorithm parameters are already replicated
per-CPU, but all CPUs operate in DCVS with the same parameters at
any given time.

These per-CPU parameters now correspond to the total number of CPUs
online. For example, if 2 CPUs are online, the algorithm parameters
for CPU2 are used.

old-changeid: If308a2fa949ac669823e759e0fd8e2cdbf6e4c03
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit c48381e2336125410549d7df1425dc8009c0c495)

msm: dcvs: add sysfs parameter for active and leakage offsets

The active and leakage energy offsets for each frequency are
best left configurable from userspace to make tuning easier.

old-changeid: I435a30d46cc02861dd7e8371b21d0433c0aa6a28
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 8104d6dde814e8dbb4f91a3e37a19627e7512f50)

msm: dcvs: set gpu actual freq when setting gpu floor

If actual_freq of gpu is not updated when a gpu floor
is set, TZ is unaware of the gpu frequency change and
computations are based on an incorrect value. By setting
actual_freq, TZ is notified of the new gpu frequency at
the next idle exit.

old-changeid: Ifc69996ef309ed4f8a5d46a2048757e57dd1a8ec
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
(cherry picked from commit 81599d50a0d122c52c966279640d6d8c64def656)

msm: dcvs: add ss_no_corr_below_freq parameter

The busy/idle behavior of different cores can be correlated by
DCVS when determining what frequency to run cores at. However,
this is not desirable below a certain frequency. Add a parameter
to establish what this frequency is. The parameter is configurable
in userspace via sysfs.

The ss_iobusy_conv parameter is currently unused, so it is
being replaced with ss_no_corr_below_freq.

(cherry picked from commit e8c6d615259af5fde8a6613f53c41c212407bda9)

old-changeid: Ibf814f3f93b92a532d7b3af80721a5bc7db1bd31
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/gpu/adreno.txt

msm: dcvs: check power collapse state after updating params

The dcvs params are updated when the number of online cores change.
When this happens, the low power modes of each CPU need to be
enabled or disabled depending on how fast they are running and what
the new power collapse frequency thresholds are.

(cherry picked from commit 1b82c72e23f013ea2bdc526ad2859b421a97f48a)

old-changeid: I88c779dc21f47acd7a1fa1ded02e90825d7dc9d6
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

msm: dcvs: enable/disable power collapse on CPU 0 only

Idle power collapse is not currently used on secondary cores
with DCVS, so it should not be manipulated after boot by DCVS.

(cherry picked from commit 7419749fb656f2f6b406d61c1df5993b2385af0a)

old-changeid: Id75829172c7c529d2b3e42a1ad406e591a94d1e9
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>

msm: dcvs: fail gracefully if TZ does not support dcvs

If dcvs attempts to initialize on a system where TZ does not support
dcvs, it will eventually cause a crash. Prevent this by disabling
dcvs if TZ does not successfully initialize its part of dcvs.

Change-Id: Ia43896f854de645cec9e628896a89d90a9e8d10c
old-changeid: Ic9cd361243c03c3832133614c4847a2815b0bbb4
Signed-off-by: Steve Muckle <smuckle@codeaurora.org>
msm8x60: kang apq8064 kgsl and update board to match

* should fix the random reboots people have been reporting for a while

Change-Id: I6571d1d521cbaaa5ea9cb657a030da9ba70b3a2f
Revert "msm_fb: display: return fail if pipe still staged"

This reverts commit 7e754830782f13c9c9fb5b1d7521bf5563773193.

Change-Id: I8af11859461f953a07adf9b58754ba908d1a3d1c
tsubasa: disable MSM DCVS

* It doesn't build currently, and we don't have it
  enabled on the other blue devices anyways, so
  disable it.

* Also cleanup other cm config

Change-Id: I9050717be328513753998cebb633a2fae519c763
Sony: update blue/msm8960

merge of jb_2.5:
* ion api
* iommu
* cma
* kgsl
* sound/soc

Change-Id: Iafa9ff56efda1cf0c425b0fdc012d64d8001be7b
blue: enable the UHID driver

The userspace HID driver, which is needed by the JB Bluetooth stack
to process input from Bluetooth keyboards, has been merged by commit
2a86b6381ea84610722c8e27dc5cd12e0fb4fce7 , but its configuration has
not been enabled. Thus, the driver does not get built together with
the kernel, and the functionality it provides is not available.

Change-Id: Ib5ee0b88bb88eb2542a1b1e39ece80b010b3f0a1
msm: kgsl: Fix the extra draw packet on resume for A305

The extra draw command on resume was missing some state. Add the missing
state registers, to avoid stability issues.

Change-Id: I88c2fa9f0dc262c0230295c456ab9c9a299e11c2
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Don't refer the NULL context

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

Change-Id: I945cf389f8ba74656bdd654090a72a00d49315b6
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: KlocWork fixes

KlocWork fixes to avoid NULL pinter dereference

Change-Id: I09f0239078f99ee5281319cae2d07e91a42e9b97
Signed-off-by: Ananta Kishore K <akollipa@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Verify the user doesn't accidentally submit a zero length IB

Indirect buffers to be executed will not be (and cannot be) zero length.
Check and reject.

Change-Id: I2114ca5de5227eb34d64789e2d30f02be396c719
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
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.

Signed-off-by: Arnav Gupta <championswimmer@aokp.co>

Conflicts:

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

Change-Id: I4286af72b487022dc9bb319d03b1a1392b79b8b6
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Init FT log level in device init

Currenlty FT log level is init in debugfs init, debugfs
could be removed from commercial software and we might
miss FT logs, initializing FT log level in device init
prevents this.

Change-Id: Ic363c2603f52eb1d37347b92c2d9c43e2df4ba5d
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Use the kmalloc/vmalloc trick for the sharedmem page array

It was previously assumed that most GPU memory allocations would be
small enough to allow us to fit the array of page pointers into one
or two pages allocated via kmalloc.  Recent reports have proven
those assumptions to be wrong - allocations on the order of 32MB will
end up trying to get 8 pages from kmalloc and 8 contiguous pages
on a busy system are a rare beast indeed.

So use the usual kmalloc/vmalloc trick instead - use kmalloc for the
page array when we can and vmalloc if we can't.

Change-Id: I72add605461cdacdeeb12bb2f6690487c499d3df
CRs-fixed: 513469
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: kgsl: Do not try to resume the device from INIT state

If the device is still in INIT state there are no open instances
of it running.  Resume calls should be no-ops.  Do not attempt
to start the device at this point.

Change-Id: Ia09cc3bf89201907c2cd587b70fbf8c156a60fcb
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
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.

Signed-off-by: Arnav Gupta <championswimmer@aokp.co>

Conflicts:

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

Change-Id: I3f3b14011c5ea470a16e7f3f3f35cb8e0fd56261
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
iommu: msm: Configure memory attribute overrides

The default IOMMU memory attribute setting results in
reduced performance as a result of downgrading memory
attributes. Fix that.

Change-Id: Id502ab2c554ca1fa57ea3de6336618d739cadc0c
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
ALSA: usb-audio: Fix the mixer control range limiting issue

- mixer_ctl_set() function is limiting the volume level
  to particular range. This results in incorrect initial
  volume setting for that device.
- In USB mixer while calculating the dBmin/dBmax values
  resolution factor is hardcoded to 256 which results in
  populating the wrong values for dBmin/dBmax.
- Fix is to use appropriate resolution factor while
  calculating the dBmin/dBmax values.

Change-Id: I7ad9134261ad46215c593847140b44cdd1326472
CRs-Fixed: 515012
Signed-off-by: Deepa Madiregama <dmadireg@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
ARM: 7527/1: uaccess: explicitly check __user pointer when !CPU_USE_DOMAINS

The {get,put}_user macros don't perform range checking on the provided
__user address when !CPU_HAS_DOMAINS.

This patch reworks the out-of-line assembly accessors to check the user
address against a specified limit, returning -EFAULT if is is out of
range.

[will: changed get_user register allocation to match put_user]
[rmk: fixed building on older ARM architectures]

Change-Id: I6e094b31cc1d447a81b265af3ad4bb733491f45e
CRs-Fixed: 504011
Reported-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Cc: stable@vger.kernel.org
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Git-commit: 8404663f81d212918ff85f493649a7991209fa04
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Giulio Cervera <giulio.cervera@cyanogenmod.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm: scm: Add scm_call_noalloc and helper macros

Currently, scm_call internally calls kmalloc() to allocate a command
buffer structure. This prevents scm_call from working before kmalloc
structures are initialized or during atomic contexts. Allow clients
to pass in a pre-allocated buffer for scm_call to be used for internal
structures.

Change-Id: I71b59906b4113b426485ba6f4e98ca449a02e167
CRs-Fixed: 498392
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
msm_hdmi: fix build -Wnarrowing

Change-Id: I9a173d2df59cbba0314547d310a31e74765aa819
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>