[PATCH v2 04/21] drm/exynos: Fix potential unbalanced calls to pm_runtime_put

Boris Brezillon boris.brezillon at collabora.com
Mon Aug 26 15:26:32 UTC 2019


The encoder->enable() can't report errors and is expected to always
succeed. If we call pm_runtime_put() in the exynos_dsi_enable() error
path (as currently done) we'll have unbalanced get/put calls when
encoder->disable() is called.

The situation is not ideal since drm_panel_{prepare,enable}() can
theoretically return an error (even if in practice I don't think any
panel driver does that). Putting a WARN_ON() is the best we can do,
unfortunately. Note that -ENOSYS is actually a valid case, it just
means the panel driver does not implement the hook.

Signed-off-by: Boris Brezillon <boris.brezillon at collabora.com>
---
Changes in v2:
* New patch
---
 drivers/gpu/drm/exynos/exynos_drm_dsi.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
index 8e655ae1fb0c..c555cecfe1f5 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c
@@ -1387,8 +1387,7 @@ static void exynos_dsi_enable(struct drm_encoder *encoder)
 
 	if (dsi->panel) {
 		ret = drm_panel_prepare(dsi->panel);
-		if (ret < 0)
-			goto err_put_sync;
+		WARN_ON(ret && ret != -ENOSYS);
 	} else {
 		drm_bridge_pre_enable(dsi->out_bridge);
 	}
@@ -1398,22 +1397,13 @@ static void exynos_dsi_enable(struct drm_encoder *encoder)
 
 	if (dsi->panel) {
 		ret = drm_panel_enable(dsi->panel);
-		if (ret < 0)
-			goto err_display_disable;
+		WARN_ON(ret && ret != -ENOSYS);
 	} else {
 		drm_bridge_enable(dsi->out_bridge);
 	}
 
 	dsi->state |= DSIM_STATE_VIDOUT_AVAILABLE;
 	return;
-
-err_display_disable:
-	exynos_dsi_set_display_enable(dsi, false);
-	drm_panel_unprepare(dsi->panel);
-
-err_put_sync:
-	dsi->state &= ~DSIM_STATE_ENABLED;
-	pm_runtime_put(dsi->dev);
 }
 
 static void exynos_dsi_disable(struct drm_encoder *encoder)
-- 
2.21.0



More information about the dri-devel mailing list