Skip to contentSkip to conversation

drm/exynos: Use pm_runtime_resume_and_get() to replace open coding

PATCH Superseded Tian Tao 4 participants 4 messages May 21, 2021 – May 24, 2021

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Tian Tao

author
#0 lore raw

PATCH v2 1/1 drm/exynos: Use pm_runtime_resume_and_get() to replace open coding

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle.

---

v2: drop unnecessary change about if condition.

---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +2 -4
index 3821ea7..32672bf 100644
@@ -268,11 +268,9 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 	if (mic->enabled)
 		goto unlock;
 
-	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(mic->dev);
+	ret = pm_runtime_resume_and_get(mic->dev);
+	if (ret < 0)
 		goto unlock;
-	}
 
 	mic_set_path(mic, 1);
 
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#1 lore raw
Quoted 2 lines · Tian Tao

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle.

It would be good to explain why: Apparently get_sync increments the refcount even if it fails, which ususally leads to leaks.

With that or similar added to the commit message:

Quoted 30 lines

---

v2: drop unnecessary change about if condition.

---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +2 -4
index 3821ea7..32672bf 100644
@@ -268,11 +268,9 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 	if (mic->enabled)
 		goto unlock;
 
-	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(mic->dev);
+	ret = pm_runtime_resume_and_get(mic->dev);
+	if (ret < 0)
 		goto unlock;
-	}
 
 	mic_set_path(mic, 1);
 
Signature · 1 line
2.7.4
Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
maintainer
#2 lore raw

21. 5. 22. 오전 12:31에 Daniel Vetter 이(가) 쓴 글:

Quoted 6 lines · Tian Tao
Quoted 2 lines

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle.

It would be good to explain why: Apparently get_sync increments the refcount even if it fails, which ususally leads to leaks.

Tian Tao, could you update the description?

Thanks,
Inki Dae

Quoted 36 lines

With that or similar added to the commit message:

Quoted 30 lines

---

v2: drop unnecessary change about if condition.

---
 drivers/gpu/drm/exynos/exynos_drm_mic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +2 -4
index 3821ea7..32672bf 100644
@@ -268,11 +268,9 @@ static void mic_pre_enable(struct drm_bridge *bridge)
 	if (mic->enabled)
 		goto unlock;
 
-	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(mic->dev);
+	ret = pm_runtime_resume_and_get(mic->dev);
+	if (ret < 0)
 		goto unlock;
-	}
 
 	mic_set_path(mic, 1);
 
Signature · 1 line
2.7.4
#3 lore raw
Quoted 8 lines · Inki Dae

21. 5. 22. 오전 12:31에 Daniel Vetter 이(가) 쓴 글:

Quoted 5 lines · Tian Tao
Quoted 2 lines

use pm_runtime_resume_and_get() to replace pm_runtime_get_sync and pm_runtime_put_noidle.

It would be good to explain why: Apparently get_sync increments the refcount even if it fails, which ususally leads to leaks.

Tian Tao, could you update the description?

done:-)

Quoted 39 lines

Thanks,
Inki Dae

Quoted 28 lines

With that or similar added to the commit message:

Quoted 24 lines

---

v2: drop unnecessary change about if condition.

---
  drivers/gpu/drm/exynos/exynos_drm_mic.c | 6 ++----
  1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/exynos/exynos_drm_mic.c +2 -4
index 3821ea7..32672bf 100644
@@ -268,11 +268,9 @@ static void mic_pre_enable(struct drm_bridge *bridge)
  	if (mic->enabled)
  		goto unlock;
 
-	ret = pm_runtime_get_sync(mic->dev);
-	if (ret < 0) {
-		pm_runtime_put_noidle(mic->dev);
+	ret = pm_runtime_resume_and_get(mic->dev);
+	if (ret < 0)
  		goto unlock;
-	}
 
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_mic.c +0 -0
  	mic_set_path(mic, 1);
 
Signature · 1 line
2.7.4

.