[PATCH] drm/panel: skip enable after a failed prepare
From: Qianhui Xu
Date: Thu Dec 03 2026 - 10:11:05 EST
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@xxxxxxxxxxxxxxxx>
---
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