Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Luo Liu" <Luo.Liu@cixtech.com>
Cc: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v7 3/5] drm/bridge: trilinear: add the DPTX DRM bridge
Date: Fri, 27 Nov 2026 08:06:51 +0000	[thread overview]
Message-ID: <sashiko-outbox-236860@kernel.org> (raw)
In-Reply-To: <20261127074639.277959-4-Luo.Liu@cixtech.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/bridge: trilinear: htotal and clock overflow in
  dptx_adjust_mode()
--

commit 121beb945da3bca1311595f6221c3e03dd980739
Author: Luo Liu <Luo.Liu@cixtech.com>

drm/bridge: trilinear: add the DPTX DRM bridge

This commit adds the DRM bridge implementation for the Trilinear DisplayPort
transmitter, handling connector detection, EDID and downstream mode
enumeration, mode validation, and atomic modesetting callbacks.

> diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_drm.c b/drivers/gpu/drm/bridge/trilinear/dptx_drm.c
> new file mode 100644
> index 0000000000000..7a081873560bf
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_drm.c

[ ... ]

> +static void dptx_adjust_mode(const struct drm_display_mode *mode,
> +			     struct drm_display_mode *adjusted_mode)
> +{
> +	int diff = mode->htotal - mode->hsync_end;
> +
> +	if (diff < DPTX_MIN_H_BACKPORCH) {
> +		adjusted_mode->htotal = mode->htotal +
> +					DPTX_MIN_H_BACKPORCH - diff;
> +		adjusted_mode->clock =
> +			div_u64(mul_u32_u32(mode->clock, adjusted_mode->htotal),
> +				mode->htotal);
> +	}

[Severity: Medium]
Can adjusted_mode->htotal and adjusted_mode->clock overflow here when a
userspace mode has a horizontal backporch smaller than DPTX_MIN_H_BACKPORCH?

Because adjusted_mode->htotal is a u16 and adjusted_mode->clock is a signed
int, a custom mode with mode->hsync_end >= 65524 wraps adjusted_mode->htotal
to 0..11 and truncates adjusted_mode->clock to 0 (or overflows
adjusted_mode->clock past INT_MAX when mode->clock is near INT_MAX).

dptx_bridge_mode_valid() and dptx_bridge_atomic_check() only check the upper
bound of adjusted_mode->clock, so the wrapped value passes validation and
reaches dptx_bridge_atomic_enable(), where dptx_hw_stream_timing_set()
underflows mode->htotal - mode->hdisplay and divides by zero on mode->clock:

drivers/gpu/drm/bridge/trilinear/dptx_hw.c:dptx_hw_stream_timing_set() {
    ...
	dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
		      (mode->htotal - mode->hdisplay) * (link_rate / 40) *
		      9 / mode->clock);
    ...
}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127074639.277959-1-Luo.Liu@cixtech.com?part=3

  reply	other threads:[~2026-11-27  8:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27  7:46 [PATCH v7 0/5] drm/bridge: trilinear: add the Sky1 DisplayPort transmitter Luo Liu
2026-11-27  7:46 ` [PATCH v7 1/5] dt-bindings: display: add CIX " Luo Liu
2026-11-27  7:46 ` [PATCH v7 2/5] drm/bridge: trilinear: add the DPTX hardware layer Luo Liu
2026-11-27  8:05   ` sashiko-bot
2026-11-27  7:46 ` [PATCH v7 3/5] drm/bridge: trilinear: add the DPTX DRM bridge Luo Liu
2026-11-27  8:06   ` sashiko-bot [this message]
2026-11-27  7:46 ` [PATCH v7 4/5] drm/bridge: trilinear: add the DPTX core and build glue Luo Liu
2026-11-27  8:02   ` sashiko-bot
2026-11-27  7:46 ` [PATCH v7 5/5] drm/cix: add the Sky1 DisplayPort platform glue Luo Liu

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=sashiko-outbox-236860@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Luo.Liu@cixtech.com \
    --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 \
    /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