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 v9 2/5] drm/bridge: trilinear: add the DPTX hardware layer
Date: Fri, 04 Dec 2026 08:13:39 +0000	[thread overview]
Message-ID: <sashiko-outbox-249377@kernel.org> (raw)
In-Reply-To: <20261204074239.133559-3-Luo.Liu@cixtech.com>

Thank you for your contribution! Sashiko AI review found 11 potential
issues to consider:
- [Medium] drm/bridge: trilinear: leave opts.dp.lanes unset in
  dptx_hw_link_rate()
- [Medium] drm/bridge: trilinear: missing pre-emphasis and swing sum
  clamping
- [Medium] drm/bridge: trilinear: hardcode CTA limited range for RGB VSC
  SDP
- [Medium] drm/bridge: trilinear: omit DCI-P3 and xvYCC/BT.709 in VSC
  SDP check
- [Medium] drm/bridge: trilinear: leave unhandled interrupt bit 5
  unmasked
- [Medium] drm/bridge: trilinear: ignore DPCD write error in
  dptx_hw_link_train_end()
- [Low] drm/bridge: trilinear: write DP_TRAINING_LANE0_SET before PHY
  update
- [Low] drm/bridge: trilinear: commit message claims unimplemented
  downshifting
- [Low] drm/bridge: trilinear: unnecessary single-implementation
  dptx_hw_ops vtable
- [Low] drm/bridge: trilinear: dptx_hw_stream_format_set() lacks YUV420
  VSC check
- [Low] drm/bridge: trilinear: 32-bit overflow in
  dptx_hw_stream_timing_set()
--

commit e7608fe3dedcf10692a9cd8f3d2a2dbebc772270
Author: Luo Liu <Luo.Liu@cixtech.com>

drm/bridge: trilinear: add the DPTX hardware layer

This commit adds the register and PHY programming layer for the Trilinear
DisplayPort transmitter, including AUX transfers, DPCD capability parsing,
link training, and per-stream timing and format setup.

> Add the register and PHY programming for the Trilinear DisplayPort
> transmitter: controller reset, host and core enable, AUX transfers
> through the controller's AUX channel, sink capability parsing from the
> DPCD, and link training with rate downshifting when the sink cannot
> lock.

[Severity: Low]
Is the commit message accurate about rate downshifting?  In this patch,
dptx_hw_link_train() only runs a single link training attempt at the
caller-supplied bw_code and lane_cnt and does not implement rate
downshifting.

> diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_hw.c b/drivers/gpu/drm/bridge/trilinear/dptx_hw.c
> new file mode 100644
> index 0000000000000..8f5ff929aa07d
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_hw.c

[ ... ]

> +#define DPTX_INTERRUPT_GP_TIMER_IRQ BIT(4)
> +#define DPTX_INTERRUPT_REPLY_TIMEOUT BIT(3)
> +#define DPTX_INTERRUPT_REPLY_RECEIVED BIT(2)
> +#define DPTX_INTERRUPT_HPD_IRQ BIT(1)
> +#define DPTX_INTERRUPT_HPD_EVENT BIT(0)
> +
> +#define DPTX_INTERRUPT_MASK_ALL 0x3f
> +#define DPTX_INTERRUPT_CFG 0x1c

[Severity: Medium]
Does DPTX_INTERRUPT_CFG leave interrupt bit 5 unmasked?

DPTX_INTERRUPT_MASK_ALL covers bits 0..5 (0x3f), where 1 masks an interrupt
and 0 enables it.  Writing DPTX_INTERRUPT_CFG (0x1c) to DPTX_INTERRUPT_MASK
in dptx_hw_host_enable() unmasks bit 5 alongside HPD_EVENT and HPD_IRQ,
even though dptx_hw_irq() only handles bits 0..4 and swallows any other
unmasked cause bit as IRQ_HANDLED.  Defining DPTX_INTERRUPT_CFG as
DPTX_INTERRUPT_MASK_ALL & ~(DPTX_INTERRUPT_HPD_EVENT |
DPTX_INTERRUPT_HPD_IRQ) (0x3c) keeps bit 5 masked.

[ ... ]

> +static int dptx_hw_link_rate(struct dp_hw *hw, struct phy *phy,
> +			     u8 bw_code, u8 lanes, bool downspread)
> +{
> +	union phy_configure_opts opts = { 0 };
> +	u32 ready = (1 << lanes) - 1;
> +	u32 value;
> +	int ret;
> +
> +	dptx_hw_write(hw, DPTX_LINK_BW_SET, bw_code);
> +
> +	opts.dp.link_rate = drm_dp_bw_code_to_link_rate(bw_code) / 100;
> +	opts.dp.ssc = downspread;
> +	opts.dp.set_rate = 1;
> +	ret = phy_configure(phy, &opts);

[Severity: Medium]
Should dptx_hw_link_rate() set opts.dp.lanes and opts.dp.set_lanes before
calling phy_configure()?

Because opts is zero-initialized, opts.dp.lanes is passed as 0 instead of
1, 2, or 4, which causes generic DP PHY drivers such as phy-cadence-torrent
to reject phy_configure() with -EINVAL.  In addition, opts.dp.set_lanes is
never set anywhere in the driver and dptx_hw_link_configure() passes
num_lanes rather than the active lane_cnt, so PHY drivers that implement
set_lanes never reconfigure their active lanes.

[ ... ]

> +static int dptx_hw_link_vs_emph(struct dp_hw *hw, struct phy *phy,
> +				u8 lane_cnt)
> +{
> +	int ret;
> +
> +	ret = drm_dp_dpcd_write(&hw->aux, DP_TRAINING_LANE0_SET, hw->train_setting,
> +				lane_cnt);
> +	if (ret < 0)
> +		return ret;
> +
> +	return dptx_hw_phy_vs_emph_set(hw, phy, lane_cnt, hw->train_setting);
> +}

[Severity: Low]
Should dptx_hw_phy_vs_emph_set() run before writing DP_TRAINING_LANE0_SET
to the sink?

Updating the sink DPCD first exposes it to stale drive levels if it starts
evaluating immediately, and leaves the sink notified even if
phy_configure() fails.

> +static void dptx_hw_link_adjust_train(struct dp_hw *hw, u8 lane_cnt,
> +				      const u8 *link_status)
> +{
> +	u8 voltage;
> +	u8 preemphasis;
> +	int i;
> +
> +	for (i = 0; i < lane_cnt; i++) {
> +		voltage = drm_dp_get_adjust_request_voltage(link_status, i);
> +		preemphasis =
> +			drm_dp_get_adjust_request_pre_emphasis(link_status, i);
> +
> +		if (voltage >= DP_TRAIN_VOLTAGE_SWING_LEVEL_3)
> +			voltage |= DP_TRAIN_MAX_SWING_REACHED;
> +
> +		if (preemphasis >= DP_TRAIN_PRE_EMPH_LEVEL_2)
> +			preemphasis |= DP_TRAIN_MAX_PRE_EMPHASIS_REACHED;
> +
> +		hw->train_setting[i] = voltage | preemphasis;
> +	}
> +}

[Severity: Medium]
Can dptx_hw_link_adjust_train() pass out-of-spec swing and pre-emphasis
levels to phy_configure()?

When a sink requests pre-emphasis level 3, this sets
DP_TRAIN_MAX_PRE_EMPHASIS_REACHED at level 2 without clamping preemphasis
to level 2, passing opts.dp.pre[i] = 3 in dptx_hw_phy_vs_emph_set().  It
also does not enforce voltage + pre-emphasis <= 3, so combinations like
swing level 2 with pre-emphasis level 2 are rejected with -EINVAL by
generic DP PHY drivers such as phy-cadence-torrent and abort link training.

[ ... ]

> +static void dptx_hw_link_train_end(struct dp_hw *hw)
> +{
> +	drm_dp_dpcd_writeb(&hw->aux, DP_TRAINING_PATTERN_SET, 0);
> +	dptx_hw_write(hw, DPTX_TRAINING_PATTERN_SET, 0);
> +	dptx_hw_write(hw, DPTX_DISABLE_SCRAMBLING, 0);
> +}
> +
> +static int dptx_hw_link_train(struct dp_hw *hw, struct phy *phy, u8 bw_code,
> +			      u8 lane_cnt, u8 num_lanes)
> +{

[ ... ]

> +	dptx_hw_link_train_end(hw);
> +
> +	return ret;
> +}

[Severity: Medium]
Should dptx_hw_link_train_end() propagate a DPCD write error when link
training otherwise succeeded?

If clearing DP_TRAINING_PATTERN_SET on the sink fails after clock recovery
and channel equalization pass, dptx_hw_link_train() still returns 0 while
the sink remains in training pattern mode, preventing callers from retrying
or downshifting.  Propagating the error when ret == 0 (while keeping any
earlier training error) avoids reporting a false success.

[ ... ]

> +	dptx_hw_write(hw, DPTX_SECONDARY_DATA_WINDOW(stream_id),
> +		      (mode->htotal - mode->hdisplay) * (link_rate / 40) *
> +		      9 / mode->clock);

[Severity: Low]
Can this DPTX_SECONDARY_DATA_WINDOW calculation overflow 32-bit unsigned
arithmetic?

Because link_rate is u32, the numerator wraps when horizontal blanking is
at least 35350 pixels at HBR2 or 23567 pixels at HBR3 for a custom
userspace mode, writing a truncated value to the register.  Using 64-bit
arithmetic with div_u64() avoids the wrap.

[ ... ]

> +static bool dptx_hw_needs_vsc_sdp(enum dp_pixelformat format,
> +				  u32 colorspace)
> +{
> +	if (format == DP_PIXELFORMAT_YUV420)
> +		return true;
> +
> +	switch (colorspace) {
> +	case DRM_MODE_COLORIMETRY_SYCC_601:
> +	case DRM_MODE_COLORIMETRY_OPYCC_601:
> +	case DRM_MODE_COLORIMETRY_BT2020_YCC:
> +	case DRM_MODE_COLORIMETRY_BT2020_RGB:
> +	case DRM_MODE_COLORIMETRY_BT2020_CYCC:
> +		return true;
> +	default:
> +		break;
> +	}
> +
> +	return false;
> +}

[Severity: Medium]
Should dptx_hw_needs_vsc_sdp() also return true for DCI-P3 RGB (D65 and
Theater), xvYCC 601/709, and BT.709 YCbCr?

dptx_hw_vsc_colorimetry() maps all five colorspaces, but when
dptx_hw_needs_vsc_sdp() returns false, dptx_hw_stream_misc() ignores
colorspace and programs MISC0 as sRGB or BT.601.  This leaves the DCI-P3
RGB cases unreachable for RGB streams and silently drops these colorspaces
unless paired with YUV420.

[ ... ]

> +static int dptx_hw_stream_format_set(struct dp_hw *hw, unsigned int stream_id,
> +				     enum dp_pixelformat format, u32 colorspace,
> +				     u8 bpc, u8 content_type)
> +{
> +	struct drm_dp_vsc_sdp vsc = {};
> +	struct dp_sdp sdp;
> +	bool enable;
> +	ssize_t len;
> +
> +	enable = hw->caps.vsc_supported &&
> +		 dptx_hw_needs_vsc_sdp(format, colorspace);

[Severity: Low]
Should dptx_hw_stream_format_set() return an error when format is
DP_PIXELFORMAT_YUV420 and hw->caps.vsc_supported is false?

If hw->caps.vsc_supported becomes false (for example, if a DPCD re-read
hits an AUX error on DP_DPRX_FEATURE_ENUMERATION_LIST, which
drm_dp_vsc_sdp_supported() converts to false), enable is false and
dptx_hw_stream_misc() falls into its default case, programming RGB in MISC0
with DPTX_MAIN_STREAM_OVERRIDE left at 0 and returning 0 instead of failing
cleanly.

[ ... ]

> +		vsc.dynamic_range = DP_DYNAMIC_RANGE_CTA;
> +		vsc.content_type = content_type;

[Severity: Medium]
Should vsc.dynamic_range be DP_DYNAMIC_RANGE_VESA when format is
DP_PIXELFORMAT_RGB?

Hardcoding DP_DYNAMIC_RANGE_CTA signals limited dynamic range (16-235) for
wide-gamut RGB modes such as BT.2020 RGB, mismatching the full-range RGB
signaled in MISC0 when VSC SDP is disabled and crushing blacks and whites
on the sink.

> diff --git a/drivers/gpu/drm/bridge/trilinear/dptx_hw.h b/drivers/gpu/drm/bridge/trilinear/dptx_hw.h
> new file mode 100644
> index 0000000000000..b56ec3161f764
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_hw.h

[ ... ]

> +struct dptx_hw_ops {
> +	bool (*hpd_state)(struct dp_hw *hw);
> +	bool (*sink_present)(struct dp_hw *hw);

[Severity: Low]
This isn't a bug, but is the 20-entry struct dptx_hw_ops vtable needed when
dptx_hw_ops in dptx_hw.c is its only implementation?  Declaring direct
dptx_hw_*() functions in dptx_hw.h would avoid the indirect call
boilerplate.

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

  reply	other threads:[~2026-12-04  8:13 UTC|newest]

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

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-249377@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