Re: [PATCH 7/8] cpufreq: mediatek: add opp notification for SVS support

Hsin-Yi Wang
2019-05-27T07:03:04Z

On Thu, May 16, 2019 at 9:08 AM Andrew-sh.Cheng
<andrew-sh.cheng@mediatek.com> wrote:
> bool need_voltage_tracking;
> + struct mutex lock; /* avoid notify and policy race condition */
> + struct notifier_block opp_nb;
> + int opp_cpu;
> + unsigned long opp_freq;
> };
>
> static LIST_HEAD(dvfs_info_list);
> @@ -239,6 +243,7 @@ static int mtk_cpufreq_set_target(struct cpufreq_policy *policy,
> vproc = dev_pm_opp_get_voltage(opp);
> dev_pm_opp_put(opp);
>
> + mutex_lock(&info->lock);

Should init mutex, otherwise it'll get lockdep warning:
[ 0.587055] Call trace:
[ 0.587069] dump_backtrace+0x0/0x168
[ 0.587077] show_stack+0x20/0x2c
[ 0.587086] dump_stack+0xe4/0x134
[ 0.587095] register_lock_class+0x3e8/0x4b0
[ 0.587103] __lock_acquire+0xac/0x14e8
[ 0.587110] lock_acquire+0x1d0/0x208
[ 0.587118] __mutex_lock_common+0xc0/0xb40
[ 0.587126] mutex_lock_nested+0x40/0x50
[ 0.587135] mtk_cpufreq_set_target+0xcc/0x2a8
[ 0.587143] __cpufreq_driver_target+0x438/0x4d8
[ 0.587150] cpufreq_online+0x5b4/0x6e0
[ 0.587156] cpufreq_add_dev+0x4c/0x84
[ 0.587164] subsys_interface_register+0xb8/0x10c
[ 0.587171] cpufreq_register_driver+0x11c/0x1c0
[ 0.587178] mtk_cpufreq_probe+0x378/0x4b8
[ 0.587185] platform_drv_probe+0x80/0xb0
[ 0.587192] really_probe+0x114/0x28c
[ 0.587198] driver_probe_device+0x64/0xfc
[ 0.587205] __device_attach_driver+0xb8/0xd0
[ 0.587211] bus_for_each_drv+0x88/0xd0
[ 0.587218] __device_attach+0xb0/0x134
[ 0.587224] device_initial_probe+0x20/0x2c
[ 0.587230] bus_probe_device+0x34/0x94
[ 0.587238] device_add+0x520/0x5b4
[ 0.587245] platform_device_add+0x17c/0x208
[ 0.587252] platform_device_register_full+0xc0/0x100
[ 0.587261] mtk_cpufreq_driver_init+0x8c/0xdc
[ 0.587268] do_one_initcall+0x1c0/0x3e0
[ 0.587276] do_initcall_level+0x1f4/0x224
[ 0.587282] do_basic_setup+0x34/0x4c
[ 0.587288] kernel_init_freeable+0x10c/0x194
[ 0.587295] kernel_init+0x14/0x100
[ 0.587302] ret_from_fork+0x10/0x18
[ 0.587510] cpufreq: cpufreq_online: CPU4: Unlisted initial
frequency changed to: 1248000 KHz