Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vsevolod Nevorotov" <sevanevorotov29@gmail.com>
Cc: robh@kernel.org, dri-devel@lists.freedesktop.org,
	devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH 2/2] drm/panel: Add Samsung AMS662ZS01 panel driver
Date: Mon, 07 Sep 2026 12:12:10 +0000	[thread overview]
Message-ID: <20260907121210.A4C741F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260907115130.95394-3-sevanevorotov29@gmail.com>

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [High] Panel reset GPIO is initialized to physical HIGH while regulators are off, causing hardware back-powering.
- [Medium] Data race on shared `dsi->mode_flags` due to non-atomic modification in sysfs backlight update callback.
- [Medium] The backlight sysfs interface issues DSI transfers to an unpowered panel.
--

commit df8bf199977cc597d9cc38caadd2457c9f44d341
Author: Vsevolod Nevorotov <sevanevorotov29@gmail.com>

    drm/panel: Add Samsung AMS662ZS01 panel driver
    
    Add support for the Samsung AMS662ZS01 AMOLED display panel used in the
    OnePlus 9RT (martini) smartphone.
    
    The panel operates in Command Mode with DSC (Display Stream Compression)
    enabled at 1080x2400 resolution at 60Hz.

> diff --git a/drivers/gpu/drm/panel/panel-samsung-ams662zs01.c b/drivers/gpu/drm/panel/panel-samsung-ams662zs01.c
> new file mode 100644
> index 0000000000000..52e7e75c08b13
> --- /dev/null
> +++ b/drivers/gpu/drm/panel/panel-samsung-ams662zs01.c
> [ ... ]
> @@ -267,11 +267,10 @@ static int ams662zs01_bl_update_status(struct backlight_device *bl)
>  {
>  	struct mipi_dsi_device *dsi = bl_get_data(bl);
>  	u16 brightness = backlight_get_brightness(bl);
>  	int ret;
>  
>  	dsi->mode_flags &= ~MIPI_DSI_MODE_LPM;
>  	ret = mipi_dsi_dcs_set_display_brightness_large(dsi, brightness);
>  	dsi->mode_flags |= MIPI_DSI_MODE_LPM;

[Severity: Medium]
Could this create a data race on dsi->mode_flags?

The backlight subsystem uses bl->update_lock while DRM uses
drm_modeset_lock, providing no mutual exclusion between these paths. A
concurrent sysfs write to the backlight brightness node during
ams662zs01_prepare() could race on dsi->mode_flags. This might cause
display initialization commands to be sent in the wrong power mode.

[Severity: Medium]
Does this function lack a check to ensure the panel is prepared and powered
on before attempting DSI communication?

If userspace writes to the backlight sysfs node while the panel is
unprepared (screen off or system suspended), this unconditionally sends DCS
commands. Attempting a DSI transfer while the panel's regulators are
disabled could cause hardware timeouts, bus errors, or host driver failures.

>  
>  	return ret;
>  }
> [ ... ]
> @@ -311,9 +310,10 @@ static int ams662zs01_probe(struct mipi_dsi_device *dsi)
>  	if (IS_ERR(ctx))
>  		return PTR_ERR(ctx);
>  
>  	ret = devm_regulator_bulk_get_const(dev, ARRAY_SIZE(ams662zs01_supplies),
>  					    ams662zs01_supplies, &ctx->supplies);
>  	if (ret < 0)
>  		return ret;
>  
>  	ctx->reset_gpio = devm_gpiod_get(dev, "reset", GPIOD_OUT_LOW);

[Severity: High]
Does this initialize the active-low reset GPIO to physical HIGH before the
panel's regulators are turned on?

Calling devm_gpiod_get() with GPIOD_OUT_LOW on an active-low GPIO
immediately drives the pin physically HIGH. Driving the reset GPIO high
while the panel's main power rails (VDDIO/VDD) are off could forward-bias
the ESD protection diodes inside the panel driver IC. This back-powers the
IC logic domain, which might cause permanent hardware damage or latch-up
preventing panel initialization.

>  	if (IS_ERR(ctx->reset_gpio))
>  		return dev_err_probe(dev, PTR_ERR(ctx->reset_gpio),
>  				     "Failed to get reset-gpios\n");
> [ ... ]
> @@ -330,9 +330,10 @@ static int ams662zs01_probe(struct mipi_dsi_device *dsi)
>  	dsi->format = MIPI_DSI_FMT_RGB888;
>  	dsi->mode_flags = MIPI_DSI_MODE_NO_EOT_PACKET |
>  			  MIPI_DSI_CLOCK_NON_CONTINUOUS |
>  			  MIPI_DSI_MODE_LPM;
>  
>  	ctx->panel.prepare_prev_first = true;
>  
>  	ctx->panel.backlight = ams662zs01_create_backlight(dsi);
>  	if (IS_ERR(ctx->panel.backlight))
>  		return dev_err_probe(dev, PTR_ERR(ctx->panel.backlight),
>  				     "Failed to create backlight\n");

[Severity: Medium]
Is it safe to expose the backlight sysfs interface here before the DSI
device is attached to the host?

Because the backlight device is registered here, it is exposed to userspace
while the panel is unprepared and before mipi_dsi_attach() is called. This
makes the unprotected DSI transfers in ams662zs01_bl_update_status()
reachable immediately, even while the panel is suspended.

>  
>  	drm_panel_add(&ctx->panel);

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

      reply	other threads:[~2026-09-07 12:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-07 11:51 [PATCH 0/2] drm/panel: Add support for Samsung AMS662ZS01 panel Vsevolod Nevorotov
2026-09-07 11:51 ` [PATCH 1/2] dt-bindings: display: panel: Add Samsung AMS662ZS01 Vsevolod Nevorotov
2026-09-07 12:01   ` sashiko-bot
2026-09-07 11:51 ` [PATCH 2/2] drm/panel: Add Samsung AMS662ZS01 panel driver Vsevolod Nevorotov
2026-09-07 12:12   ` sashiko-bot [this message]

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=20260907121210.A4C741F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sevanevorotov29@gmail.com \
    /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