提交 02c3de11 编写于 作者: L Linus Torvalds

Merge tag 'pm-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull power management updates from Rafael Wysocki:
 "The majority of changes go into the Operating Performance Points (OPP)
  framework and cpufreq this time, followed by devfreq and some
  scattered updates all over.

  The OPP changes are mostly related to switching over from RCU-based
  synchronization, that turned out to be overly complicated and
  problematic, to reference counting using krefs.

  In the cpufreq land there are core cleanups, documentation updates, a
  new driver for Broadcom BMIPS SoCs, a new cpufreq-dt sub-driver for TI
  SoCs that require special handling, ARM64 SoCs support for the qoriq
  driver, intel_pstate updates, powernv driver update and assorted
  fixes.

  The devfreq changes are mostly fixes related to the sysfs interface
  and some Exynos drivers updates.

  Apart from that, the cpuidle menu governor will support per-CPU PM QoS
  constraints for the wakeup latency now, some bugs in the wakeup IRQs
  framework are fixed, the generic power domains framework should handle
  asynchronous invocations of *noirq suspend/resume callbacks from now
  on, the analyze_suspend.py script is updated and there is a new tool
  for intel_pstate diagnostics.

  Specifics:

   - Operating Performance Points (OPP) framework fixes, cleanups and
     switch over from RCU-based synchronization to reference counting
     using krefs (Viresh Kumar, Wei Yongjun, Dave Gerlach)

   - cpufreq core cleanups and documentation updates (Viresh Kumar,
     Rafael Wysocki)

   - New cpufreq driver for Broadcom BMIPS SoCs (Markus Mayer)

   - New cpufreq-dt sub-driver for TI SoCs requiring special handling,
     like in the AM335x, AM437x, DRA7x, and AM57x families, along with
     new DT bindings for it (Dave Gerlach, Paul Gortmaker)

   - ARM64 SoCs support for the qoriq cpufreq driver (Tang Yuantian)

   - intel_pstate driver updates including a new sysfs knob to control
     the driver's operation mode and fixes related to the no_turbo sysfs
     knob and the hardware-managed P-states feature support (Rafael
     Wysocki, Srinivas Pandruvada)

   - New interface to export ultra-turbo frequencies for the powernv
     cpufreq driver (Shilpasri Bhat)

   - Assorted fixes for cpufreq drivers (Arnd Bergmann, Dan Carpenter,
     Wei Yongjun)

   - devfreq core fixes, mostly related to the sysfs interface exported
     by it (Chanwoo Choi, Chris Diamand)

   - Updates of the exynos-bus and exynos-ppmu devfreq drivers (Chanwoo
     Choi)

   - Device PM QoS extension to support CPUs and support for per-CPU
     wakeup (device resume) latency constraints in the cpuidle menu
     governor (Alex Shi)

   - Wakeup IRQs framework fixes (Grygorii Strashko)

   - Generic power domains framework update including a fix to make it
     handle asynchronous invocations of *noirq suspend/resume callbacks
     correctly (Ulf Hansson, Geert Uytterhoeven)

   - Assorted fixes and cleanups in the core suspend/hibernate code, PM
     QoS framework and x86 ACPI idle support code (Corentin Labbe, Geert
     Uytterhoeven, Geliang Tang, John Keeping, Nick Desaulniers)

   - Update of the analyze_suspend.py script is updated to version 4.5
     offering multiple improvements (Todd Brandt)

   - New tool for intel_pstate diagnostics using the pstate_sample
     tracepoint (Doug Smythies)"

* tag 'pm-4.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (85 commits)
  MAINTAINERS: cpufreq: add bmips-cpufreq.c
  PM / QoS: Fix memory leak on resume_latency.notifiers
  PM / Documentation: Spelling s/wrtie/write/
  PM / sleep: Fix test_suspend after sleep state rework
  cpufreq: CPPC: add ACPI_PROCESSOR dependency
  cpufreq: make ti-cpufreq explicitly non-modular
  cpufreq: Do not clear real_cpus mask on policy init
  tools/power/x86: Debug utility for intel_pstate driver
  AnalyzeSuspend: fix drag and zoom bug in javascript
  PM / wakeirq: report a wakeup_event on dedicated wekup irq
  PM / wakeirq: Fix spurious wake-up events for dedicated wakeirqs
  PM / wakeirq: Enable dedicated wakeirq for suspend
  cpufreq: dt: Don't use generic platdev driver for ti-cpufreq platforms
  cpufreq: ti: Add cpufreq driver to determine available OPPs at runtime
  Documentation: dt: add bindings for ti-cpufreq
  PM / OPP: Expose _of_get_opp_desc_node as dev_pm_opp API
  cpufreq: qoriq: Don't look at clock implementation details
  cpufreq: qoriq: add ARM64 SoCs support
  PM / Domains: Provide dummy governors if CONFIG_PM_GENERIC_DOMAINS=n
  cpufreq: brcmstb-avs-cpufreq: remove unnecessary platform_set_drvdata()
  ...
What: /sys/class/devfreq-event/event(x)/
Date: January 2017
Contact: Chanwoo Choi <cw00.choi@samsung.com>
Description:
Provide a place in sysfs for the devfreq-event objects.
This allows accessing various devfreq-event specific variables.
The name of devfreq-event object denoted as 'event(x)' which
includes the unique number of 'x' for each devfreq-event object.
What: /sys/class/devfreq-event/event(x)/name
Date: January 2017
Contact: Chanwoo Choi <cw00.choi@samsung.com>
Description:
The /sys/class/devfreq-event/event(x)/name attribute contains
the name of the devfreq-event object. This attribute is
read-only.
What: /sys/class/devfreq-event/event(x)/enable_count
Date: January 2017
Contact: Chanwoo Choi <cw00.choi@samsung.com>
Description:
The /sys/class/devfreq-event/event(x)/enable_count attribute
contains the reference count to enable the devfreq-event
object. If the device is enabled, the value of attribute is
greater than zero.
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
David Kimdon <dwhedon@debian.org> David Kimdon <dwhedon@debian.org>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -36,10 +38,11 @@ speed limits (like LCD drivers on ARM architecture). Additionally, the ...@@ -36,10 +38,11 @@ speed limits (like LCD drivers on ARM architecture). Additionally, the
kernel "constant" loops_per_jiffy is updated on frequency changes kernel "constant" loops_per_jiffy is updated on frequency changes
here. here.
Reference counting is done by cpufreq_get_cpu and cpufreq_put_cpu, Reference counting of the cpufreq policies is done by cpufreq_cpu_get
which make sure that the cpufreq processor driver is correctly and cpufreq_cpu_put, which make sure that the cpufreq driver is
registered with the core, and will not be unloaded until correctly registered with the core, and will not be unloaded until
cpufreq_put_cpu is called. cpufreq_put_cpu is called. That also ensures that the respective cpufreq
policy doesn't get freed while being used.
2. CPUFreq notifiers 2. CPUFreq notifiers
==================== ====================
...@@ -69,18 +72,16 @@ CPUFreq policy notifier is called twice for a policy transition: ...@@ -69,18 +72,16 @@ CPUFreq policy notifier is called twice for a policy transition:
The phase is specified in the second argument to the notifier. The phase is specified in the second argument to the notifier.
The third argument, a void *pointer, points to a struct cpufreq_policy The third argument, a void *pointer, points to a struct cpufreq_policy
consisting of five values: cpu, min, max, policy and max_cpu_freq. min consisting of several values, including min, max (the lower and upper
and max are the lower and upper frequencies (in kHz) of the new frequencies (in kHz) of the new policy).
policy, policy the new policy, cpu the number of the affected CPU; and
max_cpu_freq the maximum supported CPU frequency. This value is given
for informational purposes only.
2.2 CPUFreq transition notifiers 2.2 CPUFreq transition notifiers
-------------------------------- --------------------------------
These are notified twice when the CPUfreq driver switches the CPU core These are notified twice for each online CPU in the policy, when the
frequency and this change has any external implications. CPUfreq driver switches the CPU core frequency and this change has no
any external implications.
The second argument specifies the phase - CPUFREQ_PRECHANGE or The second argument specifies the phase - CPUFREQ_PRECHANGE or
CPUFREQ_POSTCHANGE. CPUFREQ_POSTCHANGE.
...@@ -90,6 +91,7 @@ values: ...@@ -90,6 +91,7 @@ values:
cpu - number of the affected CPU cpu - number of the affected CPU
old - old frequency old - old frequency
new - new frequency new - new frequency
flags - flags of the cpufreq driver
3. CPUFreq Table Generation with Operating Performance Point (OPP) 3. CPUFreq Table Generation with Operating Performance Point (OPP)
================================================================== ==================================================================
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -49,49 +51,65 @@ using cpufreq_register_driver() ...@@ -49,49 +51,65 @@ using cpufreq_register_driver()
What shall this struct cpufreq_driver contain? What shall this struct cpufreq_driver contain?
cpufreq_driver.name - The name of this driver. .name - The name of this driver.
cpufreq_driver.init - A pointer to the per-CPU initialization .init - A pointer to the per-policy initialization function.
function.
cpufreq_driver.verify - A pointer to a "verification" function. .verify - A pointer to a "verification" function.
cpufreq_driver.setpolicy _or_ .setpolicy _or_ .fast_switch _or_ .target _or_ .target_index - See
cpufreq_driver.target/ below on the differences.
target_index - See below on the differences.
And optionally And optionally
cpufreq_driver.exit - A pointer to a per-CPU cleanup .flags - Hints for the cpufreq core.
function called during CPU_POST_DEAD
phase of cpu hotplug process.
cpufreq_driver.stop_cpu - A pointer to a per-CPU stop function .driver_data - cpufreq driver specific data.
called during CPU_DOWN_PREPARE phase of
cpu hotplug process.
cpufreq_driver.resume - A pointer to a per-CPU resume function .resolve_freq - Returns the most appropriate frequency for a target
which is called with interrupts disabled frequency. Doesn't change the frequency though.
and _before_ the pre-suspend frequency
and/or policy is restored by a call to
->target/target_index or ->setpolicy.
cpufreq_driver.attr - A pointer to a NULL-terminated list of .get_intermediate and target_intermediate - Used to switch to stable
"struct freq_attr" which allow to frequency while changing CPU frequency.
export values to sysfs.
cpufreq_driver.get_intermediate .get - Returns current frequency of the CPU.
and target_intermediate Used to switch to stable frequency while
changing CPU frequency. .bios_limit - Returns HW/BIOS max frequency limitations for the CPU.
.exit - A pointer to a per-policy cleanup function called during
CPU_POST_DEAD phase of cpu hotplug process.
.stop_cpu - A pointer to a per-policy stop function called during
CPU_DOWN_PREPARE phase of cpu hotplug process.
.suspend - A pointer to a per-policy suspend function which is called
with interrupts disabled and _after_ the governor is stopped for the
policy.
.resume - A pointer to a per-policy resume function which is called
with interrupts disabled and _before_ the governor is started again.
.ready - A pointer to a per-policy ready function which is called after
the policy is fully initialized.
.attr - A pointer to a NULL-terminated list of "struct freq_attr" which
allow to export values to sysfs.
.boost_enabled - If set, boost frequencies are enabled.
.set_boost - A pointer to a per-policy function to enable/disable boost
frequencies.
1.2 Per-CPU Initialization 1.2 Per-CPU Initialization
-------------------------- --------------------------
Whenever a new CPU is registered with the device model, or after the Whenever a new CPU is registered with the device model, or after the
cpufreq driver registers itself, the per-CPU initialization function cpufreq driver registers itself, the per-policy initialization function
cpufreq_driver.init is called. It takes a struct cpufreq_policy cpufreq_driver.init is called if no cpufreq policy existed for the CPU.
*policy as argument. What to do now? Note that the .init() and .exit() routines are called only once for the
policy and not for each CPU managed by the policy. It takes a struct
cpufreq_policy *policy as argument. What to do now?
If necessary, activate the CPUfreq support on your CPU. If necessary, activate the CPUfreq support on your CPU.
...@@ -117,47 +135,45 @@ policy->governor must contain the "default policy" for ...@@ -117,47 +135,45 @@ policy->governor must contain the "default policy" for
cpufreq_driver.setpolicy or cpufreq_driver.setpolicy or
cpufreq_driver.target/target_index is called cpufreq_driver.target/target_index is called
with these values. with these values.
policy->cpus Update this with the masks of the
(online + offline) CPUs that do DVFS
along with this CPU (i.e. that share
clock/voltage rails with it).
For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the For setting some of these values (cpuinfo.min[max]_freq, policy->min[max]), the
frequency table helpers might be helpful. See the section 2 for more information frequency table helpers might be helpful. See the section 2 for more information
on them. on them.
SMP systems normally have same clock source for a group of cpus. For these the
.init() would be called only once for the first online cpu. Here the .init()
routine must initialize policy->cpus with mask of all possible cpus (Online +
Offline) that share the clock. Then the core would copy this mask onto
policy->related_cpus and will reset policy->cpus to carry only online cpus.
1.3 verify 1.3 verify
------------ ----------
When the user decides a new policy (consisting of When the user decides a new policy (consisting of
"policy,governor,min,max") shall be set, this policy must be validated "policy,governor,min,max") shall be set, this policy must be validated
so that incompatible values can be corrected. For verifying these so that incompatible values can be corrected. For verifying these
values, a frequency table helper and/or the values cpufreq_verify_within_limits(struct cpufreq_policy *policy,
cpufreq_verify_within_limits(struct cpufreq_policy *policy, unsigned unsigned int min_freq, unsigned int max_freq) function might be helpful.
int min_freq, unsigned int max_freq) function might be helpful. See See section 2 for details on frequency table helpers.
section 2 for details on frequency table helpers.
You need to make sure that at least one valid frequency (or operating You need to make sure that at least one valid frequency (or operating
range) is within policy->min and policy->max. If necessary, increase range) is within policy->min and policy->max. If necessary, increase
policy->max first, and only if this is no solution, decrease policy->min. policy->max first, and only if this is no solution, decrease policy->min.
1.4 target/target_index or setpolicy? 1.4 target or target_index or setpolicy or fast_switch?
---------------------------- -------------------------------------------------------
Most cpufreq drivers or even most cpu frequency scaling algorithms Most cpufreq drivers or even most cpu frequency scaling algorithms
only allow the CPU to be set to one frequency. For these, you use the only allow the CPU frequency to be set to predefined fixed values. For
->target/target_index call. these, you use the ->target(), ->target_index() or ->fast_switch()
callbacks.
Some cpufreq-capable processors switch the frequency between certain Some cpufreq capable processors switch the frequency between certain
limits on their own. These shall use the ->setpolicy call limits on their own. These shall use the ->setpolicy() callback.
1.5. target/target_index 1.5. target/target_index
------------- ------------------------
The target_index call has two arguments: struct cpufreq_policy *policy, The target_index call has two arguments: struct cpufreq_policy *policy,
and unsigned int index (into the exposed frequency table). and unsigned int index (into the exposed frequency table).
...@@ -186,9 +202,20 @@ actual frequency must be determined using the following rules: ...@@ -186,9 +202,20 @@ actual frequency must be determined using the following rules:
Here again the frequency table helper might assist you - see section 2 Here again the frequency table helper might assist you - see section 2
for details. for details.
1.6. fast_switch
----------------
1.6 setpolicy This function is used for frequency switching from scheduler's context.
--------------- Not all drivers are expected to implement it, as sleeping from within
this callback isn't allowed. This callback must be highly optimized to
do switching as fast as possible.
This function has two arguments: struct cpufreq_policy *policy and
unsigned int target_frequency.
1.7 setpolicy
-------------
The setpolicy call only takes a struct cpufreq_policy *policy as The setpolicy call only takes a struct cpufreq_policy *policy as
argument. You need to set the lower limit of the in-processor or argument. You need to set the lower limit of the in-processor or
...@@ -198,7 +225,7 @@ setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a ...@@ -198,7 +225,7 @@ setting when policy->policy is CPUFREQ_POLICY_PERFORMANCE, and a
powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check powersaving-oriented setting when CPUFREQ_POLICY_POWERSAVE. Also check
the reference implementation in drivers/cpufreq/longrun.c the reference implementation in drivers/cpufreq/longrun.c
1.7 get_intermediate and target_intermediate 1.8 get_intermediate and target_intermediate
-------------------------------------------- --------------------------------------------
Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION unset. Only for drivers with target_index() and CPUFREQ_ASYNC_NOTIFICATION unset.
...@@ -222,42 +249,36 @@ failures as core would send notifications for that. ...@@ -222,42 +249,36 @@ failures as core would send notifications for that.
As most cpufreq processors only allow for being set to a few specific As most cpufreq processors only allow for being set to a few specific
frequencies, a "frequency table" with some functions might assist in frequencies, a "frequency table" with some functions might assist in
some work of the processor driver. Such a "frequency table" consists some work of the processor driver. Such a "frequency table" consists of
of an array of struct cpufreq_frequency_table entries, with any value in an array of struct cpufreq_frequency_table entries, with driver specific
"driver_data" you want to use, and the corresponding frequency in values in "driver_data", the corresponding frequency in "frequency" and
"frequency". At the end of the table, you need to add a flags set. At the end of the table, you need to add a
cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END. And cpufreq_frequency_table entry with frequency set to CPUFREQ_TABLE_END.
if you want to skip one entry in the table, set the frequency to And if you want to skip one entry in the table, set the frequency to
CPUFREQ_ENTRY_INVALID. The entries don't need to be in ascending CPUFREQ_ENTRY_INVALID. The entries don't need to be in sorted in any
order. particular order, but if they are cpufreq core will do DVFS a bit
quickly for them as search for best match is faster.
By calling cpufreq_table_validate_and_show(struct cpufreq_policy *policy,
struct cpufreq_frequency_table *table); By calling cpufreq_table_validate_and_show(), the cpuinfo.min_freq and
the cpuinfo.min_freq and cpuinfo.max_freq values are detected, and cpuinfo.max_freq values are detected, and policy->min and policy->max
policy->min and policy->max are set to the same values. This is are set to the same values. This is helpful for the per-CPU
helpful for the per-CPU initialization stage. initialization stage.
int cpufreq_frequency_table_verify(struct cpufreq_policy *policy, cpufreq_frequency_table_verify() assures that at least one valid
struct cpufreq_frequency_table *table); frequency is within policy->min and policy->max, and all other criteria
assures that at least one valid frequency is within policy->min and are met. This is helpful for the ->verify call.
policy->max, and all other criteria are met. This is helpful for the
->verify call. cpufreq_frequency_table_target() is the corresponding frequency table
helper for the ->target stage. Just pass the values to this function,
int cpufreq_frequency_table_target(struct cpufreq_policy *policy, and this function returns the of the frequency table entry which
unsigned int target_freq, contains the frequency the CPU shall be set to.
unsigned int relation);
is the corresponding frequency table helper for the ->target
stage. Just pass the values to this function, and this function
returns the number of the frequency table entry which contains
the frequency the CPU shall be set to.
The following macros can be used as iterators over cpufreq_frequency_table: The following macros can be used as iterators over cpufreq_frequency_table:
cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency cpufreq_for_each_entry(pos, table) - iterates over all entries of frequency
table. table.
cpufreq-for_each_valid_entry(pos, table) - iterates over all entries, cpufreq_for_each_valid_entry(pos, table) - iterates over all entries,
excluding CPUFREQ_ENTRY_INVALID frequencies. excluding CPUFREQ_ENTRY_INVALID frequencies.
Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and Use arguments "pos" - a cpufreq_frequency_table * as a loop cursor and
"table" - the cpufreq_frequency_table * you want to iterate over. "table" - the cpufreq_frequency_table * you want to iterate over.
......
...@@ -34,10 +34,10 @@ cpufreq stats provides following statistics (explained in detail below). ...@@ -34,10 +34,10 @@ cpufreq stats provides following statistics (explained in detail below).
- total_trans - total_trans
- trans_table - trans_table
All the statistics will be from the time the stats driver has been inserted All the statistics will be from the time the stats driver has been inserted
to the time when a read of a particular statistic is done. Obviously, stats (or the time the stats were reset) to the time when a read of a particular
driver will not have any information about the frequency transitions before statistic is done. Obviously, stats driver will not have any information
the stats driver insertion. about the frequency transitions before the stats driver insertion.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
<mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l <mysystem>:/sys/devices/system/cpu/cpu0/cpufreq/stats # ls -l
...@@ -110,25 +110,13 @@ Config Main Menu ...@@ -110,25 +110,13 @@ Config Main Menu
CPU Frequency scaling ---> CPU Frequency scaling --->
[*] CPU Frequency scaling [*] CPU Frequency scaling
[*] CPU frequency translation statistics [*] CPU frequency translation statistics
[*] CPU frequency translation statistics details
"CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure "CPU Frequency scaling" (CONFIG_CPU_FREQ) should be enabled to configure
cpufreq-stats. cpufreq-stats.
"CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the "CPU frequency translation statistics" (CONFIG_CPU_FREQ_STAT) provides the
basic statistics which includes time_in_state and total_trans. statistics which includes time_in_state, total_trans and trans_table.
"CPU frequency translation statistics details" (CONFIG_CPU_FREQ_STAT_DETAILS) Once this option is enabled and your CPU supports cpufrequency, you
provides fine grained cpufreq stats by trans_table. The reason for having a
separate config option for trans_table is:
- trans_table goes against the traditional /sysfs rule of one value per
interface. It provides a whole bunch of value in a 2 dimensional matrix
form.
Once these two options are enabled and your CPU supports cpufrequency, you
will be able to see the CPU frequency statistics in /sysfs. will be able to see the CPU frequency statistics in /sysfs.
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
Dominik Brodowski <linux@brodo.de> Dominik Brodowski <linux@brodo.de>
some additions and corrections by Nico Golde <nico@ngolde.de> some additions and corrections by Nico Golde <nico@ngolde.de>
Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Viresh Kumar <viresh.kumar@linaro.org>
...@@ -28,32 +30,27 @@ Contents: ...@@ -28,32 +30,27 @@ Contents:
2.3 Userspace 2.3 Userspace
2.4 Ondemand 2.4 Ondemand
2.5 Conservative 2.5 Conservative
2.6 Schedutil
3. The Governor Interface in the CPUfreq Core 3. The Governor Interface in the CPUfreq Core
4. References
1. What Is A CPUFreq Governor? 1. What Is A CPUFreq Governor?
============================== ==============================
Most cpufreq drivers (except the intel_pstate and longrun) or even most Most cpufreq drivers (except the intel_pstate and longrun) or even most
cpu frequency scaling algorithms only offer the CPU to be set to one cpu frequency scaling algorithms only allow the CPU frequency to be set
frequency. In order to offer dynamic frequency scaling, the cpufreq to predefined fixed values. In order to offer dynamic frequency
core must be able to tell these drivers of a "target frequency". So scaling, the cpufreq core must be able to tell these drivers of a
these specific drivers will be transformed to offer a "->target/target_index" "target frequency". So these specific drivers will be transformed to
call instead of the existing "->setpolicy" call. For "longrun", all offer a "->target/target_index/fast_switch()" call instead of the
stays the same, though. "->setpolicy()" call. For set_policy drivers, all stays the same,
though.
How to decide what frequency within the CPUfreq policy should be used? How to decide what frequency within the CPUfreq policy should be used?
That's done using "cpufreq governors". Two are already in this patch That's done using "cpufreq governors".
-- they're the already existing "powersave" and "performance" which
set the frequency statically to the lowest or highest frequency,
respectively. At least two more such governors will be ready for
addition in the near future, but likely many more as there are various
different theories and models about dynamic frequency scaling
around. Using such a generic interface as cpufreq offers to scaling
governors, these can be tested extensively, and the best one can be
selected for each specific use.
Basically, it's the following flow graph: Basically, it's the following flow graph:
...@@ -71,7 +68,7 @@ CPU can be set to switch independently | CPU can only be set ...@@ -71,7 +68,7 @@ CPU can be set to switch independently | CPU can only be set
/ the limits of policy->{min,max} / the limits of policy->{min,max}
/ \ / \
/ \ / \
Using the ->setpolicy call, Using the ->target/target_index call, Using the ->setpolicy call, Using the ->target/target_index/fast_switch call,
the limits and the the frequency closest the limits and the the frequency closest
"policy" is set. to target_freq is set. "policy" is set. to target_freq is set.
It is assured that it It is assured that it
...@@ -109,114 +106,159 @@ directory. ...@@ -109,114 +106,159 @@ directory.
2.4 Ondemand 2.4 Ondemand
------------ ------------
The CPUfreq governor "ondemand" sets the CPU depending on the The CPUfreq governor "ondemand" sets the CPU frequency depending on the
current usage. To do this the CPU must have the capability to current system load. Load estimation is triggered by the scheduler
switch the frequency very quickly. There are a number of sysfs file through the update_util_data->func hook; when triggered, cpufreq checks
accessible parameters: the CPU-usage statistics over the last period and the governor sets the
CPU accordingly. The CPU must have the capability to switch the
sampling_rate: measured in uS (10^-6 seconds), this is how often you frequency very quickly.
want the kernel to look at the CPU usage and to make decisions on
what to do about the frequency. Typically this is set to values of Sysfs files:
around '10000' or more. It's default value is (cmp. with users-guide.txt):
transition_latency * 1000 * sampling_rate:
Be aware that transition latency is in ns and sampling_rate is in us, so you
get the same sysfs value by default. Measured in uS (10^-6 seconds), this is how often you want the kernel
Sampling rate should always get adjusted considering the transition latency to look at the CPU usage and to make decisions on what to do about the
To set the sampling rate 750 times as high as the transition latency frequency. Typically this is set to values of around '10000' or more.
in the bash (as said, 1000 is default), do: It's default value is (cmp. with users-guide.txt): transition_latency
echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) \ * 1000. Be aware that transition latency is in ns and sampling_rate
>ondemand/sampling_rate is in us, so you get the same sysfs value by default. Sampling rate
should always get adjusted considering the transition latency to set
sampling_rate_min: the sampling rate 750 times as high as the transition latency in the
The sampling rate is limited by the HW transition latency: bash (as said, 1000 is default), do:
transition_latency * 100
Or by kernel restrictions: $ echo `$(($(cat cpuinfo_transition_latency) * 750 / 1000)) > ondemand/sampling_rate
If CONFIG_NO_HZ_COMMON is set, the limit is 10ms fixed.
If CONFIG_NO_HZ_COMMON is not set or nohz=off boot parameter is used, the * sampling_rate_min:
limits depend on the CONFIG_HZ option:
HZ=1000: min=20000us (20ms) The sampling rate is limited by the HW transition latency:
HZ=250: min=80000us (80ms) transition_latency * 100
HZ=100: min=200000us (200ms)
The highest value of kernel and HW latency restrictions is shown and Or by kernel restrictions:
used as the minimum sampling rate. - If CONFIG_NO_HZ_COMMON is set, the limit is 10ms fixed.
- If CONFIG_NO_HZ_COMMON is not set or nohz=off boot parameter is
up_threshold: defines what the average CPU usage between the samplings used, the limits depend on the CONFIG_HZ option:
of 'sampling_rate' needs to be for the kernel to make a decision on HZ=1000: min=20000us (20ms)
whether it should increase the frequency. For example when it is set HZ=250: min=80000us (80ms)
to its default value of '95' it means that between the checking HZ=100: min=200000us (200ms)
intervals the CPU needs to be on average more than 95% in use to then
decide that the CPU frequency needs to be increased. The highest value of kernel and HW latency restrictions is shown and
used as the minimum sampling rate.
ignore_nice_load: this parameter takes a value of '0' or '1'. When
set to '0' (its default), all processes are counted towards the * up_threshold:
'cpu utilisation' value. When set to '1', the processes that are
run with a 'nice' value will not count (and thus be ignored) in the This defines what the average CPU usage between the samplings of
overall usage calculation. This is useful if you are running a CPU 'sampling_rate' needs to be for the kernel to make a decision on
intensive calculation on your laptop that you do not care how long it whether it should increase the frequency. For example when it is set
takes to complete as you can 'nice' it and prevent it from taking part to its default value of '95' it means that between the checking
in the deciding process of whether to increase your CPU frequency. intervals the CPU needs to be on average more than 95% in use to then
decide that the CPU frequency needs to be increased.
sampling_down_factor: this parameter controls the rate at which the
kernel makes a decision on when to decrease the frequency while running * ignore_nice_load:
at top speed. When set to 1 (the default) decisions to reevaluate load
are made at the same interval regardless of current clock speed. But This parameter takes a value of '0' or '1'. When set to '0' (its
when set to greater than 1 (e.g. 100) it acts as a multiplier for the default), all processes are counted towards the 'cpu utilisation'
scheduling interval for reevaluating load when the CPU is at its top value. When set to '1', the processes that are run with a 'nice'
speed due to high load. This improves performance by reducing the overhead value will not count (and thus be ignored) in the overall usage
of load evaluation and helping the CPU stay at its top speed when truly calculation. This is useful if you are running a CPU intensive
busy, rather than shifting back and forth in speed. This tunable has no calculation on your laptop that you do not care how long it takes to
effect on behavior at lower speeds/lower CPU loads. complete as you can 'nice' it and prevent it from taking part in the
deciding process of whether to increase your CPU frequency.
powersave_bias: this parameter takes a value between 0 to 1000. It
defines the percentage (times 10) value of the target frequency that * sampling_down_factor:
will be shaved off of the target. For example, when set to 100 -- 10%,
when ondemand governor would have targeted 1000 MHz, it will target This parameter controls the rate at which the kernel makes a decision
1000 MHz - (10% of 1000 MHz) = 900 MHz instead. This is set to 0 on when to decrease the frequency while running at top speed. When set
(disabled) by default. to 1 (the default) decisions to reevaluate load are made at the same
When AMD frequency sensitivity powersave bias driver -- interval regardless of current clock speed. But when set to greater
drivers/cpufreq/amd_freq_sensitivity.c is loaded, this parameter than 1 (e.g. 100) it acts as a multiplier for the scheduling interval
defines the workload frequency sensitivity threshold in which a lower for reevaluating load when the CPU is at its top speed due to high
frequency is chosen instead of ondemand governor's original target. load. This improves performance by reducing the overhead of load
The frequency sensitivity is a hardware reported (on AMD Family 16h evaluation and helping the CPU stay at its top speed when truly busy,
Processors and above) value between 0 to 100% that tells software how rather than shifting back and forth in speed. This tunable has no
the performance of the workload running on a CPU will change when effect on behavior at lower speeds/lower CPU loads.
frequency changes. A workload with sensitivity of 0% (memory/IO-bound)
will not perform any better on higher core frequency, whereas a * powersave_bias:
workload with sensitivity of 100% (CPU-bound) will perform better
higher the frequency. When the driver is loaded, this is set to 400 This parameter takes a value between 0 to 1000. It defines the
by default -- for CPUs running workloads with sensitivity value below percentage (times 10) value of the target frequency that will be
40%, a lower frequency is chosen. Unloading the driver or writing 0 shaved off of the target. For example, when set to 100 -- 10%, when
will disable this feature. ondemand governor would have targeted 1000 MHz, it will target
1000 MHz - (10% of 1000 MHz) = 900 MHz instead. This is set to 0
(disabled) by default.
When AMD frequency sensitivity powersave bias driver --
drivers/cpufreq/amd_freq_sensitivity.c is loaded, this parameter
defines the workload frequency sensitivity threshold in which a lower
frequency is chosen instead of ondemand governor's original target.
The frequency sensitivity is a hardware reported (on AMD Family 16h
Processors and above) value between 0 to 100% that tells software how
the performance of the workload running on a CPU will change when
frequency changes. A workload with sensitivity of 0% (memory/IO-bound)
will not perform any better on higher core frequency, whereas a
workload with sensitivity of 100% (CPU-bound) will perform better
higher the frequency. When the driver is loaded, this is set to 400 by
default -- for CPUs running workloads with sensitivity value below
40%, a lower frequency is chosen. Unloading the driver or writing 0
will disable this feature.
2.5 Conservative 2.5 Conservative
---------------- ----------------
The CPUfreq governor "conservative", much like the "ondemand" The CPUfreq governor "conservative", much like the "ondemand"
governor, sets the CPU depending on the current usage. It differs in governor, sets the CPU frequency depending on the current usage. It
behaviour in that it gracefully increases and decreases the CPU speed differs in behaviour in that it gracefully increases and decreases the
rather than jumping to max speed the moment there is any load on the CPU speed rather than jumping to max speed the moment there is any load
CPU. This behaviour more suitable in a battery powered environment. on the CPU. This behaviour is more suitable in a battery powered
The governor is tweaked in the same manner as the "ondemand" governor environment. The governor is tweaked in the same manner as the
through sysfs with the addition of: "ondemand" governor through sysfs with the addition of:
freq_step: this describes what percentage steps the cpu freq should be * freq_step:
increased and decreased smoothly by. By default the cpu frequency will
increase in 5% chunks of your maximum cpu frequency. You can change this This describes what percentage steps the cpu freq should be increased
value to anywhere between 0 and 100 where '0' will effectively lock your and decreased smoothly by. By default the cpu frequency will increase
CPU at a speed regardless of its load whilst '100' will, in theory, make in 5% chunks of your maximum cpu frequency. You can change this value
it behave identically to the "ondemand" governor. to anywhere between 0 and 100 where '0' will effectively lock your CPU
at a speed regardless of its load whilst '100' will, in theory, make
down_threshold: same as the 'up_threshold' found for the "ondemand" it behave identically to the "ondemand" governor.
governor but for the opposite direction. For example when set to its
default value of '20' it means that if the CPU usage needs to be below * down_threshold:
20% between samples to have the frequency decreased.
Same as the 'up_threshold' found for the "ondemand" governor but for
sampling_down_factor: similar functionality as in "ondemand" governor. the opposite direction. For example when set to its default value of
But in "conservative", it controls the rate at which the kernel makes '20' it means that if the CPU usage needs to be below 20% between
a decision on when to decrease the frequency while running in any samples to have the frequency decreased.
speed. Load for frequency increase is still evaluated every
sampling rate. * sampling_down_factor:
Similar functionality as in "ondemand" governor. But in
"conservative", it controls the rate at which the kernel makes a
decision on when to decrease the frequency while running in any speed.
Load for frequency increase is still evaluated every sampling rate.
2.6 Schedutil
-------------
The "schedutil" governor aims at better integration with the Linux
kernel scheduler. Load estimation is achieved through the scheduler's
Per-Entity Load Tracking (PELT) mechanism, which also provides
information about the recent load [1]. This governor currently does
load based DVFS only for tasks managed by CFS. RT and DL scheduler tasks
are always run at the highest frequency. Unlike all the other
governors, the code is located under the kernel/sched/ directory.
Sysfs files:
* rate_limit_us:
This contains a value in microseconds. The governor waits for
rate_limit_us time before reevaluating the load again, after it has
evaluated the load once.
For an in-depth comparison with the other governors refer to [2].
3. The Governor Interface in the CPUfreq Core 3. The Governor Interface in the CPUfreq Core
============================================= =============================================
...@@ -225,26 +267,10 @@ A new governor must register itself with the CPUfreq core using ...@@ -225,26 +267,10 @@ A new governor must register itself with the CPUfreq core using
"cpufreq_register_governor". The struct cpufreq_governor, which has to "cpufreq_register_governor". The struct cpufreq_governor, which has to
be passed to that function, must contain the following values: be passed to that function, must contain the following values:
governor->name - A unique name for this governor governor->name - A unique name for this governor.
governor->governor - The governor callback function governor->owner - .THIS_MODULE for the governor module (if appropriate).
governor->owner - .THIS_MODULE for the governor module (if
appropriate)
The governor->governor callback is called with the current (or to-be-set)
cpufreq_policy struct for that CPU, and an unsigned int event. The
following events are currently defined:
CPUFREQ_GOV_START: This governor shall start its duty for the CPU
policy->cpu
CPUFREQ_GOV_STOP: This governor shall end its duty for the CPU
policy->cpu
CPUFREQ_GOV_LIMITS: The limits for CPU policy->cpu have changed to
policy->min and policy->max.
If you need other "events" externally of your driver, _only_ use the
cpufreq_governor_l(unsigned int cpu, unsigned int event) call to the
CPUfreq core to ensure proper locking.
plus a set of hooks to the functions implementing the governor's logic.
The CPUfreq governor may call the CPU processor driver using one of The CPUfreq governor may call the CPU processor driver using one of
these two functions: these two functions:
...@@ -258,12 +284,18 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy, ...@@ -258,12 +284,18 @@ int __cpufreq_driver_target(struct cpufreq_policy *policy,
unsigned int relation); unsigned int relation);
target_freq must be within policy->min and policy->max, of course. target_freq must be within policy->min and policy->max, of course.
What's the difference between these two functions? When your governor What's the difference between these two functions? When your governor is
still is in a direct code path of a call to governor->governor, the in a direct code path of a call to governor callbacks, like
per-CPU cpufreq lock is still held in the cpufreq core, and there's governor->start(), the policy->rwsem is still held in the cpufreq core,
no need to lock it again (in fact, this would cause a deadlock). So and there's no need to lock it again (in fact, this would cause a
use __cpufreq_driver_target only in these cases. In all other cases deadlock). So use __cpufreq_driver_target only in these cases. In all
(for example, when there's a "daemonized" function that wakes up other cases (for example, when there's a "daemonized" function that
every second), use cpufreq_driver_target to lock the cpufreq per-CPU wakes up every second), use cpufreq_driver_target to take policy->rwsem
lock before the command is passed to the cpufreq processor driver. before the command is passed to the cpufreq driver.
4. References
=============
[1] Per-entity load tracking: https://lwn.net/Articles/531853/
[2] Improvements in CPU frequency management: https://lwn.net/Articles/682391/
...@@ -18,16 +18,29 @@ ...@@ -18,16 +18,29 @@
Documents in this directory: Documents in this directory:
---------------------------- ----------------------------
amd-powernow.txt - AMD powernow driver specific file.
boost.txt - Frequency boosting support.
core.txt - General description of the CPUFreq core and core.txt - General description of the CPUFreq core and
of CPUFreq notifiers of CPUFreq notifiers.
cpu-drivers.txt - How to implement a new cpufreq processor driver.
cpu-drivers.txt - How to implement a new cpufreq processor driver cpufreq-nforce2.txt - nVidia nForce2 platform specific file.
cpufreq-stats.txt - General description of sysfs cpufreq stats.
governors.txt - What are cpufreq governors and how to governors.txt - What are cpufreq governors and how to
implement them? implement them?
index.txt - File index, Mailing list and Links (this document) index.txt - File index, Mailing list and Links (this document)
intel-pstate.txt - Intel pstate cpufreq driver specific file.
pcc-cpufreq.txt - PCC cpufreq driver specific file.
user-guide.txt - User Guide to CPUFreq user-guide.txt - User Guide to CPUFreq
...@@ -35,9 +48,7 @@ Mailing List ...@@ -35,9 +48,7 @@ Mailing List
------------ ------------
There is a CPU frequency changing CVS commit and general list where There is a CPU frequency changing CVS commit and general list where
you can report bugs, problems or submit patches. To post a message, you can report bugs, problems or submit patches. To post a message,
send an email to linux-pm@vger.kernel.org, to subscribe go to send an email to linux-pm@vger.kernel.org.
http://vger.kernel.org/vger-lists.html#linux-pm and follow the
instructions there.
Links Links
----- -----
...@@ -48,7 +59,7 @@ how to access the CVS repository: ...@@ -48,7 +59,7 @@ how to access the CVS repository:
* http://cvs.arm.linux.org.uk/ * http://cvs.arm.linux.org.uk/
the CPUFreq Mailing list: the CPUFreq Mailing list:
* http://vger.kernel.org/vger-lists.html#cpufreq * http://vger.kernel.org/vger-lists.html#linux-pm
Clock and voltage scaling for the SA-1100: Clock and voltage scaling for the SA-1100:
* http://www.lartmaker.nl/projects/scaling * http://www.lartmaker.nl/projects/scaling
...@@ -85,6 +85,21 @@ Sysfs will show : ...@@ -85,6 +85,21 @@ Sysfs will show :
Refer to "Intel® 64 and IA-32 Architectures Software Developer’s Manual Refer to "Intel® 64 and IA-32 Architectures Software Developer’s Manual
Volume 3: System Programming Guide" to understand ratios. Volume 3: System Programming Guide" to understand ratios.
There is one more sysfs attribute in /sys/devices/system/cpu/intel_pstate/
that can be used for controlling the operation mode of the driver:
status: Three settings are possible:
"off" - The driver is not in use at this time.
"active" - The driver works as a P-state governor (default).
"passive" - The driver works as a regular cpufreq one and collaborates
with the generic cpufreq governors (it sets P-states as
requested by those governors).
The current setting is returned by reads from this attribute. Writing one
of the above strings to it changes the operation mode as indicated by that
string, if possible. If HW-managed P-states (HWP) are enabled, it is not
possible to change the driver's operation mode and attempts to write to
this attribute will fail.
cpufreq sysfs for Intel P-State cpufreq sysfs for Intel P-State
Since this driver registers with cpufreq, cpufreq sysfs is also presented. Since this driver registers with cpufreq, cpufreq sysfs is also presented.
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
Contents: Contents:
--------- ---------
1. Supported Architectures and Processors 1. Supported Architectures and Processors
1.1 ARM 1.1 ARM and ARM64
1.2 x86 1.2 x86
1.3 sparc64 1.3 sparc64
1.4 ppc 1.4 ppc
...@@ -37,16 +37,10 @@ Contents: ...@@ -37,16 +37,10 @@ Contents:
1. Supported Architectures and Processors 1. Supported Architectures and Processors
========================================= =========================================
1.1 ARM 1.1 ARM and ARM64
------- -----------------
The following ARM processors are supported by cpufreq:
ARM Integrator
ARM-SA1100
ARM-SA1110
Intel PXA
Almost all ARM and ARM64 platforms support CPU frequency scaling.
1.2 x86 1.2 x86
------- -------
...@@ -69,6 +63,7 @@ Transmeta Crusoe ...@@ -69,6 +63,7 @@ Transmeta Crusoe
Transmeta Efficeon Transmeta Efficeon
VIA Cyrix 3 / C3 VIA Cyrix 3 / C3
various processors on some ACPI 2.0-compatible systems [*] various processors on some ACPI 2.0-compatible systems [*]
And many more
[*] Only if "ACPI Processor Performance States" are available [*] Only if "ACPI Processor Performance States" are available
to the ACPI<->BIOS interface. to the ACPI<->BIOS interface.
...@@ -147,10 +142,19 @@ mounted it at /sys, the cpufreq interface is located in a subdirectory ...@@ -147,10 +142,19 @@ mounted it at /sys, the cpufreq interface is located in a subdirectory
"cpufreq" within the cpu-device directory "cpufreq" within the cpu-device directory
(e.g. /sys/devices/system/cpu/cpu0/cpufreq/ for the first CPU). (e.g. /sys/devices/system/cpu/cpu0/cpufreq/ for the first CPU).
affected_cpus : List of Online CPUs that require software
coordination of frequency.
cpuinfo_cur_freq : Current frequency of the CPU as obtained from
the hardware, in KHz. This is the frequency
the CPU actually runs at.
cpuinfo_min_freq : this file shows the minimum operating cpuinfo_min_freq : this file shows the minimum operating
frequency the processor can run at(in kHz) frequency the processor can run at(in kHz)
cpuinfo_max_freq : this file shows the maximum operating cpuinfo_max_freq : this file shows the maximum operating
frequency the processor can run at(in kHz) frequency the processor can run at(in kHz)
cpuinfo_transition_latency The time it takes on this CPU to cpuinfo_transition_latency The time it takes on this CPU to
switch between two frequencies in nano switch between two frequencies in nano
seconds. If unknown or known to be seconds. If unknown or known to be
...@@ -163,25 +167,30 @@ cpuinfo_transition_latency The time it takes on this CPU to ...@@ -163,25 +167,30 @@ cpuinfo_transition_latency The time it takes on this CPU to
userspace daemon. Make sure to not userspace daemon. Make sure to not
switch the frequency too often switch the frequency too often
resulting in performance loss. resulting in performance loss.
scaling_driver : this file shows what cpufreq driver is
used to set the frequency on this CPU related_cpus : List of Online + Offline CPUs that need software
coordination of frequency.
scaling_available_frequencies : List of available frequencies, in KHz.
scaling_available_governors : this file shows the CPUfreq governors scaling_available_governors : this file shows the CPUfreq governors
available in this kernel. You can see the available in this kernel. You can see the
currently activated governor in currently activated governor in
scaling_cur_freq : Current frequency of the CPU as determined by
the governor and cpufreq core, in KHz. This is
the frequency the kernel thinks the CPU runs
at.
scaling_driver : this file shows what cpufreq driver is
used to set the frequency on this CPU
scaling_governor, and by "echoing" the name of another scaling_governor, and by "echoing" the name of another
governor you can change it. Please note governor you can change it. Please note
that some governors won't load - they only that some governors won't load - they only
work on some specific architectures or work on some specific architectures or
processors. processors.
cpuinfo_cur_freq : Current frequency of the CPU as obtained from
the hardware, in KHz. This is the frequency
the CPU actually runs at.
scaling_available_frequencies : List of available frequencies, in KHz.
scaling_min_freq and scaling_min_freq and
scaling_max_freq show the current "policy limits" (in scaling_max_freq show the current "policy limits" (in
kHz). By echoing new values into these kHz). By echoing new values into these
...@@ -190,16 +199,11 @@ scaling_max_freq show the current "policy limits" (in ...@@ -190,16 +199,11 @@ scaling_max_freq show the current "policy limits" (in
first set scaling_max_freq, then first set scaling_max_freq, then
scaling_min_freq. scaling_min_freq.
affected_cpus : List of Online CPUs that require software scaling_setspeed This can be read to get the currently programmed
coordination of frequency. value by the governor. This can be written to
change the current frequency for a group of
related_cpus : List of Online + Offline CPUs that need software CPUs, represented by a policy. This is supported
coordination of frequency. currently only by the userspace governor.
scaling_cur_freq : Current frequency of the CPU as determined by
the governor and cpufreq core, in KHz. This is
the frequency the kernel thinks the CPU runs
at.
bios_limit : If the BIOS tells the OS to limit a CPU to bios_limit : If the BIOS tells the OS to limit a CPU to
lower frequencies, the user can read out the lower frequencies, the user can read out the
......
TI CPUFreq and OPP bindings
================================
Certain TI SoCs, like those in the am335x, am437x, am57xx, and dra7xx
families support different OPPs depending on the silicon variant in use.
The ti-cpufreq driver can use revision and an efuse value from the SoC to
provide the OPP framework with supported hardware information. This is
used to determine which OPPs from the operating-points-v2 table get enabled
when it is parsed by the OPP framework.
Required properties:
--------------------
In 'cpus' nodes:
- operating-points-v2: Phandle to the operating-points-v2 table to use.
In 'operating-points-v2' table:
- compatible: Should be
- 'operating-points-v2-ti-cpu' for am335x, am43xx, and dra7xx/am57xx SoCs
- syscon: A phandle pointing to a syscon node representing the control module
register space of the SoC.
Optional properties:
--------------------
For each opp entry in 'operating-points-v2' table:
- opp-supported-hw: Two bitfields indicating:
1. Which revision of the SoC the OPP is supported by
2. Which eFuse bits indicate this OPP is available
A bitwise AND is performed against these values and if any bit
matches, the OPP gets enabled.
Example:
--------
/* From arch/arm/boot/dts/am33xx.dtsi */
cpus {
#address-cells = <1>;
#size-cells = <0>;
cpu@0 {
compatible = "arm,cortex-a8";
device_type = "cpu";
reg = <0>;
operating-points-v2 = <&cpu0_opp_table>;
clocks = <&dpll_mpu_ck>;
clock-names = "cpu";
clock-latency = <300000>; /* From omap-cpufreq driver */
};
};
/*
* cpu0 has different OPPs depending on SoC revision and some on revisions
* 0x2 and 0x4 have eFuse bits that indicate if they are available or not
*/
cpu0_opp_table: opp-table {
compatible = "operating-points-v2-ti-cpu";
syscon = <&scm_conf>;
/*
* The three following nodes are marked with opp-suspend
* because they can not be enabled simultaneously on a
* single SoC.
*/
opp50@300000000 {
opp-hz = /bits/ 64 <300000000>;
opp-microvolt = <950000 931000 969000>;
opp-supported-hw = <0x06 0x0010>;
opp-suspend;
};
opp100@275000000 {
opp-hz = /bits/ 64 <275000000>;
opp-microvolt = <1100000 1078000 1122000>;
opp-supported-hw = <0x01 0x00FF>;
opp-suspend;
};
opp100@300000000 {
opp-hz = /bits/ 64 <300000000>;
opp-microvolt = <1100000 1078000 1122000>;
opp-supported-hw = <0x06 0x0020>;
opp-suspend;
};
opp100@500000000 {
opp-hz = /bits/ 64 <500000000>;
opp-microvolt = <1100000 1078000 1122000>;
opp-supported-hw = <0x01 0xFFFF>;
};
opp100@600000000 {
opp-hz = /bits/ 64 <600000000>;
opp-microvolt = <1100000 1078000 1122000>;
opp-supported-hw = <0x06 0x0040>;
};
opp120@600000000 {
opp-hz = /bits/ 64 <600000000>;
opp-microvolt = <1200000 1176000 1224000>;
opp-supported-hw = <0x01 0xFFFF>;
};
opp120@720000000 {
opp-hz = /bits/ 64 <720000000>;
opp-microvolt = <1200000 1176000 1224000>;
opp-supported-hw = <0x06 0x0080>;
};
oppturbo@720000000 {
opp-hz = /bits/ 64 <720000000>;
opp-microvolt = <1260000 1234800 1285200>;
opp-supported-hw = <0x01 0xFFFF>;
};
oppturbo@800000000 {
opp-hz = /bits/ 64 <800000000>;
opp-microvolt = <1260000 1234800 1285200>;
opp-supported-hw = <0x06 0x0100>;
};
oppnitro@1000000000 {
opp-hz = /bits/ 64 <1000000000>;
opp-microvolt = <1325000 1298500 1351500>;
opp-supported-hw = <0x04 0x0200>;
};
};
...@@ -123,6 +123,20 @@ Detailed correlation between sub-blocks and power line according to Exynos SoC: ...@@ -123,6 +123,20 @@ Detailed correlation between sub-blocks and power line according to Exynos SoC:
|--- FSYS |--- FSYS
|--- FSYS2 |--- FSYS2
- In case of Exynos5433, there is VDD_INT power line as following:
VDD_INT |--- G2D (parent device)
|--- MSCL
|--- GSCL
|--- JPEG
|--- MFC
|--- HEVC
|--- BUS0
|--- BUS1
|--- BUS2
|--- PERIS (Fixed clock rate)
|--- PERIC (Fixed clock rate)
|--- FSYS (Fixed clock rate)
Example1: Example1:
Show the AXI buses of Exynos3250 SoC. Exynos3250 divides the buses to Show the AXI buses of Exynos3250 SoC. Exynos3250 divides the buses to
power line (regulator). The MIF (Memory Interface) AXI bus is used to power line (regulator). The MIF (Memory Interface) AXI bus is used to
......
...@@ -79,22 +79,6 @@ dependent subsystems such as cpufreq are left to the discretion of the SoC ...@@ -79,22 +79,6 @@ dependent subsystems such as cpufreq are left to the discretion of the SoC
specific framework which uses the OPP library. Similar care needs to be taken specific framework which uses the OPP library. Similar care needs to be taken
care to refresh the cpufreq table in cases of these operations. care to refresh the cpufreq table in cases of these operations.
WARNING on OPP List locking mechanism:
-------------------------------------------------
OPP library uses RCU for exclusivity. RCU allows the query functions to operate
in multiple contexts and this synchronization mechanism is optimal for a read
intensive operations on data structure as the OPP library caters to.
To ensure that the data retrieved are sane, the users such as SoC framework
should ensure that the section of code operating on OPP queries are locked
using RCU read locks. The opp_find_freq_{exact,ceil,floor},
opp_get_{voltage, freq, opp_count} fall into this category.
opp_{add,enable,disable} are updaters which use mutex and implement it's own
RCU locking mechanisms. These functions should *NOT* be called under RCU locks
and other contexts that prevent blocking functions in RCU or mutex operations
from working.
2. Initial OPP List Registration 2. Initial OPP List Registration
================================ ================================
The SoC implementation calls dev_pm_opp_add function iteratively to add OPPs per The SoC implementation calls dev_pm_opp_add function iteratively to add OPPs per
...@@ -137,15 +121,18 @@ functions return the matching pointer representing the opp if a match is ...@@ -137,15 +121,18 @@ functions return the matching pointer representing the opp if a match is
found, else returns error. These errors are expected to be handled by standard found, else returns error. These errors are expected to be handled by standard
error checks such as IS_ERR() and appropriate actions taken by the caller. error checks such as IS_ERR() and appropriate actions taken by the caller.
Callers of these functions shall call dev_pm_opp_put() after they have used the
OPP. Otherwise the memory for the OPP will never get freed and result in
memleak.
dev_pm_opp_find_freq_exact - Search for an OPP based on an *exact* frequency and dev_pm_opp_find_freq_exact - Search for an OPP based on an *exact* frequency and
availability. This function is especially useful to enable an OPP which availability. This function is especially useful to enable an OPP which
is not available by default. is not available by default.
Example: In a case when SoC framework detects a situation where a Example: In a case when SoC framework detects a situation where a
higher frequency could be made available, it can use this function to higher frequency could be made available, it can use this function to
find the OPP prior to call the dev_pm_opp_enable to actually make it available. find the OPP prior to call the dev_pm_opp_enable to actually make it available.
rcu_read_lock();
opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false); opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false);
rcu_read_unlock(); dev_pm_opp_put(opp);
/* dont operate on the pointer.. just do a sanity check.. */ /* dont operate on the pointer.. just do a sanity check.. */
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
pr_err("frequency not disabled!\n"); pr_err("frequency not disabled!\n");
...@@ -163,9 +150,8 @@ dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the ...@@ -163,9 +150,8 @@ dev_pm_opp_find_freq_floor - Search for an available OPP which is *at most* the
frequency. frequency.
Example: To find the highest opp for a device: Example: To find the highest opp for a device:
freq = ULONG_MAX; freq = ULONG_MAX;
rcu_read_lock(); opp = dev_pm_opp_find_freq_floor(dev, &freq);
dev_pm_opp_find_freq_floor(dev, &freq); dev_pm_opp_put(opp);
rcu_read_unlock();
dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the
provided frequency. This function is useful while searching for a provided frequency. This function is useful while searching for a
...@@ -173,17 +159,15 @@ dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the ...@@ -173,17 +159,15 @@ dev_pm_opp_find_freq_ceil - Search for an available OPP which is *at least* the
frequency. frequency.
Example 1: To find the lowest opp for a device: Example 1: To find the lowest opp for a device:
freq = 0; freq = 0;
rcu_read_lock(); opp = dev_pm_opp_find_freq_ceil(dev, &freq);
dev_pm_opp_find_freq_ceil(dev, &freq); dev_pm_opp_put(opp);
rcu_read_unlock();
Example 2: A simplified implementation of a SoC cpufreq_driver->target: Example 2: A simplified implementation of a SoC cpufreq_driver->target:
soc_cpufreq_target(..) soc_cpufreq_target(..)
{ {
/* Do stuff like policy checks etc. */ /* Do stuff like policy checks etc. */
/* Find the best frequency match for the req */ /* Find the best frequency match for the req */
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(dev, &freq); opp = dev_pm_opp_find_freq_ceil(dev, &freq);
rcu_read_unlock(); dev_pm_opp_put(opp);
if (!IS_ERR(opp)) if (!IS_ERR(opp))
soc_switch_to_freq_voltage(freq); soc_switch_to_freq_voltage(freq);
else else
...@@ -208,9 +192,8 @@ dev_pm_opp_enable - Make a OPP available for operation. ...@@ -208,9 +192,8 @@ dev_pm_opp_enable - Make a OPP available for operation.
implementation might choose to do something as follows: implementation might choose to do something as follows:
if (cur_temp < temp_low_thresh) { if (cur_temp < temp_low_thresh) {
/* Enable 1GHz if it was disabled */ /* Enable 1GHz if it was disabled */
rcu_read_lock();
opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false); opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false);
rcu_read_unlock(); dev_pm_opp_put(opp);
/* just error check */ /* just error check */
if (!IS_ERR(opp)) if (!IS_ERR(opp))
ret = dev_pm_opp_enable(dev, 1000000000); ret = dev_pm_opp_enable(dev, 1000000000);
...@@ -224,9 +207,8 @@ dev_pm_opp_disable - Make an OPP to be not available for operation ...@@ -224,9 +207,8 @@ dev_pm_opp_disable - Make an OPP to be not available for operation
choose to do something as follows: choose to do something as follows:
if (cur_temp > temp_high_thresh) { if (cur_temp > temp_high_thresh) {
/* Disable 1GHz if it was enabled */ /* Disable 1GHz if it was enabled */
rcu_read_lock();
opp = dev_pm_opp_find_freq_exact(dev, 1000000000, true); opp = dev_pm_opp_find_freq_exact(dev, 1000000000, true);
rcu_read_unlock(); dev_pm_opp_put(opp);
/* just error check */ /* just error check */
if (!IS_ERR(opp)) if (!IS_ERR(opp))
ret = dev_pm_opp_disable(dev, 1000000000); ret = dev_pm_opp_disable(dev, 1000000000);
...@@ -249,10 +231,9 @@ dev_pm_opp_get_voltage - Retrieve the voltage represented by the opp pointer. ...@@ -249,10 +231,9 @@ dev_pm_opp_get_voltage - Retrieve the voltage represented by the opp pointer.
soc_switch_to_freq_voltage(freq) soc_switch_to_freq_voltage(freq)
{ {
/* do things */ /* do things */
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(dev, &freq); opp = dev_pm_opp_find_freq_ceil(dev, &freq);
v = dev_pm_opp_get_voltage(opp); v = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
if (v) if (v)
regulator_set_voltage(.., v); regulator_set_voltage(.., v);
/* do other things */ /* do other things */
...@@ -266,12 +247,12 @@ dev_pm_opp_get_freq - Retrieve the freq represented by the opp pointer. ...@@ -266,12 +247,12 @@ dev_pm_opp_get_freq - Retrieve the freq represented by the opp pointer.
{ {
/* do things.. */ /* do things.. */
max_freq = ULONG_MAX; max_freq = ULONG_MAX;
rcu_read_lock();
max_opp = dev_pm_opp_find_freq_floor(dev,&max_freq); max_opp = dev_pm_opp_find_freq_floor(dev,&max_freq);
requested_opp = dev_pm_opp_find_freq_ceil(dev,&freq); requested_opp = dev_pm_opp_find_freq_ceil(dev,&freq);
if (!IS_ERR(max_opp) && !IS_ERR(requested_opp)) if (!IS_ERR(max_opp) && !IS_ERR(requested_opp))
r = soc_test_validity(max_opp, requested_opp); r = soc_test_validity(max_opp, requested_opp);
rcu_read_unlock(); dev_pm_opp_put(max_opp);
dev_pm_opp_put(requested_opp);
/* do other things */ /* do other things */
} }
soc_test_validity(..) soc_test_validity(..)
...@@ -289,7 +270,6 @@ dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device ...@@ -289,7 +270,6 @@ dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device
soc_notify_coproc_available_frequencies() soc_notify_coproc_available_frequencies()
{ {
/* Do things */ /* Do things */
rcu_read_lock();
num_available = dev_pm_opp_get_opp_count(dev); num_available = dev_pm_opp_get_opp_count(dev);
speeds = kzalloc(sizeof(u32) * num_available, GFP_KERNEL); speeds = kzalloc(sizeof(u32) * num_available, GFP_KERNEL);
/* populate the table in increasing order */ /* populate the table in increasing order */
...@@ -298,8 +278,8 @@ dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device ...@@ -298,8 +278,8 @@ dev_pm_opp_get_opp_count - Retrieve the number of available opps for a device
speeds[i] = freq; speeds[i] = freq;
freq++; freq++;
i++; i++;
dev_pm_opp_put(opp);
} }
rcu_read_unlock();
soc_notify_coproc(AVAILABLE_FREQs, speeds, num_available); soc_notify_coproc(AVAILABLE_FREQs, speeds, num_available);
/* Do other things */ /* Do other things */
......
...@@ -25,7 +25,7 @@ to be used subsequently to change to the one represented by that string. ...@@ -25,7 +25,7 @@ to be used subsequently to change to the one represented by that string.
Consequently, there are two ways to cause the system to go into the Consequently, there are two ways to cause the system to go into the
Suspend-To-Idle sleep state. The first one is to write "freeze" directly to Suspend-To-Idle sleep state. The first one is to write "freeze" directly to
/sys/power/state. The second one is to write "s2idle" to /sys/power/mem_sleep /sys/power/state. The second one is to write "s2idle" to /sys/power/mem_sleep
and then to wrtie "mem" to /sys/power/state. Similarly, there are two ways and then to write "mem" to /sys/power/state. Similarly, there are two ways
to cause the system to go into the Power-On Suspend sleep state (the strings to to cause the system to go into the Power-On Suspend sleep state (the strings to
write to the control files in that case are "standby" or "shallow" and "mem", write to the control files in that case are "standby" or "shallow" and "mem",
respectively) if that state is supported by the platform. In turn, there is respectively) if that state is supported by the platform. In turn, there is
......
...@@ -2692,6 +2692,13 @@ F: drivers/irqchip/irq-brcmstb* ...@@ -2692,6 +2692,13 @@ F: drivers/irqchip/irq-brcmstb*
F: include/linux/bcm963xx_nvram.h F: include/linux/bcm963xx_nvram.h
F: include/linux/bcm963xx_tag.h F: include/linux/bcm963xx_tag.h
BROADCOM BMIPS CPUFREQ DRIVER
M: Markus Mayer <mmayer@broadcom.com>
M: bcm-kernel-feedback-list@broadcom.com
L: linux-pm@vger.kernel.org
S: Maintained
F: drivers/cpufreq/bmips-cpufreq.c
BROADCOM TG3 GIGABIT ETHERNET DRIVER BROADCOM TG3 GIGABIT ETHERNET DRIVER
M: Siva Reddy Kallam <siva.kallam@broadcom.com> M: Siva Reddy Kallam <siva.kallam@broadcom.com>
M: Prashant Sreedharan <prashant@broadcom.com> M: Prashant Sreedharan <prashant@broadcom.com>
......
...@@ -24,7 +24,7 @@ CONFIG_ARM_APPENDED_DTB=y ...@@ -24,7 +24,7 @@ CONFIG_ARM_APPENDED_DTB=y
CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x41000000,8M console=ttySAC1,115200 init=/linuxrc mem=256M" CONFIG_CMDLINE="root=/dev/ram0 rw ramdisk=8192 initrd=0x41000000,8M console=ttySAC1,115200 init=/linuxrc mem=256M"
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m CONFIG_CPU_FREQ_GOV_USERSPACE=m
......
...@@ -58,7 +58,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0 ...@@ -58,7 +58,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_APPENDED_DTB=y
CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_IDLE=y CONFIG_CPU_IDLE=y
CONFIG_ARM_KIRKWOOD_CPUIDLE=y CONFIG_ARM_KIRKWOOD_CPUIDLE=y
......
...@@ -132,7 +132,7 @@ CONFIG_ARM_ATAG_DTB_COMPAT=y ...@@ -132,7 +132,7 @@ CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_KEXEC=y CONFIG_KEXEC=y
CONFIG_EFI=y CONFIG_EFI=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m CONFIG_CPU_FREQ_GOV_USERSPACE=m
......
...@@ -44,7 +44,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0 ...@@ -44,7 +44,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_APPENDED_DTB=y
CONFIG_ARM_ATAG_DTB_COMPAT=y CONFIG_ARM_ATAG_DTB_COMPAT=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_IDLE=y CONFIG_CPU_IDLE=y
CONFIG_ARM_KIRKWOOD_CPUIDLE=y CONFIG_ARM_KIRKWOOD_CPUIDLE=y
......
...@@ -97,7 +97,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0 ...@@ -97,7 +97,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_CMDLINE="root=/dev/ram0 ro" CONFIG_CMDLINE="root=/dev/ram0 ro"
CONFIG_KEXEC=y CONFIG_KEXEC=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m CONFIG_CPU_FREQ_GOV_USERSPACE=m
......
...@@ -38,7 +38,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0 ...@@ -38,7 +38,7 @@ CONFIG_ZBOOT_ROM_BSS=0x0
CONFIG_ARM_APPENDED_DTB=y CONFIG_ARM_APPENDED_DTB=y
CONFIG_KEXEC=y CONFIG_KEXEC=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y CONFIG_CPU_FREQ_GOV_ONDEMAND=y
......
...@@ -130,17 +130,16 @@ static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name, ...@@ -130,17 +130,16 @@ static int __init omap2_set_init_voltage(char *vdd_name, char *clk_name,
freq = clk_get_rate(clk); freq = clk_get_rate(clk);
clk_put(clk); clk_put(clk);
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(dev, &freq); opp = dev_pm_opp_find_freq_ceil(dev, &freq);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
pr_err("%s: unable to find boot up OPP for vdd_%s\n", pr_err("%s: unable to find boot up OPP for vdd_%s\n",
__func__, vdd_name); __func__, vdd_name);
goto exit; goto exit;
} }
bootup_volt = dev_pm_opp_get_voltage(opp); bootup_volt = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
if (!bootup_volt) { if (!bootup_volt) {
pr_err("%s: unable to find voltage corresponding to the bootup OPP for vdd_%s\n", pr_err("%s: unable to find voltage corresponding to the bootup OPP for vdd_%s\n",
__func__, vdd_name); __func__, vdd_name);
......
...@@ -1703,6 +1703,8 @@ config CPU_BMIPS ...@@ -1703,6 +1703,8 @@ config CPU_BMIPS
select WEAK_ORDERING select WEAK_ORDERING
select CPU_SUPPORTS_HIGHMEM select CPU_SUPPORTS_HIGHMEM
select CPU_HAS_PREFETCH select CPU_HAS_PREFETCH
select CPU_SUPPORTS_CPUFREQ
select MIPS_EXTERNAL_TIMER
help help
Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors. Support for BMIPS32/3300/4350/4380 and BMIPS5000 processors.
......
...@@ -9,13 +9,20 @@ CONFIG_MIPS_O32_FP64_SUPPORT=y ...@@ -9,13 +9,20 @@ CONFIG_MIPS_O32_FP64_SUPPORT=y
# CONFIG_SWAP is not set # CONFIG_SWAP is not set
CONFIG_NO_HZ=y CONFIG_NO_HZ=y
CONFIG_BLK_DEV_INITRD=y CONFIG_BLK_DEV_INITRD=y
CONFIG_RD_GZIP=y
CONFIG_EXPERT=y CONFIG_EXPERT=y
# CONFIG_VM_EVENT_COUNTERS is not set # CONFIG_VM_EVENT_COUNTERS is not set
# CONFIG_SLUB_DEBUG is not set # CONFIG_SLUB_DEBUG is not set
# CONFIG_BLK_DEV_BSG is not set # CONFIG_BLK_DEV_BSG is not set
# CONFIG_IOSCHED_DEADLINE is not set # CONFIG_IOSCHED_DEADLINE is not set
# CONFIG_IOSCHED_CFQ is not set # CONFIG_IOSCHED_CFQ is not set
CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
CONFIG_BMIPS_CPUFREQ=y
CONFIG_NET=y CONFIG_NET=y
CONFIG_PACKET=y CONFIG_PACKET=y
CONFIG_PACKET_DIAG=y CONFIG_PACKET_DIAG=y
...@@ -24,7 +31,6 @@ CONFIG_INET=y ...@@ -24,7 +31,6 @@ CONFIG_INET=y
# CONFIG_INET_XFRM_MODE_TRANSPORT is not set # CONFIG_INET_XFRM_MODE_TRANSPORT is not set
# CONFIG_INET_XFRM_MODE_TUNNEL is not set # CONFIG_INET_XFRM_MODE_TUNNEL is not set
# CONFIG_INET_XFRM_MODE_BEET is not set # CONFIG_INET_XFRM_MODE_BEET is not set
# CONFIG_INET_LRO is not set
# CONFIG_INET_DIAG is not set # CONFIG_INET_DIAG is not set
CONFIG_CFG80211=y CONFIG_CFG80211=y
CONFIG_NL80211_TESTMODE=y CONFIG_NL80211_TESTMODE=y
...@@ -34,8 +40,6 @@ CONFIG_DEVTMPFS=y ...@@ -34,8 +40,6 @@ CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y CONFIG_DEVTMPFS_MOUNT=y
# CONFIG_STANDALONE is not set # CONFIG_STANDALONE is not set
# CONFIG_PREVENT_FIRMWARE_BUILD is not set # CONFIG_PREVENT_FIRMWARE_BUILD is not set
CONFIG_PRINTK_TIME=y
CONFIG_BRCMSTB_GISB_ARB=y
CONFIG_MTD=y CONFIG_MTD=y
CONFIG_MTD_CFI=y CONFIG_MTD_CFI=y
CONFIG_MTD_CFI_INTELEXT=y CONFIG_MTD_CFI_INTELEXT=y
...@@ -51,16 +55,15 @@ CONFIG_USB_USBNET=y ...@@ -51,16 +55,15 @@ CONFIG_USB_USBNET=y
# CONFIG_INPUT is not set # CONFIG_INPUT is not set
# CONFIG_SERIO is not set # CONFIG_SERIO is not set
# CONFIG_VT is not set # CONFIG_VT is not set
# CONFIG_DEVKMEM is not set
CONFIG_SERIAL_8250=y CONFIG_SERIAL_8250=y
# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set # CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_CONSOLE=y
CONFIG_SERIAL_OF_PLATFORM=y CONFIG_SERIAL_OF_PLATFORM=y
# CONFIG_HW_RANDOM is not set # CONFIG_HW_RANDOM is not set
CONFIG_POWER_SUPPLY=y
CONFIG_POWER_RESET=y CONFIG_POWER_RESET=y
CONFIG_POWER_RESET_BRCMSTB=y CONFIG_POWER_RESET_BRCMSTB=y
CONFIG_POWER_RESET_SYSCON=y CONFIG_POWER_RESET_SYSCON=y
CONFIG_POWER_SUPPLY=y
# CONFIG_HWMON is not set # CONFIG_HWMON is not set
CONFIG_USB=y CONFIG_USB=y
CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_HCD=y
...@@ -82,6 +85,7 @@ CONFIG_CIFS=y ...@@ -82,6 +85,7 @@ CONFIG_CIFS=y
CONFIG_NLS_CODEPAGE_437=y CONFIG_NLS_CODEPAGE_437=y
CONFIG_NLS_ASCII=y CONFIG_NLS_ASCII=y
CONFIG_NLS_ISO8859_1=y CONFIG_NLS_ISO8859_1=y
CONFIG_PRINTK_TIME=y
CONFIG_DEBUG_FS=y CONFIG_DEBUG_FS=y
CONFIG_MAGIC_SYSRQ=y CONFIG_MAGIC_SYSRQ=y
CONFIG_CMDLINE_BOOL=y CONFIG_CMDLINE_BOOL=y
......
...@@ -40,7 +40,6 @@ CONFIG_PM_STD_PARTITION="/dev/hda3" ...@@ -40,7 +40,6 @@ CONFIG_PM_STD_PARTITION="/dev/hda3"
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_DEBUG=y CONFIG_CPU_FREQ_DEBUG=y
CONFIG_CPU_FREQ_STAT=m CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m CONFIG_CPU_FREQ_GOV_POWERSAVE=m
CONFIG_CPU_FREQ_GOV_USERSPACE=m CONFIG_CPU_FREQ_GOV_USERSPACE=m
......
...@@ -62,7 +62,6 @@ CONFIG_MPC8610_HPCD=y ...@@ -62,7 +62,6 @@ CONFIG_MPC8610_HPCD=y
CONFIG_GEF_SBC610=y CONFIG_GEF_SBC610=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT=m CONFIG_CPU_FREQ_STAT=m
CONFIG_CPU_FREQ_STAT_DETAILS=y
CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=m CONFIG_CPU_FREQ_GOV_POWERSAVE=m
......
...@@ -25,7 +25,7 @@ CONFIG_SH_SH7785LCR=y ...@@ -25,7 +25,7 @@ CONFIG_SH_SH7785LCR=y
CONFIG_NO_HZ=y CONFIG_NO_HZ=y
CONFIG_HIGH_RES_TIMERS=y CONFIG_HIGH_RES_TIMERS=y
CONFIG_CPU_FREQ=y CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_STAT_DETAILS=y CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
CONFIG_SH_CPU_FREQ=y CONFIG_SH_CPU_FREQ=y
CONFIG_HEARTBEAT=y CONFIG_HEARTBEAT=y
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <acpi/processor.h> #include <acpi/processor.h>
#include <asm/acpi.h>
#include <asm/mwait.h> #include <asm/mwait.h>
#include <asm/special_insns.h> #include <asm/special_insns.h>
...@@ -89,7 +88,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) ...@@ -89,7 +88,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
retval = 0; retval = 0;
/* If the HW does not support any sub-states in this C-state */ /* If the HW does not support any sub-states in this C-state */
if (num_cstate_subtype == 0) { if (num_cstate_subtype == 0) {
pr_warn(FW_BUG "ACPI MWAIT C-state 0x%x not supported by HW (0x%x)\n", cx->address, edx_part); pr_warn(FW_BUG "ACPI MWAIT C-state 0x%x not supported by HW (0x%x)\n",
cx->address, edx_part);
retval = -1; retval = -1;
goto out; goto out;
} }
...@@ -104,8 +104,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx) ...@@ -104,8 +104,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
if (!mwait_supported[cstate_type]) { if (!mwait_supported[cstate_type]) {
mwait_supported[cstate_type] = 1; mwait_supported[cstate_type] = 1;
printk(KERN_DEBUG printk(KERN_DEBUG
"Monitor-Mwait will be used to enter C-%d " "Monitor-Mwait will be used to enter C-%d state\n",
"state\n", cx->type); cx->type);
} }
snprintf(cx->desc, snprintf(cx->desc,
ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x", ACPI_CX_DESC_LEN, "ACPI FFH INTEL MWAIT 0x%x",
...@@ -166,6 +166,7 @@ EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter); ...@@ -166,6 +166,7 @@ EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_enter);
static int __init ffh_cstate_init(void) static int __init ffh_cstate_init(void)
{ {
struct cpuinfo_x86 *c = &boot_cpu_data; struct cpuinfo_x86 *c = &boot_cpu_data;
if (c->x86_vendor != X86_VENDOR_INTEL) if (c->x86_vendor != X86_VENDOR_INTEL)
return -1; return -1;
......
...@@ -75,10 +75,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb, ...@@ -75,10 +75,8 @@ static int acpi_processor_ppc_notifier(struct notifier_block *nb,
struct acpi_processor *pr; struct acpi_processor *pr;
unsigned int ppc = 0; unsigned int ppc = 0;
if (event == CPUFREQ_START && ignore_ppc <= 0) { if (ignore_ppc < 0)
ignore_ppc = 0; ignore_ppc = 0;
return 0;
}
if (ignore_ppc) if (ignore_ppc)
return 0; return 0;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/cpufeature.h> #include <linux/cpufeature.h>
#include <linux/tick.h> #include <linux/tick.h>
#include <linux/pm_qos.h>
#include "base.h" #include "base.h"
...@@ -376,6 +377,7 @@ int register_cpu(struct cpu *cpu, int num) ...@@ -376,6 +377,7 @@ int register_cpu(struct cpu *cpu, int num)
per_cpu(cpu_sys_devices, num) = &cpu->dev; per_cpu(cpu_sys_devices, num) = &cpu->dev;
register_cpu_under_node(num, cpu_to_node(num)); register_cpu_under_node(num, cpu_to_node(num));
dev_pm_qos_expose_latency_limit(&cpu->dev, 0);
return 0; return 0;
} }
......
...@@ -130,7 +130,7 @@ static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev, ...@@ -130,7 +130,7 @@ static inline bool irq_safe_dev_in_no_sleep_domain(struct device *dev,
ret = pm_runtime_is_irq_safe(dev) && !genpd_is_irq_safe(genpd); ret = pm_runtime_is_irq_safe(dev) && !genpd_is_irq_safe(genpd);
/* Warn once for each IRQ safe dev in no sleep domain */ /* Warn once if IRQ safe dev in no sleep domain */
if (ret) if (ret)
dev_warn_once(dev, "PM domain %s will not be powered off\n", dev_warn_once(dev, "PM domain %s will not be powered off\n",
genpd->name); genpd->name);
...@@ -201,7 +201,7 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd) ...@@ -201,7 +201,7 @@ static void genpd_sd_counter_inc(struct generic_pm_domain *genpd)
smp_mb__after_atomic(); smp_mb__after_atomic();
} }
static int genpd_power_on(struct generic_pm_domain *genpd, bool timed) static int _genpd_power_on(struct generic_pm_domain *genpd, bool timed)
{ {
unsigned int state_idx = genpd->state_idx; unsigned int state_idx = genpd->state_idx;
ktime_t time_start; ktime_t time_start;
...@@ -231,7 +231,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, bool timed) ...@@ -231,7 +231,7 @@ static int genpd_power_on(struct generic_pm_domain *genpd, bool timed)
return ret; return ret;
} }
static int genpd_power_off(struct generic_pm_domain *genpd, bool timed) static int _genpd_power_off(struct generic_pm_domain *genpd, bool timed)
{ {
unsigned int state_idx = genpd->state_idx; unsigned int state_idx = genpd->state_idx;
ktime_t time_start; ktime_t time_start;
...@@ -262,10 +262,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed) ...@@ -262,10 +262,10 @@ static int genpd_power_off(struct generic_pm_domain *genpd, bool timed)
} }
/** /**
* genpd_queue_power_off_work - Queue up the execution of genpd_poweroff(). * genpd_queue_power_off_work - Queue up the execution of genpd_power_off().
* @genpd: PM domain to power off. * @genpd: PM domain to power off.
* *
* Queue up the execution of genpd_poweroff() unless it's already been done * Queue up the execution of genpd_power_off() unless it's already been done
* before. * before.
*/ */
static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
...@@ -274,14 +274,14 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd) ...@@ -274,14 +274,14 @@ static void genpd_queue_power_off_work(struct generic_pm_domain *genpd)
} }
/** /**
* genpd_poweron - Restore power to a given PM domain and its masters. * genpd_power_on - Restore power to a given PM domain and its masters.
* @genpd: PM domain to power up. * @genpd: PM domain to power up.
* @depth: nesting count for lockdep. * @depth: nesting count for lockdep.
* *
* Restore power to @genpd and all of its masters so that it is possible to * Restore power to @genpd and all of its masters so that it is possible to
* resume a device belonging to it. * resume a device belonging to it.
*/ */
static int genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth) static int genpd_power_on(struct generic_pm_domain *genpd, unsigned int depth)
{ {
struct gpd_link *link; struct gpd_link *link;
int ret = 0; int ret = 0;
...@@ -300,7 +300,7 @@ static int genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth) ...@@ -300,7 +300,7 @@ static int genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth)
genpd_sd_counter_inc(master); genpd_sd_counter_inc(master);
genpd_lock_nested(master, depth + 1); genpd_lock_nested(master, depth + 1);
ret = genpd_poweron(master, depth + 1); ret = genpd_power_on(master, depth + 1);
genpd_unlock(master); genpd_unlock(master);
if (ret) { if (ret) {
...@@ -309,7 +309,7 @@ static int genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth) ...@@ -309,7 +309,7 @@ static int genpd_poweron(struct generic_pm_domain *genpd, unsigned int depth)
} }
} }
ret = genpd_power_on(genpd, true); ret = _genpd_power_on(genpd, true);
if (ret) if (ret)
goto err; goto err;
...@@ -368,14 +368,14 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb, ...@@ -368,14 +368,14 @@ static int genpd_dev_pm_qos_notifier(struct notifier_block *nb,
} }
/** /**
* genpd_poweroff - Remove power from a given PM domain. * genpd_power_off - Remove power from a given PM domain.
* @genpd: PM domain to power down. * @genpd: PM domain to power down.
* @is_async: PM domain is powered down from a scheduled work * @is_async: PM domain is powered down from a scheduled work
* *
* If all of the @genpd's devices have been suspended and all of its subdomains * If all of the @genpd's devices have been suspended and all of its subdomains
* have been powered down, remove power from @genpd. * have been powered down, remove power from @genpd.
*/ */
static int genpd_poweroff(struct generic_pm_domain *genpd, bool is_async) static int genpd_power_off(struct generic_pm_domain *genpd, bool is_async)
{ {
struct pm_domain_data *pdd; struct pm_domain_data *pdd;
struct gpd_link *link; struct gpd_link *link;
...@@ -427,13 +427,13 @@ static int genpd_poweroff(struct generic_pm_domain *genpd, bool is_async) ...@@ -427,13 +427,13 @@ static int genpd_poweroff(struct generic_pm_domain *genpd, bool is_async)
/* /*
* If sd_count > 0 at this point, one of the subdomains hasn't * If sd_count > 0 at this point, one of the subdomains hasn't
* managed to call genpd_poweron() for the master yet after * managed to call genpd_power_on() for the master yet after
* incrementing it. In that case genpd_poweron() will wait * incrementing it. In that case genpd_power_on() will wait
* for us to drop the lock, so we can call .power_off() and let * for us to drop the lock, so we can call .power_off() and let
* the genpd_poweron() restore power for us (this shouldn't * the genpd_power_on() restore power for us (this shouldn't
* happen very often). * happen very often).
*/ */
ret = genpd_power_off(genpd, true); ret = _genpd_power_off(genpd, true);
if (ret) if (ret)
return ret; return ret;
} }
...@@ -459,7 +459,7 @@ static void genpd_power_off_work_fn(struct work_struct *work) ...@@ -459,7 +459,7 @@ static void genpd_power_off_work_fn(struct work_struct *work)
genpd = container_of(work, struct generic_pm_domain, power_off_work); genpd = container_of(work, struct generic_pm_domain, power_off_work);
genpd_lock(genpd); genpd_lock(genpd);
genpd_poweroff(genpd, true); genpd_power_off(genpd, true);
genpd_unlock(genpd); genpd_unlock(genpd);
} }
...@@ -578,7 +578,7 @@ static int genpd_runtime_suspend(struct device *dev) ...@@ -578,7 +578,7 @@ static int genpd_runtime_suspend(struct device *dev)
return 0; return 0;
genpd_lock(genpd); genpd_lock(genpd);
genpd_poweroff(genpd, false); genpd_power_off(genpd, false);
genpd_unlock(genpd); genpd_unlock(genpd);
return 0; return 0;
...@@ -618,7 +618,7 @@ static int genpd_runtime_resume(struct device *dev) ...@@ -618,7 +618,7 @@ static int genpd_runtime_resume(struct device *dev)
} }
genpd_lock(genpd); genpd_lock(genpd);
ret = genpd_poweron(genpd, 0); ret = genpd_power_on(genpd, 0);
genpd_unlock(genpd); genpd_unlock(genpd);
if (ret) if (ret)
...@@ -658,7 +658,7 @@ static int genpd_runtime_resume(struct device *dev) ...@@ -658,7 +658,7 @@ static int genpd_runtime_resume(struct device *dev)
if (!pm_runtime_is_irq_safe(dev) || if (!pm_runtime_is_irq_safe(dev) ||
(pm_runtime_is_irq_safe(dev) && genpd_is_irq_safe(genpd))) { (pm_runtime_is_irq_safe(dev) && genpd_is_irq_safe(genpd))) {
genpd_lock(genpd); genpd_lock(genpd);
genpd_poweroff(genpd, 0); genpd_power_off(genpd, 0);
genpd_unlock(genpd); genpd_unlock(genpd);
} }
...@@ -674,9 +674,9 @@ static int __init pd_ignore_unused_setup(char *__unused) ...@@ -674,9 +674,9 @@ static int __init pd_ignore_unused_setup(char *__unused)
__setup("pd_ignore_unused", pd_ignore_unused_setup); __setup("pd_ignore_unused", pd_ignore_unused_setup);
/** /**
* genpd_poweroff_unused - Power off all PM domains with no devices in use. * genpd_power_off_unused - Power off all PM domains with no devices in use.
*/ */
static int __init genpd_poweroff_unused(void) static int __init genpd_power_off_unused(void)
{ {
struct generic_pm_domain *genpd; struct generic_pm_domain *genpd;
...@@ -694,7 +694,7 @@ static int __init genpd_poweroff_unused(void) ...@@ -694,7 +694,7 @@ static int __init genpd_poweroff_unused(void)
return 0; return 0;
} }
late_initcall(genpd_poweroff_unused); late_initcall(genpd_power_off_unused);
#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF) #if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_GENERIC_DOMAINS_OF)
...@@ -727,18 +727,20 @@ static bool genpd_dev_active_wakeup(struct generic_pm_domain *genpd, ...@@ -727,18 +727,20 @@ static bool genpd_dev_active_wakeup(struct generic_pm_domain *genpd,
} }
/** /**
* genpd_sync_poweroff - Synchronously power off a PM domain and its masters. * genpd_sync_power_off - Synchronously power off a PM domain and its masters.
* @genpd: PM domain to power off, if possible. * @genpd: PM domain to power off, if possible.
* @use_lock: use the lock.
* @depth: nesting count for lockdep.
* *
* Check if the given PM domain can be powered off (during system suspend or * Check if the given PM domain can be powered off (during system suspend or
* hibernation) and do that if so. Also, in that case propagate to its masters. * hibernation) and do that if so. Also, in that case propagate to its masters.
* *
* This function is only called in "noirq" and "syscore" stages of system power * This function is only called in "noirq" and "syscore" stages of system power
* transitions, so it need not acquire locks (all of the "noirq" callbacks are * transitions. The "noirq" callbacks may be executed asynchronously, thus in
* executed sequentially, so it is guaranteed that it will never run twice in * these cases the lock must be held.
* parallel).
*/ */
static void genpd_sync_poweroff(struct generic_pm_domain *genpd) static void genpd_sync_power_off(struct generic_pm_domain *genpd, bool use_lock,
unsigned int depth)
{ {
struct gpd_link *link; struct gpd_link *link;
...@@ -751,26 +753,35 @@ static void genpd_sync_poweroff(struct generic_pm_domain *genpd) ...@@ -751,26 +753,35 @@ static void genpd_sync_poweroff(struct generic_pm_domain *genpd)
/* Choose the deepest state when suspending */ /* Choose the deepest state when suspending */
genpd->state_idx = genpd->state_count - 1; genpd->state_idx = genpd->state_count - 1;
genpd_power_off(genpd, false); _genpd_power_off(genpd, false);
genpd->status = GPD_STATE_POWER_OFF; genpd->status = GPD_STATE_POWER_OFF;
list_for_each_entry(link, &genpd->slave_links, slave_node) { list_for_each_entry(link, &genpd->slave_links, slave_node) {
genpd_sd_counter_dec(link->master); genpd_sd_counter_dec(link->master);
genpd_sync_poweroff(link->master);
if (use_lock)
genpd_lock_nested(link->master, depth + 1);
genpd_sync_power_off(link->master, use_lock, depth + 1);
if (use_lock)
genpd_unlock(link->master);
} }
} }
/** /**
* genpd_sync_poweron - Synchronously power on a PM domain and its masters. * genpd_sync_power_on - Synchronously power on a PM domain and its masters.
* @genpd: PM domain to power on. * @genpd: PM domain to power on.
* @use_lock: use the lock.
* @depth: nesting count for lockdep.
* *
* This function is only called in "noirq" and "syscore" stages of system power * This function is only called in "noirq" and "syscore" stages of system power
* transitions, so it need not acquire locks (all of the "noirq" callbacks are * transitions. The "noirq" callbacks may be executed asynchronously, thus in
* executed sequentially, so it is guaranteed that it will never run twice in * these cases the lock must be held.
* parallel).
*/ */
static void genpd_sync_poweron(struct generic_pm_domain *genpd) static void genpd_sync_power_on(struct generic_pm_domain *genpd, bool use_lock,
unsigned int depth)
{ {
struct gpd_link *link; struct gpd_link *link;
...@@ -778,11 +789,18 @@ static void genpd_sync_poweron(struct generic_pm_domain *genpd) ...@@ -778,11 +789,18 @@ static void genpd_sync_poweron(struct generic_pm_domain *genpd)
return; return;
list_for_each_entry(link, &genpd->slave_links, slave_node) { list_for_each_entry(link, &genpd->slave_links, slave_node) {
genpd_sync_poweron(link->master);
genpd_sd_counter_inc(link->master); genpd_sd_counter_inc(link->master);
if (use_lock)
genpd_lock_nested(link->master, depth + 1);
genpd_sync_power_on(link->master, use_lock, depth + 1);
if (use_lock)
genpd_unlock(link->master);
} }
genpd_power_on(genpd, false); _genpd_power_on(genpd, false);
genpd->status = GPD_STATE_ACTIVE; genpd->status = GPD_STATE_ACTIVE;
} }
...@@ -888,13 +906,10 @@ static int pm_genpd_suspend_noirq(struct device *dev) ...@@ -888,13 +906,10 @@ static int pm_genpd_suspend_noirq(struct device *dev)
return ret; return ret;
} }
/* genpd_lock(genpd);
* Since all of the "noirq" callbacks are executed sequentially, it is
* guaranteed that this function will never run twice in parallel for
* the same PM domain, so it is not necessary to use locking here.
*/
genpd->suspended_count++; genpd->suspended_count++;
genpd_sync_poweroff(genpd); genpd_sync_power_off(genpd, true, 0);
genpd_unlock(genpd);
return 0; return 0;
} }
...@@ -919,13 +934,10 @@ static int pm_genpd_resume_noirq(struct device *dev) ...@@ -919,13 +934,10 @@ static int pm_genpd_resume_noirq(struct device *dev)
if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev)) if (dev->power.wakeup_path && genpd_dev_active_wakeup(genpd, dev))
return 0; return 0;
/* genpd_lock(genpd);
* Since all of the "noirq" callbacks are executed sequentially, it is genpd_sync_power_on(genpd, true, 0);
* guaranteed that this function will never run twice in parallel for
* the same PM domain, so it is not necessary to use locking here.
*/
genpd_sync_poweron(genpd);
genpd->suspended_count--; genpd->suspended_count--;
genpd_unlock(genpd);
if (genpd->dev_ops.stop && genpd->dev_ops.start) if (genpd->dev_ops.stop && genpd->dev_ops.start)
ret = pm_runtime_force_resume(dev); ret = pm_runtime_force_resume(dev);
...@@ -1002,22 +1014,20 @@ static int pm_genpd_restore_noirq(struct device *dev) ...@@ -1002,22 +1014,20 @@ static int pm_genpd_restore_noirq(struct device *dev)
return -EINVAL; return -EINVAL;
/* /*
* Since all of the "noirq" callbacks are executed sequentially, it is
* guaranteed that this function will never run twice in parallel for
* the same PM domain, so it is not necessary to use locking here.
*
* At this point suspended_count == 0 means we are being run for the * At this point suspended_count == 0 means we are being run for the
* first time for the given domain in the present cycle. * first time for the given domain in the present cycle.
*/ */
genpd_lock(genpd);
if (genpd->suspended_count++ == 0) if (genpd->suspended_count++ == 0)
/* /*
* The boot kernel might put the domain into arbitrary state, * The boot kernel might put the domain into arbitrary state,
* so make it appear as powered off to genpd_sync_poweron(), * so make it appear as powered off to genpd_sync_power_on(),
* so that it tries to power it on in case it was really off. * so that it tries to power it on in case it was really off.
*/ */
genpd->status = GPD_STATE_POWER_OFF; genpd->status = GPD_STATE_POWER_OFF;
genpd_sync_poweron(genpd); genpd_sync_power_on(genpd, true, 0);
genpd_unlock(genpd);
if (genpd->dev_ops.stop && genpd->dev_ops.start) if (genpd->dev_ops.stop && genpd->dev_ops.start)
ret = pm_runtime_force_resume(dev); ret = pm_runtime_force_resume(dev);
...@@ -1072,9 +1082,9 @@ static void genpd_syscore_switch(struct device *dev, bool suspend) ...@@ -1072,9 +1082,9 @@ static void genpd_syscore_switch(struct device *dev, bool suspend)
if (suspend) { if (suspend) {
genpd->suspended_count++; genpd->suspended_count++;
genpd_sync_poweroff(genpd); genpd_sync_power_off(genpd, false, 0);
} else { } else {
genpd_sync_poweron(genpd); genpd_sync_power_on(genpd, false, 0);
genpd->suspended_count--; genpd->suspended_count--;
} }
} }
...@@ -2043,7 +2053,7 @@ int genpd_dev_pm_attach(struct device *dev) ...@@ -2043,7 +2053,7 @@ int genpd_dev_pm_attach(struct device *dev)
dev->pm_domain->sync = genpd_dev_pm_sync; dev->pm_domain->sync = genpd_dev_pm_sync;
genpd_lock(pd); genpd_lock(pd);
ret = genpd_poweron(pd, 0); ret = genpd_power_on(pd, 0);
genpd_unlock(pd); genpd_unlock(pd);
out: out:
return ret ? -EPROBE_DEFER : 0; return ret ? -EPROBE_DEFER : 0;
......
此差异已折叠。
...@@ -42,11 +42,6 @@ ...@@ -42,11 +42,6 @@
* *
* WARNING: It is important for the callers to ensure refreshing their copy of * WARNING: It is important for the callers to ensure refreshing their copy of
* the table if any of the mentioned functions have been invoked in the interim. * the table if any of the mentioned functions have been invoked in the interim.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Since we just use the regular accessor functions to access the internal data
* structures, we use RCU read lock inside this function. As a result, users of
* this function DONOT need to use explicit locks for invoking.
*/ */
int dev_pm_opp_init_cpufreq_table(struct device *dev, int dev_pm_opp_init_cpufreq_table(struct device *dev,
struct cpufreq_frequency_table **table) struct cpufreq_frequency_table **table)
...@@ -56,19 +51,13 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, ...@@ -56,19 +51,13 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
int i, max_opps, ret = 0; int i, max_opps, ret = 0;
unsigned long rate; unsigned long rate;
rcu_read_lock();
max_opps = dev_pm_opp_get_opp_count(dev); max_opps = dev_pm_opp_get_opp_count(dev);
if (max_opps <= 0) { if (max_opps <= 0)
ret = max_opps ? max_opps : -ENODATA; return max_opps ? max_opps : -ENODATA;
goto out;
}
freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_ATOMIC); freq_table = kcalloc((max_opps + 1), sizeof(*freq_table), GFP_ATOMIC);
if (!freq_table) { if (!freq_table)
ret = -ENOMEM; return -ENOMEM;
goto out;
}
for (i = 0, rate = 0; i < max_opps; i++, rate++) { for (i = 0, rate = 0; i < max_opps; i++, rate++) {
/* find next rate */ /* find next rate */
...@@ -83,6 +72,8 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, ...@@ -83,6 +72,8 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
/* Is Boost/turbo opp ? */ /* Is Boost/turbo opp ? */
if (dev_pm_opp_is_turbo(opp)) if (dev_pm_opp_is_turbo(opp))
freq_table[i].flags = CPUFREQ_BOOST_FREQ; freq_table[i].flags = CPUFREQ_BOOST_FREQ;
dev_pm_opp_put(opp);
} }
freq_table[i].driver_data = i; freq_table[i].driver_data = i;
...@@ -91,7 +82,6 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev, ...@@ -91,7 +82,6 @@ int dev_pm_opp_init_cpufreq_table(struct device *dev,
*table = &freq_table[0]; *table = &freq_table[0];
out: out:
rcu_read_unlock();
if (ret) if (ret)
kfree(freq_table); kfree(freq_table);
...@@ -147,12 +137,6 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of) ...@@ -147,12 +137,6 @@ void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of)
* This removes the OPP tables for CPUs present in the @cpumask. * This removes the OPP tables for CPUs present in the @cpumask.
* This should be used to remove all the OPPs entries associated with * This should be used to remove all the OPPs entries associated with
* the cpus in @cpumask. * the cpus in @cpumask.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask) void dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask)
{ {
...@@ -169,12 +153,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table); ...@@ -169,12 +153,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_cpumask_remove_table);
* @cpumask. * @cpumask.
* *
* Returns -ENODEV if OPP table isn't already present. * Returns -ENODEV if OPP table isn't already present.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev,
const struct cpumask *cpumask) const struct cpumask *cpumask)
...@@ -184,13 +162,9 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, ...@@ -184,13 +162,9 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev,
struct device *dev; struct device *dev;
int cpu, ret = 0; int cpu, ret = 0;
mutex_lock(&opp_table_lock);
opp_table = _find_opp_table(cpu_dev); opp_table = _find_opp_table(cpu_dev);
if (IS_ERR(opp_table)) { if (IS_ERR(opp_table))
ret = PTR_ERR(opp_table); return PTR_ERR(opp_table);
goto unlock;
}
for_each_cpu(cpu, cpumask) { for_each_cpu(cpu, cpumask) {
if (cpu == cpu_dev->id) if (cpu == cpu_dev->id)
...@@ -213,8 +187,8 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev, ...@@ -213,8 +187,8 @@ int dev_pm_opp_set_sharing_cpus(struct device *cpu_dev,
/* Mark opp-table as multiple CPUs are sharing it now */ /* Mark opp-table as multiple CPUs are sharing it now */
opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED; opp_table->shared_opp = OPP_TABLE_ACCESS_SHARED;
} }
unlock:
mutex_unlock(&opp_table_lock); dev_pm_opp_put_opp_table(opp_table);
return ret; return ret;
} }
...@@ -229,12 +203,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus); ...@@ -229,12 +203,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_set_sharing_cpus);
* *
* Returns -ENODEV if OPP table isn't already present and -EINVAL if the OPP * Returns -ENODEV if OPP table isn't already present and -EINVAL if the OPP
* table's status is access-unknown. * table's status is access-unknown.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
{ {
...@@ -242,17 +210,13 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) ...@@ -242,17 +210,13 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
struct opp_table *opp_table; struct opp_table *opp_table;
int ret = 0; int ret = 0;
mutex_lock(&opp_table_lock);
opp_table = _find_opp_table(cpu_dev); opp_table = _find_opp_table(cpu_dev);
if (IS_ERR(opp_table)) { if (IS_ERR(opp_table))
ret = PTR_ERR(opp_table); return PTR_ERR(opp_table);
goto unlock;
}
if (opp_table->shared_opp == OPP_TABLE_ACCESS_UNKNOWN) { if (opp_table->shared_opp == OPP_TABLE_ACCESS_UNKNOWN) {
ret = -EINVAL; ret = -EINVAL;
goto unlock; goto put_opp_table;
} }
cpumask_clear(cpumask); cpumask_clear(cpumask);
...@@ -264,8 +228,8 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask) ...@@ -264,8 +228,8 @@ int dev_pm_opp_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask)
cpumask_set_cpu(cpu_dev->id, cpumask); cpumask_set_cpu(cpu_dev->id, cpumask);
} }
unlock: put_opp_table:
mutex_unlock(&opp_table_lock); dev_pm_opp_put_opp_table(opp_table);
return ret; return ret;
} }
......
...@@ -24,9 +24,11 @@ ...@@ -24,9 +24,11 @@
static struct opp_table *_managed_opp(const struct device_node *np) static struct opp_table *_managed_opp(const struct device_node *np)
{ {
struct opp_table *opp_table; struct opp_table *opp_table, *managed_table = NULL;
mutex_lock(&opp_table_lock);
list_for_each_entry_rcu(opp_table, &opp_tables, node) { list_for_each_entry(opp_table, &opp_tables, node) {
if (opp_table->np == np) { if (opp_table->np == np) {
/* /*
* Multiple devices can point to the same OPP table and * Multiple devices can point to the same OPP table and
...@@ -35,14 +37,18 @@ static struct opp_table *_managed_opp(const struct device_node *np) ...@@ -35,14 +37,18 @@ static struct opp_table *_managed_opp(const struct device_node *np)
* But the OPPs will be considered as shared only if the * But the OPPs will be considered as shared only if the
* OPP table contains a "opp-shared" property. * OPP table contains a "opp-shared" property.
*/ */
if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) if (opp_table->shared_opp == OPP_TABLE_ACCESS_SHARED) {
return opp_table; _get_opp_table_kref(opp_table);
managed_table = opp_table;
}
return NULL; break;
} }
} }
return NULL; mutex_unlock(&opp_table_lock);
return managed_table;
} }
void _of_init_opp_table(struct opp_table *opp_table, struct device *dev) void _of_init_opp_table(struct opp_table *opp_table, struct device *dev)
...@@ -229,34 +235,28 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev, ...@@ -229,34 +235,28 @@ static int opp_parse_supplies(struct dev_pm_opp *opp, struct device *dev,
* @dev: device pointer used to lookup OPP table. * @dev: device pointer used to lookup OPP table.
* *
* Free OPPs created using static entries present in DT. * Free OPPs created using static entries present in DT.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function indirectly uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
void dev_pm_opp_of_remove_table(struct device *dev) void dev_pm_opp_of_remove_table(struct device *dev)
{ {
_dev_pm_opp_remove_table(dev, false); _dev_pm_opp_find_and_remove_table(dev, false);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table); EXPORT_SYMBOL_GPL(dev_pm_opp_of_remove_table);
/* Returns opp descriptor node for a device, caller must do of_node_put() */ /* Returns opp descriptor node for a device, caller must do of_node_put() */
static struct device_node *_of_get_opp_desc_node(struct device *dev) struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev)
{ {
/* /*
* TODO: Support for multiple OPP tables.
*
* There should be only ONE phandle present in "operating-points-v2" * There should be only ONE phandle present in "operating-points-v2"
* property. * property.
*/ */
return of_parse_phandle(dev->of_node, "operating-points-v2", 0); return of_parse_phandle(dev->of_node, "operating-points-v2", 0);
} }
EXPORT_SYMBOL_GPL(dev_pm_opp_of_get_opp_desc_node);
/** /**
* _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings) * _opp_add_static_v2() - Allocate static OPPs (As per 'v2' DT bindings)
* @opp_table: OPP table
* @dev: device for which we do this operation * @dev: device for which we do this operation
* @np: device node * @np: device node
* *
...@@ -264,12 +264,6 @@ static struct device_node *_of_get_opp_desc_node(struct device *dev) ...@@ -264,12 +264,6 @@ static struct device_node *_of_get_opp_desc_node(struct device *dev)
* opp can be controlled using dev_pm_opp_enable/disable functions and may be * opp can be controlled using dev_pm_opp_enable/disable functions and may be
* removed by dev_pm_opp_remove. * removed by dev_pm_opp_remove.
* *
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*
* Return: * Return:
* 0 On success OR * 0 On success OR
* Duplicate OPPs (both freq and volt are same) and opp->available * Duplicate OPPs (both freq and volt are same) and opp->available
...@@ -278,22 +272,17 @@ static struct device_node *_of_get_opp_desc_node(struct device *dev) ...@@ -278,22 +272,17 @@ static struct device_node *_of_get_opp_desc_node(struct device *dev)
* -ENOMEM Memory allocation failure * -ENOMEM Memory allocation failure
* -EINVAL Failed parsing the OPP node * -EINVAL Failed parsing the OPP node
*/ */
static int _opp_add_static_v2(struct device *dev, struct device_node *np) static int _opp_add_static_v2(struct opp_table *opp_table, struct device *dev,
struct device_node *np)
{ {
struct opp_table *opp_table;
struct dev_pm_opp *new_opp; struct dev_pm_opp *new_opp;
u64 rate; u64 rate;
u32 val; u32 val;
int ret; int ret;
/* Hold our table modification lock here */ new_opp = _opp_allocate(opp_table);
mutex_lock(&opp_table_lock); if (!new_opp)
return -ENOMEM;
new_opp = _allocate_opp(dev, &opp_table);
if (!new_opp) {
ret = -ENOMEM;
goto unlock;
}
ret = of_property_read_u64(np, "opp-hz", &rate); ret = of_property_read_u64(np, "opp-hz", &rate);
if (ret < 0) { if (ret < 0) {
...@@ -327,8 +316,12 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) ...@@ -327,8 +316,12 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np)
goto free_opp; goto free_opp;
ret = _opp_add(dev, new_opp, opp_table); ret = _opp_add(dev, new_opp, opp_table);
if (ret) if (ret) {
/* Don't return error for duplicate OPPs */
if (ret == -EBUSY)
ret = 0;
goto free_opp; goto free_opp;
}
/* OPP to select on device suspend */ /* OPP to select on device suspend */
if (of_property_read_bool(np, "opp-suspend")) { if (of_property_read_bool(np, "opp-suspend")) {
...@@ -345,8 +338,6 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) ...@@ -345,8 +338,6 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np)
if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max) if (new_opp->clock_latency_ns > opp_table->clock_latency_ns_max)
opp_table->clock_latency_ns_max = new_opp->clock_latency_ns; opp_table->clock_latency_ns_max = new_opp->clock_latency_ns;
mutex_unlock(&opp_table_lock);
pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu\n", pr_debug("%s: turbo:%d rate:%lu uv:%lu uvmin:%lu uvmax:%lu latency:%lu\n",
__func__, new_opp->turbo, new_opp->rate, __func__, new_opp->turbo, new_opp->rate,
new_opp->supplies[0].u_volt, new_opp->supplies[0].u_volt_min, new_opp->supplies[0].u_volt, new_opp->supplies[0].u_volt_min,
...@@ -356,13 +347,12 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np) ...@@ -356,13 +347,12 @@ static int _opp_add_static_v2(struct device *dev, struct device_node *np)
* Notify the changes in the availability of the operable * Notify the changes in the availability of the operable
* frequency/voltage list. * frequency/voltage list.
*/ */
srcu_notifier_call_chain(&opp_table->srcu_head, OPP_EVENT_ADD, new_opp); blocking_notifier_call_chain(&opp_table->head, OPP_EVENT_ADD, new_opp);
return 0; return 0;
free_opp: free_opp:
_opp_remove(opp_table, new_opp, false); _opp_free(new_opp);
unlock:
mutex_unlock(&opp_table_lock);
return ret; return ret;
} }
...@@ -373,41 +363,35 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) ...@@ -373,41 +363,35 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
struct opp_table *opp_table; struct opp_table *opp_table;
int ret = 0, count = 0; int ret = 0, count = 0;
mutex_lock(&opp_table_lock);
opp_table = _managed_opp(opp_np); opp_table = _managed_opp(opp_np);
if (opp_table) { if (opp_table) {
/* OPPs are already managed */ /* OPPs are already managed */
if (!_add_opp_dev(dev, opp_table)) if (!_add_opp_dev(dev, opp_table))
ret = -ENOMEM; ret = -ENOMEM;
mutex_unlock(&opp_table_lock); goto put_opp_table;
return ret;
} }
mutex_unlock(&opp_table_lock);
opp_table = dev_pm_opp_get_opp_table(dev);
if (!opp_table)
return -ENOMEM;
/* We have opp-table node now, iterate over it and add OPPs */ /* We have opp-table node now, iterate over it and add OPPs */
for_each_available_child_of_node(opp_np, np) { for_each_available_child_of_node(opp_np, np) {
count++; count++;
ret = _opp_add_static_v2(dev, np); ret = _opp_add_static_v2(opp_table, dev, np);
if (ret) { if (ret) {
dev_err(dev, "%s: Failed to add OPP, %d\n", __func__, dev_err(dev, "%s: Failed to add OPP, %d\n", __func__,
ret); ret);
goto free_table; _dev_pm_opp_remove_table(opp_table, dev, false);
goto put_opp_table;
} }
} }
/* There should be one of more OPP defined */ /* There should be one of more OPP defined */
if (WARN_ON(!count)) if (WARN_ON(!count)) {
return -ENOENT; ret = -ENOENT;
goto put_opp_table;
mutex_lock(&opp_table_lock);
opp_table = _find_opp_table(dev);
if (WARN_ON(IS_ERR(opp_table))) {
ret = PTR_ERR(opp_table);
mutex_unlock(&opp_table_lock);
goto free_table;
} }
opp_table->np = opp_np; opp_table->np = opp_np;
...@@ -416,12 +400,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) ...@@ -416,12 +400,8 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
else else
opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE; opp_table->shared_opp = OPP_TABLE_ACCESS_EXCLUSIVE;
mutex_unlock(&opp_table_lock); put_opp_table:
dev_pm_opp_put_opp_table(opp_table);
return 0;
free_table:
dev_pm_opp_of_remove_table(dev);
return ret; return ret;
} }
...@@ -429,9 +409,10 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np) ...@@ -429,9 +409,10 @@ static int _of_add_opp_table_v2(struct device *dev, struct device_node *opp_np)
/* Initializes OPP tables based on old-deprecated bindings */ /* Initializes OPP tables based on old-deprecated bindings */
static int _of_add_opp_table_v1(struct device *dev) static int _of_add_opp_table_v1(struct device *dev)
{ {
struct opp_table *opp_table;
const struct property *prop; const struct property *prop;
const __be32 *val; const __be32 *val;
int nr; int nr, ret = 0;
prop = of_find_property(dev->of_node, "operating-points", NULL); prop = of_find_property(dev->of_node, "operating-points", NULL);
if (!prop) if (!prop)
...@@ -449,18 +430,27 @@ static int _of_add_opp_table_v1(struct device *dev) ...@@ -449,18 +430,27 @@ static int _of_add_opp_table_v1(struct device *dev)
return -EINVAL; return -EINVAL;
} }
opp_table = dev_pm_opp_get_opp_table(dev);
if (!opp_table)
return -ENOMEM;
val = prop->value; val = prop->value;
while (nr) { while (nr) {
unsigned long freq = be32_to_cpup(val++) * 1000; unsigned long freq = be32_to_cpup(val++) * 1000;
unsigned long volt = be32_to_cpup(val++); unsigned long volt = be32_to_cpup(val++);
if (_opp_add_v1(dev, freq, volt, false)) ret = _opp_add_v1(opp_table, dev, freq, volt, false);
dev_warn(dev, "%s: Failed to add OPP %ld\n", if (ret) {
__func__, freq); dev_err(dev, "%s: Failed to add OPP %ld (%d)\n",
__func__, freq, ret);
_dev_pm_opp_remove_table(opp_table, dev, false);
break;
}
nr -= 2; nr -= 2;
} }
return 0; dev_pm_opp_put_opp_table(opp_table);
return ret;
} }
/** /**
...@@ -469,12 +459,6 @@ static int _of_add_opp_table_v1(struct device *dev) ...@@ -469,12 +459,6 @@ static int _of_add_opp_table_v1(struct device *dev)
* *
* Register the initial OPP table with the OPP library for given device. * Register the initial OPP table with the OPP library for given device.
* *
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function indirectly uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*
* Return: * Return:
* 0 On success OR * 0 On success OR
* Duplicate OPPs (both freq and volt are same) and opp->available * Duplicate OPPs (both freq and volt are same) and opp->available
...@@ -495,7 +479,7 @@ int dev_pm_opp_of_add_table(struct device *dev) ...@@ -495,7 +479,7 @@ int dev_pm_opp_of_add_table(struct device *dev)
* OPPs have two version of bindings now. The older one is deprecated, * OPPs have two version of bindings now. The older one is deprecated,
* try for the new binding first. * try for the new binding first.
*/ */
opp_np = _of_get_opp_desc_node(dev); opp_np = dev_pm_opp_of_get_opp_desc_node(dev);
if (!opp_np) { if (!opp_np) {
/* /*
* Try old-deprecated bindings for backward compatibility with * Try old-deprecated bindings for backward compatibility with
...@@ -519,12 +503,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table); ...@@ -519,12 +503,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table);
* *
* This removes the OPP tables for CPUs present in the @cpumask. * This removes the OPP tables for CPUs present in the @cpumask.
* This should be used only to remove static entries created from DT. * This should be used only to remove static entries created from DT.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask) void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask)
{ {
...@@ -537,12 +515,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table); ...@@ -537,12 +515,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_remove_table);
* @cpumask: cpumask for which OPP table needs to be added. * @cpumask: cpumask for which OPP table needs to be added.
* *
* This adds the OPP tables for CPUs present in the @cpumask. * This adds the OPP tables for CPUs present in the @cpumask.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask) int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask)
{ {
...@@ -590,12 +562,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table); ...@@ -590,12 +562,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
* This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev. * This updates the @cpumask with CPUs that are sharing OPPs with @cpu_dev.
* *
* Returns -ENOENT if operating-points-v2 isn't present for @cpu_dev. * Returns -ENOENT if operating-points-v2 isn't present for @cpu_dev.
*
* Locking: The internal opp_table and opp structures are RCU protected.
* Hence this function internally uses RCU updater strategy with mutex locks
* to keep the integrity of the internal data structures. Callers should ensure
* that this function is *NOT* called under RCU protection or in contexts where
* mutex cannot be locked.
*/ */
int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
struct cpumask *cpumask) struct cpumask *cpumask)
...@@ -605,7 +571,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, ...@@ -605,7 +571,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
int cpu, ret = 0; int cpu, ret = 0;
/* Get OPP descriptor node */ /* Get OPP descriptor node */
np = _of_get_opp_desc_node(cpu_dev); np = dev_pm_opp_of_get_opp_desc_node(cpu_dev);
if (!np) { if (!np) {
dev_dbg(cpu_dev, "%s: Couldn't find opp node.\n", __func__); dev_dbg(cpu_dev, "%s: Couldn't find opp node.\n", __func__);
return -ENOENT; return -ENOENT;
...@@ -630,7 +596,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, ...@@ -630,7 +596,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev,
} }
/* Get OPP descriptor node */ /* Get OPP descriptor node */
tmp_np = _of_get_opp_desc_node(tcpu_dev); tmp_np = dev_pm_opp_of_get_opp_desc_node(tcpu_dev);
if (!tmp_np) { if (!tmp_np) {
dev_err(tcpu_dev, "%s: Couldn't find opp node.\n", dev_err(tcpu_dev, "%s: Couldn't find opp node.\n",
__func__); __func__);
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
#include <linux/device.h> #include <linux/device.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kref.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/limits.h> #include <linux/limits.h>
#include <linux/pm_opp.h> #include <linux/pm_opp.h>
#include <linux/rculist.h> #include <linux/notifier.h>
#include <linux/rcupdate.h>
struct clk; struct clk;
struct regulator; struct regulator;
...@@ -51,11 +51,9 @@ extern struct list_head opp_tables; ...@@ -51,11 +51,9 @@ extern struct list_head opp_tables;
* @node: opp table node. The nodes are maintained throughout the lifetime * @node: opp table node. The nodes are maintained throughout the lifetime
* of boot. It is expected only an optimal set of OPPs are * of boot. It is expected only an optimal set of OPPs are
* added to the library by the SoC framework. * added to the library by the SoC framework.
* RCU usage: opp table is traversed with RCU locks. node
* modification is possible realtime, hence the modifications
* are protected by the opp_table_lock for integrity.
* IMPORTANT: the opp nodes should be maintained in increasing * IMPORTANT: the opp nodes should be maintained in increasing
* order. * order.
* @kref: for reference count of the OPP.
* @available: true/false - marks if this OPP as available or not * @available: true/false - marks if this OPP as available or not
* @dynamic: not-created from static DT entries. * @dynamic: not-created from static DT entries.
* @turbo: true if turbo (boost) OPP * @turbo: true if turbo (boost) OPP
...@@ -65,7 +63,6 @@ extern struct list_head opp_tables; ...@@ -65,7 +63,6 @@ extern struct list_head opp_tables;
* @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's
* frequency from any other OPP's frequency. * frequency from any other OPP's frequency.
* @opp_table: points back to the opp_table struct this opp belongs to * @opp_table: points back to the opp_table struct this opp belongs to
* @rcu_head: RCU callback head used for deferred freeing
* @np: OPP's device node. * @np: OPP's device node.
* @dentry: debugfs dentry pointer (per opp) * @dentry: debugfs dentry pointer (per opp)
* *
...@@ -73,6 +70,7 @@ extern struct list_head opp_tables; ...@@ -73,6 +70,7 @@ extern struct list_head opp_tables;
*/ */
struct dev_pm_opp { struct dev_pm_opp {
struct list_head node; struct list_head node;
struct kref kref;
bool available; bool available;
bool dynamic; bool dynamic;
...@@ -85,7 +83,6 @@ struct dev_pm_opp { ...@@ -85,7 +83,6 @@ struct dev_pm_opp {
unsigned long clock_latency_ns; unsigned long clock_latency_ns;
struct opp_table *opp_table; struct opp_table *opp_table;
struct rcu_head rcu_head;
struct device_node *np; struct device_node *np;
...@@ -98,7 +95,6 @@ struct dev_pm_opp { ...@@ -98,7 +95,6 @@ struct dev_pm_opp {
* struct opp_device - devices managed by 'struct opp_table' * struct opp_device - devices managed by 'struct opp_table'
* @node: list node * @node: list node
* @dev: device to which the struct object belongs * @dev: device to which the struct object belongs
* @rcu_head: RCU callback head used for deferred freeing
* @dentry: debugfs dentry pointer (per device) * @dentry: debugfs dentry pointer (per device)
* *
* This is an internal data structure maintaining the devices that are managed * This is an internal data structure maintaining the devices that are managed
...@@ -107,7 +103,6 @@ struct dev_pm_opp { ...@@ -107,7 +103,6 @@ struct dev_pm_opp {
struct opp_device { struct opp_device {
struct list_head node; struct list_head node;
const struct device *dev; const struct device *dev;
struct rcu_head rcu_head;
#ifdef CONFIG_DEBUG_FS #ifdef CONFIG_DEBUG_FS
struct dentry *dentry; struct dentry *dentry;
...@@ -125,12 +120,11 @@ enum opp_table_access { ...@@ -125,12 +120,11 @@ enum opp_table_access {
* @node: table node - contains the devices with OPPs that * @node: table node - contains the devices with OPPs that
* have been registered. Nodes once added are not modified in this * have been registered. Nodes once added are not modified in this
* table. * table.
* RCU usage: nodes are not modified in the table of opp_table, * @head: notifier head to notify the OPP availability changes.
* however addition is possible and is secured by opp_table_lock
* @srcu_head: notifier head to notify the OPP availability changes.
* @rcu_head: RCU callback head used for deferred freeing
* @dev_list: list of devices that share these OPPs * @dev_list: list of devices that share these OPPs
* @opp_list: table of opps * @opp_list: table of opps
* @kref: for reference count of the table.
* @lock: mutex protecting the opp_list.
* @np: struct device_node pointer for opp's DT node. * @np: struct device_node pointer for opp's DT node.
* @clock_latency_ns_max: Max clock latency in nanoseconds. * @clock_latency_ns_max: Max clock latency in nanoseconds.
* @shared_opp: OPP is shared between multiple devices. * @shared_opp: OPP is shared between multiple devices.
...@@ -151,18 +145,15 @@ enum opp_table_access { ...@@ -151,18 +145,15 @@ enum opp_table_access {
* This is an internal data structure maintaining the link to opps attached to * This is an internal data structure maintaining the link to opps attached to
* a device. This structure is not meant to be shared to users as it is * a device. This structure is not meant to be shared to users as it is
* meant for book keeping and private to OPP library. * meant for book keeping and private to OPP library.
*
* Because the opp structures can be used from both rcu and srcu readers, we
* need to wait for the grace period of both of them before freeing any
* resources. And so we have used kfree_rcu() from within call_srcu() handlers.
*/ */
struct opp_table { struct opp_table {
struct list_head node; struct list_head node;
struct srcu_notifier_head srcu_head; struct blocking_notifier_head head;
struct rcu_head rcu_head;
struct list_head dev_list; struct list_head dev_list;
struct list_head opp_list; struct list_head opp_list;
struct kref kref;
struct mutex lock;
struct device_node *np; struct device_node *np;
unsigned long clock_latency_ns_max; unsigned long clock_latency_ns_max;
...@@ -190,14 +181,17 @@ struct opp_table { ...@@ -190,14 +181,17 @@ struct opp_table {
}; };
/* Routines internal to opp core */ /* Routines internal to opp core */
void _get_opp_table_kref(struct opp_table *opp_table);
struct opp_table *_find_opp_table(struct device *dev); struct opp_table *_find_opp_table(struct device *dev);
struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table); struct opp_device *_add_opp_dev(const struct device *dev, struct opp_table *opp_table);
void _dev_pm_opp_remove_table(struct device *dev, bool remove_all); void _dev_pm_opp_remove_table(struct opp_table *opp_table, struct device *dev, bool remove_all);
struct dev_pm_opp *_allocate_opp(struct device *dev, struct opp_table **opp_table); void _dev_pm_opp_find_and_remove_table(struct device *dev, bool remove_all);
struct dev_pm_opp *_opp_allocate(struct opp_table *opp_table);
void _opp_free(struct dev_pm_opp *opp);
int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table); int _opp_add(struct device *dev, struct dev_pm_opp *new_opp, struct opp_table *opp_table);
void _opp_remove(struct opp_table *opp_table, struct dev_pm_opp *opp, bool notify); int _opp_add_v1(struct opp_table *opp_table, struct device *dev, unsigned long freq, long u_volt, bool dynamic);
int _opp_add_v1(struct device *dev, unsigned long freq, long u_volt, bool dynamic);
void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of); void _dev_pm_opp_cpumask_remove_table(const struct cpumask *cpumask, bool of);
struct opp_table *_add_opp_table(struct device *dev);
#ifdef CONFIG_OF #ifdef CONFIG_OF
void _of_init_opp_table(struct opp_table *opp_table, struct device *dev); void _of_init_opp_table(struct opp_table *opp_table, struct device *dev);
......
...@@ -281,7 +281,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev) ...@@ -281,7 +281,7 @@ void dev_pm_qos_constraints_destroy(struct device *dev)
dev->power.qos = ERR_PTR(-ENODEV); dev->power.qos = ERR_PTR(-ENODEV);
spin_unlock_irq(&dev->power.lock); spin_unlock_irq(&dev->power.lock);
kfree(c->notifiers); kfree(qos->resume_latency.notifiers);
kfree(qos); kfree(qos);
out: out:
......
...@@ -141,6 +141,13 @@ static irqreturn_t handle_threaded_wake_irq(int irq, void *_wirq) ...@@ -141,6 +141,13 @@ static irqreturn_t handle_threaded_wake_irq(int irq, void *_wirq)
struct wake_irq *wirq = _wirq; struct wake_irq *wirq = _wirq;
int res; int res;
/* Maybe abort suspend? */
if (irqd_is_wakeup_set(irq_get_irq_data(irq))) {
pm_wakeup_event(wirq->dev, 0);
return IRQ_HANDLED;
}
/* We don't want RPM_ASYNC or RPM_NOWAIT here */ /* We don't want RPM_ASYNC or RPM_NOWAIT here */
res = pm_runtime_resume(wirq->dev); res = pm_runtime_resume(wirq->dev);
if (res < 0) if (res < 0)
...@@ -183,6 +190,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq) ...@@ -183,6 +190,9 @@ int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
wirq->irq = irq; wirq->irq = irq;
irq_set_status_flags(irq, IRQ_NOAUTOEN); irq_set_status_flags(irq, IRQ_NOAUTOEN);
/* Prevent deferred spurious wakeirqs with disable_irq_nosync() */
irq_set_status_flags(irq, IRQ_DISABLE_UNLAZY);
/* /*
* Consumer device may need to power up and restore state * Consumer device may need to power up and restore state
* so we use a threaded irq. * so we use a threaded irq.
...@@ -312,8 +322,12 @@ void dev_pm_arm_wake_irq(struct wake_irq *wirq) ...@@ -312,8 +322,12 @@ void dev_pm_arm_wake_irq(struct wake_irq *wirq)
if (!wirq) if (!wirq)
return; return;
if (device_may_wakeup(wirq->dev)) if (device_may_wakeup(wirq->dev)) {
if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED)
enable_irq(wirq->irq);
enable_irq_wake(wirq->irq); enable_irq_wake(wirq->irq);
}
} }
/** /**
...@@ -328,6 +342,10 @@ void dev_pm_disarm_wake_irq(struct wake_irq *wirq) ...@@ -328,6 +342,10 @@ void dev_pm_disarm_wake_irq(struct wake_irq *wirq)
if (!wirq) if (!wirq)
return; return;
if (device_may_wakeup(wirq->dev)) if (device_may_wakeup(wirq->dev)) {
disable_irq_wake(wirq->irq); disable_irq_wake(wirq->irq);
if (wirq->status & WAKE_IRQ_DEDICATED_ALLOCATED)
disable_irq_nosync(wirq->irq);
}
} }
...@@ -633,16 +633,12 @@ static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate) ...@@ -633,16 +633,12 @@ static int find_lut_index_for_rate(struct tegra_dfll *td, unsigned long rate)
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
int i, uv; int i, uv;
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(td->soc->dev, &rate); opp = dev_pm_opp_find_freq_ceil(td->soc->dev, &rate);
if (IS_ERR(opp)) { if (IS_ERR(opp))
rcu_read_unlock();
return PTR_ERR(opp); return PTR_ERR(opp);
}
uv = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); uv = dev_pm_opp_get_voltage(opp);
dev_pm_opp_put(opp);
for (i = 0; i < td->i2c_lut_size; i++) { for (i = 0; i < td->i2c_lut_size; i++) {
if (regulator_list_voltage(td->vdd_reg, td->i2c_lut[i]) == uv) if (regulator_list_voltage(td->vdd_reg, td->i2c_lut[i]) == uv)
...@@ -1440,8 +1436,6 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td) ...@@ -1440,8 +1436,6 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
int lut; int lut;
rcu_read_lock();
rate = ULONG_MAX; rate = ULONG_MAX;
opp = dev_pm_opp_find_freq_floor(td->soc->dev, &rate); opp = dev_pm_opp_find_freq_floor(td->soc->dev, &rate);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
...@@ -1449,6 +1443,7 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td) ...@@ -1449,6 +1443,7 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
goto out; goto out;
} }
v_max = dev_pm_opp_get_voltage(opp); v_max = dev_pm_opp_get_voltage(opp);
dev_pm_opp_put(opp);
v = td->soc->cvb->min_millivolts * 1000; v = td->soc->cvb->min_millivolts * 1000;
lut = find_vdd_map_entry_exact(td, v); lut = find_vdd_map_entry_exact(td, v);
...@@ -1465,6 +1460,8 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td) ...@@ -1465,6 +1460,8 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
if (v_opp <= td->soc->cvb->min_millivolts * 1000) if (v_opp <= td->soc->cvb->min_millivolts * 1000)
td->dvco_rate_min = dev_pm_opp_get_freq(opp); td->dvco_rate_min = dev_pm_opp_get_freq(opp);
dev_pm_opp_put(opp);
for (;;) { for (;;) {
v += max(1, (v_max - v) / (MAX_DFLL_VOLTAGES - j)); v += max(1, (v_max - v) / (MAX_DFLL_VOLTAGES - j));
if (v >= v_opp) if (v >= v_opp)
...@@ -1496,8 +1493,6 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td) ...@@ -1496,8 +1493,6 @@ static int dfll_build_i2c_lut(struct tegra_dfll *td)
ret = 0; ret = 0;
out: out:
rcu_read_unlock();
return ret; return ret;
} }
......
...@@ -37,14 +37,6 @@ config CPU_FREQ_STAT ...@@ -37,14 +37,6 @@ config CPU_FREQ_STAT
If in doubt, say N. If in doubt, say N.
config CPU_FREQ_STAT_DETAILS
bool "CPU frequency transition statistics details"
depends on CPU_FREQ_STAT
help
Show detailed CPU frequency transition table in sysfs.
If in doubt, say N.
choice choice
prompt "Default CPUFreq governor" prompt "Default CPUFreq governor"
default CPU_FREQ_DEFAULT_GOV_USERSPACE if ARM_SA1100_CPUFREQ || ARM_SA1110_CPUFREQ default CPU_FREQ_DEFAULT_GOV_USERSPACE if ARM_SA1100_CPUFREQ || ARM_SA1110_CPUFREQ
...@@ -271,6 +263,16 @@ config IA64_ACPI_CPUFREQ ...@@ -271,6 +263,16 @@ config IA64_ACPI_CPUFREQ
endif endif
if MIPS if MIPS
config BMIPS_CPUFREQ
tristate "BMIPS CPUfreq Driver"
help
This option adds a CPUfreq driver for BMIPS processors with
support for configurable CPU frequency.
For now, BMIPS5 chips are supported (such as the Broadcom 7425).
If in doubt, say N.
config LOONGSON2_CPUFREQ config LOONGSON2_CPUFREQ
tristate "Loongson2 CPUFreq Driver" tristate "Loongson2 CPUFreq Driver"
help help
...@@ -332,7 +334,7 @@ endif ...@@ -332,7 +334,7 @@ endif
config QORIQ_CPUFREQ config QORIQ_CPUFREQ
tristate "CPU frequency scaling driver for Freescale QorIQ SoCs" tristate "CPU frequency scaling driver for Freescale QorIQ SoCs"
depends on OF && COMMON_CLK && (PPC_E500MC || ARM) depends on OF && COMMON_CLK && (PPC_E500MC || ARM || ARM64)
depends on !CPU_THERMAL || THERMAL depends on !CPU_THERMAL || THERMAL
select CLK_QORIQ select CLK_QORIQ
help help
......
...@@ -247,6 +247,17 @@ config ARM_TEGRA124_CPUFREQ ...@@ -247,6 +247,17 @@ config ARM_TEGRA124_CPUFREQ
help help
This adds the CPUFreq driver support for Tegra124 SOCs. This adds the CPUFreq driver support for Tegra124 SOCs.
config ARM_TI_CPUFREQ
bool "Texas Instruments CPUFreq support"
depends on ARCH_OMAP2PLUS
help
This driver enables valid OPPs on the running platform based on
values contained within the SoC in use. Enable this in order to
use the cpufreq-dt driver on all Texas Instruments platforms that
provide dt based operating-points-v2 tables with opp-supported-hw
data provided. Required for cpufreq support on AM335x, AM437x,
DRA7x, and AM57x platforms.
config ARM_PXA2xx_CPUFREQ config ARM_PXA2xx_CPUFREQ
tristate "Intel PXA2xx CPUfreq driver" tristate "Intel PXA2xx CPUfreq driver"
depends on PXA27x || PXA25x depends on PXA27x || PXA25x
...@@ -257,7 +268,7 @@ config ARM_PXA2xx_CPUFREQ ...@@ -257,7 +268,7 @@ config ARM_PXA2xx_CPUFREQ
config ACPI_CPPC_CPUFREQ config ACPI_CPPC_CPUFREQ
tristate "CPUFreq driver based on the ACPI CPPC spec" tristate "CPUFreq driver based on the ACPI CPPC spec"
depends on ACPI depends on ACPI_PROCESSOR
select ACPI_CPPC_LIB select ACPI_CPPC_LIB
default n default n
help help
......
...@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o ...@@ -77,6 +77,7 @@ obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o
obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o
obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o
obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o
obj-$(CONFIG_ARM_TI_CPUFREQ) += ti-cpufreq.o
obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ) += vexpress-spc-cpufreq.o
obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o
obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o obj-$(CONFIG_MACH_MVEBU_V7) += mvebu-cpufreq.o
...@@ -98,6 +99,7 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o ...@@ -98,6 +99,7 @@ obj-$(CONFIG_POWERNV_CPUFREQ) += powernv-cpufreq.o
# Other platform drivers # Other platform drivers
obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o obj-$(CONFIG_AVR32_AT32AP_CPUFREQ) += at32ap-cpufreq.o
obj-$(CONFIG_BFIN_CPU_FREQ) += blackfin-cpufreq.o obj-$(CONFIG_BFIN_CPU_FREQ) += blackfin-cpufreq.o
obj-$(CONFIG_BMIPS_CPUFREQ) += bmips-cpufreq.o
obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o obj-$(CONFIG_CRIS_MACH_ARTPEC3) += cris-artpec3-cpufreq.o
obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o obj-$(CONFIG_ETRAXFS) += cris-etraxfs-cpufreq.o
obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o obj-$(CONFIG_IA64_ACPI_CPUFREQ) += ia64-acpi-cpufreq.o
......
/*
* CPU frequency scaling for Broadcom BMIPS SoCs
*
* Copyright (c) 2017 Broadcom
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any
* kind, whether express or implied; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/cpufreq.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/slab.h>
/* for mips_hpt_frequency */
#include <asm/time.h>
#define BMIPS_CPUFREQ_PREFIX "bmips"
#define BMIPS_CPUFREQ_NAME BMIPS_CPUFREQ_PREFIX "-cpufreq"
#define TRANSITION_LATENCY (25 * 1000) /* 25 us */
#define BMIPS5_CLK_DIV_SET_SHIFT 0x7
#define BMIPS5_CLK_DIV_SHIFT 0x4
#define BMIPS5_CLK_DIV_MASK 0xf
enum bmips_type {
BMIPS5000,
BMIPS5200,
};
struct cpufreq_compat {
const char *compatible;
unsigned int bmips_type;
unsigned int clk_mult;
unsigned int max_freqs;
};
#define BMIPS(c, t, m, f) { \
.compatible = c, \
.bmips_type = (t), \
.clk_mult = (m), \
.max_freqs = (f), \
}
static struct cpufreq_compat bmips_cpufreq_compat[] = {
BMIPS("brcm,bmips5000", BMIPS5000, 8, 4),
BMIPS("brcm,bmips5200", BMIPS5200, 8, 4),
{ }
};
static struct cpufreq_compat *priv;
static int htp_freq_to_cpu_freq(unsigned int clk_mult)
{
return mips_hpt_frequency * clk_mult / 1000;
}
static struct cpufreq_frequency_table *
bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *table;
unsigned long cpu_freq;
int i;
cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult);
table = kmalloc((priv->max_freqs + 1) * sizeof(*table), GFP_KERNEL);
if (!table)
return ERR_PTR(-ENOMEM);
for (i = 0; i < priv->max_freqs; i++) {
table[i].frequency = cpu_freq / (1 << i);
table[i].driver_data = i;
}
table[i].frequency = CPUFREQ_TABLE_END;
return table;
}
static unsigned int bmips_cpufreq_get(unsigned int cpu)
{
unsigned int div;
uint32_t mode;
switch (priv->bmips_type) {
case BMIPS5200:
case BMIPS5000:
mode = read_c0_brcm_mode();
div = ((mode >> BMIPS5_CLK_DIV_SHIFT) & BMIPS5_CLK_DIV_MASK);
break;
default:
div = 0;
}
return htp_freq_to_cpu_freq(priv->clk_mult) / (1 << div);
}
static int bmips_cpufreq_target_index(struct cpufreq_policy *policy,
unsigned int index)
{
unsigned int div = policy->freq_table[index].driver_data;
switch (priv->bmips_type) {
case BMIPS5200:
case BMIPS5000:
change_c0_brcm_mode(BMIPS5_CLK_DIV_MASK << BMIPS5_CLK_DIV_SHIFT,
(1 << BMIPS5_CLK_DIV_SET_SHIFT) |
(div << BMIPS5_CLK_DIV_SHIFT));
break;
default:
return -ENOTSUPP;
}
return 0;
}
static int bmips_cpufreq_exit(struct cpufreq_policy *policy)
{
kfree(policy->freq_table);
return 0;
}
static int bmips_cpufreq_init(struct cpufreq_policy *policy)
{
struct cpufreq_frequency_table *freq_table;
int ret;
freq_table = bmips_cpufreq_get_freq_table(policy);
if (IS_ERR(freq_table)) {
ret = PTR_ERR(freq_table);
pr_err("%s: couldn't determine frequency table (%d).\n",
BMIPS_CPUFREQ_NAME, ret);
return ret;
}
ret = cpufreq_generic_init(policy, freq_table, TRANSITION_LATENCY);
if (ret)
bmips_cpufreq_exit(policy);
else
pr_info("%s: registered\n", BMIPS_CPUFREQ_NAME);
return ret;
}
static struct cpufreq_driver bmips_cpufreq_driver = {
.flags = CPUFREQ_NEED_INITIAL_FREQ_CHECK,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = bmips_cpufreq_target_index,
.get = bmips_cpufreq_get,
.init = bmips_cpufreq_init,
.exit = bmips_cpufreq_exit,
.attr = cpufreq_generic_attr,
.name = BMIPS_CPUFREQ_PREFIX,
};
static int __init bmips_cpufreq_probe(void)
{
struct cpufreq_compat *cc;
struct device_node *np;
for (cc = bmips_cpufreq_compat; cc->compatible; cc++) {
np = of_find_compatible_node(NULL, "cpu", cc->compatible);
if (np) {
of_node_put(np);
priv = cc;
break;
}
}
/* We hit the guard element of the array. No compatible CPU found. */
if (!cc->compatible)
return -ENODEV;
return cpufreq_register_driver(&bmips_cpufreq_driver);
}
device_initcall(bmips_cpufreq_probe);
MODULE_AUTHOR("Markus Mayer <mmayer@broadcom.com>");
MODULE_DESCRIPTION("CPUfreq driver for Broadcom BMIPS SoCs");
MODULE_LICENSE("GPL");
...@@ -878,7 +878,6 @@ static int brcm_avs_prepare_init(struct platform_device *pdev) ...@@ -878,7 +878,6 @@ static int brcm_avs_prepare_init(struct platform_device *pdev)
iounmap(priv->avs_intr_base); iounmap(priv->avs_intr_base);
unmap_base: unmap_base:
iounmap(priv->base); iounmap(priv->base);
platform_set_drvdata(pdev, NULL);
return ret; return ret;
} }
...@@ -1042,7 +1041,6 @@ static int brcm_avs_cpufreq_remove(struct platform_device *pdev) ...@@ -1042,7 +1041,6 @@ static int brcm_avs_cpufreq_remove(struct platform_device *pdev)
priv = platform_get_drvdata(pdev); priv = platform_get_drvdata(pdev);
iounmap(priv->base); iounmap(priv->base);
iounmap(priv->avs_intr_base); iounmap(priv->avs_intr_base);
platform_set_drvdata(pdev, NULL);
return 0; return 0;
} }
......
...@@ -87,8 +87,6 @@ static const struct of_device_id machines[] __initconst = { ...@@ -87,8 +87,6 @@ static const struct of_device_id machines[] __initconst = {
{ .compatible = "socionext,uniphier-ld11", }, { .compatible = "socionext,uniphier-ld11", },
{ .compatible = "socionext,uniphier-ld20", }, { .compatible = "socionext,uniphier-ld20", },
{ .compatible = "ti,am33xx", },
{ .compatible = "ti,dra7", },
{ .compatible = "ti,omap2", }, { .compatible = "ti,omap2", },
{ .compatible = "ti,omap3", }, { .compatible = "ti,omap3", },
{ .compatible = "ti,omap4", }, { .compatible = "ti,omap4", },
......
...@@ -148,7 +148,6 @@ static int cpufreq_init(struct cpufreq_policy *policy) ...@@ -148,7 +148,6 @@ static int cpufreq_init(struct cpufreq_policy *policy)
struct private_data *priv; struct private_data *priv;
struct device *cpu_dev; struct device *cpu_dev;
struct clk *cpu_clk; struct clk *cpu_clk;
struct dev_pm_opp *suspend_opp;
unsigned int transition_latency; unsigned int transition_latency;
bool fallback = false; bool fallback = false;
const char *name; const char *name;
...@@ -252,11 +251,7 @@ static int cpufreq_init(struct cpufreq_policy *policy) ...@@ -252,11 +251,7 @@ static int cpufreq_init(struct cpufreq_policy *policy)
policy->driver_data = priv; policy->driver_data = priv;
policy->clk = cpu_clk; policy->clk = cpu_clk;
rcu_read_lock(); policy->suspend_freq = dev_pm_opp_get_suspend_opp_freq(cpu_dev) / 1000;
suspend_opp = dev_pm_opp_get_suspend_opp(cpu_dev);
if (suspend_opp)
policy->suspend_freq = dev_pm_opp_get_freq(suspend_opp) / 1000;
rcu_read_unlock();
ret = cpufreq_table_validate_and_show(policy, freq_table); ret = cpufreq_table_validate_and_show(policy, freq_table);
if (ret) { if (ret) {
......
...@@ -1078,15 +1078,11 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) ...@@ -1078,15 +1078,11 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
return NULL; return NULL;
} }
static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy, bool notify) static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy)
{ {
struct kobject *kobj; struct kobject *kobj;
struct completion *cmp; struct completion *cmp;
if (notify)
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_REMOVE_POLICY, policy);
down_write(&policy->rwsem); down_write(&policy->rwsem);
cpufreq_stats_free_table(policy); cpufreq_stats_free_table(policy);
kobj = &policy->kobj; kobj = &policy->kobj;
...@@ -1104,7 +1100,7 @@ static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy, bool notify) ...@@ -1104,7 +1100,7 @@ static void cpufreq_policy_put_kobj(struct cpufreq_policy *policy, bool notify)
pr_debug("wait complete\n"); pr_debug("wait complete\n");
} }
static void cpufreq_policy_free(struct cpufreq_policy *policy, bool notify) static void cpufreq_policy_free(struct cpufreq_policy *policy)
{ {
unsigned long flags; unsigned long flags;
int cpu; int cpu;
...@@ -1117,7 +1113,7 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy, bool notify) ...@@ -1117,7 +1113,7 @@ static void cpufreq_policy_free(struct cpufreq_policy *policy, bool notify)
per_cpu(cpufreq_cpu_data, cpu) = NULL; per_cpu(cpufreq_cpu_data, cpu) = NULL;
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
cpufreq_policy_put_kobj(policy, notify); cpufreq_policy_put_kobj(policy);
free_cpumask_var(policy->real_cpus); free_cpumask_var(policy->real_cpus);
free_cpumask_var(policy->related_cpus); free_cpumask_var(policy->related_cpus);
free_cpumask_var(policy->cpus); free_cpumask_var(policy->cpus);
...@@ -1170,8 +1166,6 @@ static int cpufreq_online(unsigned int cpu) ...@@ -1170,8 +1166,6 @@ static int cpufreq_online(unsigned int cpu)
if (new_policy) { if (new_policy) {
/* related_cpus should at least include policy->cpus. */ /* related_cpus should at least include policy->cpus. */
cpumask_copy(policy->related_cpus, policy->cpus); cpumask_copy(policy->related_cpus, policy->cpus);
/* Clear mask of registered CPUs */
cpumask_clear(policy->real_cpus);
} }
/* /*
...@@ -1244,17 +1238,12 @@ static int cpufreq_online(unsigned int cpu) ...@@ -1244,17 +1238,12 @@ static int cpufreq_online(unsigned int cpu)
goto out_exit_policy; goto out_exit_policy;
cpufreq_stats_create_table(policy); cpufreq_stats_create_table(policy);
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_CREATE_POLICY, policy);
write_lock_irqsave(&cpufreq_driver_lock, flags); write_lock_irqsave(&cpufreq_driver_lock, flags);
list_add(&policy->policy_list, &cpufreq_policy_list); list_add(&policy->policy_list, &cpufreq_policy_list);
write_unlock_irqrestore(&cpufreq_driver_lock, flags); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
} }
blocking_notifier_call_chain(&cpufreq_policy_notifier_list,
CPUFREQ_START, policy);
ret = cpufreq_init_policy(policy); ret = cpufreq_init_policy(policy);
if (ret) { if (ret) {
pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n", pr_err("%s: Failed to initialize policy for cpu: %d (%d)\n",
...@@ -1282,7 +1271,7 @@ static int cpufreq_online(unsigned int cpu) ...@@ -1282,7 +1271,7 @@ static int cpufreq_online(unsigned int cpu)
if (cpufreq_driver->exit) if (cpufreq_driver->exit)
cpufreq_driver->exit(policy); cpufreq_driver->exit(policy);
out_free_policy: out_free_policy:
cpufreq_policy_free(policy, !new_policy); cpufreq_policy_free(policy);
return ret; return ret;
} }
...@@ -1403,7 +1392,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) ...@@ -1403,7 +1392,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)
remove_cpu_dev_symlink(policy, dev); remove_cpu_dev_symlink(policy, dev);
if (cpumask_empty(policy->real_cpus)) if (cpumask_empty(policy->real_cpus))
cpufreq_policy_free(policy, true); cpufreq_policy_free(policy);
} }
/** /**
......
...@@ -24,9 +24,7 @@ struct cpufreq_stats { ...@@ -24,9 +24,7 @@ struct cpufreq_stats {
unsigned int last_index; unsigned int last_index;
u64 *time_in_state; u64 *time_in_state;
unsigned int *freq_table; unsigned int *freq_table;
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
unsigned int *trans_table; unsigned int *trans_table;
#endif
}; };
static int cpufreq_stats_update(struct cpufreq_stats *stats) static int cpufreq_stats_update(struct cpufreq_stats *stats)
...@@ -45,9 +43,7 @@ static void cpufreq_stats_clear_table(struct cpufreq_stats *stats) ...@@ -45,9 +43,7 @@ static void cpufreq_stats_clear_table(struct cpufreq_stats *stats)
unsigned int count = stats->max_state; unsigned int count = stats->max_state;
memset(stats->time_in_state, 0, count * sizeof(u64)); memset(stats->time_in_state, 0, count * sizeof(u64));
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
memset(stats->trans_table, 0, count * count * sizeof(int)); memset(stats->trans_table, 0, count * count * sizeof(int));
#endif
stats->last_time = get_jiffies_64(); stats->last_time = get_jiffies_64();
stats->total_trans = 0; stats->total_trans = 0;
} }
...@@ -83,7 +79,6 @@ static ssize_t store_reset(struct cpufreq_policy *policy, const char *buf, ...@@ -83,7 +79,6 @@ static ssize_t store_reset(struct cpufreq_policy *policy, const char *buf,
return count; return count;
} }
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
{ {
struct cpufreq_stats *stats = policy->stats; struct cpufreq_stats *stats = policy->stats;
...@@ -128,7 +123,6 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf) ...@@ -128,7 +123,6 @@ static ssize_t show_trans_table(struct cpufreq_policy *policy, char *buf)
return len; return len;
} }
cpufreq_freq_attr_ro(trans_table); cpufreq_freq_attr_ro(trans_table);
#endif
cpufreq_freq_attr_ro(total_trans); cpufreq_freq_attr_ro(total_trans);
cpufreq_freq_attr_ro(time_in_state); cpufreq_freq_attr_ro(time_in_state);
...@@ -138,9 +132,7 @@ static struct attribute *default_attrs[] = { ...@@ -138,9 +132,7 @@ static struct attribute *default_attrs[] = {
&total_trans.attr, &total_trans.attr,
&time_in_state.attr, &time_in_state.attr,
&reset.attr, &reset.attr,
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
&trans_table.attr, &trans_table.attr,
#endif
NULL NULL
}; };
static struct attribute_group stats_attr_group = { static struct attribute_group stats_attr_group = {
...@@ -199,9 +191,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy) ...@@ -199,9 +191,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
alloc_size = count * sizeof(int) + count * sizeof(u64); alloc_size = count * sizeof(int) + count * sizeof(u64);
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
alloc_size += count * count * sizeof(int); alloc_size += count * count * sizeof(int);
#endif
/* Allocate memory for time_in_state/freq_table/trans_table in one go */ /* Allocate memory for time_in_state/freq_table/trans_table in one go */
stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL); stats->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
...@@ -210,9 +200,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy) ...@@ -210,9 +200,7 @@ void cpufreq_stats_create_table(struct cpufreq_policy *policy)
stats->freq_table = (unsigned int *)(stats->time_in_state + count); stats->freq_table = (unsigned int *)(stats->time_in_state + count);
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
stats->trans_table = stats->freq_table + count; stats->trans_table = stats->freq_table + count;
#endif
stats->max_state = count; stats->max_state = count;
...@@ -258,8 +246,6 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy, ...@@ -258,8 +246,6 @@ void cpufreq_stats_record_transition(struct cpufreq_policy *policy,
cpufreq_stats_update(stats); cpufreq_stats_update(stats);
stats->last_index = new_index; stats->last_index = new_index;
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
stats->trans_table[old_index * stats->max_state + new_index]++; stats->trans_table[old_index * stats->max_state + new_index]++;
#endif
stats->total_trans++; stats->total_trans++;
} }
...@@ -118,12 +118,10 @@ static int init_div_table(void) ...@@ -118,12 +118,10 @@ static int init_div_table(void)
unsigned int tmp, clk_div, ema_div, freq, volt_id; unsigned int tmp, clk_div, ema_div, freq, volt_id;
struct dev_pm_opp *opp; struct dev_pm_opp *opp;
rcu_read_lock();
cpufreq_for_each_entry(pos, freq_tbl) { cpufreq_for_each_entry(pos, freq_tbl) {
opp = dev_pm_opp_find_freq_exact(dvfs_info->dev, opp = dev_pm_opp_find_freq_exact(dvfs_info->dev,
pos->frequency * 1000, true); pos->frequency * 1000, true);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
dev_err(dvfs_info->dev, dev_err(dvfs_info->dev,
"failed to find valid OPP for %u KHZ\n", "failed to find valid OPP for %u KHZ\n",
pos->frequency); pos->frequency);
...@@ -140,6 +138,7 @@ static int init_div_table(void) ...@@ -140,6 +138,7 @@ static int init_div_table(void)
/* Calculate EMA */ /* Calculate EMA */
volt_id = dev_pm_opp_get_voltage(opp); volt_id = dev_pm_opp_get_voltage(opp);
volt_id = (MAX_VOLTAGE - volt_id) / VOLTAGE_STEP; volt_id = (MAX_VOLTAGE - volt_id) / VOLTAGE_STEP;
if (volt_id < PMIC_HIGH_VOLT) { if (volt_id < PMIC_HIGH_VOLT) {
ema_div = (CPUEMA_HIGH << P0_7_CPUEMA_SHIFT) | ema_div = (CPUEMA_HIGH << P0_7_CPUEMA_SHIFT) |
...@@ -157,9 +156,9 @@ static int init_div_table(void) ...@@ -157,9 +156,9 @@ static int init_div_table(void)
__raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 * __raw_writel(tmp, dvfs_info->base + XMU_PMU_P0_7 + 4 *
(pos - freq_tbl)); (pos - freq_tbl));
dev_pm_opp_put(opp);
} }
rcu_read_unlock();
return 0; return 0;
} }
......
...@@ -53,16 +53,15 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index) ...@@ -53,16 +53,15 @@ static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
freq_hz = new_freq * 1000; freq_hz = new_freq * 1000;
old_freq = clk_get_rate(arm_clk) / 1000; old_freq = clk_get_rate(arm_clk) / 1000;
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz); opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
dev_err(cpu_dev, "failed to find OPP for %ld\n", freq_hz); dev_err(cpu_dev, "failed to find OPP for %ld\n", freq_hz);
return PTR_ERR(opp); return PTR_ERR(opp);
} }
volt = dev_pm_opp_get_voltage(opp); volt = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
volt_old = regulator_get_voltage(arm_reg); volt_old = regulator_get_voltage(arm_reg);
dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n", dev_dbg(cpu_dev, "%u MHz, %ld mV --> %u MHz, %ld mV\n",
...@@ -321,14 +320,15 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) ...@@ -321,14 +320,15 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
* freq_table initialised from OPP is therefore sorted in the * freq_table initialised from OPP is therefore sorted in the
* same order. * same order.
*/ */
rcu_read_lock();
opp = dev_pm_opp_find_freq_exact(cpu_dev, opp = dev_pm_opp_find_freq_exact(cpu_dev,
freq_table[0].frequency * 1000, true); freq_table[0].frequency * 1000, true);
min_volt = dev_pm_opp_get_voltage(opp); min_volt = dev_pm_opp_get_voltage(opp);
dev_pm_opp_put(opp);
opp = dev_pm_opp_find_freq_exact(cpu_dev, opp = dev_pm_opp_find_freq_exact(cpu_dev,
freq_table[--num].frequency * 1000, true); freq_table[--num].frequency * 1000, true);
max_volt = dev_pm_opp_get_voltage(opp); max_volt = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
ret = regulator_set_voltage_time(arm_reg, min_volt, max_volt); ret = regulator_set_voltage_time(arm_reg, min_volt, max_volt);
if (ret > 0) if (ret > 0)
transition_latency += ret * 1000; transition_latency += ret * 1000;
......
此差异已折叠。
...@@ -232,16 +232,14 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy, ...@@ -232,16 +232,14 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
freq_hz = freq_table[index].frequency * 1000; freq_hz = freq_table[index].frequency * 1000;
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz); opp = dev_pm_opp_find_freq_ceil(cpu_dev, &freq_hz);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
pr_err("cpu%d: failed to find OPP for %ld\n", pr_err("cpu%d: failed to find OPP for %ld\n",
policy->cpu, freq_hz); policy->cpu, freq_hz);
return PTR_ERR(opp); return PTR_ERR(opp);
} }
vproc = dev_pm_opp_get_voltage(opp); vproc = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
/* /*
* If the new voltage or the intermediate voltage is higher than the * If the new voltage or the intermediate voltage is higher than the
...@@ -411,16 +409,14 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu) ...@@ -411,16 +409,14 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
/* Search a safe voltage for intermediate frequency. */ /* Search a safe voltage for intermediate frequency. */
rate = clk_get_rate(inter_clk); rate = clk_get_rate(inter_clk);
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate); opp = dev_pm_opp_find_freq_ceil(cpu_dev, &rate);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
pr_err("failed to get intermediate opp for cpu%d\n", cpu); pr_err("failed to get intermediate opp for cpu%d\n", cpu);
ret = PTR_ERR(opp); ret = PTR_ERR(opp);
goto out_free_opp_table; goto out_free_opp_table;
} }
info->intermediate_voltage = dev_pm_opp_get_voltage(opp); info->intermediate_voltage = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
info->cpu_dev = cpu_dev; info->cpu_dev = cpu_dev;
info->proc_reg = proc_reg; info->proc_reg = proc_reg;
......
...@@ -63,16 +63,14 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index) ...@@ -63,16 +63,14 @@ static int omap_target(struct cpufreq_policy *policy, unsigned int index)
freq = ret; freq = ret;
if (mpu_reg) { if (mpu_reg) {
rcu_read_lock();
opp = dev_pm_opp_find_freq_ceil(mpu_dev, &freq); opp = dev_pm_opp_find_freq_ceil(mpu_dev, &freq);
if (IS_ERR(opp)) { if (IS_ERR(opp)) {
rcu_read_unlock();
dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n", dev_err(mpu_dev, "%s: unable to find MPU OPP for %d\n",
__func__, new_freq); __func__, new_freq);
return -EINVAL; return -EINVAL;
} }
volt = dev_pm_opp_get_voltage(opp); volt = dev_pm_opp_get_voltage(opp);
rcu_read_unlock(); dev_pm_opp_put(opp);
tol = volt * OPP_TOLERANCE / 100; tol = volt * OPP_TOLERANCE / 100;
volt_old = regulator_get_voltage(mpu_reg); volt_old = regulator_get_voltage(mpu_reg);
} }
......
...@@ -144,6 +144,7 @@ static struct powernv_pstate_info { ...@@ -144,6 +144,7 @@ static struct powernv_pstate_info {
unsigned int max; unsigned int max;
unsigned int nominal; unsigned int nominal;
unsigned int nr_pstates; unsigned int nr_pstates;
bool wof_enabled;
} powernv_pstate_info; } powernv_pstate_info;
/* Use following macros for conversions between pstate_id and index */ /* Use following macros for conversions between pstate_id and index */
...@@ -203,6 +204,7 @@ static int init_powernv_pstates(void) ...@@ -203,6 +204,7 @@ static int init_powernv_pstates(void)
const __be32 *pstate_ids, *pstate_freqs; const __be32 *pstate_ids, *pstate_freqs;
u32 len_ids, len_freqs; u32 len_ids, len_freqs;
u32 pstate_min, pstate_max, pstate_nominal; u32 pstate_min, pstate_max, pstate_nominal;
u32 pstate_turbo, pstate_ultra_turbo;
power_mgt = of_find_node_by_path("/ibm,opal/power-mgt"); power_mgt = of_find_node_by_path("/ibm,opal/power-mgt");
if (!power_mgt) { if (!power_mgt) {
...@@ -225,8 +227,29 @@ static int init_powernv_pstates(void) ...@@ -225,8 +227,29 @@ static int init_powernv_pstates(void)
pr_warn("ibm,pstate-nominal not found\n"); pr_warn("ibm,pstate-nominal not found\n");
return -ENODEV; return -ENODEV;
} }
if (of_property_read_u32(power_mgt, "ibm,pstate-ultra-turbo",
&pstate_ultra_turbo)) {
powernv_pstate_info.wof_enabled = false;
goto next;
}
if (of_property_read_u32(power_mgt, "ibm,pstate-turbo",
&pstate_turbo)) {
powernv_pstate_info.wof_enabled = false;
goto next;
}
if (pstate_turbo == pstate_ultra_turbo)
powernv_pstate_info.wof_enabled = false;
else
powernv_pstate_info.wof_enabled = true;
next:
pr_info("cpufreq pstate min %d nominal %d max %d\n", pstate_min, pr_info("cpufreq pstate min %d nominal %d max %d\n", pstate_min,
pstate_nominal, pstate_max); pstate_nominal, pstate_max);
pr_info("Workload Optimized Frequency is %s in the platform\n",
(powernv_pstate_info.wof_enabled) ? "enabled" : "disabled");
pstate_ids = of_get_property(power_mgt, "ibm,pstate-ids", &len_ids); pstate_ids = of_get_property(power_mgt, "ibm,pstate-ids", &len_ids);
if (!pstate_ids) { if (!pstate_ids) {
...@@ -268,6 +291,13 @@ static int init_powernv_pstates(void) ...@@ -268,6 +291,13 @@ static int init_powernv_pstates(void)
powernv_pstate_info.nominal = i; powernv_pstate_info.nominal = i;
else if (id == pstate_min) else if (id == pstate_min)
powernv_pstate_info.min = i; powernv_pstate_info.min = i;
if (powernv_pstate_info.wof_enabled && id == pstate_turbo) {
int j;
for (j = i - 1; j >= (int)powernv_pstate_info.max; j--)
powernv_freqs[j].flags = CPUFREQ_BOOST_FREQ;
}
} }
/* End of list marker entry */ /* End of list marker entry */
...@@ -305,9 +335,12 @@ static ssize_t cpuinfo_nominal_freq_show(struct cpufreq_policy *policy, ...@@ -305,9 +335,12 @@ static ssize_t cpuinfo_nominal_freq_show(struct cpufreq_policy *policy,
struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq = struct freq_attr cpufreq_freq_attr_cpuinfo_nominal_freq =
__ATTR_RO(cpuinfo_nominal_freq); __ATTR_RO(cpuinfo_nominal_freq);
#define SCALING_BOOST_FREQS_ATTR_INDEX 2
static struct freq_attr *powernv_cpu_freq_attr[] = { static struct freq_attr *powernv_cpu_freq_attr[] = {
&cpufreq_freq_attr_scaling_available_freqs, &cpufreq_freq_attr_scaling_available_freqs,
&cpufreq_freq_attr_cpuinfo_nominal_freq, &cpufreq_freq_attr_cpuinfo_nominal_freq,
&cpufreq_freq_attr_scaling_boost_freqs,
NULL, NULL,
}; };
...@@ -1013,11 +1046,22 @@ static int __init powernv_cpufreq_init(void) ...@@ -1013,11 +1046,22 @@ static int __init powernv_cpufreq_init(void)
register_reboot_notifier(&powernv_cpufreq_reboot_nb); register_reboot_notifier(&powernv_cpufreq_reboot_nb);
opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb); opal_message_notifier_register(OPAL_MSG_OCC, &powernv_cpufreq_opal_nb);
if (powernv_pstate_info.wof_enabled)
powernv_cpufreq_driver.boost_enabled = true;
else
powernv_cpu_freq_attr[SCALING_BOOST_FREQS_ATTR_INDEX] = NULL;
rc = cpufreq_register_driver(&powernv_cpufreq_driver); rc = cpufreq_register_driver(&powernv_cpufreq_driver);
if (!rc) if (rc) {
return 0; pr_info("Failed to register the cpufreq driver (%d)\n", rc);
goto cleanup_notifiers;
}
pr_info("Failed to register the cpufreq driver (%d)\n", rc); if (powernv_pstate_info.wof_enabled)
cpufreq_enable_boost_support();
return 0;
cleanup_notifiers:
unregister_all_notifiers(); unregister_all_notifiers();
clean_chip_info(); clean_chip_info();
out: out:
......
...@@ -100,9 +100,6 @@ static int pmi_notifier(struct notifier_block *nb, ...@@ -100,9 +100,6 @@ static int pmi_notifier(struct notifier_block *nb,
/* Should this really be called for CPUFREQ_ADJUST and CPUFREQ_NOTIFY /* Should this really be called for CPUFREQ_ADJUST and CPUFREQ_NOTIFY
* policy events?) * policy events?)
*/ */
if (event == CPUFREQ_START)
return 0;
node = cbe_cpu_to_node(policy->cpu); node = cbe_cpu_to_node(policy->cpu);
pr_debug("got notified, event=%lu, node=%u\n", event, node); pr_debug("got notified, event=%lu, node=%u\n", event, node);
......
此差异已折叠。
...@@ -400,7 +400,6 @@ static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy) ...@@ -400,7 +400,6 @@ static int s3c2416_cpufreq_driver_init(struct cpufreq_policy *policy)
rate = clk_get_rate(s3c_freq->hclk); rate = clk_get_rate(s3c_freq->hclk);
if (rate < 133 * 1000 * 1000) { if (rate < 133 * 1000 * 1000) {
pr_err("cpufreq: HCLK not at 133MHz\n"); pr_err("cpufreq: HCLK not at 133MHz\n");
clk_put(s3c_freq->hclk);
ret = -EINVAL; ret = -EINVAL;
goto err_armclk; goto err_armclk;
} }
......
...@@ -160,6 +160,7 @@ static int sti_cpufreq_set_opp_info(void) ...@@ -160,6 +160,7 @@ static int sti_cpufreq_set_opp_info(void)
int pcode, substrate, major, minor; int pcode, substrate, major, minor;
int ret; int ret;
char name[MAX_PCODE_NAME_LEN]; char name[MAX_PCODE_NAME_LEN];
struct opp_table *opp_table;
reg_fields = sti_cpufreq_match(); reg_fields = sti_cpufreq_match();
if (!reg_fields) { if (!reg_fields) {
...@@ -211,20 +212,20 @@ static int sti_cpufreq_set_opp_info(void) ...@@ -211,20 +212,20 @@ static int sti_cpufreq_set_opp_info(void)
snprintf(name, MAX_PCODE_NAME_LEN, "pcode%d", pcode); snprintf(name, MAX_PCODE_NAME_LEN, "pcode%d", pcode);
ret = dev_pm_opp_set_prop_name(dev, name); opp_table = dev_pm_opp_set_prop_name(dev, name);
if (ret) { if (IS_ERR(opp_table)) {
dev_err(dev, "Failed to set prop name\n"); dev_err(dev, "Failed to set prop name\n");
return ret; return PTR_ERR(opp_table);
} }
version[0] = BIT(major); version[0] = BIT(major);
version[1] = BIT(minor); version[1] = BIT(minor);
version[2] = BIT(substrate); version[2] = BIT(substrate);
ret = dev_pm_opp_set_supported_hw(dev, version, VERSION_ELEMENTS); opp_table = dev_pm_opp_set_supported_hw(dev, version, VERSION_ELEMENTS);
if (ret) { if (IS_ERR(opp_table)) {
dev_err(dev, "Failed to set supported hardware\n"); dev_err(dev, "Failed to set supported hardware\n");
return ret; return PTR_ERR(opp_table);
} }
dev_dbg(dev, "pcode: %d major: %d minor: %d substrate: %d\n", dev_dbg(dev, "pcode: %d major: %d minor: %d substrate: %d\n",
......
此差异已折叠。
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/tick.h> #include <linux/tick.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/math64.h> #include <linux/math64.h>
#include <linux/cpu.h>
/* /*
* Please note when changing the tuning values: * Please note when changing the tuning values:
...@@ -280,17 +281,23 @@ static unsigned int get_typical_interval(struct menu_device *data) ...@@ -280,17 +281,23 @@ static unsigned int get_typical_interval(struct menu_device *data)
static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
{ {
struct menu_device *data = this_cpu_ptr(&menu_devices); struct menu_device *data = this_cpu_ptr(&menu_devices);
struct device *device = get_cpu_device(dev->cpu);
int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY); int latency_req = pm_qos_request(PM_QOS_CPU_DMA_LATENCY);
int i; int i;
unsigned int interactivity_req; unsigned int interactivity_req;
unsigned int expected_interval; unsigned int expected_interval;
unsigned long nr_iowaiters, cpu_load; unsigned long nr_iowaiters, cpu_load;
int resume_latency = dev_pm_qos_read_value(device);
if (data->needs_update) { if (data->needs_update) {
menu_update(drv, dev); menu_update(drv, dev);
data->needs_update = 0; data->needs_update = 0;
} }
/* resume_latency is 0 means no restriction */
if (resume_latency && resume_latency < latency_req)
latency_req = resume_latency;
/* Special case when user has set very strict latency requirement */ /* Special case when user has set very strict latency requirement */
if (unlikely(latency_req == 0)) if (unlikely(latency_req == 0))
return 0; return 0;
...@@ -357,9 +364,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) ...@@ -357,9 +364,9 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev)
if (s->disabled || su->disable) if (s->disabled || su->disable)
continue; continue;
if (s->target_residency > data->predicted_us) if (s->target_residency > data->predicted_us)
continue; break;
if (s->exit_latency > latency_req) if (s->exit_latency > latency_req)
continue; break;
data->last_state_idx = i; data->last_state_idx = i;
} }
......
...@@ -306,7 +306,7 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev, ...@@ -306,7 +306,7 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
struct devfreq_event_desc *desc) struct devfreq_event_desc *desc)
{ {
struct devfreq_event_dev *edev; struct devfreq_event_dev *edev;
static atomic_t event_no = ATOMIC_INIT(0); static atomic_t event_no = ATOMIC_INIT(-1);
int ret; int ret;
if (!dev || !desc) if (!dev || !desc)
...@@ -329,7 +329,7 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev, ...@@ -329,7 +329,7 @@ struct devfreq_event_dev *devfreq_event_add_edev(struct device *dev,
edev->dev.class = devfreq_event_class; edev->dev.class = devfreq_event_class;
edev->dev.release = devfreq_event_release_edev; edev->dev.release = devfreq_event_release_edev;
dev_set_name(&edev->dev, "event.%d", atomic_inc_return(&event_no) - 1); dev_set_name(&edev->dev, "event%d", atomic_inc_return(&event_no));
ret = device_register(&edev->dev); ret = device_register(&edev->dev);
if (ret < 0) { if (ret < 0) {
put_device(&edev->dev); put_device(&edev->dev);
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -38,4 +38,6 @@ extern void devfreq_interval_update(struct devfreq *devfreq, ...@@ -38,4 +38,6 @@ extern void devfreq_interval_update(struct devfreq *devfreq,
extern int devfreq_add_governor(struct devfreq_governor *governor); extern int devfreq_add_governor(struct devfreq_governor *governor);
extern int devfreq_remove_governor(struct devfreq_governor *governor); extern int devfreq_remove_governor(struct devfreq_governor *governor);
extern int devfreq_update_status(struct devfreq *devfreq, unsigned long freq);
#endif /* _GOVERNOR_H */ #endif /* _GOVERNOR_H */
此差异已折叠。
/* /*
* linux/drivers/devfreq/governor_simpleondemand.c * linux/drivers/devfreq/governor_userspace.c
* *
* Copyright (C) 2011 Samsung Electronics * Copyright (C) 2011 Samsung Electronics
* MyungJoo Ham <myungjoo.ham@samsung.com> * MyungJoo Ham <myungjoo.ham@samsung.com>
...@@ -50,7 +50,6 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr, ...@@ -50,7 +50,6 @@ static ssize_t store_freq(struct device *dev, struct device_attribute *attr,
unsigned long wanted; unsigned long wanted;
int err = 0; int err = 0;
mutex_lock(&devfreq->lock); mutex_lock(&devfreq->lock);
data = devfreq->data; data = devfreq->data;
...@@ -112,7 +111,13 @@ static int userspace_init(struct devfreq *devfreq) ...@@ -112,7 +111,13 @@ static int userspace_init(struct devfreq *devfreq)
static void userspace_exit(struct devfreq *devfreq) static void userspace_exit(struct devfreq *devfreq)
{ {
sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group); /*
* Remove the sysfs entry, unless this is being called after
* device_del(), which should have done this already via kobject_del().
*/
if (devfreq->dev.kobj.sd)
sysfs_remove_group(&devfreq->dev.kobj, &dev_attr_group);
kfree(devfreq->data); kfree(devfreq->data);
devfreq->data = NULL; devfreq->data = NULL;
} }
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册