Skip to contentSkip to conversation

drm/panel: Convert nt37705 and rm69220 prepare() to _multi()

PATCH New Hsieh Hung-En 1 participant 4 messages Dec 6

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover drm/panel: Convert nt37705 and rm69220 prepare() to _multi()

Both the Novatek NT37705 and Raydium RM69220 panel drivers already use the mipi_dsi_*_multi() helpers in their *_on() and *_off() routines, but still use the non-_multi DSC helpers in prepare(). This series fixes a prepare() error cleanup bug in NT37705 and finishes converting the remaining prepare() DSC setup sequence in both drivers:

- Patch 1 fixes nt37705_prepare() so that failures in mipi_dsi_picture_parameter_set() or mipi_dsi_compression_mode() assert reset_gpio and disable the regulators instead of leaking their enable counts.
- Patch 2 converts the DSC setup sequence in nt37705_prepare() to mipi_dsi_picture_parameter_set_multi(), mipi_dsi_compression_mode_multi(), and mipi_dsi_msleep().
- Patch 3 applies the same conversion to raydium_rm69220_prepare().

The existing *_on() helpers already use their own mipi_dsi_multi_context and are left untouched to keep the diffs minimal.

Compile-tested on arm64 with W=1, building each patch individually; not tested on hardware.

Changes in v2:
- Patch 1: Collect Reviewed-by from Neil Armstrong.
- Patches 2-3: Return early when dsi_ctx.accum_err is clear and fall through to the err label on failure, as suggested by Neil Armstrong.
- Link to v1: https://lore.kernel.org/r/[email protected]

Hsieh Hung-En (3):
drm/panel: novatek-nt37705: Fix prepare error cleanup drm/panel: novatek-nt37705: Use mipi_dsi_*_multi() in prepare() drm/panel: raydium-rm69220: Use mipi_dsi_*_multi() in prepare()

 drivers/gpu/drm/panel/panel-novatek-nt37705.c | 28 ++++++++-----------
 drivers/gpu/drm/panel/panel-raydium-rm69220.c | 21 +++++---------
 2 files changed, 19 insertions(+), 30 deletions(-)

base-commit: d7248c50b2b09f2680071b0b6d02ce9c2a569f5f

Signature · 1 line
2.43.0
#1 lore raw

PATCH v2 1/3 drm/panel: novatek-nt37705: Fix prepare error cleanup

If mipi_dsi_picture_parameter_set() or mipi_dsi_compression_mode() fails in nt37705_prepare(), the error is returned directly without asserting reset_gpio or disabling the regulators. Because drm_panel_prepare() does not mark the panel as prepared on failure, nt37705_unprepare() will not be called, leaving reset deasserted and leaking the enable count on all three supplies (vddio, dvdd, vci) so they can no longer be powered off.

Route all failure paths after nt37705_reset() through a shared error cleanup path that asserts reset_gpio and disables the supplies.

Fixes 9ffe0df0262b ("drm/panel: Add driver for Novatek NT37705 panel")
---
 drivers/gpu/drm/panel/panel-novatek-nt37705.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/panel/panel-novatek-nt37705.c +8 -5
index 342e58591bab..a37bbd569ee5 100644
@@ -209,9 +209,7 @@ static int nt37705_prepare(struct drm_panel *panel)
 	ret = nt37705_on(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(nt37705_supplies), ctx->supplies);
-		return ret;
+		goto err;
 	}
 
 	drm_dsc_pps_payload_pack(&pps, &ctx->dsc);
@@ -219,18 +217,23 @@ static int nt37705_prepare(struct drm_panel *panel)
 	ret = mipi_dsi_picture_parameter_set(ctx->dsi, &pps);
 	if (ret < 0) {
 		dev_err(panel->dev, "failed to transmit PPS: %d\n", ret);
-		return ret;
+		goto err;
 	}
 
 	ret = mipi_dsi_compression_mode(ctx->dsi, true);
 	if (ret < 0) {
 		dev_err(dev, "failed to enable compression mode: %d\n", ret);
-		return ret;
+		goto err;
 	}
 
 	msleep(28); /* TODO: Is this panel-dependent? */
 
 	return 0;
+
+err:
+	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
+	regulator_bulk_disable(ARRAY_SIZE(nt37705_supplies), ctx->supplies);
+	return ret;
 }
 
 static int nt37705_unprepare(struct drm_panel *panel)
Signature · 1 line
2.43.0
#2 lore raw

PATCH v2 2/3 drm/panel: novatek-nt37705: Use mipi_dsi_*_multi() in prepare()

In reply to Hsieh Hung-En

Replace the deprecated mipi_dsi_picture_parameter_set() call in nt37705_prepare() with mipi_dsi_picture_parameter_set_multi(), as suggested in Documentation/gpu/todo.rst. Also convert the subsequent mipi_dsi_compression_mode() and msleep(28) calls to mipi_dsi_compression_mode_multi() and mipi_dsi_msleep() so the whole DSC setup sequence shares one mipi_dsi_multi_context and a single error check.

The _multi() helpers log transfer errors automatically, removing the need for the manual dev_err() calls. As before, the 28ms delay is skipped on failure. The command sequence and error cleanup path are unchanged.

---
 drivers/gpu/drm/panel/panel-novatek-nt37705.c | 21 +++++++------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-novatek-nt37705.c +7 -14
index a37bbd569ee5..bff1955581d9 100644
@@ -194,6 +194,7 @@ static int nt37705_off(struct nt37705_panel *ctx)
 static int nt37705_prepare(struct drm_panel *panel)
 {
 	struct nt37705_panel *ctx = to_nt37705_panel(panel);
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 	struct device *dev = &ctx->dsi->dev;
 	struct drm_dsc_picture_parameter_set pps;
 	int ret;
@@ -213,22 +214,14 @@ static int nt37705_prepare(struct drm_panel *panel)
 	}
 
 	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); /* TODO: Is this panel-dependent? */
 
-	ret = mipi_dsi_picture_parameter_set(ctx->dsi, &pps);
-	if (ret < 0) {
-		dev_err(panel->dev, "failed to transmit PPS: %d\n", ret);
-		goto err;
-	}
-
-	ret = mipi_dsi_compression_mode(ctx->dsi, true);
-	if (ret < 0) {
-		dev_err(dev, "failed to enable compression mode: %d\n", ret);
-		goto err;
-	}
+	if (!dsi_ctx.accum_err)
+		return 0;
 
-	msleep(28); /* TODO: Is this panel-dependent? */
-
-	return 0;
+	ret = dsi_ctx.accum_err;
 
 err:
 	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
Signature · 1 line
2.43.0
#3 lore raw

PATCH v2 3/3 drm/panel: raydium-rm69220: Use mipi_dsi_*_multi() in prepare()

In reply to Hsieh Hung-En

Replace the deprecated mipi_dsi_picture_parameter_set() call in raydium_rm69220_prepare() with mipi_dsi_picture_parameter_set_multi(), as suggested in Documentation/gpu/todo.rst. Also convert the subsequent mipi_dsi_compression_mode() and msleep(28) calls to mipi_dsi_compression_mode_multi() and mipi_dsi_msleep() so the whole DSC setup sequence shares one mipi_dsi_multi_context and a single error check.

The _multi() helpers log transfer errors automatically, removing the need for the manual dev_err() calls. As before, the 28ms delay is skipped on failure. The command sequence and error cleanup path are unchanged.

---
 drivers/gpu/drm/panel/panel-raydium-rm69220.c | 21 +++++++------------
 1 file changed, 7 insertions(+), 14 deletions(-)
drivers/gpu/drm/panel/panel-raydium-rm69220.c +7 -14
index 3030f8b89760..9ea621d6fb92 100644
@@ -218,6 +218,7 @@ static int raydium_rm69220_off(struct raydium_rm69220 *ctx)
 static int raydium_rm69220_prepare(struct drm_panel *panel)
 {
 	struct raydium_rm69220 *ctx = to_raydium_rm69220(panel);
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = ctx->dsi };
 	struct device *dev = &ctx->dsi->dev;
 	struct drm_dsc_picture_parameter_set pps;
 	int ret;
@@ -237,22 +238,14 @@ static int raydium_rm69220_prepare(struct drm_panel *panel)
 	}
 
 	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 = mipi_dsi_picture_parameter_set(ctx->dsi, &pps);
-	if (ret < 0) {
-		dev_err(dev, "failed to transmit PPS: %d\n", ret);
-		goto err;
-	}
-
-	ret = mipi_dsi_compression_mode(ctx->dsi, true);
-	if (ret < 0) {
-		dev_err(dev, "failed to enable compression mode: %d\n", ret);
-		goto err;
-	}
+	if (!dsi_ctx.accum_err)
+		return 0;
 
-	msleep(28);
-
-	return 0;
+	ret = dsi_ctx.accum_err;
 
 err:
 	gpiod_set_value_cansleep(ctx->reset_gpio, 1);
Signature · 1 line
2.43.0