From 197a2d322ade9d40fa8eda88ecceaadb5b60c535 Mon Sep 17 00:00:00 2001 From: Tao Huang Date: Tue, 27 Mar 2018 18:59:59 +0800 Subject: [PATCH] soc: rockchip: opp_select: add missing rcu lock =============================== [ 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: [] __device_attach+0x28/0x104 #1: (cpu_hotplug.lock){++++++}, at: [] get_online_cpus+0x38/0x9c #2: (subsys mutex#6){+.+.+.}, at: [] 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: [] dump_backtrace+0x0/0x1b8 [] show_stack+0x14/0x1c [] dump_stack+0xa8/0xe8 [] lockdep_rcu_suspicious+0xe4/0x10c [] dev_pm_opp_find_freq_ceil+0x6c/0x108 [] rockchip_adjust_opp_by_irdrop+0xf4/0x1e8 [] cpufreq_init+0x134/0x414 [] cpufreq_online+0x1b4/0x68c [] cpufreq_add_dev+0x3c/0x94 [] subsys_interface_register+0xa8/0xc4 [] cpufreq_register_driver+0x10c/0x1a8 [] dt_cpufreq_probe+0xcc/0xe8 [] platform_drv_probe+0x54/0xa8 [] driver_probe_device+0x188/0x26c [] __device_attach_driver+0x60/0x9c [] bus_for_each_drv+0x84/0x94 [] __device_attach+0xac/0x104 [] device_initial_probe+0x10/0x18 [] bus_probe_device+0x2c/0x90 [] device_add+0x434/0x4dc [] platform_device_add+0xa0/0x1e4 [] platform_device_register_full+0xa0/0xe0 [] rockchip_cpufreq_driver_init+0xb4/0x360 [] do_one_initcall+0xe8/0x194 [] kernel_init_freeable+0x1d0/0x1d4 [] kernel_init+0x14/0x148 [] ret_from_fork+0x10/0x30 Note: we should use dev_pm_opp_put on new kernel. Change-Id: I39e85892f6e7994bbe4816d09e4446de5cd25cad Signed-off-by: Tao Huang --- drivers/soc/rockchip/rockchip_opp_select.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/soc/rockchip/rockchip_opp_select.c b/drivers/soc/rockchip/rockchip_opp_select.c index 0f34a4b5f0a0..9f52a53f922e 100644 --- a/drivers/soc/rockchip/rockchip_opp_select.c +++ b/drivers/soc/rockchip/rockchip_opp_select.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "../../clk/rockchip/clk.h" @@ -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; @@ -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; }