drm/panel: samsung-s6d16d0: Power off on prepare failure
Subsystems (3)
PATCH v3 1/1 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.
---
Changes in v3:
- Regenerate with git-format-patch to preserve tabs and whitespace.
- No code changes.
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(-)
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c +8 -2
@@ -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)
Signature · 1 line
2.51.2
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] Early return in s6d16d0_unprepare() on DSI error leaks power regulator and desynchronizes DRM panel state. --
commit e398cf036f75b574cfdb355a824bb1c7fcdb24f9
Author: Laxman Acharya Padhya <[email protected]>
drm/panel: samsung-s6d16d0: Power off on prepare failure
This commit fixes an issue in s6d16d0_prepare() where failing to enable tearing mode or exiting sleep mode would return without asserting reset or disabling the power supply. The change updates the error path to correctly assert reset and disable the regulator before returning.
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c static int s6d16d0_prepare(struct drm_panel *panel)
Quoted 5 lines
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c +0
-0@@ -88,16 +88,22 @@ static int s6d16d0_prepare(struct drm_panel *panel)
[Severity: Medium]
This is a pre-existing issue, but I noticed a similar resource leak in s6d16d0_unprepare() located just above this function in drivers/gpu/drm/panel/panel-samsung-s6d16d0.c.
If mipi_dsi_dcs_enter_sleep_mode() fails during display disable, the function returns early:
static int s6d16d0_unprepare(struct drm_panel *panel)
{
...
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 leak the regulator enable count by skipping regulator_disable() on the error path?
Would this leave the DRM panel state machine desynchronized since the resource cleanup is skipped?
Quoted 24 lines
drivers/gpu/drm/panel/panel-samsung-s6d16d0.c +8
-2MIPI_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)
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 11 lines · 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-5Signed-off-by Laxman Acharya Padhya <[email protected]>
Patch applied!
Yours,
Linus Walleij