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

Thank you for your contribution! Sashiko AI review found 5 potential
issues to consider:
- [High] drm/bridge: trilinear: dptx_hw_link_vs_emph() returns positive
  byte count
- [Medium] drm/bridge: dptx_hw_link_adjust_train() clamps pre-emphasis
  instead of swing
- [Medium] drm/bridge: trilinear: missing CR limits in
  dptx_hw_link_clock_recovery()
- [Low] drm/bridge: trilinear: duplicate DPCD power helpers in dptx_hw.c
- [Low] drm/bridge: trilinear: unnecessary single-implementation
  dptx_hw_ops vtable
--

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

drm/bridge: trilinear: add the DPTX hardware layer

This commit adds the register, AUX channel, DPCD capability, link training,
and main stream programming layer for the Trilinear DisplayPort transmitter.

> 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..bdf24e464b942
> --- /dev/null
> +++ b/drivers/gpu/drm/bridge/trilinear/dptx_hw.c

[ ... ]

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

[Severity: High]
Does dptx_hw_link_vs_emph() return a positive byte count on success?

drm_dp_dpcd_write() returns the number of bytes written (lane_cnt) rather
than 0.  Both dptx_hw_link_clock_recovery() and
dptx_hw_link_channel_equalization() treat any non-zero return as an error,
so link training aborts on the first clock-recovery iteration, skips
channel equalization, and fails modeset enable.

Using drm_dp_dpcd_write_data() here returns 0 on a full write and a
negative error code on failure or a short write.

> +
> +static void dptx_hw_link_adjust_train(struct dp_hw *hw, u8 lane_cnt,
> +				      const u8 *link_status)
> +{
> +	u8 voltage;
> +	u8 preemphasis;
> +	u8 pre_level;
> +	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);
> +		pre_level = preemphasis >> DP_TRAIN_PRE_EMPHASIS_SHIFT;
> +
> +		if (voltage + pre_level > 3) {
> +			pre_level = 3 - voltage;
> +			preemphasis = pre_level << DP_TRAIN_PRE_EMPHASIS_SHIFT;
> +		}

[Severity: Medium]
Should this clamp voltage swing instead of pre-emphasis when
voltage + pre_level > 3?

Per the DisplayPort specification, when a requested combination exceeds 3,
the transmitter keeps the requested pre-emphasis and clamps voltage to
3 - pre_level.  Clamping pre-emphasis instead drops requested pre-emphasis
during link training and fails DisplayPort compliance tests.

[ ... ]

> +static int dptx_hw_link_clock_recovery(struct dp_hw *hw, struct phy *phy,
> +				       u8 lane_cnt)
> +{

[ ... ]

> +	for (i = 0; i < 512; i++) {
> +		ret = dptx_hw_link_vs_emph(hw, phy, lane_cnt);
> +		if (ret)
> +			return ret;
> +
> +		drm_dp_link_train_clock_recovery_delay(&hw->aux, hw->dpcd);
> +		ret = drm_dp_dpcd_read_link_status(&hw->aux, link_status);
> +		if (ret < 0)
> +			return ret;
> +
> +		train_done = drm_dp_clock_recovery_ok(link_status, lane_cnt);
> +		if (train_done)
> +			break;
> +
> +		memcpy(prev, hw->train_setting, lane_cnt);
> +		dptx_hw_link_adjust_train(hw, lane_cnt, link_status);
> +
> +		if (!memcmp(hw->train_setting, prev, lane_cnt))
> +			tries++;
> +		else
> +			tries = 0;
> +
> +		if (tries == DP_MAX_TRAINING_TRIES)
> +			break;
> +	}

[Severity: Medium]
Can this 512-iteration clock-recovery loop stall link training for seconds
on a marginal or oscillating sink?

The loop never stops when DP_TRAIN_MAX_SWING_REACHED is set and does not
enforce the DP 1.4 10-iteration limit (or a bounded cap such as 80
iterations for pre-DP 1.4 sinks).

On an oscillating pre-DP 1.4 sink with DP_TRAINING_AUX_RD_INTERVAL == 4,
drm_dp_link_train_clock_recovery_delay() sleeps 16 to 32 ms per iteration,
turning 512 iterations into an 8 to 16 second stall per training attempt.

[ ... ]

> +static int dptx_hw_dpcd_power_up(struct dp_hw *hw,
> +				 unsigned int delay_ms)
> +{
> +	u8 value;
> +	int ret;
> +
> +	if (hw->dpcd[DP_DPCD_REV] < DP_DPCD_REV_11)
> +		return 0;
> +
> +	ret = drm_dp_dpcd_readb(&hw->aux, DP_SET_POWER, &value);
> +	if (ret < 0)
> +		return ret;
> +
> +	value = (value & ~DP_SET_POWER_MASK) | DP_SET_POWER_D0;
> +
> +	ret = drm_dp_dpcd_writeb(&hw->aux, DP_SET_POWER, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	msleep(delay_ms);
> +
> +	return 0;
> +}
> +
> +static int dptx_hw_dpcd_power_down(struct dp_hw *hw, bool hpd)
> +{
> +	u8 value;
> +	int ret;
> +
> +	if (!hpd)
> +		return 0;
> +
> +	if (hw->dpcd[DP_DPCD_REV] < DP_DPCD_REV_11)
> +		return 0;
> +
> +	ret = drm_dp_dpcd_readb(&hw->aux, DP_SET_POWER, &value);
> +	if (ret < 0)
> +		return ret;
> +
> +	value = (value & ~DP_SET_POWER_MASK) | DP_SET_POWER_D3;
> +
> +	ret = drm_dp_dpcd_writeb(&hw->aux, DP_SET_POWER, value);
> +	if (ret < 0)
> +		return ret;
> +
> +	usleep_range(200, 205);
> +
> +	return 0;
> +}

[Severity: Low]
Can dptx_hw_dpcd_power_up() and dptx_hw_dpcd_power_down() reuse
drm_dp_link_power_up() and drm_dp_link_power_down()?

Those core helpers already check DP_DPCD_REV_11 and perform the
DP_SET_POWER read-modify-write, avoiding duplicate DPCD power-state code.

[ ... ]

> 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..420ef242a4f61
> --- /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);
> +
> +	void (*host_enable)(struct dp_hw *hw, bool enable);
> +	void (*reset)(struct dp_hw *hw, bool assert);
> +	void (*core_enable)(struct dp_hw *hw, int source_id, bool enable);

[Severity: Low]
Is the 20-method struct dptx_hw_ops vtable needed?

There is only one implementation (dptx_hw_ops in dptx_hw.c), assigned
unconditionally in dptx_hw_init().  Declaring direct dptx_hw_*() functions
in dptx_hw.h would avoid the boilerplate and indirect calls.

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

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

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04 11:43 [PATCH v10 0/5] drm/bridge: trilinear: add the Sky1 DisplayPort transmitter Luo Liu
2026-12-04 11:43 ` [PATCH v10 1/5] dt-bindings: display: add CIX " Luo Liu
2026-12-04 11:43 ` [PATCH v10 2/5] drm/bridge: trilinear: add the DPTX hardware layer Luo Liu
2026-12-04 12:06   ` sashiko-bot [this message]
2026-12-04 11:43 ` [PATCH v10 3/5] drm/bridge: trilinear: add the DPTX DRM bridge Luo Liu
2026-12-04 12:16   ` sashiko-bot
2026-12-04 11:43 ` [PATCH v10 4/5] drm/bridge: trilinear: add the DPTX core and build glue Luo Liu
2026-12-04 12:15   ` sashiko-bot
2026-12-04 11:43 ` [PATCH v10 5/5] drm/cix: add the Sky1 DisplayPort platform glue Luo Liu
2026-12-04 12:01   ` sashiko-bot
2026-12-04 12:11     ` 回复: " 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-249755@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