mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle
@ 2026-12-02  9:09 Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 1/4] drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT PP8807HB1-1 Qianhui Xu
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Qianhui Xu @ 2026-12-02  9:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel

Changes in v3:
 - patch 1: reorder the 40 Hz mode so the list stays highest to lowest
   (120/60/40/30/24); patches 2-4 are unchanged since v2
Changes in v2:
 - patches 2-4: add Fixes: and Cc: stable, the bugs are in the driver
   since it was merged in v7.3
 - patch 4: state in the commit message why the guard is not moved into
   drm_panel_enable(): that function is void and "prepare never called" is
   indistinguishable from "prepare failed", so panels whose bridge ops do
   not call drm_panel_prepare() would be skipped as well

The 40 Hz and 24 Hz modes were measured on the panel. The lifecycle fixes
are build-tested and boot-tested on one board using this panel, not on
others.
*** AI-assistance disclosure ***
Prepared with the help of an LLM coding assistant. The author reviewed
every line, checked each claim against the source tree and ran the gates
quoted above; the design decisions and any errors are the author's.


Qianhui Xu (4):
  drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT
    PP8807HB1-1
  drm/panel: novatek-nt36536: finish setup before attaching DSI devices
  drm/panel: novatek-nt36536: power off on any prepare failure
  drm/panel: novatek-nt36536: reject enable when prepare failed

 drivers/gpu/drm/panel/panel-novatek-nt36536.c | 74 +++++++++++++++----
 1 file changed, 58 insertions(+), 16 deletions(-)

-- 
2.53.0


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

* [PATCH v3 1/4] drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT PP8807HB1-1
  2026-12-02  9:09 [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle Qianhui Xu
@ 2026-12-02  9:09 ` Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices Qianhui Xu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 9+ messages in thread
From: Qianhui Xu @ 2026-12-02  9:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel

The panel supports 40Hz and 24Hz refresh rates in addition to the modes
the driver currently exposes. Add both, keeping the mode ordering from
highest to lowest refresh rate.
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
 drivers/gpu/drm/panel/panel-novatek-nt36536.c | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
index 8bd1256501680..003e8561dc45b 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
@@ -309,6 +309,17 @@ static const struct drm_display_mode csot_pp8807hb1_1_modes[] = {
 		.vsync_end = 3040 + 3426 + 4,
 		.vtotal = 3040 + 3426 + 4 + 330,
 	},
+	{
+		.clock = (952 + 138 + 16 + 16) * 2 * (3040 + 6826 + 4 + 330) * 40 / 1000,
+		.hdisplay = 952 * 2,
+		.hsync_start = (952 + 138) * 2,
+		.hsync_end = (952 + 138 + 16) * 2,
+		.htotal = (952 + 138 + 16 + 16) * 2,
+		.vdisplay = 3040,
+		.vsync_start = 3040 + 6826,
+		.vsync_end = 3040 + 6826 + 4,
+		.vtotal = 3040 + 6826 + 4 + 330,
+	},
 	{
 		.clock = (952 + 138 + 16 + 16) * 2 * (3040 + 10226 + 4 + 330) * 30 / 1000,
 		.hdisplay = 952 * 2,
@@ -320,6 +331,17 @@ static const struct drm_display_mode csot_pp8807hb1_1_modes[] = {
 		.vsync_end = 3040 + 10226 + 4,
 		.vtotal = 3040 + 10226 + 4 + 330,
 	},
+	{
+		.clock = (952 + 138 + 16 + 16) * 2 * (3040 + 13626 + 4 + 330) * 24 / 1000,
+		.hdisplay = 952 * 2,
+		.hsync_start = (952 + 138) * 2,
+		.hsync_end = (952 + 138 + 16) * 2,
+		.htotal = (952 + 138 + 16 + 16) * 2,
+		.vdisplay = 3040,
+		.vsync_start = 3040 + 13626,
+		.vsync_end = 3040 + 13626 + 4,
+		.vtotal = 3040 + 13626 + 4 + 330,
+	},
 	/* 1064606.4 KHz */
 	{
 		.clock = (952 + 50 + 16 + 16) * 2 * (3040 + 26 + 4 + 50) * 165 / 1000,
-- 
2.53.0


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

* [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices
  2026-12-02  9:09 [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 1/4] drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT PP8807HB1-1 Qianhui Xu
@ 2026-12-02  9:09 ` Qianhui Xu
  2026-12-03 10:18   ` Neil Armstrong
  2026-12-02  9:09 ` [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed Qianhui Xu
  3 siblings, 1 reply; 9+ messages in thread
From: Qianhui Xu @ 2026-12-02  9:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

Attaching a DSI device can bind the DRM bridge and immediately prepare
the panel. Two things must be ready by then: the backlight device, which
prepare() enables, and the MIPI DSI format/mode flags of every DSI
device of a dual-DSI panel. Resolve the backlight before
drm_panel_add()/attach, and configure all DSI devices in a separate loop
before attaching any of them.

Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
 drivers/gpu/drm/panel/panel-novatek-nt36536.c | 26 +++++++++++--------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
index 003e8561dc45b..7aa26796e2a90 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
@@ -439,6 +439,18 @@ static int novatek_probe(struct mipi_dsi_device *dsi)
 	ctx->dsi[0] = dsi;
 	mipi_dsi_set_drvdata(dsi, ctx);
 
+	/* Resolve suppliers before attachment can bind DRM and prepare the panel. */
+	if (desc->has_dcs_backlight) {
+		ctx->backlight = novatek_create_backlight(ctx);
+		if (IS_ERR(ctx->backlight))
+			return dev_err_probe(dev, PTR_ERR(ctx->backlight),
+					     "Failed to create backlight\n");
+	} else {
+		ret = drm_panel_of_backlight(&ctx->panel);
+		if (ret)
+			return dev_err_probe(dev, ret, "Failed to get backlight\n");
+	}
+
 	ctx->panel.prepare_prev_first = true;
 
 	ret = devm_drm_panel_add(dev, &ctx->panel);
@@ -450,23 +462,15 @@ static int novatek_probe(struct mipi_dsi_device *dsi)
 		ctx->dsi[i]->format = desc->format;
 		ctx->dsi[i]->mode_flags = desc->mode_flags;
 		ctx->dsi[i]->dsc = &ctx->dsc;
+	}
+
+	for (i = 0; i < num_dsi; i++) {
 		ret = devm_mipi_dsi_attach(dev, ctx->dsi[i]);
 		if (ret < 0)
 			return dev_err_probe(dev, ret,
 					     "Failed to attach to DSI host\n");
 	}
 
-	if (desc->has_dcs_backlight) {
-		ctx->backlight = novatek_create_backlight(ctx);
-		if (IS_ERR(ctx->backlight))
-			return dev_err_probe(dev, PTR_ERR(ctx->backlight),
-					     "Failed to create backlight\n");
-	} else {
-		ret = drm_panel_of_backlight(&ctx->panel);
-		if (ret)
-			return dev_err_probe(dev, ret, "Failed to get backlight\n");
-	}
-
 	return 0;
 }
 
-- 
2.53.0


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

* [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure
  2026-12-02  9:09 [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 1/4] drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT PP8807HB1-1 Qianhui Xu
  2026-12-02  9:09 ` [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices Qianhui Xu
@ 2026-12-02  9:09 ` Qianhui Xu
  2026-12-03 10:19   ` Neil Armstrong
  2026-12-02  9:09 ` [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed Qianhui Xu
  3 siblings, 1 reply; 9+ messages in thread
From: Qianhui Xu @ 2026-12-02  9:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

prepare() only undid the power-up when the initialisation sequence
failed. Failures of the picture parameter set, the compression mode
commands or the backlight enable were ignored, leaving the panel powered
with a wrong state and -- for the backlight -- with the error swallowed.
Use a single power_off label for all error paths and also check
dsi_ctx.accum_err after the batched MIPI writes, as those helpers only
record their error there.

Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
 drivers/gpu/drm/panel/panel-novatek-nt36536.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
index 7aa26796e2a90..e372e346d8b77 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
@@ -100,18 +100,27 @@ static int novatek_prepare(struct drm_panel *panel)
 	ret = ctx->desc->init_sequence(&dsi_ctx);
 	if (ret < 0) {
 		dev_err(dev, "Failed to initialize panel: %d\n", ret);
-		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
-		regulator_bulk_disable(ARRAY_SIZE(novatek_supplies),
-				       ctx->supplies);
-		return ret;
+		goto power_off;
 	}
 
 	drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
 	mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
 	mipi_dsi_compression_mode_multi(&dsi_ctx, true);
 	mipi_dsi_msleep(&dsi_ctx, 28);
+	ret = dsi_ctx.accum_err;
+	if (ret)
+		goto power_off;
+
+	ret = backlight_enable(ctx->backlight);
+	if (ret)
+		goto power_off;
+
+	return 0;
 
-	return backlight_enable(ctx->backlight);
+power_off:
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(novatek_supplies), ctx->supplies);
+	return ret;
 }
 
 static int novatek_off(struct mipi_dsi_multi_context *dsi_ctx)
-- 
2.53.0


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

* [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed
  2026-12-02  9:09 [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle Qianhui Xu
                   ` (2 preceding siblings ...)
  2026-12-02  9:09 ` [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure Qianhui Xu
@ 2026-12-02  9:09 ` Qianhui Xu
  2026-12-03 10:20   ` Neil Armstrong
  3 siblings, 1 reply; 9+ messages in thread
From: Qianhui Xu @ 2026-12-02  9:09 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

drm_panel_prepare() cannot report a failure to its caller, so the enable
part of the bridge chain still runs with panel->prepared unset. Provide
an enable() callback that returns -EIO in that case, so the panel is not
marked as enabled and the backlight stays off.

Checking this in drm_panel_enable() instead was considered: the state
lives in the core, but drm_panel_enable() is void and there is no way to
tell "prepare was never called" from "prepare failed". Panels that never
implement prepare(), or whose bridge ops skip drm_panel_prepare(), would
then be skipped as well, so the guard stays local to the driver that can
actually fail.

Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
---
 drivers/gpu/drm/panel/panel-novatek-nt36536.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
index e372e346d8b77..d38ddf271b0cd 100644
--- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
+++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
@@ -123,6 +123,12 @@ static int novatek_prepare(struct drm_panel *panel)
 	return ret;
 }
 
+static int novatek_enable(struct drm_panel *panel)
+{
+	/* The bridge enable chain can continue after a failed prepare callback. */
+	return panel->prepared ? 0 : -EIO;
+}
+
 static int novatek_off(struct mipi_dsi_multi_context *dsi_ctx)
 {
 	mipi_dsi_dcs_set_display_off_multi(dsi_ctx);
@@ -186,6 +192,7 @@ static int novatek_get_modes(struct drm_panel *panel,
 
 static const struct drm_panel_funcs novatek_panel_funcs = {
 	.prepare = novatek_prepare,
+	.enable = novatek_enable,
 	.unprepare = novatek_unprepare,
 	.get_modes = novatek_get_modes,
 };
-- 
2.53.0


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

* Re: [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices
  2026-12-02  9:09 ` [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices Qianhui Xu
@ 2026-12-03 10:18   ` Neil Armstrong
  0 siblings, 0 replies; 9+ messages in thread
From: Neil Armstrong @ 2026-12-03 10:18 UTC (permalink / raw)
  To: Qianhui Xu, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

On 12/2/26 10:09, Qianhui Xu wrote:
> Attaching a DSI device can bind the DRM bridge and immediately prepare
> the panel. Two things must be ready by then: the backlight device, which
> prepare() enables, and the MIPI DSI format/mode flags of every DSI
> device of a dual-DSI panel. Resolve the backlight before
> drm_panel_add()/attach, and configure all DSI devices in a separate loop
> before attaching any of them.
> 
> Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
> ---
>   drivers/gpu/drm/panel/panel-novatek-nt36536.c | 26 +++++++++++--------
>   1 file changed, 15 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> index 003e8561dc45b..7aa26796e2a90 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> @@ -439,6 +439,18 @@ static int novatek_probe(struct mipi_dsi_device *dsi)
>   	ctx->dsi[0] = dsi;
>   	mipi_dsi_set_drvdata(dsi, ctx);
>   
> +	/* Resolve suppliers before attachment can bind DRM and prepare the panel. */
> +	if (desc->has_dcs_backlight) {
> +		ctx->backlight = novatek_create_backlight(ctx);
> +		if (IS_ERR(ctx->backlight))
> +			return dev_err_probe(dev, PTR_ERR(ctx->backlight),
> +					     "Failed to create backlight\n");
> +	} else {
> +		ret = drm_panel_of_backlight(&ctx->panel);
> +		if (ret)
> +			return dev_err_probe(dev, ret, "Failed to get backlight\n");
> +	}
> +
>   	ctx->panel.prepare_prev_first = true;
>   
>   	ret = devm_drm_panel_add(dev, &ctx->panel);
> @@ -450,23 +462,15 @@ static int novatek_probe(struct mipi_dsi_device *dsi)
>   		ctx->dsi[i]->format = desc->format;
>   		ctx->dsi[i]->mode_flags = desc->mode_flags;
>   		ctx->dsi[i]->dsc = &ctx->dsc;
> +	}
> +
> +	for (i = 0; i < num_dsi; i++) {
>   		ret = devm_mipi_dsi_attach(dev, ctx->dsi[i]);
>   		if (ret < 0)
>   			return dev_err_probe(dev, ret,
>   					     "Failed to attach to DSI host\n");
>   	}
>   
> -	if (desc->has_dcs_backlight) {
> -		ctx->backlight = novatek_create_backlight(ctx);
> -		if (IS_ERR(ctx->backlight))
> -			return dev_err_probe(dev, PTR_ERR(ctx->backlight),
> -					     "Failed to create backlight\n");
> -	} else {
> -		ret = drm_panel_of_backlight(&ctx->panel);
> -		if (ret)
> -			return dev_err_probe(dev, ret, "Failed to get backlight\n");
> -	}
> -
>   	return 0;
>   }
>   

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

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

* Re: [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure
  2026-12-02  9:09 ` [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure Qianhui Xu
@ 2026-12-03 10:19   ` Neil Armstrong
  0 siblings, 0 replies; 9+ messages in thread
From: Neil Armstrong @ 2026-12-03 10:19 UTC (permalink / raw)
  To: Qianhui Xu, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

On 12/2/26 10:09, Qianhui Xu wrote:
> prepare() only undid the power-up when the initialisation sequence
> failed. Failures of the picture parameter set, the compression mode
> commands or the backlight enable were ignored, leaving the panel powered
> with a wrong state and -- for the backlight -- with the error swallowed.
> Use a single power_off label for all error paths and also check
> dsi_ctx.accum_err after the batched MIPI writes, as those helpers only
> record their error there.
> 
> Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
> ---
>   drivers/gpu/drm/panel/panel-novatek-nt36536.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> index 7aa26796e2a90..e372e346d8b77 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> @@ -100,18 +100,27 @@ static int novatek_prepare(struct drm_panel *panel)
>   	ret = ctx->desc->init_sequence(&dsi_ctx);
>   	if (ret < 0) {
>   		dev_err(dev, "Failed to initialize panel: %d\n", ret);
> -		gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> -		regulator_bulk_disable(ARRAY_SIZE(novatek_supplies),
> -				       ctx->supplies);
> -		return ret;
> +		goto power_off;
>   	}
>   
>   	drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
>   	mipi_dsi_picture_parameter_set_multi(&dsi_ctx, &pps);
>   	mipi_dsi_compression_mode_multi(&dsi_ctx, true);
>   	mipi_dsi_msleep(&dsi_ctx, 28);
> +	ret = dsi_ctx.accum_err;
> +	if (ret)
> +		goto power_off;
> +
> +	ret = backlight_enable(ctx->backlight);
> +	if (ret)
> +		goto power_off;
> +
> +	return 0;
>   
> -	return backlight_enable(ctx->backlight);
> +power_off:
> +	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
> +	regulator_bulk_disable(ARRAY_SIZE(novatek_supplies), ctx->supplies);
> +	return ret;
>   }
>   
>   static int novatek_off(struct mipi_dsi_multi_context *dsi_ctx)

Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>

Thanks,
Neil

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

* Re: [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed
  2026-12-02  9:09 ` [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed Qianhui Xu
@ 2026-12-03 10:20   ` Neil Armstrong
  2026-12-03 14:37     ` Qianhui Xu
  0 siblings, 1 reply; 9+ messages in thread
From: Neil Armstrong @ 2026-12-03 10:20 UTC (permalink / raw)
  To: Qianhui Xu, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

On 12/2/26 10:09, Qianhui Xu wrote:
> drm_panel_prepare() cannot report a failure to its caller, so the enable
> part of the bridge chain still runs with panel->prepared unset. Provide
> an enable() callback that returns -EIO in that case, so the panel is not
> marked as enabled and the backlight stays off.
> 
> Checking this in drm_panel_enable() instead was considered: the state
> lives in the core, but drm_panel_enable() is void and there is no way to
> tell "prepare was never called" from "prepare failed". Panels that never
> implement prepare(), or whose bridge ops skip drm_panel_prepare(), would
> then be skipped as well, so the guard stays local to the driver that can
> actually fail.
> 
> Fixes: 75a5dbd1f4f7 ("drm/panel: Add Novatek NT36536 panel driver")
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Qianhui Xu <xiaqinghuan@mail.ustc.edu.cn>
> ---
>   drivers/gpu/drm/panel/panel-novatek-nt36536.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panel/panel-novatek-nt36536.c b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> index e372e346d8b77..d38ddf271b0cd 100644
> --- a/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> +++ b/drivers/gpu/drm/panel/panel-novatek-nt36536.c
> @@ -123,6 +123,12 @@ static int novatek_prepare(struct drm_panel *panel)
>   	return ret;
>   }
>   
> +static int novatek_enable(struct drm_panel *panel)
> +{
> +	/* The bridge enable chain can continue after a failed prepare callback. */
> +	return panel->prepared ? 0 : -EIO;
> +}
> +
>   static int novatek_off(struct mipi_dsi_multi_context *dsi_ctx)
>   {
>   	mipi_dsi_dcs_set_display_off_multi(dsi_ctx);
> @@ -186,6 +192,7 @@ static int novatek_get_modes(struct drm_panel *panel,
>   
>   static const struct drm_panel_funcs novatek_panel_funcs = {
>   	.prepare = novatek_prepare,
> +	.enable = novatek_enable,
>   	.unprepare = novatek_unprepare,
>   	.get_modes = novatek_get_modes,
>   };

This is a hack, fix it in the core instead

Neil

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

* Re: [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed
  2026-12-03 10:20   ` Neil Armstrong
@ 2026-12-03 14:37     ` Qianhui Xu
  0 siblings, 0 replies; 9+ messages in thread
From: Qianhui Xu @ 2026-12-03 14:37 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang, dri-devel
  Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
	David Airlie, Simona Vetter, linux-kernel, stable

Hi Neil,
You are right, and I am withdrawing 4/4. Patches 1/4 to 3/4 are unchanged
and can be picked up as they are.

For the core side: drm_panel_prepare() is void and returns early when
funcs->prepare() fails, and drm_panel_enable() then calls funcs->enable()
regardless, with panel->prepared still false. The fix is to keep the
failed state in the core and not enable the panel afterwards.

I will write that as a separate change against drm-misc-next, after going
through the in-tree callers of drm_panel_enable(), and post it on its own
so this series is not held up by it.
Regards, Qianhui
---
Prepared with AI assistance (pi coding agent); reviewed and edited by me.


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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-02  9:09 [PATCH v3 0/4] drm/panel: novatek-nt36536: add 40/24 Hz modes, fix lifecycle Qianhui Xu
2026-12-02  9:09 ` [PATCH v3 1/4] drm/panel: novatek-nt36536: add 40Hz and 24Hz modes for CSOT PP8807HB1-1 Qianhui Xu
2026-12-02  9:09 ` [PATCH v3 2/4] drm/panel: novatek-nt36536: finish setup before attaching DSI devices Qianhui Xu
2026-12-03 10:18   ` Neil Armstrong
2026-12-02  9:09 ` [PATCH v3 3/4] drm/panel: novatek-nt36536: power off on any prepare failure Qianhui Xu
2026-12-03 10:19   ` Neil Armstrong
2026-12-02  9:09 ` [PATCH v3 4/4] drm/panel: novatek-nt36536: reject enable when prepare failed Qianhui Xu
2026-12-03 10:20   ` Neil Armstrong
2026-12-03 14:37     ` Qianhui Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®