<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/cpufreq/cpufreq.c, branch linux-3.14.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-3.14.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2015-03-06T22:43:23Z</updated>
<entry>
<title>cpufreq: Set cpufreq_cpu_data to NULL before putting kobject</title>
<updated>2015-03-06T22:43:23Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2015-01-31T00:32:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=42cd4f25af84038552f7d28db87e4b8cdff5a420'/>
<id>urn:sha1:42cd4f25af84038552f7d28db87e4b8cdff5a420</id>
<content type='text'>
commit 6ffae8c06fab058d6c3f8ecb7f921327721034e7 upstream.

In __cpufreq_remove_dev_finish(), per-cpu 'cpufreq_cpu_data' needs
to be cleared before calling kobject_put(&amp;policy-&gt;kobj) and under
cpufreq_driver_lock. Otherwise, if someone else calls cpufreq_cpu_get()
in parallel with it, they can obtain a non-NULL policy from that after
kobject_put(&amp;policy-&gt;kobj) was executed.

Consider this case:

Thread A				Thread B
cpufreq_cpu_get()
  acquire cpufreq_driver_lock
  read-per-cpu cpufreq_cpu_data
					kobject_put(&amp;policy-&gt;kobj);
  kobject_get(&amp;policy-&gt;kobj);
					...
					per_cpu(&amp;cpufreq_cpu_data, cpu) = NULL

And this will result in a warning like this one:

 ------------[ cut here ]------------
 WARNING: CPU: 0 PID: 4 at include/linux/kref.h:47
 kobject_get+0x41/0x50()
 Modules linked in: acpi_cpufreq(+) nfsd auth_rpcgss nfs_acl
 lockd grace sunrpc xfs libcrc32c sd_mod ixgbe igb mdio ahci hwmon
 ...
 Call Trace:
  [&lt;ffffffff81661b14&gt;] dump_stack+0x46/0x58
  [&lt;ffffffff81072b61&gt;] warn_slowpath_common+0x81/0xa0
  [&lt;ffffffff81072c7a&gt;] warn_slowpath_null+0x1a/0x20
  [&lt;ffffffff812e16d1&gt;] kobject_get+0x41/0x50
  [&lt;ffffffff815262a5&gt;] cpufreq_cpu_get+0x75/0xc0
  [&lt;ffffffff81527c3e&gt;] cpufreq_update_policy+0x2e/0x1f0
  [&lt;ffffffff810b8cb2&gt;] ? up+0x32/0x50
  [&lt;ffffffff81381aa9&gt;] ? acpi_ns_get_node+0xcb/0xf2
  [&lt;ffffffff81381efd&gt;] ? acpi_evaluate_object+0x22c/0x252
  [&lt;ffffffff813824f6&gt;] ? acpi_get_handle+0x95/0xc0
  [&lt;ffffffff81360967&gt;] ? acpi_has_method+0x25/0x40
  [&lt;ffffffff81391e08&gt;] acpi_processor_ppc_has_changed+0x77/0x82
  [&lt;ffffffff81089566&gt;] ? move_linked_works+0x66/0x90
  [&lt;ffffffff8138e8ed&gt;] acpi_processor_notify+0x58/0xe7
  [&lt;ffffffff8137410c&gt;] acpi_ev_notify_dispatch+0x44/0x5c
  [&lt;ffffffff8135f293&gt;] acpi_os_execute_deferred+0x15/0x22
  [&lt;ffffffff8108c910&gt;] process_one_work+0x160/0x410
  [&lt;ffffffff8108d05b&gt;] worker_thread+0x11b/0x520
  [&lt;ffffffff8108cf40&gt;] ? rescuer_thread+0x380/0x380
  [&lt;ffffffff81092421&gt;] kthread+0xe1/0x100
  [&lt;ffffffff81092340&gt;] ? kthread_create_on_node+0x1b0/0x1b0
  [&lt;ffffffff81669ebc&gt;] ret_from_fork+0x7c/0xb0
  [&lt;ffffffff81092340&gt;] ? kthread_create_on_node+0x1b0/0x1b0
 ---[ end trace 89e66eb9795efdf7 ]---

The actual code flow is as follows:

 Thread A: Workqueue: kacpi_notify

 acpi_processor_notify()
   acpi_processor_ppc_has_changed()
         cpufreq_update_policy()
           cpufreq_cpu_get()
             kobject_get()

 Thread B: xenbus_thread()

 xenbus_thread()
   msg-&gt;u.watch.handle-&gt;callback()
     handle_vcpu_hotplug_event()
       vcpu_hotplug()
         cpu_down()
           __cpu_notify(CPU_POST_DEAD..)
             cpufreq_cpu_callback()
               __cpufreq_remove_dev_finish()
                 cpufreq_policy_put_kobj()
                   kobject_put()

cpufreq_cpu_get() gets the policy from per-cpu variable cpufreq_cpu_data
under cpufreq_driver_lock, and once it gets a valid policy it expects it
to not be freed until cpufreq_cpu_put() is called.

But the race happens when another thread puts the kobject first and updates
cpufreq_cpu_data before or later. And so the first thread gets a valid policy
structure and before it does kobject_get() on it, the second one has already
done kobject_put().

Fix this by setting cpufreq_cpu_data to NULL before putting the kobject and that
too under locks.

Reported-by: Ethan Zhao &lt;ethan.zhao@oracle.com&gt;
Reported-by: Santosh Shilimkar &lt;santosh.shilimkar@oracle.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>cpufreq: expose scaling_cur_freq sysfs file for set_policy() drivers</title>
<updated>2014-11-14T16:59:59Z</updated>
<author>
<name>Dirk Brandewie</name>
</author>
<published>2014-10-13T15:37:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ff97584461314a3ded5937ebaf936bac7ba1e13d'/>
<id>urn:sha1:ff97584461314a3ded5937ebaf936bac7ba1e13d</id>
<content type='text'>
commit c034b02e213d271b98c45c4a7b54af8f69aaac1e upstream.

Currently the core does not expose scaling_cur_freq for set_policy()
drivers this breaks some userspace monitoring tools.
Change the core to expose this file for all drivers and if the
set_policy() driver supports the get() callback use it to retrieve the
current frequency.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=73741
Signed-off-by: Dirk Brandewie &lt;dirk.j.brandewie@intel.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: release policy-&gt;rwsem on error</title>
<updated>2014-10-05T21:52:22Z</updated>
<author>
<name>Prarit Bhargava</name>
</author>
<published>2014-09-10T14:12:08Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=c9bf87daad34a80e4f742a94238cf8449e444add'/>
<id>urn:sha1:c9bf87daad34a80e4f742a94238cf8449e444add</id>
<content type='text'>
commit 7106e02baed4a72fb23de56b02ad4d31daa74d95 upstream.

While debugging a cpufreq-related hardware failure on a system I saw the
following lockdep warning:

 =========================
 [ BUG: held lock freed! ] 3.17.0-rc4+ #1 Tainted: G            E
 -------------------------
 insmod/2247 is freeing memory ffff88006e1b1400-ffff88006e1b17ff, with a lock still held there!
  (&amp;policy-&gt;rwsem){+.+...}, at: [&lt;ffffffff8156d37d&gt;] __cpufreq_add_dev.isra.21+0x47d/0xb80
 3 locks held by insmod/2247:
  #0:  (subsys mutex#5){+.+.+.}, at: [&lt;ffffffff81485579&gt;] subsys_interface_register+0x69/0x120
  #1:  (cpufreq_rwsem){.+.+.+}, at: [&lt;ffffffff8156cf73&gt;] __cpufreq_add_dev.isra.21+0x73/0xb80
  #2:  (&amp;policy-&gt;rwsem){+.+...}, at: [&lt;ffffffff8156d37d&gt;] __cpufreq_add_dev.isra.21+0x47d/0xb80

 stack backtrace:
 CPU: 0 PID: 2247 Comm: insmod Tainted: G            E  3.17.0-rc4+ #1
 Hardware name: HP ProLiant MicroServer Gen8, BIOS J06 08/24/2013
  0000000000000000 000000008f3063c4 ffff88006f87bb30 ffffffff8171b358
  ffff88006bcf3750 ffff88006f87bb68 ffffffff810e09e1 ffff88006e1b1400
  ffffea0001b86c00 ffffffff8156d327 ffff880073003500 0000000000000246
 Call Trace:
  [&lt;ffffffff8171b358&gt;] dump_stack+0x4d/0x66
  [&lt;ffffffff810e09e1&gt;] debug_check_no_locks_freed+0x171/0x180
  [&lt;ffffffff8156d327&gt;] ? __cpufreq_add_dev.isra.21+0x427/0xb80
  [&lt;ffffffff8121412b&gt;] kfree+0xab/0x2b0
  [&lt;ffffffff8156d327&gt;] __cpufreq_add_dev.isra.21+0x427/0xb80
  [&lt;ffffffff81724cf7&gt;] ? _raw_spin_unlock+0x27/0x40
  [&lt;ffffffffa003517f&gt;] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq]
  [&lt;ffffffff8156da8e&gt;] cpufreq_add_dev+0xe/0x10
  [&lt;ffffffff814855d1&gt;] subsys_interface_register+0xc1/0x120
  [&lt;ffffffff8156bcf2&gt;] cpufreq_register_driver+0x112/0x340
  [&lt;ffffffff8121415a&gt;] ? kfree+0xda/0x2b0
  [&lt;ffffffffa003517f&gt;] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq]
  [&lt;ffffffffa003562e&gt;] pcc_cpufreq_init+0x4af/0xe81 [pcc_cpufreq]
  [&lt;ffffffffa003517f&gt;] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq]
  [&lt;ffffffff81002144&gt;] do_one_initcall+0xd4/0x210
  [&lt;ffffffff811f7472&gt;] ? __vunmap+0xd2/0x120
  [&lt;ffffffff81127155&gt;] load_module+0x1315/0x1b70
  [&lt;ffffffff811222a0&gt;] ? store_uevent+0x70/0x70
  [&lt;ffffffff811229d9&gt;] ? copy_module_from_fd.isra.44+0x129/0x180
  [&lt;ffffffff81127b86&gt;] SyS_finit_module+0xa6/0xd0
  [&lt;ffffffff81725b69&gt;] system_call_fastpath+0x16/0x1b
 cpufreq: __cpufreq_add_dev: -&gt;get() failed
insmod: ERROR: could not insert module pcc-cpufreq.ko: No such device

The warning occurs in the __cpufreq_add_dev() code which does

        down_write(&amp;policy-&gt;rwsem);
	...
        if (cpufreq_driver-&gt;get &amp;&amp; !cpufreq_driver-&gt;setpolicy) {
                policy-&gt;cur = cpufreq_driver-&gt;get(policy-&gt;cpu);
                if (!policy-&gt;cur) {
                        pr_err("%s: -&gt;get() failed\n", __func__);
                        goto err_get_freq;
                }

If cpufreq_driver-&gt;get(policy-&gt;cpu) returns an error we execute the
code at err_get_freq, which does not up the policy-&gt;rwsem.  This causes
the lockdep warning.

Trivial patch to up the policy-&gt;rwsem in the error path.

After the patch has been applied, and an error occurs in the
cpufreq_driver-&gt;get(policy-&gt;cpu) call we will now see

cpufreq: __cpufreq_add_dev: -&gt;get() failed
cpufreq: __cpufreq_add_dev: -&gt;get() failed
modprobe: ERROR: could not insert 'pcc_cpufreq': No such device

Fixes: 4e97b631f24c (cpufreq: Initialize governor for a new policy under policy-&gt;rwsem)
Signed-off-by: Prarit Bhargava &lt;prarit@redhat.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;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>cpufreq: move policy kobj to policy-&gt;cpu at resume</title>
<updated>2014-08-07T21:52:38Z</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=04fe5c13847a0ba1b3620af2782c6a10f4d88243'/>
<id>urn:sha1:04fe5c13847a0ba1b3620af2782c6a10f4d88243</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)
Cc:  3.13+ &lt;stable@vger.kernel.org&gt; # 3.13+
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: Skip current frequency initialization for -&gt;setpolicy drivers</title>
<updated>2014-03-12T23:37:16Z</updated>
<author>
<name>Rafael J. Wysocki</name>
</author>
<published>2014-03-12T20:49:33Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=2ed99e39cb9392312c100d9da591c20641c64d12'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>cpufreq: Initialize governor for a new policy under policy-&gt;rwsem</title>
<updated>2014-03-06T12:25:30Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-04T03:44:01Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4e97b631f24c927b2302368f4f83efbba82076ee'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>cpufreq: Initialize policy before making it available for others to use</title>
<updated>2014-03-06T12:25:29Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2014-03-04T03:44:00Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5a7e56a5d29071bcccd947dee6e3b9f8e4eb3309'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>cpufreq: use cpufreq_cpu_get() to avoid cpufreq_get() race conditions</title>
<updated>2014-03-06T12:25:16Z</updated>
<author>
<name>Aaron Plattner</name>
</author>
<published>2014-03-04T20:42:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=999976e0f6233322a878b0b7148c810544d6c8a8'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>cpufreq: remove sysfs link when a cpu != policy-&gt;cpu, is removed</title>
<updated>2014-02-19T00:04:40Z</updated>
<author>
<name>viresh kumar</name>
</author>
<published>2014-02-17T09:22:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6964d91db2becfe80658f50584d264708ca7f49e'/>
<id>urn:sha1: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>
</entry>
<entry>
<title>cpufreq: Add boost frequency support in core</title>
<updated>2014-01-17T01:00:44Z</updated>
<author>
<name>Lukasz Majewski</name>
</author>
<published>2013-12-20T14:24:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6f19efc0a1ca08bc61841b971d8b85ab505d95c8'/>
<id>urn:sha1: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>
</entry>
</feed>
