Skip to content

Commit

Permalink
drm/msm/gpu: Cancel idle/boost work on suspend
Browse files Browse the repository at this point in the history
With system suspend using pm_runtime_force_suspend() we can't rely on
the pm_runtime_get_if_in_use() trick to deal with devfreq callbacks
after (or racing with) suspend.  So flush any pending idle or boost
work in the suspend path.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Link: https://lore.kernel.org/r/20220108180913.814448-3-robdclark@gmail.com
Signed-off-by: Rob Clark <robdclark@chromium.org>
  • Loading branch information
Rob Clark committed Jan 25, 2022
1 parent 167a668 commit 6aa89ae
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions drivers/gpu/drm/msm/msm_gpu_devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ void msm_devfreq_init(struct msm_gpu *gpu)
CLOCK_MONOTONIC, HRTIMER_MODE_REL);
}

static void cancel_idle_work(struct msm_gpu_devfreq *df)
{
hrtimer_cancel(&df->idle_work.timer);
kthread_cancel_work_sync(&df->idle_work.work);
}

static void cancel_boost_work(struct msm_gpu_devfreq *df)
{
hrtimer_cancel(&df->boost_work.timer);
kthread_cancel_work_sync(&df->boost_work.work);
}

void msm_devfreq_cleanup(struct msm_gpu *gpu)
{
struct msm_gpu_devfreq *df = &gpu->devfreq;
Expand All @@ -152,7 +164,12 @@ void msm_devfreq_resume(struct msm_gpu *gpu)

void msm_devfreq_suspend(struct msm_gpu *gpu)
{
devfreq_suspend_device(gpu->devfreq.devfreq);
struct msm_gpu_devfreq *df = &gpu->devfreq;

devfreq_suspend_device(df->devfreq);

cancel_idle_work(df);
cancel_boost_work(df);
}

static void msm_devfreq_boost_work(struct kthread_work *work)
Expand Down Expand Up @@ -196,7 +213,7 @@ void msm_devfreq_active(struct msm_gpu *gpu)
/*
* Cancel any pending transition to idle frequency:
*/
hrtimer_cancel(&df->idle_work.timer);
cancel_idle_work(df);

idle_time = ktime_to_ms(ktime_sub(ktime_get(), df->idle_time));

Expand Down

0 comments on commit 6aa89ae

Please sign in to comment.