From 171f4d6320d97f46cf68e030b0435c60c357296c Mon Sep 17 00:00:00 2001 From: Liang Chen Date: Sat, 7 Jan 2023 06:23:19 +0800 Subject: [PATCH] cpufreq: interactive: fix deadlock on touchboost Call trace: __switch_to+0xe4/0x138 __schedule+0x2f4/0x930 schedule+0x38/0xa0 rwsem_down_write_failed+0x12c/0x248 down_write+0x48/0x60 ------lock(&policy->rwsem) cpufreq_update_policy+0x40/0xf8 cpufreq_interactive_speedchange_task+0x3a8/0x408 ------lock(&icpu->enable_sem) kthread+0x12c/0x158 ret_from_fork+0x10/0x18 Call trace: __switch_to+0xe4/0x138 __schedule+0x2f4/0x930 schedule+0x38/0xa0 rwsem_down_write_failed+0x12c/0x248 down_write+0x48/0x60 ------lock(&icpu->enable_sem) cpufreq_interactive_stop+0x8c/0xe8 cpufreq_stop_governor.part.2+0x1c/0x30 cpufreq_set_policy+0x250/0x290 store_scaling_governor+0x84/0xe0 store+0xa8/0xc8 ------lock(&policy->rwsem) sysfs_kf_write+0x48/0x58 kernfs_fop_write+0xf4/0x220 __vfs_write+0x34/0x158 vfs_write+0xb0/0x1d0 ksys_write+0x64/0xe0 __arm64_sys_write+0x14/0x20 el0_svc_common.constprop.0+0x64/0x178 el0_svc_handler+0x28/0x78 el0_svc+0x8/0xc Fixes: f54f7a44b273 ("cpufreq: interactive: set rockchip system monitor boosted when touchboost") Signed-off-by: Liang Chen Change-Id: Ie4a6c3cdc41493d868aed32fca4de7da8815c778 --- drivers/cpufreq/cpufreq_interactive.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/cpufreq_interactive.c b/drivers/cpufreq/cpufreq_interactive.c index baf8d4046c47..83db0bc4fb42 100644 --- a/drivers/cpufreq/cpufreq_interactive.c +++ b/drivers/cpufreq/cpufreq_interactive.c @@ -610,6 +610,7 @@ again: struct cpufreq_policy *policy; #ifdef CONFIG_ARCH_ROCKCHIP struct interactive_tunables *tunables; + bool update_policy = false; u64 now; now = ktime_to_us(ktime_get()); @@ -631,17 +632,19 @@ again: now > tunables->touchboostpulse_endtime) { tunables->touchboost = false; rockchip_monitor_clear_boosted(); - cpufreq_update_policy(cpu); + update_policy = true; } if (!tunables->is_touchboosted && tunables->touchboost) { rockchip_monitor_set_boosted(); - cpufreq_update_policy(cpu); + update_policy = true; } tunables->is_touchboosted = tunables->touchboost; up_read(&icpu->enable_sem); + if (update_policy) + cpufreq_update_policy(cpu); #endif policy = cpufreq_cpu_get(cpu); if (!policy)