Skip to contentSkip to conversation

drm/msm/gpu: Drop qos request if devm_devfreq_add_device() fails

PATCH In review Bjorn Andersson 3 participants 3 messages Jul 8, 2022 – Aug 2, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/gpu: Drop qos request if devm_devfreq_add_device() fails

In the event that devm_devfreq_add_device() fails the device's qos freq list is left referencing df->idle_freq and df->boost_freq. Attempting to initialize devfreq again after a probe deferral will then cause invalid memory accesses in dev_pm_qos_add_request().

Fix this by dropping the requests in the error path.

Fixes 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +2 -0
index c2ea978c8921..21e271a318ee 100644
@@ -198,6 +198,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)
 
 	if (IS_ERR(df->devfreq)) {
 		DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
+		dev_pm_qos_remove_request(&df->idle_freq);
+		dev_pm_qos_remove_request(&df->boost_freq);
 		df->devfreq = NULL;
 		return;
 	}
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bjorn Andersson

In the event that devm_devfreq_add_device() fails the device's qos freq list is left referencing df->idle_freq and df->boost_freq. Attempting to initialize devfreq again after a probe deferral will then cause invalid memory accesses in dev_pm_qos_add_request().

Fix this by dropping the requests in the error path.

Fixes 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
Quoted 20 lines
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +2 -1
index c2ea978c8921..21e271a318ee 100644
@@ -198,6 +198,8 @@ void msm_devfreq_init(struct msm_gpu *gpu)
 
        if (IS_ERR(df->devfreq)) {
                DRM_DEV_ERROR(&gpu->pdev->dev, "Couldn't initialize GPU devfreq\n");
+               dev_pm_qos_remove_request(&df->idle_freq);
+               dev_pm_qos_remove_request(&df->boost_freq);
                df->devfreq = NULL;
                return;
        }
--

2.35.1

Reviewed-by on v1 1/1
#2 lore raw
In reply to Bjorn Andersson
Quoted 9 lines · Bjorn Andersson

In the event that devm_devfreq_add_device() fails the device's qos freq list is left referencing df->idle_freq and df->boost_freq. Attempting to initialize devfreq again after a probe deferral will then cause invalid memory accesses in dev_pm_qos_add_request().

Fix this by dropping the requests in the error path.

Fixes 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
Quoted 3 lines
---
  drivers/gpu/drm/msm/msm_gpu_devfreq.c | 2 ++
  1 file changed, 2 insertions(+)
Signature · 2 lines
With best wishes
Dmitry