mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Akash Sukhavasi <akash.sukhavasi@gmail.com>
To: Doug Anderson <dianders@chromium.org>,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Jessica Zhang <jesszhan0024@gmail.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	 David Airlie <airlied@gmail.com>,
	Simona Vetter <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 Akash Sukhavasi <akash.sukhavasi@gmail.com>,
	 Chris Morgan <macromorgan@hotmail.com>
Subject: [PATCH 4/4] drm/panel: newvision-nv3051d: Use mipi_dsi_*_multi(); fix minor bugs
Date: Mon, 12 Oct 2026 23:34:39 -0500	[thread overview]
Message-ID: <20261012-mipi-multi-series-v1-4-6a29add1ec92@gmail.com> (raw)
In-Reply-To: <20261012-mipi-multi-series-v1-0-6a29add1ec92@gmail.com>

The mipi_dsi_dcs_*() functions used by this driver are deprecated in
favour of their _multi() counterparts, as noted in
Documentation/gpu/todo.rst. The _multi() variants record the first
error in a context structure and skip subsequent calls once an error
is set, removing the need to check the return value after each command.
They also log failures internally, making the per-call dev_err() calls
redundant.

Convert prepare() and unprepare() to use the _multi() equivalents.

In prepare(), use mipi_dsi_msleep() and mipi_dsi_usleep_range() instead
of plain msleep()/usleep_range() for delays between DSI commands, so
they are skipped on prior error since the function will clean up via the
existing disable_vdd label anyway.

In unprepare(), keep plain msleep() and usleep_range() since the
hardware delays must execute regardless of any prior DSI error. The
original code logged a set_display_off() failure and still attempted
enter_sleep_mode(), so clear accum_err after set_display_off_multi()
to keep that behaviour.

This also fixes a bug where a failure in enter_sleep_mode would return
early, skipping the post-sleep delay, reset GPIO assertion, and
regulator disable, leaving the panel stuck in a prepared state. Because
drm_panel_unprepare() does not clear panel->prepared when the callback
returns an error, drm_panel_prepare() would return early on the next
call, leaving the panel unable to be re-initialised.

Cc: Chris Morgan <macromorgan@hotmail.com>
Signed-off-by: Akash Sukhavasi <akash.sukhavasi@gmail.com>
---
Compile tested only, no hardware available. checkpatch and a W=1
build are clean.
---
 drivers/gpu/drm/panel/panel-newvision-nv3051d.c | 36 +++++++++----------------
 1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-newvision-nv3051d.c b/drivers/gpu/drm/panel/panel-newvision-nv3051d.c
index 22560384e48e..7dc25102a773 100644
--- a/drivers/gpu/drm/panel/panel-newvision-nv3051d.c
+++ b/drivers/gpu/drm/panel/panel-newvision-nv3051d.c
@@ -247,19 +247,14 @@ static int panel_nv3051d_unprepare(struct drm_panel *panel)
 {
 	struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
-	int ret;
-
-	ret = mipi_dsi_dcs_set_display_off(dsi);
-	if (ret < 0)
-		dev_err(ctx->dev, "failed to set display off: %d\n", ret);
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 
+	mipi_dsi_dcs_set_display_off_multi(&dsi_ctx);
+	/* Reset error to continue power-down sequence even if display off failed */
+	dsi_ctx.accum_err = 0;
 	msleep(20);
-
-	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(ctx->dev, "failed to enter sleep mode: %d\n", ret);
-		return ret;
-	}
+	/* Enter sleep mode; error does not prevent power-off */
+	mipi_dsi_dcs_enter_sleep_mode_multi(&dsi_ctx);
 
 	usleep_range(10000, 15000);
 
@@ -274,6 +269,7 @@ static int panel_nv3051d_prepare(struct drm_panel *panel)
 {
 	struct panel_nv3051d *ctx = panel_to_panelnv3051d(panel);
 	struct mipi_dsi_device *dsi = to_mipi_dsi_device(ctx->dev);
+	struct mipi_dsi_multi_context dsi_ctx = { .dsi = dsi };
 	int ret;
 
 	dev_dbg(ctx->dev, "Resetting the panel\n");
@@ -295,22 +291,16 @@ static int panel_nv3051d_prepare(struct drm_panel *panel)
 		goto disable_vdd;
 	}
 
-	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
-	if (ret < 0) {
-		dev_err(ctx->dev, "Failed to exit sleep mode: %d\n", ret);
-		goto disable_vdd;
-	}
-
-	msleep(200);
+	mipi_dsi_dcs_exit_sleep_mode_multi(&dsi_ctx);
+	mipi_dsi_msleep(&dsi_ctx, 200);
+	mipi_dsi_dcs_set_display_on_multi(&dsi_ctx);
+	mipi_dsi_usleep_range(&dsi_ctx, 10000, 15000);
 
-	ret = mipi_dsi_dcs_set_display_on(dsi);
-	if (ret < 0) {
-		dev_err(ctx->dev, "Failed to set display on: %d\n", ret);
+	if (dsi_ctx.accum_err) {
+		ret = dsi_ctx.accum_err;
 		goto disable_vdd;
 	}
 
-	usleep_range(10000, 15000);
-
 	return 0;
 
 disable_vdd:

-- 
2.56.0


  parent reply	other threads:[~2026-10-13  4:35 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13  4:34 [PATCH 0/4] drm/panel: Convert four panel drivers to mipi_dsi_*_multi() Akash Sukhavasi
2026-10-13  4:34 ` [PATCH 1/4] drm/panel: leadtek-ltk500hd1829: Use mipi_dsi_*_multi() Akash Sukhavasi
2026-10-30  2:09   ` Doug Anderson
2026-10-13  4:34 ` [PATCH 2/4] drm/panel: kingdisplay-kd097d04: Use mipi_dsi_*_multi(); fix minor bugs Akash Sukhavasi
2026-10-30  2:09   ` Doug Anderson
2026-10-13  4:34 ` [PATCH 3/4] drm/panel: innolux-p079zca: " Akash Sukhavasi
2026-10-30  2:09   ` Doug Anderson
2026-10-13  4:34 ` Akash Sukhavasi [this message]
2026-10-30  2:09   ` [PATCH 4/4] drm/panel: newvision-nv3051d: " Doug Anderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261012-mipi-multi-series-v1-4-6a29add1ec92@gmail.com \
    --to=akash.sukhavasi@gmail.com \
    --cc=airlied@gmail.com \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=macromorgan@hotmail.com \
    --cc=mripard@kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®