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 <[email protected]> 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/[email protected]?part=17
