drm/vc4: Fix pm_runtime_get_sync() error checking
Subsystems (3)
PATCH 1/1 drm/vc4: Fix pm_runtime_get_sync() error checking
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +1 -1
@@ -847,7 +847,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)int ret; ret =pm_runtime_get_sync (dev); -if (ret) { +if (ret <0 ) {DRM_ERROR ("Failed to runtime PM enable on DSI%d\n" , dsi->variant->port);return ; }
Signature · 1 line
2.17.1
Hi,
Quoted 15 lines · Miaoqian Lin
If the device is already in a runtime PM enabled state
pm_runtime_get_sync()will return 1, so a test for negative value should be used to check for errors.Fixes 4078f5757144 ("drm/vc4: Add DSI driver")Signed-off-by Miaoqian Lin <[email protected]>--- drivers/gpu/drm/vc4/vc4_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/vc4/vc4_dsi.c +0
-0
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 853
Quoted 8 lines
drivers/gpu/drm/vc4/vc4_dsi.c +1
-1@@ -847,7 +847,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)int ret; ret =pm_runtime_get_sync (dev); -if (ret) { +if (ret <0 ) {DRM_ERROR ("Failed to runtime PM enable on DSI%d\n" , dsi->variant->port);return ; }
We also don't put back our reference after an error. I think a better fix would be to switch to pm_runtime_resume_and_get.
Maxime
PATCH v2 1/1 drm/vc4: Fix pm_runtime_get_sync() usage
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1, so a test for negative value should be used to check for errors.
Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.
---
change in v2:
- switch to pm_runtime_resume_and_get() to fix refcount leak.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vc4/vc4_dsi.c +2 -2
@@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)unsigned long phy_clock;int ret; - ret =pm_runtime_get_sync (dev); -if (ret) { + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) {DRM_ERROR ("Failed to runtime PM enable on DSI%d\n" , dsi->variant->port);return ; }
Signature · 1 line
2.17.1
Re: [PATCH v2] drm/vc4: Fix pm_runtime_get_sync() usage
Quoted 22 lines · Miaoqian Lin
If the device is already in a runtime PM enabled state
pm_runtime_get_sync()will return 1, so a test for negative value should be used to check for errors.Also, we need to call
pm_runtime_put_noidle()whenpm_runtime_get_sync()fails, so usepm_runtime_resume_and_get()instead. this function will handle this.Fixes 4078f5757144 ("drm/vc4: Add DSI driver")Signed-off-by Miaoqian Lin <[email protected]>---
change in v2:
- switch topm_runtime_resume_and_get()to fix refcount leak.--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/vc4/vc4_dsi.c +0
-0
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 850
Quoted 7 lines
drivers/gpu/drm/vc4/vc4_dsi.c +2
-2@@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)unsigned long phy_clock;int ret; - ret =pm_runtime_get_sync (dev); -if (ret) { + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) {
pm_runtime_resume_and_get will return 0 on success, so the previous check was correct
Maxime
Re: [PATCH v2] drm/vc4: Fix pm_runtime_get_sync() usage
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Miaoqian Lin
If the device is already in a runtime PM enabled state
pm_runtime_get_sync()will return 1, so a test for negative value should be used to check for errors.Also, we need to call
pm_runtime_put_noidle()whenpm_runtime_get_sync()fails, so usepm_runtime_resume_and_get()instead. this function will handle this.Fixes 4078f5757144 ("drm/vc4: Add DSI driver")Signed-off-by Miaoqian Lin <[email protected]>---
change in v2:
- switch topm_runtime_resume_and_get()to fix refcount leak.--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/vc4/vc4_dsi.c +0
-0@@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)unsigned long phy_clock;int ret;
Quoted 5 lines
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 850
Quoted 4 lines
drivers/gpu/drm/vc4/vc4_dsi.c +2
-2- ret =pm_runtime_get_sync (dev); -if (ret) { + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) {
pm_runtime_resume_and_getwill return 0 on success, so the previous check was correct
previous check is for pm_runtime_get_sync() not for pm_runtime_resume_and_get (),
I switch to pm_runtime_resume_and_get() to fix the refcount leak bug at the same time.
Sure it's ok to use check if(ret) to check the retval, I just follow a more common way
for usage of pm_runtime_resume_and_get() in the codebase—— check ret<0
Since pm_runtime_resume_and_get() return negative error code.
Quoted 1 line
Maxime
Re: [PATCH v2] drm/vc4: Fix pm_runtime_get_sync() usage
Quoted 36 lines · Miaoqian Lin
Quoted 26 lines · Maxime Ripard
Quoted 25 lines · Miaoqian Lin
If the device is already in a runtime PM enabled state
pm_runtime_get_sync()will return 1, so a test for negative value should be used to check for errors.Also, we need to call
pm_runtime_put_noidle()whenpm_runtime_get_sync()fails, so usepm_runtime_resume_and_get()instead. this function will handle this.Fixes 4078f5757144 ("drm/vc4: Add DSI driver")Signed-off-by Miaoqian Lin <[email protected]>---
change in v2:
- switch topm_runtime_resume_and_get()to fix refcount leak.--- drivers/gpu/drm/vc4/vc4_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/vc4/vc4_dsi.c +0
-0@@ -846,8 +846,8 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)unsigned long phy_clock;int ret;Quoted 5 lines
drivers/gpu/drm/vc4/vc4_dsi.c static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) · line 850
Quoted 4 lines
drivers/gpu/drm/vc4/vc4_dsi.c +2
-2- ret =pm_runtime_get_sync (dev); -if (ret) { + ret =pm_runtime_resume_and_get (dev); +if (ret <0 ) {
pm_runtime_resume_and_getwill return 0 on success, so the previous check was correctprevious check is for
pm_runtime_get_sync()not forpm_runtime_resume_and_get(),
Quoted 7 lines
I switch to
pm_runtime_resume_and_get()to fix the refcount leak bug at the same time.Sure it's ok to use check if(ret) to check the retval, I just follow a more common way
for usage of
pm_runtime_resume_and_get()in the codebase—— check ret<0Since
pm_runtime_resume_and_get()return negative error code.
If it ain't broke, don't fix it. The previous condition was working perfectly fine to catch the errors from pm_runtime_resume_and_get, there's no reason to change it.
Maxime
PATCH v3 1/1 drm/vc4: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage
If the device is already in a runtime PM enabled state pm_runtime_get_sync() will return 1.
Also, we need to call pm_runtime_put_noidle() when pm_runtime_get_sync() fails, so use pm_runtime_resume_and_get() instead. this function will handle this.
---
change in v2:
- switch to pm_runtime_resume_and_get() to fix refcount leak. changes in v3:
- keep the original checking way for retval.
--- drivers/gpu/drm/vc4/vc4_dsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/vc4/vc4_dsi.c +1 -1
@@ -846,7 +846,7 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder)unsigned long phy_clock;int ret; - ret =pm_runtime_get_sync (dev); + ret =pm_runtime_resume_and_get (dev);if (ret) {DRM_ERROR ("Failed to runtime PM enable on DSI%d\n" , dsi->variant->port);return ;
Signature · 1 line
2.17.1
Maxime Ripard
AppliedRe: (subset) [PATCH v3] drm/vc4: Use pm_runtime_resume_and_get to fix pm_runtime_get_sync() usage
Quoted 8 lines · Miaoqian Lin
If the device is already in a runtime PM enabled state
pm_runtime_get_sync()will return 1.Also, we need to call
pm_runtime_put_noidle()whenpm_runtime_get_sync()fails, so usepm_runtime_resume_and_get()instead. this function will handle this.[...]
Applied to drm/drm-misc (drm-misc-fixes).
Thanks!
Maxime