sched: Add sysinterface for GENTLE_FAIR_SLEEPERS

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
s2w/dt2w: Add power key toggle

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ARM: sched_clock: Load cycle count after epoch stabilizes

There is a small race between when the cycle count is read from
the hardware and when the epoch stabilizes. Consider this
scenario:

 CPU0                           CPU1
 ----                           ----
 cyc = read_sched_clock()
 cyc_to_sched_clock()
                                 update_sched_clock()
                                  ...
                                  cd.epoch_cyc = cyc;
  epoch_cyc = cd.epoch_cyc;
  ...
  epoch_ns + cyc_to_ns((cyc - epoch_cyc)

The cyc on cpu0 was read before the epoch changed. But we
calculate the nanoseconds based on the new epoch by subtracting
the new epoch from the old cycle count. Since epoch is most likely
larger than the old cycle count we calculate a large number that
will be converted to nanoseconds and added to epoch_ns, causing
time to jump forward too much.

Fix this problem by reading the hardware after the epoch has
stabilized.

Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
s2w/dt2w: Prevent touches during phone calls

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Add a sampling_down_factor for max frequencies

Change min_sample_time to 100ms when running at max

Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: sync freq feature for interactive governor

1) Add load info to cpufreq_interactive_cpuinfo
2) If load on any other online cpu exceeds sync_freq_load_threshold,
   do not allow the frequency to drop below sync_freq

Change-Id: I3617e10f87b85178914a18bcf04ac2a31a4f1ec1
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
(cherry picked from commit c26e25944543c61b34b1830938bb6f353a2580ac)
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Allow 1 ms error in above_hispeed_delay comparisons

Allow for an error of 1 ms while taking into account
above_hispeed_delay for a frequency

Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Reset floor_validate_time if busy at max for 100ms

When the interactive governor selects to run at max frequency it doesn't
re-schedule the timer until it hits an idle. This change checks if the CPU
has been continuously busy for last 100ms on hitting an idle start. If yes,
then floor_validate_time is reset so that the CPU stays at max frequency
for at least another 100 ms before stepping down.
This is an important feature for detecting CPU intensive workloads which
require high frequencies for achieving better performance.

Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Remove trace event from idle_start handler

Removed the trace_cpufreq_interactive_idle_start.
Also fix a crash resulting from accessing NULL policy before taking
the pcpu->enable_sem lock. The policy can be NULL if the core is
hotplugged out before the enable_sem lock is taken.

Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Fix race in sync freq feature

When we switch to the interactive governor, the kernel will panic
because the policy object is NULL on affected cpus. Add a check to
avoid this situation.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: interactive: Initialize sync feature defaults

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: ondemand:Fix NULL check for dbs_info->cur_policy

dbs_info->cur_policy can go NULL when processing
CPUFREQ_GOV_LIMITS, NULL check is required
before processing it

Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
cpufreq: ondemand:kernel NULL pointer dereference at dbs_check_cpu

Function dbs_check_cpu  calls __cpufreq_driver_getavg
With  policy as IN/OUT parameter.
There is possiblity of policy becoming NULL in
 __cpufreq_driver_getavg. Same policy is getting
accessed in the for loop which leads to NULL pointer dereference.
So NULL check is required for the policy

Signed-off-by: Swetha Chikkaboraiah <schikk@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: Get CP_RPTR from register instead of shadow memory

Sometimes the RPTR shadow memory is unreliable causing timeouts
in adreno_idle().  Read it directly from the register instead.

Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: When switching pagetable use current context ID

When we switch pagetables then the pagetable switch commands
should be executed on behalf of the currect active context and
not the context to which we are switching. This is because
until the pagetable switch occurs the GPU will be using the
pagetable of the active context.

Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Tarun Karra <tkarra@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: kgsl: Account for fixed perfcounter groups

Most performance counter groups have general purpose counters that
can be programmed to any number of countable types.  That said
some groups have counters with fixed countables.  When reserving those
groups the countable is equal to the register - so when you ask for
countable 0 in VBIF_PWR for example it is expected that will always
match to a certain register.  Add a flag member to the perfcounter
group and declare PWR and VBIF_PWR as fixed groups and handle them
accordingly in adreno_perfcounter_get() so that the correct register
is returned.

Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
PM / devfreq: improve devfreq->data support

This field is treated as governer specific data for
a devfreq instance. But there's currently no way to
set the correct data when switching governors through
sysfs. Add support for optionally passing a set of
name / data pairs in struct devfreq_dev_profile,
representing the data for each governor.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
PM / devfreq: allow governors to use devfreq_get_freq_level

Level based governors may need to perform this lookup to
interpret the current frequency of the device.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
PM / devfreq: fix find_governor_data() function

find_governor_data() was added to the devfreq infrastructure earlier.
It uses an incorrect condition in an if-statement when it searches
a governor by its name. Fixing the condition.

Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
PM / devfreq: add msm-adreno-tz governor

This governor can be used to control adreno GPUs.
It is unlikely to be useful for other devices.

Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Signed-off-by: Vladimir Razgulin <vrazguli@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>