Skip to content

Commit

Permalink
soc: rockchip: opp_select: add missing rcu lock
Browse files Browse the repository at this point in the history
===============================
[ INFO: suspicious RCU usage. ]
4.4.120 #194 Not tainted
-------------------------------
drivers/base/power/opp/core.c:453 Missing rcu_read_lock() or opp_table_lock protection!

other info that might help us debug this:

rcu_scheduler_active = 1, debug_locks = 1
3 locks held by swapper/0/1:
 #0:  (&dev->mutex){......}, at: [<ffffff80082bf1e0>] __device_attach+0x28/0x104
 #1:  (cpu_hotplug.lock){++++++}, at: [<ffffff800809aac0>] get_online_cpus+0x38/0x9c
 #2:  (subsys mutex#6){+.+.+.}, at: [<ffffff80082be46c>] subsys_interface_register+0x38/0xc4

stack backtrace:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.4.120 #194
Hardware name: Rockchip RK3308 evb digital-pdm mic board (DT)
Call trace:
[<ffffff8008087f08>] dump_backtrace+0x0/0x1b8
[<ffffff80080880d4>] show_stack+0x14/0x1c
[<ffffff800820ac14>] dump_stack+0xa8/0xe8
[<ffffff80080d82d8>] lockdep_rcu_suspicious+0xe4/0x10c
[<ffffff80082ce72c>] dev_pm_opp_find_freq_ceil+0x6c/0x108
[<ffffff800824d84c>] rockchip_adjust_opp_by_irdrop+0xf4/0x1e8
[<ffffff80083a66fc>] cpufreq_init+0x134/0x414
[<ffffff80083a0eec>] cpufreq_online+0x1b4/0x68c
[<ffffff80083a1464>] cpufreq_add_dev+0x3c/0x94
[<ffffff80082be4dc>] subsys_interface_register+0xa8/0xc4
[<ffffff80083a1700>] cpufreq_register_driver+0x10c/0x1a8
[<ffffff80083a6aa8>] dt_cpufreq_probe+0xcc/0xe8
[<ffffff80082c0db4>] platform_drv_probe+0x54/0xa8
[<ffffff80082bf478>] driver_probe_device+0x188/0x26c
[<ffffff80082bf694>] __device_attach_driver+0x60/0x9c
[<ffffff80082bda4c>] bus_for_each_drv+0x84/0x94
[<ffffff80082bf264>] __device_attach+0xac/0x104
[<ffffff80082bf80c>] device_initial_probe+0x10/0x18
[<ffffff80082be8e4>] bus_probe_device+0x2c/0x90
[<ffffff80082bcd48>] device_add+0x434/0x4dc
[<ffffff80082c0ad0>] platform_device_add+0xa0/0x1e4
[<ffffff80082c1520>] platform_device_register_full+0xa0/0xe0
[<ffffff800882512c>] rockchip_cpufreq_driver_init+0xb4/0x360
[<ffffff800808312c>] do_one_initcall+0xe8/0x194
[<ffffff8008810cec>] kernel_init_freeable+0x1d0/0x1d4
[<ffffff80085b8fa4>] kernel_init+0x14/0x148
[<ffffff8008082ee0>] ret_from_fork+0x10/0x30

Note: we should use dev_pm_opp_put on new kernel.

Change-Id: I39e85892f6e7994bbe4816d09e4446de5cd25cad
Signed-off-by: Tao Huang <[email protected]>
  • Loading branch information
rkhuangtao committed Mar 27, 2018
1 parent dcda0fb commit 197a2d3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/soc/rockchip/rockchip_opp_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <linux/soc/rockchip/pvtm.h>
#include <linux/thermal.h>
#include <linux/pm_opp.h>
#include <linux/version.h>
#include <soc/rockchip/rockchip_opp_select.h>

#include "../../clk/rockchip/clk.h"
Expand Down Expand Up @@ -384,6 +385,9 @@ int rockchip_adjust_opp_by_irdrop(struct device *dev)
of_property_read_u32_index(np, "rockchip,max-volt", 0, &max_volt);
of_property_read_u32_index(np, "rockchip,evb-irdrop", 0, &evb_irdrop);

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
rcu_read_lock();
#endif
count = dev_pm_opp_get_opp_count(dev);
if (count <= 0) {
ret = count ? count : -ENODATA;
Expand Down Expand Up @@ -427,6 +431,9 @@ int rockchip_adjust_opp_by_irdrop(struct device *dev)
}
}
out:
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
rcu_read_unlock();
#endif
of_node_put(np);
return ret;
}
Expand Down

0 comments on commit 197a2d3

Please sign in to comment.