[PATCH] drm/msm/gpu: Fix missing error check for dev_pm_qos_add_request()

Jinjie Ruan ruanjinjie at huawei.com
Sat Oct 26 09:37:38 UTC 2024


dev_pm_qos_add_request() can fail, and it returns -EINVAL in case of
wrong parameters, return -ENOMEM if there's not enough memory to allocate
for data structures, and return -ENODEV if the device has just been
removed from the system. If it fails in msm_devfreq_init(), there is
no point in going on, also call dev_pm_qos_remove_request() in the next
error path is also meaningless

Fixes: 7c0ffcd40b16 ("drm/msm/gpu: Respect PM QoS constraints")
Signed-off-by: Jinjie Ruan <ruanjinjie at huawei.com>
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_gpu_devfreq.c b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
index ea70c1c32d94..9a7a18d4335b 100644
--- a/drivers/gpu/drm/msm/msm_gpu_devfreq.c
+++ b/drivers/gpu/drm/msm/msm_gpu_devfreq.c
@@ -138,8 +138,9 @@ static bool has_devfreq(struct msm_gpu *gpu)
 
 void msm_devfreq_init(struct msm_gpu *gpu)
 {
-	struct msm_gpu_devfreq *df = &gpu->devfreq;
 	struct msm_drm_private *priv = gpu->dev->dev_private;
+	struct msm_gpu_devfreq *df = &gpu->devfreq;
+	int ret;
 
 	/* We need target support to do devfreq */
 	if (!gpu->funcs->gpu_busy)
@@ -156,8 +157,10 @@ void msm_devfreq_init(struct msm_gpu *gpu)
 
 	mutex_init(&df->lock);
 
-	dev_pm_qos_add_request(&gpu->pdev->dev, &df->boost_freq,
-			       DEV_PM_QOS_MIN_FREQUENCY, 0);
+	ret = dev_pm_qos_add_request(&gpu->pdev->dev, &df->boost_freq,
+				     DEV_PM_QOS_MIN_FREQUENCY, 0);
+	if (ret < 0)
+		return;
 
 	msm_devfreq_profile.initial_freq = gpu->fast_rate;
 
-- 
2.34.1



More information about the Freedreno mailing list