<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/cpufreq/cpufreq.c, branch linux-3.15.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.15.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.15.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2014-07-28T15:08:27Z</updated>
<entry>
<title>cpufreq: move policy kobj to policy-&gt;cpu at resume</title>
<updated>2014-07-28T15:08:27Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-07-17T05:18:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f089f0e364939faf818fd14b45f41a33b23dca54'/>
<id>urn:sha1:f089f0e364939faf818fd14b45f41a33b23dca54</id>
<content type='text'>
commit 92c14bd9477a20a83144f08c0ca25b0308bf0730 upstream.

This is only relevant to implementations with multiple clusters, where clusters
have separate clock lines but all CPUs within a cluster share it.

Consider a dual cluster platform with 2 cores per cluster. During suspend we
start hot unplugging CPUs in order 1 to 3. When CPU2 is removed, policy-&gt;kobj
would be moved to CPU3 and when CPU3 goes down we wouldn't free policy or its
kobj as we want to retain permissions/values/etc.

Now on resume, we will get CPU2 before CPU3 and will call __cpufreq_add_dev().
We will recover the old policy and update policy-&gt;cpu from 3 to 2 from
update_policy_cpu().

But the kobj is still tied to CPU3 and isn't moved to CPU2. We wouldn't create a
link for CPU2, but would try that for CPU3 while bringing it online. Which will
report errors as CPU3 already has kobj assigned to it.

This bug got introduced with commit 42f921a, which overlooked this scenario.

To fix this, lets move kobj to the new policy-&gt;cpu while bringing first CPU of a
cluster back. Also do a WARN_ON() if kobject_move failed, as we would reach here
only for the first CPU of a non-boot cluster. And we can't recover from this
situation, if kobject_move() fails.

Fixes: 42f921a6f10c (cpufreq: remove sysfs files for CPUs which failed to come back after resume)
Reported-and-tested-by: Bu Yitian &lt;ybu@qti.qualcomm.com&gt;
Reported-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Reviewed-by: Srivatsa S. Bhat &lt;srivatsa@mit.edu&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>cpufreq: unlock when failing cpufreq_update_policy()</title>
<updated>2014-07-07T01:59:12Z</updated>
<author>
<name>Aaron Plattner</name>
</author>
<published>2014-06-18T18:27:32Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=dd0bcbeae6ddc9658b1738ab5499cf379d5d418e'/>
<id>urn:sha1:dd0bcbeae6ddc9658b1738ab5499cf379d5d418e</id>
<content type='text'>
commit fefa8ff810c5ab4c4206aed9d159c4d6fe8d4f1c upstream.

Commit bd0fa9bb455d introduced a failure path to cpufreq_update_policy() if
cpufreq_driver-&gt;get(cpu) returns NULL.  However, it jumps to the 'no_policy'
label, which exits without unlocking any of the locks the function acquired
earlier.  This causes later calls into cpufreq to hang.

Fix this by creating a new 'unlock' label and jumping to that instead.

Fixes: bd0fa9bb455d ("cpufreq: Return error if -&gt;get() failed in cpufreq_update_policy()")
Link: https://devtalk.nvidia.com/default/topic/751903/kernel-3-15-and-nv-drivers-337-340-failed-to-initialize-the-nvidia-kernel-module-gtx-550-ti-/
Signed-off-by: Aaron Plattner &lt;aplattner@nvidia.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>cpufreq: Make cpufreq_notify_transition &amp; cpufreq_notify_post_transition static</title>
<updated>2014-03-26T15:41:41Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-24T08:05:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=236a98005274d8011136aee4aef52241588a9712'/>
<id>urn:sha1:236a98005274d8011136aee4aef52241588a9712</id>
<content type='text'>
cpufreq_notify_transition() and cpufreq_notify_post_transition() shouldn't be
called directly by cpufreq drivers anymore and so these should be marked static.

Reviewed-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Convert existing drivers to use cpufreq_freq_transition_{begin|end}</title>
<updated>2014-03-26T15:41:41Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-24T08:05:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=8fec051eea736ec1d8060a2c8766bf3a6b32c3d2'/>
<id>urn:sha1:8fec051eea736ec1d8060a2c8766bf3a6b32c3d2</id>
<content type='text'>
CPUFreq core has new infrastructure that would guarantee serialized calls to
target() or target_index() callbacks. These are called
cpufreq_freq_transition_begin() and cpufreq_freq_transition_end().

This patch converts existing drivers to use these new set of routines.

Reviewed-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Make sure frequency transitions are serialized</title>
<updated>2014-03-26T15:41:40Z</updated>
<author>
<name>Srivatsa S. Bhat</name>
</author>
<published>2014-03-24T08:05:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=12478cf0c55e5969f740bb38a24b1a0104ae18d8'/>
<id>urn:sha1:12478cf0c55e5969f740bb38a24b1a0104ae18d8</id>
<content type='text'>
Whenever we change the frequency of a CPU, we call the PRECHANGE and POSTCHANGE
notifiers. They must be serialized, i.e. PRECHANGE and POSTCHANGE notifiers
should strictly alternate, thereby preventing two different sets of PRECHANGE or
POSTCHANGE notifiers from interleaving arbitrarily.

The following examples illustrate why this is important:

Scenario 1:
-----------
A thread reading the value of cpuinfo_cur_freq, will call
__cpufreq_cpu_get()-&gt;cpufreq_out_of_sync()-&gt;cpufreq_notify_transition()

The ondemand governor can decide to change the frequency of the CPU at the same
time and hence it can end up sending the notifications via -&gt;target().

If the notifiers are not serialized, the following sequence can occur:
- PRECHANGE Notification for freq A (from cpuinfo_cur_freq)
- PRECHANGE Notification for freq B (from target())
- Freq changed by target() to B
- POSTCHANGE Notification for freq B
- POSTCHANGE Notification for freq A

We can see from the above that the last POSTCHANGE Notification happens for freq
A but the hardware is set to run at freq B.

Where would we break then?: adjust_jiffies() in cpufreq.c &amp; cpufreq_callback()
in arch/arm/kernel/smp.c (which also adjusts the jiffies). All the
loops_per_jiffy calculations will get messed up.

Scenario 2:
-----------
The governor calls __cpufreq_driver_target() to change the frequency. At the
same time, if we change scaling_{min|max}_freq from sysfs, it will end up
calling the governor's CPUFREQ_GOV_LIMITS notification, which will also call
__cpufreq_driver_target(). And hence we end up issuing concurrent calls to
-&gt;target().

Typically, platforms have the following logic in their -&gt;target() routines:
(Eg: cpufreq-cpu0, omap, exynos, etc)

A. If new freq is more than old: Increase voltage
B. Change freq
C. If new freq is less than old: decrease voltage

Now, if the two concurrent calls to -&gt;target() are X and Y, where X is trying to
increase the freq and Y is trying to decrease it, we get the following race
condition:

X.A: voltage gets increased for larger freq
Y.A: nothing happens
Y.B: freq gets decreased
Y.C: voltage gets decreased
X.B: freq gets increased
X.C: nothing happens

Thus we can end up setting a freq which is not supported by the voltage we have
set. That will probably make the clock to the CPU unstable and the system might
not work properly anymore.

This patch introduces a set of synchronization primitives to serialize frequency
transitions, which are to be used as shown below:

cpufreq_freq_transition_begin();

//Perform the frequency change

cpufreq_freq_transition_end();

The _begin() call sends the PRECHANGE notification whereas the _end() call sends
the POSTCHANGE notification. Also, all the necessary synchronization is handled
within these calls. In particular, even drivers which set the ASYNC_NOTIFICATION
flag can also use these APIs for performing frequency transitions (ie., you can
call _begin() from one task, and call the corresponding _end() from a different
task).

The actual synchronization underneath is not that complicated:

The key challenge is to allow drivers to begin the transition from one thread
and end it in a completely different thread (this is to enable drivers that do
asynchronous POSTCHANGE notification from bottom-halves, to also use the same
interface).

To achieve this, a 'transition_ongoing' flag, a 'transition_lock' spinlock and a
wait-queue are added per-policy. The flag and the wait-queue are used in
conjunction to create an "uninterrupted flow" from _begin() to _end(). The
spinlock is used to ensure that only one such "flow" is in flight at any given
time. Put together, this provides us all the necessary synchronization.

Signed-off-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: resume drivers before enabling governors</title>
<updated>2014-03-26T15:37:18Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-24T07:00:29Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0c5aa405a9437d97e09ec289d4f29bb62e0f01b6'/>
<id>urn:sha1:0c5aa405a9437d97e09ec289d4f29bb62e0f01b6</id>
<content type='text'>
During suspend, we first stop governors and then suspend cpufreq drivers and
resume must be exactly opposite of that. i.e. resume drivers first and then
start governors.

But the current code in resume enables governors first and then resume drivers.
Fix it be changing code sequence there.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Add stop CPU callback to cpufreq_driver interface</title>
<updated>2014-03-20T02:50:12Z</updated>
<author>
<name>Dirk Brandewie</name>
</author>
<published>2014-03-19T15:45:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=367dc4aa932bfb33a3189064d33f7890a8ec1ca8'/>
<id>urn:sha1:367dc4aa932bfb33a3189064d33f7890a8ec1ca8</id>
<content type='text'>
This callback allows the driver to do clean up before the CPU is
completely down and its state cannot be modified.  This is used
by the intel_pstate driver to reduce the requested P state prior to
the core going away.  This is required because the requested P state
of the offline core is used to select the package P state. This
effectively sets the floor package P state to the requested P state on
the offline core.

Signed-off-by: Dirk Brandewie &lt;dirk.j.brandewie@intel.com&gt;
[rjw: Minor modifications]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Remove unnecessary braces</title>
<updated>2014-03-20T02:40:48Z</updated>
<author>
<name>Stratos Karafotis</name>
</author>
<published>2014-03-19T23:25:13Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bda9f552f9826313ef8a477fc8e4891de9ae5e73'/>
<id>urn:sha1:bda9f552f9826313ef8a477fc8e4891de9ae5e73</id>
<content type='text'>
Remove unnecessary braces from a single statement.

Signed-off-by: Stratos Karafotis &lt;stratosk@semaphore.gr&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: Fix checkpatch errors and warnings</title>
<updated>2014-03-20T02:39:28Z</updated>
<author>
<name>Stratos Karafotis</name>
</author>
<published>2014-03-19T21:29:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=e5c87b762871c3377e456f6a57769dc63bdddd4b'/>
<id>urn:sha1:e5c87b762871c3377e456f6a57769dc63bdddd4b</id>
<content type='text'>
Fix 2 checkpatch errors about using assignment in if condition,
1 checkpatch error about a required space after comma
and 3 warnings about line over 80 characters.

Signed-off-by: Stratos Karafotis &lt;stratosk@semaphore.gr&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: remove unused notifier: CPUFREQ_{SUSPENDCHANGE|RESUMECHANGE}</title>
<updated>2014-03-19T13:10:24Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-19T05:54:58Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0b443ead714f0cba797a7f2476dd756f22b5421e'/>
<id>urn:sha1:0b443ead714f0cba797a7f2476dd756f22b5421e</id>
<content type='text'>
Two cpufreq notifiers CPUFREQ_RESUMECHANGE and CPUFREQ_SUSPENDCHANGE have
not been used for some time, so remove them to clean up code a bit.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Reviewed-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
</feed>
