All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/panel: skip enable after a failed prepare
@ 2026-12-03 15:09 Qianhui Xu
  2026-12-03 15:33 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Qianhui Xu @ 2026-12-03 15:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
	Simona Vetter, linux-kernel

drm_panel_prepare() cannot report a failure to its caller, so a panel
whose prepare callback failed is left unprepared while the bridge enable
chain still calls drm_panel_enable(). The core already knows the panel
was not prepared, since panel->prepared stays false, but that is
indistinguishable from a panel that never had a prepare callback.

Record the failure in drm_panel_prepare() and skip the enable callback
while it is set. unprepare() clears it, as the panel callbacks and
followers were never run, and disable() returns early for the same
reason. A later prepare() starts from a clean state, so a retry can
recover.

Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
Prepared with AI assistance (pi coding agent); reviewed and edited by me.

 drivers/gpu/drm/drm_panel.c | 24 +++++++++++++++++++++++-
 include/drm/drm_panel.h     |  8 ++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c
index 26d9378..0f22d45 100644
--- a/drivers/gpu/drm/drm_panel.c
+++ b/drivers/gpu/drm/drm_panel.c
@@ -588,10 +588,13 @@ void drm_panel_prepare(struct drm_panel *panel)
 
 	mutex_lock(&panel->follower_lock);
 
+	panel->prepare_failed = false;
 	if (panel->funcs && panel->funcs->prepare) {
 		ret = panel->funcs->prepare(panel);
-		if (ret < 0)
+		if (ret < 0) {
+			panel->prepare_failed = true;
 			goto exit;
+		}
 	}
 	panel->prepared = true;
 
@@ -627,6 +630,16 @@ void drm_panel_unprepare(struct drm_panel *panel)
 	if (!panel)
 		return;
 
+	/*
+	 * A failed prepare() left the panel unprepared. Drop the failure state
+	 * so that a later prepare() starts from a clean slate; the panel
+	 * callbacks and followers were never run.
+	 */
+	if (panel->prepare_failed) {
+		panel->prepare_failed = false;
+		return;
+	}
+
 	/*
 	 * If you are seeing the warning below it likely means one of two things:
 	 * - Your panel driver incorrectly calls drm_panel_unprepare() in its
@@ -683,6 +696,11 @@ void drm_panel_enable(struct drm_panel *panel)
 	if (!panel)
 		return;
 
+	if (panel->prepare_failed) {
+		dev_warn(panel->dev, "Skipping enable of panel that failed to prepare\n");
+		return;
+	}
+
 	if (panel->enabled) {
 		dev_warn(panel->dev, "Skipping enable of already enabled panel\n");
 		return;
@@ -733,6 +751,10 @@ void drm_panel_disable(struct drm_panel *panel)
 	if (!panel)
 		return;
 
+	/* The panel was never enabled after the failed prepare(). */
+	if (panel->prepare_failed)
+		return;
+
 	/*
 	 * If you are seeing the warning below it likely means one of two things:
 	 * - Your panel driver incorrectly calls drm_panel_disable() in its
diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h
index d9059a9..60bcc3f 100644
--- a/include/drm/drm_panel.h
+++ b/include/drm/drm_panel.h
@@ -280,6 +280,14 @@ struct drm_panel {
 	 * If true then the panel has been enabled.
 	 */
 	bool enabled;
+
+	/**
+	 * @prepare_failed:
+	 *
+	 * If true then the last call to prepare() failed. The panel is not
+	 * prepared, and enable() will be skipped until prepare() succeeds.
+	 */
+	bool prepare_failed;
 };
 
 void *__devm_drm_panel_alloc(struct device *dev, size_t size, size_t offset,
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-03 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-03 15:09 [PATCH] drm/panel: skip enable after a failed prepare Qianhui Xu
2026-12-03 15:33 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.