From 3de126898c047dd37c0151f562ab29dd85d635ed Mon Sep 17 00:00:00 2001 From: Amir Vajid Date: Wed, 11 Mar 2020 23:26:09 -0700 Subject: [PATCH] PM / devfreq: memlat: fix suspend/resume calls to devfreq_monitor The memlat governor suspend/resume callbacks always call devfreq_monitor suspend/resume functions. The devfreq_monitor suspend/resume functions run with the assumption that we had started devfreq->work and do a sync wait to cancel it. However, when should_ignore_df_monitor flag is set, memlat relies on its own workqueue and devfreq->work is never started. Cancelling a timer that was never started leads to a crash. Fix this by only calling devfreq_monitor suspend/resume functions when the should_ignore_df_monitor flag is not set. Change-Id: Ie4aff96b6b845f4f5424652943405a572b91b8ca Signed-off-by: Amir Vajid --- drivers/devfreq/governor_memlat.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/governor_memlat.c b/drivers/devfreq/governor_memlat.c index dc7ec7e22368..02b1bf5fdf0e 100644 --- a/drivers/devfreq/governor_memlat.c +++ b/drivers/devfreq/governor_memlat.c @@ -208,10 +208,12 @@ err_start: static int gov_suspend(struct devfreq *df) { struct memlat_node *node = df->data; + struct memlat_hwmon *hw = node->hw; unsigned long prev_freq = df->previous_freq; node->mon_started = false; - devfreq_monitor_suspend(df); + if (!hw->should_ignore_df_monitor) + devfreq_monitor_suspend(df); mutex_lock(&df->lock); update_devfreq(df); @@ -225,6 +227,7 @@ static int gov_suspend(struct devfreq *df) static int gov_resume(struct devfreq *df) { struct memlat_node *node = df->data; + struct memlat_hwmon *hw = node->hw; mutex_lock(&df->lock); update_devfreq(df); @@ -232,7 +235,8 @@ static int gov_resume(struct devfreq *df) node->resume_freq = 0; - devfreq_monitor_resume(df); + if (!hw->should_ignore_df_monitor) + devfreq_monitor_resume(df); node->mon_started = true; return 0;