Commit graph

564837 commits

Author SHA1 Message Date
Junjie Wu
093a9c53b9 cpufreq: interactive: Ignore hispeed_freq logic for notification
When governor gets a notification from scheduler, scheduler provides
exact load that is required by the workload. Ignore hispeed_freq logic
and directly use choose_freq result for notifications.

Also use is_notif field to distinguish notifications instead of
MAX_LOCAL_LOAD.

Change-Id: I409ea66c00f4277adf32d18c339631e1a8b0f97b
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:27 -07:00
Junjie Wu
0d694cbd7e cpufreq: interactive: Pass target_load to scheduler
Scheduler needs to understand governor's target_load in order to make
correct decisions when scheduling tasks.

Change-Id: Ia440986de813632def0352e34425fa69da3b2923
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2016-03-23 20:03:27 -07:00
Junjie Wu
2043c3df36 cpufreq: interactive: Use target_freq for load calculation
With per-policy timer implemented, there is no need to use policy->cur
in load calculation and delay enforcement. Each CPUs in policy will
naturally get the cluster frequency in target_freq. Using policy->cur
has side effects if second evaluation comes before frequency switch
requested by first evaluation is finished. When that occurs, the second
evalution could enforce delays incorrectly based on the stale
policy->cur while the timestamps have been updated when target_freq is
updated by earlier evaluation.

For example, assume current frequency is 1.5GHz, hispeed_freq is 1GHz.
First evaluation drops target_freq to 500MHz. It also resets
hispeed_validate_time. While frequency switch is still underway and
policy->cur is still 1.5GHz, a second evaluation happens, and the
evaluation result is 1GHz. Current evaluation would enforce
hispeed_delay for 1.5GHz using the updated hispeed_validate_time and
thus incorrectly delaying the ramp up to 1GHz.

Change from policy->cur to target_freq in load calculation and delay
enforcement.

Change-Id: I416e1d524e14b2c082944b88678eb3105bd70d88
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:26 -07:00
Junjie Wu
5e3baefe8e cpufreq: interactive: Make skipping delay for migration optional
Commit 92352c0a65bc ("cpufreq: interactive: Ramp up directly if
cpu_load exceeds 100") and commit 594945e67031 ("cpufreq: interactive:
Skip delay in frequency changes due to migration") allow interactive
governor to skip above_hispeed_delay and min_sample_time if the
frequency evaluation request comes from scheduler. Power and performance
benefits of these two features are dependent on the behavior of each
workload. Adverse load pattern may experience regression instead of
improvement.

Make both features optional by introducing a sysfs file for each. Both
features are disabled by default.

Change-Id: I394c7fac00e6b20259dd198bd526a32ead54f14e
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:25 -07:00
Junjie Wu
e5e613be75 cpufreq: interactive: Use sched_get_cpus_busy() to query busy time
sched_get_cpus_busy() provides a snapshot of all CPUs' busy time
information for the set of CPUs being queried. This avoids race
condition due to migration when CPU load is queried one by one.

Change-Id: I6afdfa74ff9f3ef616872df4e2c3bb04f6233c3f
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:24 -07:00
Junjie Wu
7ebf7c3881 cpufreq: interactive: Correctly reschedule timer for slack_only case
Slack timer's expire field was not correctly initialized if slack_only
is true in cpufreq_interactive_timer_resched(). This causes both
compilation warning and functional breakage.

Fix expire field by setting it properly.

Change-Id: I2f8c454d63626876522c163eb8d3c5d1c8adfd51
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:23 -07:00
Junjie Wu
4a461ca557 cpufreq: interactive: Add cpuload trace events
With per-cluster timer implementation, only max load across CPUs in
cluster is traced in timer function. Add cpufreq_interactive_cpuload
trace to provide per-cpu load information.

Change-Id: Icea9f2574332a4bc472b14193e77d76100a896ed
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:22 -07:00
Junjie Wu
4cfdb6b2f7 cpufreq: interactive: Replace per-cpu timer with per-policy timer
Interactive governor currently uses per-cpu timer to evaluate each
CPU's frequency. For policies that manages multiples CPUs, each CPU
runs its own algorithm to decide its frequency and then final result
is aggregated in speedchange task. This implementation has a few
drawbacks.

Due to the use of deferrable timers, timers between CPUs can be easily
misaligned. If a load migrates from CPU A to CPU B, there exists a gap
where CPU A could have dropped its frequency vote yet CPU B hasn't
seen the demand to ramp up its vote. This would result in an incorrect
drop in policy frequency which is harmful for performance.

In addition, for CPU waking up in middle of a window, the timestamps
it takes will not be aligned with jiffy boundaries, and thus when next
time timer fires, it could incorrectly prevent frequency ramp up/down
for one more window.

Change-Id: Ia82c7b0cff5bb1ea165fb83fbb7a5546ea7d0396
[junjiew@codeaurora.org: Resolved merge conflicts. ]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:22 -07:00
Junjie Wu
3c1a0a6645 cpufreq: interactive: Remove first_cpu field
first_cpu field was introduced to handle tunable save and restore, but
later improvements removed the need for it. Remove it from
cpufreq_interactive_cpuinfo struct.

Change-Id: Ib6fd7546451ee537f55d874f93d0e52bec58f124
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:21 -07:00
Hanumath Prasad
fd488c4b4d cpufreq: interactive: enable use_sched_load early
Set use_sched_load tunable early in store so that we pass
the correct 64-bit jiffy to scheduler.

Change-Id: I46ed73441c9d242f15e5759360d0cea4a9dd23d0
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2016-03-23 20:03:20 -07:00
Hanumath Prasad
e9cb090ff7 cpufreq: interactive:call __cpufreq_driver_target() for cur frequency
There is a race window as explained below when governor tries to change
the cpu frequency and some other thread (say thermal mitigation) try to
change the policy limits simultaneously.

speedchange task (ThreadA)			Thread B(say Thermal)

cpufreq_interactive_speedchange_task()
	|
__cpufreq_driver_target()
	|
set_cpu_freq()
	|
						cpufreq_update_policy()
							|
						modified policy_max
							|
						check policy->curr against
						new policy limits,return
						without calling
						__cpufreq_driver_target as
						policy->curr(which is not
						updated by ThreadA) is still
						within the new policy limits.

	|
sent CPUFREQ_POSTCHANGE notification
	|
updated policy->cur which happens to be higher than policy->max

This results the current frequency being higher than the policy->max and
violating the policy limits. This causes thermal impact and in turn high
power consumption. So Fix this by calling __cpufreq_driver_target() always
with current frequency and leave it to __cpufreq_driver_target() to
guarantee there is no race condition when multiple threads are changing
frequencies.

Change-Id: I9136e9245677e8fc90a628d3099aca8d63d3677c
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2016-03-23 20:03:19 -07:00
Junjie Wu
1965233d03 cpufreq: interactive: BUG_ON when tunables are NULL after init
When tunables are not available for events other than
CPUFREQ_GOV_POLICY_INIT in cpufreq_governor_interactive(), trigger a
panic instead of throwing a warning.

When the original warning happens, some race condition must have
occurred, and governor will be in a bad state even if it might still
run for a while. Panic directly so that it's easier to catch the
first race event.

Change-Id: I2dc1185cabfe72a63739452731fe242924d2cf45
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:18 -07:00
Junjie Wu
9a35bf0f82 cpufreq: interactive: Skip delay in frequency changes due to migration
The above hispeed delay and min sample time delays are used to
distinguish between sporadic load changes versus steady state load
changes. The governor tried to make sure the frequency changes only
when the load change is a steady state load change.

However, when the load change is for predictable reasons like
migration, the delays only negatively affect performance and power.
Once a significant load is migrated into a CPU, it's fairly reasonable
to assume it's going to continue contributing that additional load.
Similarly once a significant load is migrated away from a CPU, it's
fairly reasonable to assume the load will be gone forever. Future
migrations can bring back a load or take it away, but the
notifications that come along with it will allow us to quickly correct
for it. For this reason, when the load change is due to a
notification, do not delay frequency changes.

Change-Id: I19ad294b599e30654fbbeb0c56e8b50b0e19198f
[junjiew@codeaurora.org: Resolved merge conflicts.]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:17 -07:00
Junjie Wu
3af8f8a219 cpufreq: interactive: Reschedule timer if min_freq is reduced
When a CPU is running at policy->min, slack timer will not be scheduled.
If policy->min is reduced later, current implementation doesn't
reschedule slack timer and thus could leave CPU at a higher
frequency indefinitely as long as the CPU is idle. This behavior is
undesirable from power perspective.

Change-Id: I40bfd7c93ad3fd06e3837dc48befdc07f29c78c8
[junjiew@codeaurora.org: Resolved merge conflicts.]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:16 -07:00
Junjie Wu
82a0e1c81f cpufreq: interactive: Ramp up directly if cpu_load exceeds 100
When governor is using regular busy time tracking, cpu_load will
never exceed 100 because busy time will never exceed elapsed time in
any one sampling window. The only exception is when frequency is
reduced in middle of a window (e.g. due to thermal throttling). In
this case, cpu_load is likely irrelevant since current frequency
governor has been voting is already higher than what target can run
at.

However, on a heterogeneous CPU system with scheduler input enabled
to track the load of migrated tasks, cpu_load could also exceed 100
when a task migrates from more capable CPU to slower CPU. When this
happens, governor already knows the exact frequency required to handle
this load. There is no need to progressively ramp up frequency in order
to assess the load's real demand. It's not desirable to starve such a
migrating task by forcing it through ramping up process on the slower
CPU.

Direclty jump beyond hispeed_freq and ignore above_hispeed_delay if
cpu_load exceeds 100.

Change-Id: Ib87057e4f00732fad943ab595a33e3059494ef15
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:16 -07:00
Junjie Wu
ce5c462516 cpufreq: interactive: Fix refcount for migration notification
Current implementation of cpufreq_interactive_enable_sched_input()
returns early if use_sched_input is already enabled. This breaks
refcounting for migration notification registration. It could also
result in failure of registering migration notification after
hotplugging the entire cluster and/or suspend/resume.

Change-Id: I079b2c70b182f696cd8a883f5c8e3a37b5c6d21d
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:15 -07:00
Junjie Wu
1bef8bd6b6 cpufreq: interactive: Avoid down_read_trylock if down_write() is held
down_read_trylock is not always non-blocking if the same thread calls
down_write() before.

CPU1					CPU2
					down_read()
down_write()
  __down_write_nested()
    schedule()
      __down_read_trylock()
					up_read()
					  acquires sem->wait_lock
					    __rwsem_wake_one_writer()
	tries to lock sem->wait_lock

Now CPU2 is waiting for CPU1's schedule() to complete, while holding
sem->wait_lock. CPU1 needs sem->wait_lock to continue.

This problem only happens after cpufreq_interactive introduced load
change notification that could be called within schedule().

Add a separate flag to ignore notification if current thread is in
middle of down_write(). This avoids attempting to hold sem->wait_lock.
The additional flag doesn't have any side effects because
down_read_trylock() would have failed anyway.

Change-Id: Iff97cac36c170cf6d03f36de695141289c3d6930
[junjiew@codeaurora.org: Resolved merge conflicts. Dropped changes
 to code that no longer exists.]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:14 -07:00
Rohit Gupta
f4d69aec4f cpufreq: interactive: Report CPU loads through govinfo notifier
Report CPU load to modules subscribed to cpufreq govinfo notification
chain every time governor timer expires to evaluate load.

Change-Id: I0b35947b1924c179649aafa0b7b93d974164af1a
[junjiew@codeaurora.org: Resolved trivial merge conflicts]
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2016-03-23 20:03:13 -07:00
Junjie Wu
2d91526439 cpufreq: interactive: Do not align sample windows by default
Disable sample window alignment by default to match default behavior
of upstream interactive governor.

Change-Id: Ibbf4bdd4dd423f97d3a9dd5442eba78b378e66e2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:12 -07:00
Junjie Wu
c7cdf7954e cpufreq: interactive: Re-evaluate immediately in load change callback
Previously, there was a limitation in load change callback that it
can't attempt to wake up a task. Therefore the best we can do is to
schedule timer at current jiffy. The timer function will only be
executed at next timer tick. This could take up to 10ms.

Now that this limitation is removed, re-evaluate load immediately upon
receiving this callback.

Change-Id: Iab3de4705b9aae96054655b1541e32fb040f7e60
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:11 -07:00
Junjie Wu
50d577eb97 cpufreq: interactive: Make window alignment optional
Make sampling window alignment optional when scheduler inputs
are not enabled.

Change-Id: If69c111a3efe219cdd1e38c1f46f03404789c0bb
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:11 -07:00
Junjie Wu
814503a967 cpufreq: interactive: Add max_freq_hysteresis feature
Previously known as sampling down factor, max_freq_hysteresis
extends the period that interactive governor will stay at policy->max.
This feature is to accomodate short idle periods in an otherwise very
intensive workload.

When the feature is enabled, it ensures that once a CPU goes to max
frequency, it doesn't reduce the frequency for max_freq_hysteresis
microseconds from the time it first goes to idle.

Change-Id: Ia54985cb554f63f8c22d0b554a0a0f2ed2be038f
[junjiew@codeaurora.org: Resolved conflicts. Dropped changes to code
 that no longer exists. Trivial checkpatch fix. Renamed
 max_freq_idle_start_time to max_freq_hyst_start_time.]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:10 -07:00
Junjie Wu
6cd960aa45 cpufreq: interactive: Add support for using scheduler inputs
Interactive governor does not have enough information about the tasks
on a CPU to make a more informed decision on the frequency the CPUs
should run at. To address this problem, modify interactive governor
to get load information from scheduler. In addition, it can get
notification from scheduler on significant load change to reevaluate
CPU frequency immediately.

Add two sysfs file to control the behavior of load evaluation:
use_sched_load:
	When enabled, governor uses load information from scheduler
	instead of busy/idle time from past window.
use_migration_notif:
	Whenever a task migrates, scheduler might send a notification
	so that governor can re-evaluate load and scale frequency.
	Governor will ignore this notification unless both
	use_sched_hint 	and use_migration_notification are true for
	the policy group.

Change-Id: Iaf66e424c6166ec15480db027002b3a3b357d79c
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:09 -07:00
Junjie Wu
3b48f85cd1 cpufreq: interactive: Use del_timer/add_timer_on to rearm timers
Replace mod_timer_pinned() with del_timer(), add_timer_on().
mod_timer_pinned() always adds timer onto current CPU. Interactive
governor expects each CPU's timers to be running on the same CPU.
If cpufreq_interactive_timer_resched() is called from another CPU,
the timer will be armed on the wrong CPU.

Replacing mod_timer_pinned() with del_timer() and add_timer_on()
guarantees timers are still run on the right CPU even if another
CPU reschedules the timer. This would provide more flexibility
for future changes.

Change-Id: I3a10be37632afc0ea4e0cc9c86323b9783b216b1
[junjiew@codeaurora.org: Dropped changes that are no longer needed
 due to removal of relevant code]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:08 -07:00
Junjie Wu
bbe0d10d97 cpufreq: interactive: Cache tunables when they are created
Currently, tunables are only saved to per_cpu field when
CPUFREQ_GOV_POLICY_EXIT event happens. Save tunables the moment they
are created so that per_cpu cached_tunables field always matches
the tunables in use. This is useful for modifying tunable values
across clusters.

Change-Id: I9e30d5e93d6fde1282b5450458d8a605d568a0f5
[junjiew@codeaurora.org: Resolved trivial conflicts]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:07 -07:00
Junjie Wu
6673fa0f98 cpufreq: interactive: Align timer windows for all CPUs
It's more advantageous to evaluate all CPUs at same time so that
interactive governor gets a complete picture of the load on
each CPU at a specific time. It could also reduce number of speed
changes made if there are many CPUs controlled by same policy. In
addition, waking up all CPUs at same time would allow the cluster
to go into a deeper sleep state when it's idle.

Change-Id: I6915050c5339ef1af106eb906ebe4b7c618061e2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:06 -07:00
Junjie Wu
7b9f8f19a1 cpufreq: interactive: Move cached_tunables into cpuinfo
Interactive governor already has a per_cpu field cpuinfo to keep track
of per_cpu data. Move cached_tunables into cpuinfo.

Change-Id: I77fda0cda76b56ff949456a95f96d129d877aa7b
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:06 -07:00
Saravana Kannan
9993217296 cpufreq: interactive: Fix freeing of cached tunabled during module_exit()
To avoid multiple frees of an allocated tunables struct during
module_exit(), the pointer to the allocated tunables should be stored in
only one of the per-CPU cached_tunables pointer.

So, in the case of per policy governor configuration, store the cached
values in the pointer of first CPU in a policy. In the case of one governor
across all policies, store it in the CPU0 pointer.

Change-Id: Id4334246491519ac91ab725a8758b2748f743bb0
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2016-03-23 20:03:05 -07:00
Junjie Wu
249a58c4a5 cpufreq: interactive: Permanently cache tunable values
Userspace might change tunable values for a governor. Currently, if
all CPUs in a policy go offline, governor frees its tunable. This
wipes out all userspace modifications. Kernel drivers can call
cpu_up/down() directly and thus userspace won't have a chance to
restore the tunables.

Permanently save tunable struct in a per_cpu field so that we
preserve tunable values across hotplug, suspend/resume and governor
switch.

Change-Id: I126b8278c8e75c8eadb3e2ddfe97fcc72cddfa23
[junjiew@codeaurora.org: Resolved merge conflicts]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:04 -07:00
Junjie Wu
546c1f0400 cpufreq: interactive: Remove cpufreq_get/put_global_kobject()
Change-Id: I9bb41acc4c86074c2c14562f34480004184494f7
[junjiew@codeaurora.org: resolved trivial merge conflicts]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:03 -07:00
Junjie Wu
edacb2395e cpufreq: Use pr_info() for driver registration and unregistration
Many subsystems depend on cpufreq API for CPU frequency scaling.
Cpufreq API is expected to fail until cpufreq device registers.

Change pr_debug() to pr_info() so that user could determine when
cpufreq API becomes available during boot from kernel messages. This
is crucial to understand whether a cpufreq API failure is benign
during early boot.

Change-Id: Id2dfa009ae33859ec3efcdb29a3296e891852c6a
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:02 -07:00
Junjie Wu
fcb680bdad cpufreq: Improve governor related CPUFreq error messages
Governor error messages point to important failures in governor or
framework. Output triggering CPU and policy->cpu to help debugging.

Resolved conflicts for 3.18 kernel.

Change-Id: I4c5c392ec973b764ec3240bb2eb455c624bcaf63
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:01 -07:00
Junjie Wu
79d8f58e5e cpufreq: qcom-cpufreq: Check return of cpufreq_frequency_get_table
cpufreq_frequency_get_table could return NULL. Do error check on the
return value instead of continue with a potentially NULL pointer.

Change-Id: I0cb8a3a8ae3499e738683e5f45271aeadee488f6
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:00 -07:00
Junjie Wu
1a7d6caef6 cpufreq: Check current frequency in device driver
__cpufreq_driver_target() checks if policy->cur is same as target_freq
without holding any lock. This function is used by governor to
directly set CPU frequency. Governor calling this function can't hold
any CPUfreq framework locks due to deadlock possibility.

However, this results in a race condition where one thread could see
a stale policy->cur while another thread is changing CPU frequency.

Thread A: Governor calls __cpufreq_driver_target(), starts increasing
frequency but hasn't sent out CPUFREQ_POSTCHANGE notification yet.
Thread B: Some other driver (could be thermal mitigation) starts
limiting frequency using cpufreq_update_policy(). Every limits are
applied to policy->min/max and final policy->max happens to be same as
policy->cur. __cpufreq_driver_target() simply returns 0.
Thread A: Governor finish scaling and now policy->cur violates
policy->max and could last forever until next CPU frequency scaling
happens.

Shifting the responsibility of checking policy->cur and target_freq
to CPUfreq device driver would resolve the race as long as the device
driver holds a common mutex.

Change-Id: I6f943228e793a4a4300c58b3ae0143e09ed01d7d
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:03:00 -07:00
Rohit Gupta
db44d1e057 cpufreq: Add a notifer chain that governors can use to report information
Some modules can benefit from getting additional information cpufreq
governors use to make frequency switch decisions.
This change lays down a basic framework that the governors can use
to report additional information (Eg: CPU's load) information to
the clients that subscribe to cpufreq govinfo notifier chain.

Change-Id: I511b4bdb7d12394a31ce5352ae47553861e49303
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[imaund@codeaurora.org: resolved context conflicts]
Signed-off-by: Ian Maund <imaund@codeaurora.org>
2016-03-23 20:02:59 -07:00
Junjie Wu
db35fc6d65 qcom-cpufreq: Use devm_kfree() to match devm_kzalloc()
Frequency table is allocated with devm_kzalloc() and thus should be
freed using devm_kfree().

Change-Id: I9c08838eadb9fc04bda9cc66596e1e0b45b3e4db
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:58 -07:00
Junjie Wu
cc0057fe57 qcom-cpufreq: Fill in policy->freq_table
CPUfreq framework replaced per-cpu freq_table with per-policy
freq_table, and deprecated previous per-cpu APIs.

Fill in policy->freq_table.

Change-Id: Ifc9ac1b6695fd12629a447984dbbd57d657961b2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:57 -07:00
Junjie Wu
1502197f64 qcom-cpufreq: Use new cpufreq_freq_transition_begin/end() API
Previous cpufreq_notify_transition() is deprecated in favor of
cpufreq_freq_transition_begin/end() API which provides serialization
guarantee for notifications.

Use the new API for transition notification.

Change-Id: I8d559e5c6ef4771986b24e017c900476da1f6cdf
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:56 -07:00
Junjie Wu
14d4d12ad6 qcom-cpufreq: Rename cpufreq_suspend to suspend_data
cpufreq_suspend is now a function in core CPUfreq framework. Rename
qcom-cpufreq's local per-cpu variable to suspend_data.

Change-Id: I2f567f0c04271d728d4e6a17b61cea2152c4d8f7
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:55 -07:00
Junjie Wu
16d6aa6ee5 qcom-cpufreq: Remove save/restore of scheduling policy
Different structures might need to be saved and restored based on
different scheduling policies of current thread. Saving and restoring
priority using scheduler APIs is very fragile due to potential changes
in scheduler code. In addition, the priority change doesn't
provide any starvation guarantee because threads can be preempted
before the priority change.

Therefore remove save and restore of priority to avoid potential bugs
when scheduler API changes. Caller will now be responsible for setting
the right priority for their CPU frequency scaling workqueue/thread.

Change-Id: I2a5d8599e75c0c4aa902df3214c17ab2b13dc9a9
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:55 -07:00
Junjie Wu
f1e1ba3b6c qcom-cpufreq: Restore CPU frequency during resume
qcom-cpufreq blocks CPU frequency change request during suspend, because
its dependencies might be suspended. Thus a freq change request would
fail silently, and CPU clock won't change until first frequency update
is requested after system comes out of suspend. This creates a period
when thermal driver cannot perform frequency mitigation, even though
policy->min/max have been correctly updated.

Check each online CPU's policy during resume to correct any frequency
violation as soon as possible.

Change-Id: I3be79cf91e7d5e361314020c9806b770823c0b72
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:54 -07:00
Junjie Wu
9c69b365d2 qcom-cpufreq: Remove per-cpu workqueue
It's no longer a requirement to pin frequency change on the CPU that
is being scaled. Therefore, there is no longer a need for per-cpu
workqueue in qcom-cpufreq. Remove the workqueue.

Change-Id: Ic6fd7f898fa8b1b1226a178b04530c24f0398daa
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:53 -07:00
Junjie Wu
a80a914583 arm: msm: Remove MSM_CPU_FREQ_SET_MIN_MAX related config
MSM_CPU_FREQ_SET_MIN_MAX and related Kconfigs are deprecated. Purge
them from Kconfig and qcom-cpufreq.

Change-Id: I8ac786c155c7e235154b60c79f97d76ea15dace2
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:52 -07:00
Matt Wagantall
c7984141ec trace: power: add cpu_frequency_switch_{start, end}
It is sometimes useful to profile how long CPU frequency switches
take, since they often involve variable overhead (PLL lock times,
voltage increase time, etc.). Add additional traces to to make this
possible.

Since the overhead involved may differ based on the frequencies
being switched between, record both the start and the end frequencies
as part of the trace.

Change-Id: I2de743fc357dad3590fd4980f65f38f6073d426e
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[abhimany: resolve trivial merge conflicts]
Signed-off-by: Abhimanyu Kapur <abhimany@codeaurora.org>
2016-03-23 20:02:51 -07:00
Stephen Boyd
7252c408d4 cpufreq: Add snapshot of qcom-cpufreq driver
This is a snapshot of qcom-cpufreq as of msm-3.10 commit

acdce027751d5a7488b283f0ce3111f873a5816d (Merge "defconfig: arm64:
Enable ONESHOT_SYNC for msm8994")

Change-Id: Idb99a856330566ffad6309c48edabb220cee7917
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[junjiew@codeaurora.org: resolved conflicts in Kconfig.arm
 and Makefile. Dropped dependency on ARCH_MSM.]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:50 -07:00
Junjie Wu
86ace8299b cpufreq: cpu-boost: Move CPU_BOOST Kconfig to correct section
cpu-boost driver is not a CPUFreq device. Moving it to the end of
CPUFreq governor section.

Change-Id: Ib433f81e7596789a2e6ea03d0bd0a8d166ecf9e9
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2016-03-23 20:02:49 -07:00
Rohit Gupta
03b71555db cpufreq: cpu-boost: Force most/all tasks to big cluster on input event
Scheduler provides an API to force tasks to the big cluster. To
improve performance, use this API to move most/all tasks to the
big cluster for short duration on an input event. On the removal of
frequency boost (after input_boost_ms), this scheduler boost is also
deactivated.

Change-Id: I9d643914ebc75266478cc22260a45862faad6236
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2016-03-23 20:02:49 -07:00
Joonwoo Park
449517019b defconfig: msm: enable CONFIG_SCHED_DEBUG
Enable CONFIG_SCHED_DEBUG in order to expose /proc/sched_debug.

Change-Id: Id784c80fe6203f007501637c3d17876528329e2b
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2016-03-23 20:02:48 -07:00
Joonwoo Park
48b7015c47 defconfig: msm: enable HMP scheduler
Enable HMP scheduler along with scheduler guided frequency input.

Change-Id: Ia0e7cf6c5c5ff44492836ebb5189574f55cb742e
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2016-03-23 20:02:47 -07:00
Joonwoo Park
d794be8975 defconfig: msm: clean up msm_defconfig and msm-perf_defconfig
Clean up msm_defconfig and msm-perf_defconfig with 'make savedefconfig'.

Change-Id: I118d9d4ddc1fb89b4301cb7ceffdbccc60699329
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>
2016-03-23 20:02:46 -07:00