Skip to content

Commit 05afd57

Browse files
committed
drm/msm/gpu: Fix crash on devices without devfreq support (v2)
Avoid going down devfreq paths on devices where devfreq is not initialized. v2: Change has_devfreq() logic [Dmitry] Reported-by: Linux Kernel Functional Testing <lkft@linaro.org> Reported-by: Anders Roxell <anders.roxell@linaro.org> Signed-off-by: Rob Clark <robdclark@chromium.org> Fixes: 6aa89ae ("drm/msm/gpu: Cancel idle/boost work on suspend") Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Link: https://lore.kernel.org/r/20220308184844.1121029-1-robdclark@gmail.com
1 parent aaa743d commit 05afd57

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

drivers/gpu/drm/msm/msm_gpu_devfreq.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ static struct devfreq_dev_profile msm_devfreq_profile = {
8383
static void msm_devfreq_boost_work(struct kthread_work *work);
8484
static void msm_devfreq_idle_work(struct kthread_work *work);
8585

86+
static bool has_devfreq(struct msm_gpu *gpu)
87+
{
88+
struct msm_gpu_devfreq *df = &gpu->devfreq;
89+
return !!df->devfreq;
90+
}
91+
8692
void msm_devfreq_init(struct msm_gpu *gpu)
8793
{
8894
struct msm_gpu_devfreq *df = &gpu->devfreq;
@@ -149,23 +155,34 @@ void msm_devfreq_cleanup(struct msm_gpu *gpu)
149155
{
150156
struct msm_gpu_devfreq *df = &gpu->devfreq;
151157

158+
if (!has_devfreq(gpu))
159+
return;
160+
152161
devfreq_cooling_unregister(gpu->cooling);
153162
dev_pm_qos_remove_request(&df->boost_freq);
154163
dev_pm_qos_remove_request(&df->idle_freq);
155164
}
156165

157166
void msm_devfreq_resume(struct msm_gpu *gpu)
158167
{
159-
gpu->devfreq.busy_cycles = 0;
160-
gpu->devfreq.time = ktime_get();
168+
struct msm_gpu_devfreq *df = &gpu->devfreq;
161169

162-
devfreq_resume_device(gpu->devfreq.devfreq);
170+
if (!has_devfreq(gpu))
171+
return;
172+
173+
df->busy_cycles = 0;
174+
df->time = ktime_get();
175+
176+
devfreq_resume_device(df->devfreq);
163177
}
164178

165179
void msm_devfreq_suspend(struct msm_gpu *gpu)
166180
{
167181
struct msm_gpu_devfreq *df = &gpu->devfreq;
168182

183+
if (!has_devfreq(gpu))
184+
return;
185+
169186
devfreq_suspend_device(df->devfreq);
170187

171188
cancel_idle_work(df);
@@ -185,6 +202,9 @@ void msm_devfreq_boost(struct msm_gpu *gpu, unsigned factor)
185202
struct msm_gpu_devfreq *df = &gpu->devfreq;
186203
uint64_t freq;
187204

205+
if (!has_devfreq(gpu))
206+
return;
207+
188208
freq = get_freq(gpu);
189209
freq *= factor;
190210

@@ -207,7 +227,7 @@ void msm_devfreq_active(struct msm_gpu *gpu)
207227
struct devfreq_dev_status status;
208228
unsigned int idle_time;
209229

210-
if (!df->devfreq)
230+
if (!has_devfreq(gpu))
211231
return;
212232

213233
/*
@@ -253,7 +273,7 @@ void msm_devfreq_idle(struct msm_gpu *gpu)
253273
{
254274
struct msm_gpu_devfreq *df = &gpu->devfreq;
255275

256-
if (!df->devfreq)
276+
if (!has_devfreq(gpu))
257277
return;
258278

259279
msm_hrtimer_queue_work(&df->idle_work, ms_to_ktime(1),

0 commit comments

Comments
 (0)