dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Devarsh Thakkar" <devarsht@ti.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 05/14] drm/solomon: ssd16xx: Add clear_on_init/close/disable session management
Date: Sun, 27 Sep 2026 18:38:12 +0000	[thread overview]
Message-ID: <20260927183812.A2F3F1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260927182329.4193961-6-devarsht@ti.com>

Thank you for your contribution! Sashiko AI review found 6 potential issue(s) to consider:
- [High] drm: sleeping in atomic context during CRTC enable/disable
- [High] drm/solomon: unsynchronized clear in master_drop races with atomic commits
- [High] drm/solomon: clear_display hardcodes RAM address counters to 0x00
- [Medium] drm/solomon: clear_display writes 0xFF to RED RAM causing red screen
- [Medium] drm/solomon: display_cleared_on_deinit flag is not reset on enable
- [Medium] drm/solomon: clear_on_init bypasses active CRTCs during master handover
--

commit 90ac1ffc13e17b560cc95b731a7e77c4602e7b77
Author: Devarsh Thakkar <devarsht@ti.com>

drm/solomon: ssd16xx: Add clear_on_init/close/disable session management

E-paper displays are bistable: the last rendered image persists indefinitely
across sessions and power cycles. This creates a session management choice
with no LCD/OLED equivalent since unlike volatile displays, content
visibility outlives the rendering process. Add session-lifetime display
clearing with three configurable hooks: clear_on_init, clear_on_close, and
clear_on_disable.

> diff --git a/drivers/gpu/drm/solomon/ssd16xx.c b/drivers/gpu/drm/solomon/ssd16xx.c
> index d3af055c67398..c478309d08e9f 100644
> --- a/drivers/gpu/drm/solomon/ssd16xx.c
> +++ b/drivers/gpu/drm/solomon/ssd16xx.c
[ ... ]
> @@ -746,6 +766,111 @@ static int ssd16xx_hw_init(struct ssd16xx_device *device)
>  	return err;
>  }
>  
> +/*
> + * Clear display by writing all-white to both BW and RED RAM.
> + * The ctrl2 argument selects the waveform (full/partial/fast refresh).
> + * Border waveform is set to init value before clearing, then restored
> + * to the update value to preserve the border during subsequent updates.
> + */
> +static int ssd16xx_clear_display(struct ssd16xx_device *device, u8 ctrl2)
> +{
> +	const u8 *bw_tbl = device->controller_cfg->border_waveform_table;
> +	int err = 0;
> +	unsigned int data_size = (device->width * device->height) / 8;
> +	u8 *white_buffer = device->tx_buf;
> +
> +	memset(white_buffer, 0xFF, data_size);

[Severity: High]
Can this unsynchronized memset cause a data race? 

When a DRM master drops, ssd16xx_drm_master_drop calls
ssd16xx_clear_display_on_exit. If an atomic commit is concurrently executing
in a background worker, both paths will mutate device->tx_buf without locks,
which could interleave SPI commands and corrupt the controller state.

> +
> +	ssd16xx_send_cmd(device, SSD16XX_CMD_SET_RAM_X_ADDRESS_COUNTER, &err);
> +	ssd16xx_send_x_param(device, 0x00, &err);
> +
> +	ssd16xx_send_cmd(device, SSD16XX_CMD_SET_RAM_Y_ADDRESS_COUNTER, &err);
> +	ssd16xx_send_y_param(device, 0x00, &err);

[Severity: High]
Does hardcoding the RAM X and Y address counters to 0x00 break decrement-mode
writes and omit window setup? 

In portrait orientation (decrement entry modes), starting at 0x00 might
immediately underflow the counter and write out-of-bounds. 

Also, if the previous operation was a partial update, could the RAM window
remain restricted, causing the clear operation to wrap around and fail to
clear the full screen?

> +
> +	ssd16xx_send_cmd(device, SSD16XX_CMD_WRITE_RAM_BW, &err);
> +	ssd16xx_send_data_bulk(device, white_buffer, data_size, &err);
> +
> +	ssd16xx_send_cmd(device, SSD1683_CMD_WRITE_RAM_RED, &err);
> +	ssd16xx_send_data_bulk(device, white_buffer, data_size, &err);

[Severity: Medium]
Does this write 0xFF to the RED RAM unconditionally? 

On 3-color (BWR) panels where a 1 bit represents red ink, this would clear
the screen to solid red instead of white. On 2-color panels, it sends an
unsupported command (0x26), which could corrupt hardware state.

[ ... ]
> @@ -1356,11 +1481,26 @@ static void ssd16xx_crtc_atomic_disable(struct drm_crtc *crtc,
>  					struct drm_atomic_commit *state)
>  {
>  	struct ssd16xx_device *device = crtc_to_ssd16xx_device(crtc);
> -	int idx;
> +	int ret, idx;
>  
>  	if (!drm_dev_enter(&device->drm, &idx))
>  		return;
>  
> +	if (device->clear_on_disable < 0 || device->display_cleared_on_deinit)
> +		goto out;
> +
> +	drm_dbg(&device->drm, "clear_on_disable: running, mode=%d\n",
> +		device->clear_on_disable);
> +	ret = ssd16xx_clear_display(device,
> +				    ssd16xx_refresh_mode_to_ctrl2(device,
> +								  device->clear_on_disable));

[Severity: High]
Can this cause a sleep in atomic context? 

The CRTC atomic_disable callback executes in atomic context where sleeping is
forbidden, but it conditionally calls ssd16xx_clear_display, which relies on
SPI transactions and polling with usleep_range in ssd16xx_wait_for_device.

> +	if (ret) {
> +		drm_err(&device->drm, "atomic_disable: clear failed: %d\n", ret);
> +		goto out;
> +	}
> +
> +	device->display_cleared_on_deinit = true;

[Severity: Medium]
Is the display_cleared_on_deinit flag missing a reset on enable? 

DPMS off sets the flag to true, but since atomic_enable does not reset it,
subsequent DPMS toggles during a single session might silently skip the clear
operation.

> +out:
>  	drm_dev_exit(idx);
>  }
>  
> @@ -1383,6 +1523,11 @@ static void ssd16xx_crtc_atomic_enable(struct drm_crtc *crtc,
>  	}
>  	device->initialized = true;
>  
> +	/* Clear display on first app launch if configured */
> +	ret = ssd16xx_clear_display_on_init(device);

[Severity: High]
Can this cause a sleep in atomic context? 

Similar to atomic_disable, the CRTC atomic_enable callback executes in atomic
context where sleeping is forbidden, but calling ssd16xx_clear_display_on_init
leads to ssd16xx_clear_display which eventually polls with usleep_range.

[Severity: Medium]
Does this bypass active CRTCs during master handover? 

The clear_on_init hook is inside atomic_enable, which is only called on
transitions from disabled to enabled. If a new DRM master takes over without
triggering a full modeset (e.g. the CRTC remains active), the clean-slate
clear might not fire.

> +	if (ret)
> +		drm_err(&device->drm, "crtc_atomic_enable: clear on init failed: %d\n", ret);
> +
>  	/*
>  	 * If refresh_mode_init is set, arm init_refresh_pending so
>  	 * plane_atomic_update uses the specified mode for the first frame

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260927182329.4193961-1-devarsht@ti.com?part=5

  reply	other threads:[~2026-09-27 18:38 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-27 18:23 [PATCH v2 00/14] Add DRM driver for Solomon SSD16xx e-paper display controllers Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 01/14] dt-bindings: vendor-prefixes: Add Dalian Good Display Co., Ltd Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 02/14] dt-bindings: display: Add Solomon SSD16xx e-paper controller binding Devarsh Thakkar
2026-09-27 18:37   ` sashiko-bot
2026-10-01  6:28   ` Krzysztof Kozlowski
2026-10-05 16:36     ` Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 03/14] dt-bindings: display: solomon, ssd16xx: Add Solomon SSD1677 controller Devarsh Thakkar
2026-09-27 18:35   ` [PATCH v2 03/14] dt-bindings: display: solomon,ssd16xx: " sashiko-bot
2026-10-01  6:26   ` Krzysztof Kozlowski
2026-09-27 18:23 ` [PATCH v2 04/14] drm/solomon: Add DRM driver for Solomon SSD16xx e-paper display controllers Devarsh Thakkar
2026-09-27 18:42   ` sashiko-bot
2026-09-28  7:00   ` Thomas Zimmermann
2026-09-29 16:43     ` Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 05/14] drm/solomon: ssd16xx: Add clear_on_init/close/disable session management Devarsh Thakkar
2026-09-27 18:38   ` sashiko-bot [this message]
2026-09-27 18:23 ` [PATCH v2 06/14] drm/solomon: ssd16xx: Add support for Solomon SSD1677 controller Devarsh Thakkar
2026-09-27 18:40   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 07/14] drm/solomon: ssd16xx: Add power management support Devarsh Thakkar
2026-09-27 18:41   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 08/14] drm/solomon: ssd16xx: Expose refresh mode as plane property Devarsh Thakkar
2026-09-27 18:43   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 09/14] drm/solomon: ssd16xx: Expose color " Devarsh Thakkar
2026-09-27 18:43   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 10/14] drm/solomon: ssd16xx: Expose session management as plane properties Devarsh Thakkar
2026-09-27 18:38   ` sashiko-bot
2026-09-27 18:23 ` [PATCH v2 11/14] drm/solomon: ssd16xx: support panels whose RAM X order is reversed Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 12/14] MAINTAINERS: Add entry for Solomon SSD16xx DRM driver Devarsh Thakkar
2026-09-27 18:23 ` [PATCH v2 13/14] arm64: defconfig: Enable DRM_SSD16XX for AM62L3 EVM Devarsh Thakkar
2026-09-27 18:23 ` [DO_NOT_MERGE PATCH v2 14/14] arm64: dts: ti: Add AM62L3 EVM overlay for GDEY042T81 e-paper display Devarsh Thakkar
2026-09-27 18:40   ` sashiko-bot
2026-10-02  8:56 ` [PATCH v2 00/14] Add DRM driver for Solomon SSD16xx e-paper display controllers LiangCheng Wang

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