<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/drivers/cpufreq/cpufreq.c, branch v3.14</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>cpufreq: Skip current frequency initialization for -&gt;setpolicy drivers</title>
<updated>2014-03-12T23:37:16+00:00</updated>
<author>
<name>Rafael J. Wysocki</name>
<email>rafael.j.wysocki@intel.com</email>
</author>
<published>2014-03-12T20:49:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=2ed99e39cb9392312c100d9da591c20641c64d12'/>
<id>2ed99e39cb9392312c100d9da591c20641c64d12</id>
<content type='text'>
After commit da60ce9f2fac (cpufreq: call cpufreq_driver-&gt;get() after
calling -&gt;init()) __cpufreq_add_dev() sometimes fails for CPUs handled
by intel_pstate, because that driver may return 0 from its -&gt;get()
callback if it has not run long enough to collect enough samples on the
given CPU.  That didn't happen before commit da60ce9f2fac which added
policy-&gt;cur initialization to __cpufreq_add_dev() to help reduce code
duplication in other cpufreq drivers.

However, the code added by commit da60ce9f2fac need not be executed
for cpufreq drivers having the -&gt;setpolicy callback defined, because
the subsequent invocation of cpufreq_set_policy() will use that
callback to initialize the policy anyway and it doesn't need
policy-&gt;cur to be initialized upfront.  The analogous code in
cpufreq_update_policy() is also unnecessary for cpufreq drivers
having -&gt;setpolicy set and may be skipped for them as well.

Since intel_pstate provides -&gt;setpolicy, skipping the upfront
policy-&gt;cur initialization for cpufreq drivers with that callback
set will cover intel_pstate and the problem it's been having after
commit da60ce9f2fac will be addressed.

Fixes: da60ce9f2fac (cpufreq: call cpufreq_driver-&gt;get() after calling -&gt;init())
References: https://bugzilla.kernel.org/show_bug.cgi?id=71931
Reported-and-tested-by: Patrik Lundquist &lt;patrik.lundquist@gmail.com&gt;
Acked-by: Dirk Brandewie &lt;dirk.j.brandewie@intel.com&gt;
Cc: 3.13+ &lt;stable@vger.kernel.org&gt; # 3.13+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After commit da60ce9f2fac (cpufreq: call cpufreq_driver-&gt;get() after
calling -&gt;init()) __cpufreq_add_dev() sometimes fails for CPUs handled
by intel_pstate, because that driver may return 0 from its -&gt;get()
callback if it has not run long enough to collect enough samples on the
given CPU.  That didn't happen before commit da60ce9f2fac which added
policy-&gt;cur initialization to __cpufreq_add_dev() to help reduce code
duplication in other cpufreq drivers.

However, the code added by commit da60ce9f2fac need not be executed
for cpufreq drivers having the -&gt;setpolicy callback defined, because
the subsequent invocation of cpufreq_set_policy() will use that
callback to initialize the policy anyway and it doesn't need
policy-&gt;cur to be initialized upfront.  The analogous code in
cpufreq_update_policy() is also unnecessary for cpufreq drivers
having -&gt;setpolicy set and may be skipped for them as well.

Since intel_pstate provides -&gt;setpolicy, skipping the upfront
policy-&gt;cur initialization for cpufreq drivers with that callback
set will cover intel_pstate and the problem it's been having after
commit da60ce9f2fac will be addressed.

Fixes: da60ce9f2fac (cpufreq: call cpufreq_driver-&gt;get() after calling -&gt;init())
References: https://bugzilla.kernel.org/show_bug.cgi?id=71931
Reported-and-tested-by: Patrik Lundquist &lt;patrik.lundquist@gmail.com&gt;
Acked-by: Dirk Brandewie &lt;dirk.j.brandewie@intel.com&gt;
Cc: 3.13+ &lt;stable@vger.kernel.org&gt; # 3.13+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: Initialize governor for a new policy under policy-&gt;rwsem</title>
<updated>2014-03-06T12:25:30+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2014-03-04T03:44:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=4e97b631f24c927b2302368f4f83efbba82076ee'/>
<id>4e97b631f24c927b2302368f4f83efbba82076ee</id>
<content type='text'>
policy-&gt;rwsem is used to lock access to all parts of code modifying
struct cpufreq_policy, but it's not used on a new policy created by
__cpufreq_add_dev().

Because of that, if cpufreq_update_policy() is called in a tight loop
on one CPU in parallel with offline/online of another CPU, then the
following crash can be triggered:

Unable to handle kernel NULL pointer dereference at virtual address 00000020
pgd = c0003000
[00000020] *pgd=80000000004003, *pmd=00000000
Internal error: Oops: 206 [#1] PREEMPT SMP ARM

PC is at __cpufreq_governor+0x10/0x1ac
LR is at cpufreq_update_policy+0x114/0x150

---[ end trace f23a8defea6cd706 ]---
Kernel panic - not syncing: Fatal exception
CPU0: stopping
CPU: 0 PID: 7136 Comm: mpdecision Tainted: G      D W    3.10.0-gd727407-00074-g979ede8 #396

[&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68) from [&lt;c02a23ac&gt;] (__blocking_notifier_call_chain+0x40/0x58)
[&lt;c02a23ac&gt;] (__blocking_notifier_call_chain+0x40/0x58) from [&lt;c02a23d8&gt;] (blocking_notifier_call_chain+0x14/0x1c)
[&lt;c02a23d8&gt;] (blocking_notifier_call_chain+0x14/0x1c) from [&lt;c0803c68&gt;] (cpufreq_set_policy+0xd4/0x2b8)
[&lt;c0803c68&gt;] (cpufreq_set_policy+0xd4/0x2b8) from [&lt;c0803e7c&gt;] (cpufreq_init_policy+0x30/0x98)
[&lt;c0803e7c&gt;] (cpufreq_init_policy+0x30/0x98) from [&lt;c0805a18&gt;] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4)
[&lt;c0805a18&gt;] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4) from [&lt;c0805d38&gt;] (cpufreq_cpu_callback+0x58/0x84)
[&lt;c0805d38&gt;] (cpufreq_cpu_callback+0x58/0x84) from [&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68)
[&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68) from [&lt;c02812dc&gt;] (__cpu_notify+0x28/0x44)
[&lt;c02812dc&gt;] (__cpu_notify+0x28/0x44) from [&lt;c0aeed90&gt;] (_cpu_up+0xf4/0x1dc)
[&lt;c0aeed90&gt;] (_cpu_up+0xf4/0x1dc) from [&lt;c0aeeed4&gt;] (cpu_up+0x5c/0x78)
[&lt;c0aeeed4&gt;] (cpu_up+0x5c/0x78) from [&lt;c0aec808&gt;] (store_online+0x44/0x74)
[&lt;c0aec808&gt;] (store_online+0x44/0x74) from [&lt;c03a40f4&gt;] (sysfs_write_file+0x108/0x14c)
[&lt;c03a40f4&gt;] (sysfs_write_file+0x108/0x14c) from [&lt;c03517d4&gt;] (vfs_write+0xd0/0x180)
[&lt;c03517d4&gt;] (vfs_write+0xd0/0x180) from [&lt;c0351ca8&gt;] (SyS_write+0x38/0x68)
[&lt;c0351ca8&gt;] (SyS_write+0x38/0x68) from [&lt;c0205de0&gt;] (ret_fast_syscall+0x0/0x30)

Fix that by taking locks at appropriate places in __cpufreq_add_dev()
as well.

Reported-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Suggested-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
policy-&gt;rwsem is used to lock access to all parts of code modifying
struct cpufreq_policy, but it's not used on a new policy created by
__cpufreq_add_dev().

Because of that, if cpufreq_update_policy() is called in a tight loop
on one CPU in parallel with offline/online of another CPU, then the
following crash can be triggered:

Unable to handle kernel NULL pointer dereference at virtual address 00000020
pgd = c0003000
[00000020] *pgd=80000000004003, *pmd=00000000
Internal error: Oops: 206 [#1] PREEMPT SMP ARM

PC is at __cpufreq_governor+0x10/0x1ac
LR is at cpufreq_update_policy+0x114/0x150

---[ end trace f23a8defea6cd706 ]---
Kernel panic - not syncing: Fatal exception
CPU0: stopping
CPU: 0 PID: 7136 Comm: mpdecision Tainted: G      D W    3.10.0-gd727407-00074-g979ede8 #396

[&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68) from [&lt;c02a23ac&gt;] (__blocking_notifier_call_chain+0x40/0x58)
[&lt;c02a23ac&gt;] (__blocking_notifier_call_chain+0x40/0x58) from [&lt;c02a23d8&gt;] (blocking_notifier_call_chain+0x14/0x1c)
[&lt;c02a23d8&gt;] (blocking_notifier_call_chain+0x14/0x1c) from [&lt;c0803c68&gt;] (cpufreq_set_policy+0xd4/0x2b8)
[&lt;c0803c68&gt;] (cpufreq_set_policy+0xd4/0x2b8) from [&lt;c0803e7c&gt;] (cpufreq_init_policy+0x30/0x98)
[&lt;c0803e7c&gt;] (cpufreq_init_policy+0x30/0x98) from [&lt;c0805a18&gt;] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4)
[&lt;c0805a18&gt;] (__cpufreq_add_dev.isra.17+0x4dc/0x7a4) from [&lt;c0805d38&gt;] (cpufreq_cpu_callback+0x58/0x84)
[&lt;c0805d38&gt;] (cpufreq_cpu_callback+0x58/0x84) from [&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68)
[&lt;c0afe180&gt;] (notifier_call_chain+0x40/0x68) from [&lt;c02812dc&gt;] (__cpu_notify+0x28/0x44)
[&lt;c02812dc&gt;] (__cpu_notify+0x28/0x44) from [&lt;c0aeed90&gt;] (_cpu_up+0xf4/0x1dc)
[&lt;c0aeed90&gt;] (_cpu_up+0xf4/0x1dc) from [&lt;c0aeeed4&gt;] (cpu_up+0x5c/0x78)
[&lt;c0aeeed4&gt;] (cpu_up+0x5c/0x78) from [&lt;c0aec808&gt;] (store_online+0x44/0x74)
[&lt;c0aec808&gt;] (store_online+0x44/0x74) from [&lt;c03a40f4&gt;] (sysfs_write_file+0x108/0x14c)
[&lt;c03a40f4&gt;] (sysfs_write_file+0x108/0x14c) from [&lt;c03517d4&gt;] (vfs_write+0xd0/0x180)
[&lt;c03517d4&gt;] (vfs_write+0xd0/0x180) from [&lt;c0351ca8&gt;] (SyS_write+0x38/0x68)
[&lt;c0351ca8&gt;] (SyS_write+0x38/0x68) from [&lt;c0205de0&gt;] (ret_fast_syscall+0x0/0x30)

Fix that by taking locks at appropriate places in __cpufreq_add_dev()
as well.

Reported-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Suggested-by: Srivatsa S. Bhat &lt;srivatsa.bhat@linux.vnet.ibm.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: Initialize policy before making it available for others to use</title>
<updated>2014-03-06T12:25:29+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2014-03-04T03:44:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=5a7e56a5d29071bcccd947dee6e3b9f8e4eb3309'/>
<id>5a7e56a5d29071bcccd947dee6e3b9f8e4eb3309</id>
<content type='text'>
Policy must be fully initialized before it is being made available
for use by others. Otherwise cpufreq_cpu_get() would be able to grab
a half initialized policy structure that might not have affected_cpus
(for example) populated. Then, anybody accessing those fields will get
a wrong value and that will lead to unpredictable results.

In order to fix this, do all the necessary initialization before we
make the policy structure available via cpufreq_cpu_get(). That will
guarantee that any code accessing fields of the policy will get
correct data from them.

Reported-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Policy must be fully initialized before it is being made available
for use by others. Otherwise cpufreq_cpu_get() would be able to grab
a half initialized policy structure that might not have affected_cpus
(for example) populated. Then, anybody accessing those fields will get
a wrong value and that will lead to unpredictable results.

In order to fix this, do all the necessary initialization before we
make the policy structure available via cpufreq_cpu_get(). That will
guarantee that any code accessing fields of the policy will get
correct data from them.

Reported-by: Saravana Kannan &lt;skannan@codeaurora.org&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Changelog]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: use cpufreq_cpu_get() to avoid cpufreq_get() race conditions</title>
<updated>2014-03-06T12:25:16+00:00</updated>
<author>
<name>Aaron Plattner</name>
<email>aplattner@nvidia.com</email>
</author>
<published>2014-03-04T20:42:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=999976e0f6233322a878b0b7148c810544d6c8a8'/>
<id>999976e0f6233322a878b0b7148c810544d6c8a8</id>
<content type='text'>
If a module calls cpufreq_get while cpufreq is initializing, it's
possible for it to be called after cpufreq_driver is set but before
cpufreq_cpu_data is written during subsys_interface_register.  This
happens because cpufreq_get doesn't take the cpufreq_driver_lock
around its use of cpufreq_cpu_data.

Fix this by using cpufreq_cpu_get(cpu) to look up the policy rather
than reading it out of cpufreq_cpu_data directly.  cpufreq_cpu_get()
takes the appropriate locks to prevent this race from happening.

Since it's possible for policy to be NULL if the caller passes in an
invalid CPU number or calls the function before cpufreq is initialized,
delete the BUG_ON(!policy) and simply return 0.  Don't try to return
-ENOENT because that's negative and the function returns an unsigned
integer.

References: https://bbs.archlinux.org/viewtopic.php?id=177934
Signed-off-by: Aaron Plattner &lt;aplattner@nvidia.com&gt;
Cc: 3.13+ &lt;stable@vger.kernel.org&gt; # 3.13+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If a module calls cpufreq_get while cpufreq is initializing, it's
possible for it to be called after cpufreq_driver is set but before
cpufreq_cpu_data is written during subsys_interface_register.  This
happens because cpufreq_get doesn't take the cpufreq_driver_lock
around its use of cpufreq_cpu_data.

Fix this by using cpufreq_cpu_get(cpu) to look up the policy rather
than reading it out of cpufreq_cpu_data directly.  cpufreq_cpu_get()
takes the appropriate locks to prevent this race from happening.

Since it's possible for policy to be NULL if the caller passes in an
invalid CPU number or calls the function before cpufreq is initialized,
delete the BUG_ON(!policy) and simply return 0.  Don't try to return
-ENOENT because that's negative and the function returns an unsigned
integer.

References: https://bbs.archlinux.org/viewtopic.php?id=177934
Signed-off-by: Aaron Plattner &lt;aplattner@nvidia.com&gt;
Cc: 3.13+ &lt;stable@vger.kernel.org&gt; # 3.13+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: remove sysfs link when a cpu != policy-&gt;cpu, is removed</title>
<updated>2014-02-19T00:04:40+00:00</updated>
<author>
<name>viresh kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2014-02-17T09:22:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6964d91db2becfe80658f50584d264708ca7f49e'/>
<id>6964d91db2becfe80658f50584d264708ca7f49e</id>
<content type='text'>
Commit 42f921a (cpufreq: remove sysfs files for CPUs which failed to
come back after resume) tried to do this but missed this piece of code
to fix.

Currently we are getting this on suspend/resume:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 877 at fs/sysfs/dir.c:52 sysfs_warn_dup+0x68/0x84()
sysfs: cannot create duplicate filename '/devices/system/cpu/cpu1/cpufreq'
Modules linked in: brcmfmac brcmutil
CPU: 0 PID: 877 Comm: test-rtc-resume Not tainted 3.14.0-rc2-00259-g9398a10cd964 #12
[&lt;c0015bac&gt;] (unwind_backtrace) from [&lt;c0011850&gt;] (show_stack+0x10/0x14)
[&lt;c0011850&gt;] (show_stack) from [&lt;c056e018&gt;] (dump_stack+0x80/0xcc)
[&lt;c056e018&gt;] (dump_stack) from [&lt;c0025e44&gt;] (warn_slowpath_common+0x64/0x88)
[&lt;c0025e44&gt;] (warn_slowpath_common) from [&lt;c0025efc&gt;] (warn_slowpath_fmt+0x30/0x40)
[&lt;c0025efc&gt;] (warn_slowpath_fmt) from [&lt;c012776c&gt;] (sysfs_warn_dup+0x68/0x84)
[&lt;c012776c&gt;] (sysfs_warn_dup) from [&lt;c0127a54&gt;] (sysfs_do_create_link_sd+0xb0/0xb8)
[&lt;c0127a54&gt;] (sysfs_do_create_link_sd) from [&lt;c038ef64&gt;] (__cpufreq_add_dev.isra.27+0x2a8/0x814)
[&lt;c038ef64&gt;] (__cpufreq_add_dev.isra.27) from [&lt;c038f548&gt;] (cpufreq_cpu_callback+0x70/0x8c)
[&lt;c038f548&gt;] (cpufreq_cpu_callback) from [&lt;c0043864&gt;] (notifier_call_chain+0x44/0x84)
[&lt;c0043864&gt;] (notifier_call_chain) from [&lt;c0025f60&gt;] (__cpu_notify+0x28/0x44)
[&lt;c0025f60&gt;] (__cpu_notify) from [&lt;c00261e8&gt;] (_cpu_up+0xf0/0x140)
[&lt;c00261e8&gt;] (_cpu_up) from [&lt;c0569eb8&gt;] (enable_nonboot_cpus+0x68/0xb0)
[&lt;c0569eb8&gt;] (enable_nonboot_cpus) from [&lt;c006339c&gt;] (suspend_devices_and_enter+0x198/0x2dc)
[&lt;c006339c&gt;] (suspend_devices_and_enter) from [&lt;c0063654&gt;] (pm_suspend+0x174/0x1e8)
[&lt;c0063654&gt;] (pm_suspend) from [&lt;c00624e0&gt;] (state_store+0x6c/0xbc)
[&lt;c00624e0&gt;] (state_store) from [&lt;c01fc200&gt;] (kobj_attr_store+0x14/0x20)
[&lt;c01fc200&gt;] (kobj_attr_store) from [&lt;c0126e50&gt;] (sysfs_kf_write+0x44/0x48)
[&lt;c0126e50&gt;] (sysfs_kf_write) from [&lt;c012a274&gt;] (kernfs_fop_write+0xb4/0x14c)
[&lt;c012a274&gt;] (kernfs_fop_write) from [&lt;c00d4818&gt;] (vfs_write+0xa8/0x180)
[&lt;c00d4818&gt;] (vfs_write) from [&lt;c00d4bb8&gt;] (SyS_write+0x3c/0x70)
[&lt;c00d4bb8&gt;] (SyS_write) from [&lt;c000e620&gt;] (ret_fast_syscall+0x0/0x30)
---[ end trace 76969904b614c18f ]---

Fix this by removing sysfs link for cpufreq directory when cpu removed
isn't policy-&gt;cpu.

Revamps: 42f921a (cpufreq: remove sysfs files for CPUs which failed to come back after resume)
Reported-and-tested-by: Stephen Warren &lt;swarren@nvidia.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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Commit 42f921a (cpufreq: remove sysfs files for CPUs which failed to
come back after resume) tried to do this but missed this piece of code
to fix.

Currently we are getting this on suspend/resume:

------------[ cut here ]------------
WARNING: CPU: 0 PID: 877 at fs/sysfs/dir.c:52 sysfs_warn_dup+0x68/0x84()
sysfs: cannot create duplicate filename '/devices/system/cpu/cpu1/cpufreq'
Modules linked in: brcmfmac brcmutil
CPU: 0 PID: 877 Comm: test-rtc-resume Not tainted 3.14.0-rc2-00259-g9398a10cd964 #12
[&lt;c0015bac&gt;] (unwind_backtrace) from [&lt;c0011850&gt;] (show_stack+0x10/0x14)
[&lt;c0011850&gt;] (show_stack) from [&lt;c056e018&gt;] (dump_stack+0x80/0xcc)
[&lt;c056e018&gt;] (dump_stack) from [&lt;c0025e44&gt;] (warn_slowpath_common+0x64/0x88)
[&lt;c0025e44&gt;] (warn_slowpath_common) from [&lt;c0025efc&gt;] (warn_slowpath_fmt+0x30/0x40)
[&lt;c0025efc&gt;] (warn_slowpath_fmt) from [&lt;c012776c&gt;] (sysfs_warn_dup+0x68/0x84)
[&lt;c012776c&gt;] (sysfs_warn_dup) from [&lt;c0127a54&gt;] (sysfs_do_create_link_sd+0xb0/0xb8)
[&lt;c0127a54&gt;] (sysfs_do_create_link_sd) from [&lt;c038ef64&gt;] (__cpufreq_add_dev.isra.27+0x2a8/0x814)
[&lt;c038ef64&gt;] (__cpufreq_add_dev.isra.27) from [&lt;c038f548&gt;] (cpufreq_cpu_callback+0x70/0x8c)
[&lt;c038f548&gt;] (cpufreq_cpu_callback) from [&lt;c0043864&gt;] (notifier_call_chain+0x44/0x84)
[&lt;c0043864&gt;] (notifier_call_chain) from [&lt;c0025f60&gt;] (__cpu_notify+0x28/0x44)
[&lt;c0025f60&gt;] (__cpu_notify) from [&lt;c00261e8&gt;] (_cpu_up+0xf0/0x140)
[&lt;c00261e8&gt;] (_cpu_up) from [&lt;c0569eb8&gt;] (enable_nonboot_cpus+0x68/0xb0)
[&lt;c0569eb8&gt;] (enable_nonboot_cpus) from [&lt;c006339c&gt;] (suspend_devices_and_enter+0x198/0x2dc)
[&lt;c006339c&gt;] (suspend_devices_and_enter) from [&lt;c0063654&gt;] (pm_suspend+0x174/0x1e8)
[&lt;c0063654&gt;] (pm_suspend) from [&lt;c00624e0&gt;] (state_store+0x6c/0xbc)
[&lt;c00624e0&gt;] (state_store) from [&lt;c01fc200&gt;] (kobj_attr_store+0x14/0x20)
[&lt;c01fc200&gt;] (kobj_attr_store) from [&lt;c0126e50&gt;] (sysfs_kf_write+0x44/0x48)
[&lt;c0126e50&gt;] (sysfs_kf_write) from [&lt;c012a274&gt;] (kernfs_fop_write+0xb4/0x14c)
[&lt;c012a274&gt;] (kernfs_fop_write) from [&lt;c00d4818&gt;] (vfs_write+0xa8/0x180)
[&lt;c00d4818&gt;] (vfs_write) from [&lt;c00d4bb8&gt;] (SyS_write+0x3c/0x70)
[&lt;c00d4bb8&gt;] (SyS_write) from [&lt;c000e620&gt;] (ret_fast_syscall+0x0/0x30)
---[ end trace 76969904b614c18f ]---

Fix this by removing sysfs link for cpufreq directory when cpu removed
isn't policy-&gt;cpu.

Revamps: 42f921a (cpufreq: remove sysfs files for CPUs which failed to come back after resume)
Reported-and-tested-by: Stephen Warren &lt;swarren@nvidia.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;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: Add boost frequency support in core</title>
<updated>2014-01-17T01:00:44+00:00</updated>
<author>
<name>Lukasz Majewski</name>
<email>l.majewski@samsung.com</email>
</author>
<published>2013-12-20T14:24:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6f19efc0a1ca08bc61841b971d8b85ab505d95c8'/>
<id>6f19efc0a1ca08bc61841b971d8b85ab505d95c8</id>
<content type='text'>
This commit adds boost frequency support in cpufreq core (Hardware &amp;
Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency
above its normal operation limits. Such mode shall be only used for a
short time.

Overclocking (boost) support is essentially provided by platform
dependent cpufreq driver.

This commit unifies support for SW and HW (Intel) overclocking solutions
in the core cpufreq driver. Previously the "boost" sysfs attribute was
defined in the ACPI processor driver code. By default boost is disabled.
One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.

It only shows up when cpufreq driver supports overclocking.
Under the hood frequencies dedicated for boosting are marked with a
special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table.
It is the user's concern to enable/disable overclocking with a proper call
to sysfs.

The cpufreq_boost_trigger_state() function is defined non static on purpose.
It is used later with thermal subsystem to provide automatic enable/disable
of the BOOST feature.

Signed-off-by: Lukasz Majewski &lt;l.majewski@samsung.com&gt;
Signed-off-by: Myungjoo Ham &lt;myungjoo.ham@samsung.com&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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds boost frequency support in cpufreq core (Hardware &amp;
Software). Some SoCs (like Exynos4 - e.g. 4x12) allow setting frequency
above its normal operation limits. Such mode shall be only used for a
short time.

Overclocking (boost) support is essentially provided by platform
dependent cpufreq driver.

This commit unifies support for SW and HW (Intel) overclocking solutions
in the core cpufreq driver. Previously the "boost" sysfs attribute was
defined in the ACPI processor driver code. By default boost is disabled.
One global attribute is available at: /sys/devices/system/cpu/cpufreq/boost.

It only shows up when cpufreq driver supports overclocking.
Under the hood frequencies dedicated for boosting are marked with a
special flag (CPUFREQ_BOOST_FREQ) at driver's frequency table.
It is the user's concern to enable/disable overclocking with a proper call
to sysfs.

The cpufreq_boost_trigger_state() function is defined non static on purpose.
It is used later with thermal subsystem to provide automatic enable/disable
of the BOOST feature.

Signed-off-by: Lukasz Majewski &lt;l.majewski@samsung.com&gt;
Signed-off-by: Myungjoo Ham &lt;myungjoo.ham@samsung.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: introduce cpufreq_generic_get() routine</title>
<updated>2014-01-17T01:00:44+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2014-01-09T15:08:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=652ed95d5fa6074b3c4ea245deb0691f1acb6656'/>
<id>652ed95d5fa6074b3c4ea245deb0691f1acb6656</id>
<content type='text'>
CPUFreq drivers that use clock frameworks interface,i.e. clk_get_rate(),
to get CPUs clk rate, have similar sort of code used in most of them.

This patch adds a generic -&gt;get() which will do the same thing for them.
All those drivers are required to now is to set .get to cpufreq_generic_get()
and set their clk pointer in policy-&gt;clk during -&gt;init().

Acked-by: Hans-Christian Egtvedt &lt;egtvedt@samfundet.no&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Acked-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Acked-by: Stephen Warren &lt;swarren@nvidia.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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
CPUFreq drivers that use clock frameworks interface,i.e. clk_get_rate(),
to get CPUs clk rate, have similar sort of code used in most of them.

This patch adds a generic -&gt;get() which will do the same thing for them.
All those drivers are required to now is to set .get to cpufreq_generic_get()
and set their clk pointer in policy-&gt;clk during -&gt;init().

Acked-by: Hans-Christian Egtvedt &lt;egtvedt@samfundet.no&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Acked-by: Linus Walleij &lt;linus.walleij@linaro.org&gt;
Acked-by: Shawn Guo &lt;shawn.guo@linaro.org&gt;
Acked-by: Stephen Warren &lt;swarren@nvidia.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;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: stats: handle cpufreq_unregister_driver() and suspend/resume properly</title>
<updated>2014-01-17T01:00:43+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2014-01-07T01:40:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=fcd7af917abba798cd954419030142e95139359f'/>
<id>fcd7af917abba798cd954419030142e95139359f</id>
<content type='text'>
There are several problems with cpufreq stats in the way it handles
cpufreq_unregister_driver() and suspend/resume..

 - We must not lose data collected so far when suspend/resume happens
   and so stats directories must not be removed/allocated during these
   operations, which is done currently.

 - cpufreq_stat has registered notifiers with both cpufreq and hotplug.
   It adds sysfs stats directory with a cpufreq notifier: CPUFREQ_NOTIFY
   and removes this directory with a notifier from hotplug core.

   In case cpufreq_unregister_driver() is called (on rmmod cpufreq driver),
   stats directories per cpu aren't removed as CPUs are still online. The
   only call cpufreq_stats gets is cpufreq_stats_update_policy_cpu() for
   all CPUs except the last of each policy. And pointer to stat information
   is stored in the entry for last CPU in the per-cpu cpufreq_stats_table.
   But policy structure would be freed inside cpufreq core and so that will
   result in memory leak inside cpufreq stats (as we are never freeing
   memory for stats).

   Now if we again insert the module cpufreq_register_driver() will be
   called and we will again allocate stats data and put it on for first
   CPU of every policy.  In case we only have a single CPU per policy, we
   will return with a error from cpufreq_stats_create_table() due to this
   code:

	if (per_cpu(cpufreq_stats_table, cpu))
		return -EBUSY;

   And so probably cpufreq stats directory would not show up anymore (as
   it was added inside last policies-&gt;kobj which doesn't exist anymore).
   I haven't tested it, though. Also the values in stats files wouldn't
   be refreshed as we are using the earlier stats structure.

 - CPUFREQ_NOTIFY is called from cpufreq_set_policy() which is called for
   scenarios where we don't really want cpufreq_stat_notifier_policy() to get
   called. For example whenever we are changing anything related to a policy:
   min/max/current freq, etc. cpufreq_set_policy() is called and so cpufreq
   stats is notified. Where we don't do any useful stuff other than simply
   returning with -EBUSY from cpufreq_stats_create_table(). And so this
   isn't the right notifier that cpufreq stats..

 Due to all above reasons this patch does following changes:
 - Add new notifiers CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY,
   which are only called when policy is created/destroyed. They aren't
   called for suspend/resume paths..
 - Use these notifiers in cpufreq_stat_notifier_policy() to create/destory
   stats sysfs entries. And so cpufreq_unregister_driver() or suspend/resume
   shouldn't be a problem for cpufreq_stats.
 - Return early from cpufreq_stat_cpu_callback() for suspend/resume sequence,
   so that we don't free stats structure.

Acked-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Tested-by: Nicolas Pitre &lt;nico@linaro.org&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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
There are several problems with cpufreq stats in the way it handles
cpufreq_unregister_driver() and suspend/resume..

 - We must not lose data collected so far when suspend/resume happens
   and so stats directories must not be removed/allocated during these
   operations, which is done currently.

 - cpufreq_stat has registered notifiers with both cpufreq and hotplug.
   It adds sysfs stats directory with a cpufreq notifier: CPUFREQ_NOTIFY
   and removes this directory with a notifier from hotplug core.

   In case cpufreq_unregister_driver() is called (on rmmod cpufreq driver),
   stats directories per cpu aren't removed as CPUs are still online. The
   only call cpufreq_stats gets is cpufreq_stats_update_policy_cpu() for
   all CPUs except the last of each policy. And pointer to stat information
   is stored in the entry for last CPU in the per-cpu cpufreq_stats_table.
   But policy structure would be freed inside cpufreq core and so that will
   result in memory leak inside cpufreq stats (as we are never freeing
   memory for stats).

   Now if we again insert the module cpufreq_register_driver() will be
   called and we will again allocate stats data and put it on for first
   CPU of every policy.  In case we only have a single CPU per policy, we
   will return with a error from cpufreq_stats_create_table() due to this
   code:

	if (per_cpu(cpufreq_stats_table, cpu))
		return -EBUSY;

   And so probably cpufreq stats directory would not show up anymore (as
   it was added inside last policies-&gt;kobj which doesn't exist anymore).
   I haven't tested it, though. Also the values in stats files wouldn't
   be refreshed as we are using the earlier stats structure.

 - CPUFREQ_NOTIFY is called from cpufreq_set_policy() which is called for
   scenarios where we don't really want cpufreq_stat_notifier_policy() to get
   called. For example whenever we are changing anything related to a policy:
   min/max/current freq, etc. cpufreq_set_policy() is called and so cpufreq
   stats is notified. Where we don't do any useful stuff other than simply
   returning with -EBUSY from cpufreq_stats_create_table(). And so this
   isn't the right notifier that cpufreq stats..

 Due to all above reasons this patch does following changes:
 - Add new notifiers CPUFREQ_CREATE_POLICY and CPUFREQ_REMOVE_POLICY,
   which are only called when policy is created/destroyed. They aren't
   called for suspend/resume paths..
 - Use these notifiers in cpufreq_stat_notifier_policy() to create/destory
   stats sysfs entries. And so cpufreq_unregister_driver() or suspend/resume
   shouldn't be a problem for cpufreq_stats.
 - Return early from cpufreq_stat_cpu_callback() for suspend/resume sequence,
   so that we don't free stats structure.

Acked-by: Nicolas Pitre &lt;nico@linaro.org&gt;
Tested-by: Nicolas Pitre &lt;nico@linaro.org&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;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: Make sure CPU is running on a freq from freq-table</title>
<updated>2014-01-06T13:17:25+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2013-12-03T05:50:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=d3916691c90dfc9f08328d5cef8181e9ea508c55'/>
<id>d3916691c90dfc9f08328d5cef8181e9ea508c55</id>
<content type='text'>
Sometimes boot loaders set CPU frequency to a value outside of frequency table
present with cpufreq core. In such cases CPU might be unstable if it has to run
on that frequency for long duration of time and so its better to set it to a
frequency which is specified in freq-table. This also makes cpufreq stats
inconsistent as cpufreq-stats would fail to register because current frequency
of CPU isn't found in freq-table.

Because we don't want this change to affect boot process badly, we go for the
next freq which is &gt;= policy-&gt;cur ('cur' must be set by now, otherwise we will
end up setting freq to lowest of the table as 'cur' is initialized to zero).

In case current frequency doesn't match any frequency from freq-table, we throw
warnings to user, so that user can get this fixed in their bootloaders or
freq-tables.

Reported-by: Carlos Hernandez &lt;ceh@ti.com&gt;
Reported-and-tested-by: Nishanth Menon &lt;nm@ti.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>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Sometimes boot loaders set CPU frequency to a value outside of frequency table
present with cpufreq core. In such cases CPU might be unstable if it has to run
on that frequency for long duration of time and so its better to set it to a
frequency which is specified in freq-table. This also makes cpufreq stats
inconsistent as cpufreq-stats would fail to register because current frequency
of CPU isn't found in freq-table.

Because we don't want this change to affect boot process badly, we go for the
next freq which is &gt;= policy-&gt;cur ('cur' must be set by now, otherwise we will
end up setting freq to lowest of the table as 'cur' is initialized to zero).

In case current frequency doesn't match any frequency from freq-table, we throw
warnings to user, so that user can get this fixed in their bootloaders or
freq-tables.

Reported-by: Carlos Hernandez &lt;ceh@ti.com&gt;
Reported-and-tested-by: Nishanth Menon &lt;nm@ti.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;
</pre>
</div>
</content>
</entry>
<entry>
<title>cpufreq: send new set of notification for transition failures</title>
<updated>2014-01-06T00:43:44+00:00</updated>
<author>
<name>Viresh Kumar</name>
<email>viresh.kumar@linaro.org</email>
</author>
<published>2013-12-02T05:34:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=ab1b1c4e8223f9ee66aa93aaf64c36e77cadffac'/>
<id>ab1b1c4e8223f9ee66aa93aaf64c36e77cadffac</id>
<content type='text'>
In the current code, if we fail during a frequency transition, we
simply send the POSTCHANGE notification with the old frequency. This
isn't enough.

One of the core users of these notifications is the code responsible
for keeping loops_per_jiffy aligned with frequency changes. And mostly
it is written as:

	if ((val == CPUFREQ_PRECHANGE  &amp;&amp; freq-&gt;old &lt; freq-&gt;new) ||
	    (val == CPUFREQ_POSTCHANGE &amp;&amp; freq-&gt;old &gt; freq-&gt;new)) {
		update-loops-per-jiffy...
	}

So, suppose we are changing to a higher frequency and failed during
transition, then following will happen:
- CPUFREQ_PRECHANGE notification with freq-new &gt; freq-old
- CPUFREQ_POSTCHANGE notification with freq-new == freq-old

The first one will update loops_per_jiffy and second one will do
nothing. Even if we send the 2nd notification by exchanging values of
freq-new and old, some users of these notifications might get
unstable.

This can be fixed by simply calling cpufreq_notify_post_transition()
with error code and this routine will take care of sending
notifications in the correct order.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Folded 3 patches into one, rebased unicore2 changes]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the current code, if we fail during a frequency transition, we
simply send the POSTCHANGE notification with the old frequency. This
isn't enough.

One of the core users of these notifications is the code responsible
for keeping loops_per_jiffy aligned with frequency changes. And mostly
it is written as:

	if ((val == CPUFREQ_PRECHANGE  &amp;&amp; freq-&gt;old &lt; freq-&gt;new) ||
	    (val == CPUFREQ_POSTCHANGE &amp;&amp; freq-&gt;old &gt; freq-&gt;new)) {
		update-loops-per-jiffy...
	}

So, suppose we are changing to a higher frequency and failed during
transition, then following will happen:
- CPUFREQ_PRECHANGE notification with freq-new &gt; freq-old
- CPUFREQ_POSTCHANGE notification with freq-new == freq-old

The first one will update loops_per_jiffy and second one will do
nothing. Even if we send the 2nd notification by exchanging values of
freq-new and old, some users of these notifications might get
unstable.

This can be fixed by simply calling cpufreq_notify_post_transition()
with error code and this routine will take care of sending
notifications in the correct order.

Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
[rjw: Folded 3 patches into one, rebased unicore2 changes]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
