Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Benjamin Robin" <benjamin.robin@bootlin.com>
Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linux-phy@lists.infradead.org, robh@kernel.org,
	conor+dt@kernel.org, vkoul@kernel.org, neil.armstrong@linaro.org,
	olteanv@gmail.com
Subject: Re: [PATCH v2 17/22] phy: cadence-torrent: unify link configuration in the probe
Date: Wed, 02 Dec 2026 15:37:27 +0000	[thread overview]
Message-ID: <sashiko-outbox-246115@kernel.org> (raw)
In-Reply-To: <20261202-phy-cadence-torrent-ng-v2-17-0b493387347b@bootlin.com>

Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] phy: cadence-torrent: missing return statement in
  tp_configure_links()
- [High] phy: cadence-torrent: A3 power-state timeout in
  tp_dp_set_rate()
- [Medium] phy: cadence-torrent: tp_phy_off() leaves PHY in reset when
  already_configured
--

commit d9682d304dc8f77ceb7780c5aacc3465f1589265
Author: Benjamin Robin <benjamin.robin@bootlin.com>

phy: cadence-torrent: unify link configuration in the probe

This commit moves PHY register configuration for both single-link and
multi-link setups into probe and resume, and moves reset and DisplayPort
link startup handling into the PHY power_on and power_off callbacks.

> diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cadence/phy-cadence-torrent.c
> index 9a2621fb3ac74..3b4d52ee7a531 100644
> --- a/drivers/phy/cadence/phy-cadence-torrent.c
> +++ b/drivers/phy/cadence/phy-cadence-torrent.c
[ ... ]
> @@ -1065,6 +1089,13 @@ static int tp_dptx_set_power_state(const struct tp_data *tp_data, u32 mlane, u32
>  		mask |= PMA_XCVR_POWER_STATE_REQ_LN_MASK << PHY_POWER_STATE_LN(mlane + i);
>  	}
>  
> +	/* Do not got to power state A3 if already off */
> +	if (powerstate == POWERSTATE_A3) {
> +		read_val = tp_reg_dptx_read(tp_data, PHY_PMA_XCVR_POWER_STATE_ACK);
> +		if ((read_val & mask) == 0)
> +			return 0;
> +	}
> +
>  	/* Set power state A<n>. */
>  	tp_reg_dptx_write(tp_data, PHY_PMA_XCVR_POWER_STATE_REQ, value);
[ ... ]
> @@ -1353,55 +1368,29 @@ static int tp_dp_set_lanes(struct tp_data *tp_data, struct tp_link *link, u32 nu
>  	/* update the number of used lanes */
>  	link->num_lanes = num_lanes;
[ ... ]
>  }
>  
>  /* Configure link rate as required. */
>  static int tp_dp_set_rate(struct tp_data *tp_data, struct tp_link *link,
> -			  struct phy_configure_opts_dp *dp)
> +			  const struct phy_configure_opts_dp *dp)
>  {
>  	int ret;
>  
> -	ret = tp_dptx_set_power_state(tp_data, link->mlane, link->num_lanes, POWERSTATE_A3);
> +	ret = tp_dptx_set_power_state(tp_data, link->mlane, link->max_lanes, POWERSTATE_A3);
>  	if (ret)
>  		return ret;

[Severity: High]
Will tp_dptx_set_power_state() time out waiting for POWERSTATE_A3 when a
running DisplayPort link uses fewer than link->max_lanes lanes?

tp_dp_set_lanes() holds unused lanes (link->num_lanes .. link->max_lanes - 1)
in reset with PHY_PMA_XCVR_PLLCLK_EN cleared, and tp_dp_run() only brings
up link->num_lanes lanes to POWERSTATE_A0.  When tp_dp_set_rate() passes
link->max_lanes on an active link, the active lanes have non-zero bits in
PHY_PMA_XCVR_POWER_STATE_ACK, so the early return in
tp_dptx_set_power_state() is not taken.  readl_poll_timeout() then waits
for all link->max_lanes lanes to acknowledge POWERSTATE_A3 (0x08), which
unused lanes held in reset never do, failing link rate changes for 1-lane
or 2-lane configs on a 4-lane PHY with -ETIMEDOUT.

Also, when tp_phy_configure() is called on a running link with both
set_lanes and set_rate set, tp_dp_set_lanes() runs first and clears
PHY_PMA_XCVR_PLLCLK_EN on all lanes and puts newly disabled lanes into
reset before tp_dp_set_rate() requests POWERSTATE_A3.

[ ... ]

> @@ -1479,46 +1476,65 @@ static int tp_phy_on(struct phy *phy)
>  	u16 val;
>  	int ret;
>  
> +	guard(mutex)(&tp_data->lock);
> +
>  	if (tp_data->already_configured) {
>  		/* Give 5ms to 10ms delay for the PIPE clock to be stable */
>  		usleep_range(5000, 10000);
> +		tp_data->nb_phy_on++;
>  		return 0;
>  	}
[ ... ]
>  static int tp_phy_off(struct phy *phy)
> @@ -1527,112 +1543,79 @@ static int tp_phy_off(struct phy *phy)
>  	struct tp_data *tp_data = dev_get_drvdata(phy->dev.parent);
>  	int ret;
>  
> -	if (tp_data->nb_links != 1)
> -		return 0;
> +	guard(mutex)(&tp_data->lock);
>  
> -	ret = reset_control_assert(tp_data->phy_rst);
> +	ret = reset_control_assert(link->lnk_rst);
>  	if (ret)
>  		return ret;
>  
> -	return reset_control_assert(link->lnk_rst);
> +	if (tp_data->nb_phy_on == 1) {
> +		ret = reset_control_assert(tp_data->phy_rst);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	tp_data->nb_phy_on--;
> +	return 0;
>  }

[Severity: Medium]
If tp_data->already_configured is true, does a runtime phy_power_off()
followed by phy_power_on() leave the PHY held in reset?

tp_phy_off() unconditionally asserts link->lnk_rst and tp_data->phy_rst,
but tp_phy_on() returns early when tp_data->already_configured is set
without deasserting either reset (and probe skipped tp_ref_clks_init() and
tp_configure_links()).

[ ... ]

> +static int tp_configure_links(struct tp_data *tp_data)
> +{
> +	int ret;
> +
> +	if (tp_data->nb_links > 1)
> +		ret = cdns_torrent_phy_configure_multilink(tp_data);
> +	else
> +		ret = tp_configure_single_link(tp_data, &tp_data->links[0]);
> +
>  	if (ret)
>  		return ret;
>  
> -	return 0;
> +	/*
> +	 * PHY PMA registers configuration functions
> +	 * Initialize PHY with max supported link rate, without SSC.
> +	 */
> +	for (u8 i = 0; i < tp_data->nb_links; ++i) {
> +		struct tp_link *link = &tp_data->links[i];
> +
> +		if (link->phy_type == TYPE_DP)
> +			tp_dp_update_pll_freq(tp_data, link, link->max_bit_rate, false);
> +	}
>  }

[Severity: High]
Does tp_configure_links() fall off the end without returning 0 on the
success path?

This breaks bisection by failing the build with -Werror=return-type until
commit "phy: cadence-torrent: rewrite Torrent PHY driver" later in the
series adds the return statement.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com?part=17

  reply	other threads:[~2026-12-02 15:37 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 15:08 [PATCH v2 00/22] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 01/22] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
2026-12-02 15:24   ` sashiko-bot
2026-12-02 15:08 ` [PATCH v2 02/22] drm/bridge: cdns-mhdp8546: Power on/off the PHY in probe/remove Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 03/22] dt-bindings: phy: cadence-torrent: make cdns,num-lanes optional again Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 04/22] dt-bindings: phy: cadence-torrent: add phy-mode constants Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 05/22] phy: cadence-torrent: make cdns,num-lanes optional again Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 06/22] phy: torrent: fix `RX_DIAG_NQST_CTRL` register address Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 07/22] phy: cadence-torrent: rename symbols to prepare for rewrite Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 08/22] phy: cadence-torrent: replace regmap with readw/writew Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 09/22] phy: cadence-torrent: move refclk clk_init_data to the stack Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 10/22] phy: cadence-torrent: drop diag_tx_drv from DP voltage coeff Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 11/22] phy: cadence-torrent: use link lane count and mlane for DP config Benjamin Robin
2026-12-02 15:28   ` sashiko-bot
2026-12-02 15:08 ` [PATCH v2 12/22] phy: cadence-torrent: use devm_of_clk_add_hw_provider() Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 13/22] phy: cadence-torrent: rework subnode parsing and lane validation Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 14/22] phy: cadence-torrent: rework ref clock init and probe cleanup Benjamin Robin
2026-12-02 15:24   ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 15/22] phy: cadence-torrent: factor out DP PLL frequency update Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 16/22] phy: cadence-torrent: store clock and reset handles only on success Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 17/22] phy: cadence-torrent: unify link configuration in the probe Benjamin Robin
2026-12-02 15:37   ` sashiko-bot [this message]
2026-12-02 15:09 ` [PATCH v2 18/22] phy: cadence-torrent: allow config on an already-configured DP link Benjamin Robin
2026-12-02 15:31   ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 19/22] phy: cadence-torrent: track current DP link bit rate Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 20/22] phy: cadence-torrent: rework suspend/resume to restore link config Benjamin Robin
2026-12-02 15:34   ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 21/22] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
2026-12-02 15:38   ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 22/22] phy: cadence-torrent: support 8 lanes on the sd0801 PHY Benjamin Robin
2026-12-02 15:30   ` 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-246115@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=benjamin.robin@bootlin.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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