diff mbox series

drm/msm/devfreq: Insert missing null check in msm_devfreq_idle

Message ID 20211117111134.315709-1-marijn.suijten@somainline.org (mailing list archive)
State New, archived
Headers show
Series drm/msm/devfreq: Insert missing null check in msm_devfreq_idle | expand

Commit Message

Marijn Suijten Nov. 17, 2021, 11:11 a.m. UTC
msm_devfreq_init only initializes the idle_work hrtimer when it succeeds
to create a devfreq instance (devfreq support is optional), yet
msm_devfreq_idle is called unconditionally from retire_submit and queues
work on it.  We're seeing:

    [    2.005265] adreno 1c00000.gpu: [drm:msm_devfreq_init] *ERROR* Couldn't initialize GPU devfreq

Followed by a pagefault in:

    [   16.650316] pc : hrtimer_start_range_ns+0x64/0x360
    [   16.650336] lr : msm_hrtimer_queue_work+0x18/0x2c

Moments later.  Just like msm_devfreq_active, check if the devfreq
instance is not NULL before proceeding.

Fixes: 658f4c829688 ("drm/msm/devfreq: Add 1ms delay before clamping freq")
Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 3 +++
 1 file changed, 3 insertions(+)

--
2.34.0

Comments

AngeloGioacchino Del Regno Nov. 17, 2021, 2:09 p.m. UTC | #1
Il 17/11/21 12:11, Marijn Suijten ha scritto:
> msm_devfreq_init only initializes the idle_work hrtimer when it succeeds
> to create a devfreq instance (devfreq support is optional), yet
> msm_devfreq_idle is called unconditionally from retire_submit and queues
> work on it.  We're seeing:
> 
>      [    2.005265] adreno 1c00000.gpu: [drm:msm_devfreq_init] *ERROR* Couldn't initialize GPU devfreq
> 
> Followed by a pagefault in:
> 
>      [   16.650316] pc : hrtimer_start_range_ns+0x64/0x360
>      [   16.650336] lr : msm_hrtimer_queue_work+0x18/0x2c
> 
> Moments later.  Just like msm_devfreq_active, check if the devfreq
> instance is not NULL before proceeding.
> 
> Fixes: 658f4c829688 ("drm/msm/devfreq: Add 1ms delay before clamping freq")
> Reviewed-by: Konrad Dybcio <konrad.dybcio@somainline.org>
> Signed-off-by: Marijn Suijten <marijn.suijten@somainline.org>

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
index 8b7473f69cb8..ae3309ff96e4 100644
--- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c
+++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
@@ -227,6 +227,9 @@  void msm_devfreq_idle(struct msm_gpu *gpu)
 {
 	struct msm_gpu_devfreq *df = &gpu->devfreq;

+	if (!df->devfreq)
+		return;
+
 	msm_hrtimer_queue_work(&df->idle_work, ms_to_ktime(1),
 			       HRTIMER_MODE_ABS);
 }