All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/panel: samsung-s6d16d0: Power off on prepare failure
@ 2026-07-03 16:56 Laxman Acharya Padhya
  2026-07-03 17:06 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Laxman Acharya Padhya @ 2026-07-03 16:56 UTC (permalink / raw)
  To: Neil Armstrong, Jessica Zhang
  Cc: Linus Walleij, dri-devel, linux-kernel, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Laxman Acharya Padhya

If enabling tearing mode or exiting sleep mode fails after the
regulator is enabled, s6d16d0_prepare() returns without asserting
reset or disabling the supply. Since the DRM panel core leaves the
panel unprepared, a later unprepare call skips the driver callback
and the supply remains enabled.

Assert reset and disable the supply before returning the DSI command error.

Fixes: ac1d6d74884e ("drm/panel: Add driver for Samsung S6D16D0 panel")
Assisted-by: Codex:gpt-5
Signed-off-by: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>
---
Changes in v2:
- Resend as plain text with git-send-email.
- Correct author, sign-off, and recipient formatting.
- No code changes.

 drivers/gpu/drm/panel/panel-samsung-s6d16d0.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
index ba1a02000..04e19b5f2 100644
--- a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
+++ b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
@@ -89,16 +89,22 @@ static int s6d16d0_prepare(struct drm_panel *panel)
 				       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
 	if (ret) {
 		dev_err(s6->dev, "failed to enable vblank TE (%d)\n", ret);
-		return ret;
+		goto err_power_off;
 	}
 	/* Exit sleep mode and power on */
 	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
 	if (ret) {
 		dev_err(s6->dev, "failed to exit sleep mode (%d)\n", ret);
-		return ret;
+		goto err_power_off;
 	}
 
 	return 0;
+
+err_power_off:
+	gpiod_set_value_cansleep(s6->reset_gpio, 1);
+	regulator_disable(s6->supply);
+
+	return ret;
 }
 
 static int s6d16d0_enable(struct drm_panel *panel)
-- 
2.51.2

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

* Re: [PATCH v2] drm/panel: samsung-s6d16d0: Power off on prepare failure
  2026-07-03 16:56 [PATCH v2] drm/panel: samsung-s6d16d0: Power off on prepare failure Laxman Acharya Padhya
@ 2026-07-03 17:06 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-07-03 17:06 UTC (permalink / raw)
  To: Laxman Acharya Padhya; +Cc: dri-devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Early returns on DSI command failures in teardown functions (`s6d16d0_unprepare` and `s6d16d0_disable`) bypass hardware power-off and cause DRM state machine desynchronization.
--

commit 5d36b39e4bbd28714a2875efbe7aa78f7026a69d
Author: Laxman Acharya Padhya <acharyalaxman8848@gmail.com>

drm/panel: samsung-s6d16d0: Power off on prepare failure

If enabling tearing mode or exiting sleep mode fails after the
regulator is enabled, s6d16d0_prepare() returns without asserting
reset or disabling the supply. Since the DRM panel core leaves the
panel unprepared, a later unprepare call skips the driver callback
and the supply remains enabled.

Assert reset and disable the supply before returning the DSI command error.

> diff --git a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
> index ba1a02000bb9d..04e19b5f22f8b 100644
> --- a/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
> +++ b/drivers/gpu/drm/panel/panel-samsung-s6d16d0.c
> @@ -89,16 +89,22 @@ static int s6d16d0_prepare(struct drm_panel *panel)
>  				       MIPI_DSI_DCS_TEAR_MODE_VBLANK);
>  	if (ret) {
>  		dev_err(s6->dev, "failed to enable vblank TE (%d)\n", ret);
> -		return ret;
> +		goto err_power_off;
>  	}
>  	/* Exit sleep mode and power on */
>  	ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
>  	if (ret) {
>  		dev_err(s6->dev, "failed to exit sleep mode (%d)\n", ret);
> -		return ret;
> +		goto err_power_off;
>  	}
>  
>  	return 0;
> +
> +err_power_off:
> +	gpiod_set_value_cansleep(s6->reset_gpio, 1);
> +	regulator_disable(s6->supply);
> +
> +	return ret;
>  }

[Severity: High]
This is a pre-existing issue, but since this patch fixes the error path in
s6d16d0_prepare(), does the same early return problem exist in
s6d16d0_unprepare() and s6d16d0_disable()?

Looking at s6d16d0_unprepare(), if mipi_dsi_dcs_enter_sleep_mode() fails,
it returns early:

drivers/gpu/drm/panel/panel-samsung-s6d16d0.c:s6d16d0_unprepare() {
    ...
	ret = mipi_dsi_dcs_enter_sleep_mode(dsi);
	if (ret) {
		dev_err(s6->dev, "failed to enter sleep mode (%d)\n", ret);
		return ret;
	}

	/* Assert RESET */
	gpiod_set_value_cansleep(s6->reset_gpio, 1);
	regulator_disable(s6->supply);

	return 0;
}

Can this early return bypass regulator_disable(), leaving the regulator
permanently enabled?

Furthermore, because these functions return an error, the DRM core skips
updating the panel state. 

Similarly, if mipi_dsi_dcs_set_display_off() fails in s6d16d0_disable():

drivers/gpu/drm/panel/panel-samsung-s6d16d0.c:s6d16d0_disable() {
    ...
	ret = mipi_dsi_dcs_set_display_off(dsi);
	if (ret) {
		dev_err(s6->dev, "failed to turn display off (%d)\n", ret);
		return ret;
	}
    ...
}

Will the early error return in both of these teardown functions cause a
permanent desynchronization between the panel and the DRM state machine,
where subsequent attempts to enable the panel skip the prepare and enable
callbacks?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703165632.27027-1-acharyalaxman8848@gmail.com?part=1

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

end of thread, other threads:[~2026-07-03 17:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-03 16:56 [PATCH v2] drm/panel: samsung-s6d16d0: Power off on prepare failure Laxman Acharya Padhya
2026-07-03 17:06 ` 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.