Skip to contentSkip to conversation

drm/msm/devfreq: Fix OPP refcnt leak

PATCH In review Rob Clark 4 participants 4 messages Nov 5, 2021

Subsystems (4)
lore
Share & tools
lore

Rob Clark

author
#0 lore raw

PATCH v2 1/1 drm/msm/devfreq: Fix OPP refcnt leak

From: Rob Clark <[email protected]>

Fixes 9bc95570175a ("drm/msm: Devfreq tuning")
---
 drivers/gpu/drm/msm/msm_gpu_devfreq.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +5 -0
index d32b729b4616..07f1169df89b 100644
@@ -20,6 +20,10 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
 	struct msm_gpu *gpu = dev_to_gpu(dev);
 	struct dev_pm_opp *opp;
 
+	/*
+	 * Note that devfreq_recommended_opp() can modify the freq
+	 * to something that actually is in the opp table:
+	 */
 	opp = devfreq_recommended_opp(dev, freq, flags);
 
 	/*
@@ -28,6 +32,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
 	 */
 	if (gpu->devfreq.idle_freq) {
 		gpu->devfreq.idle_freq = *freq;
+		dev_pm_opp_put(opp);
 		return 0;
 	}
 
Signature · 1 line
2.31.1
Tested-by on v2 1/1
#2 lore raw
In reply to Rob Clark
Quoted 25 lines · Rob Clark

From: Rob Clark <[email protected]>

Fixes 9bc95570175a ("drm/msm: Devfreq tuning")
---
  drivers/gpu/drm/msm/msm_gpu_devfreq.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +4 -0
index d32b729b4616..07f1169df89b 100644
@@ -20,6 +20,10 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
  	struct msm_gpu *gpu = dev_to_gpu(dev);
  	struct dev_pm_opp *opp;
 
+	/*
+	 * Note that devfreq_recommended_opp() can modify the freq
+	 * to something that actually is in the opp table:
+	 */
  	opp = devfreq_recommended_opp(dev, freq, flags);
 
  	/*

drivers/gpu/drm/msm/msm_gpu_devfreq.c static int msm_devfreq_target(struct device *dev, unsigned long *freq, · line 38

Quoted 7 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +1 -0
@@ -28,6 +32,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
  	 */
  	if (gpu->devfreq.idle_freq) {
  		gpu->devfreq.idle_freq = *freq;
+		dev_pm_opp_put(opp);
  		return 0;
  	}
 

Tested on the Lenovo Yoga C630 and don't see the message from v1 :D

Reviewed-by on v2 1/1
#3 lore raw
In reply to Rob Clark
Quoted 26 lines · Rob Clark

From: Rob Clark <[email protected]>

Fixes 9bc95570175a ("drm/msm: Devfreq tuning")
---
  drivers/gpu/drm/msm/msm_gpu_devfreq.c | 5 +++++
  1 file changed, 5 insertions(+)
drivers/gpu/drm/msm/msm_gpu_devfreq.c +4 -0
index d32b729b4616..07f1169df89b 100644
@@ -20,6 +20,10 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
  	struct msm_gpu *gpu = dev_to_gpu(dev);
  	struct dev_pm_opp *opp;
 
+	/*
+	 * Note that devfreq_recommended_opp() can modify the freq
+	 * to something that actually is in the opp table:
+	 */
  	opp = devfreq_recommended_opp(dev, freq, flags);
 
  	/*

drivers/gpu/drm/msm/msm_gpu_devfreq.c static int msm_devfreq_target(struct device *dev, unsigned long *freq, · line 38

Quoted 7 lines
drivers/gpu/drm/msm/msm_gpu_devfreq.c +1 -0
@@ -28,6 +32,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq,
  	 */
  	if (gpu->devfreq.idle_freq) {
  		gpu->devfreq.idle_freq = *freq;
+		dev_pm_opp_put(opp);
  		return 0;
  	}
 

-Akhil