On Wednesday, December 2, 2026 at 4:28 PM, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential
> issue to consider:
> - [Medium] phy: cadence-torrent: per-lane CDB init uses num_lanes
>   instead of max_lanes
> --
> 
> commit a7bb6d81b805f076baf2e912724f7f59b580f8d8
> Author: Benjamin Robin <[email protected]>
> 
> phy: cadence-torrent: use link lane count and mlane for DP config
> 
> This commit splits the link lane count into max_lanes and num_lanes in
> struct tp_link so DisplayPort reconfiguration uses the active lane count
> when set_lanes is not set, and shifts per-lane register masks by
> link->mlane.
> 
> > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c 
> > b/drivers/phy/cadence/phy-cadence-torrent.c
> > index 28627bd234458..6e48c315e6b1a 100644
> > --- a/drivers/phy/cadence/phy-cadence-torrent.c
> > +++ b/drivers/phy/cadence/phy-cadence-torrent.c
> [ ... ]
> > @@ -1190,7 +1209,7 @@ static int tp_dp_configure_rate(struct tp_data 
> > *tp_data, struct tp_link *link,
> >             /* PMA common configuration 100MHz */
> >             cdns_torrent_dp_pma_cmn_vco_cfg_100mhz(tp_data, dp->link_rate, 
> > dp->ssc);
> >  
> > -   cdns_torrent_dp_pma_cmn_rate(tp_data, link, dp->link_rate, dp->lanes);
> > +   cdns_torrent_dp_pma_cmn_rate(tp_data, link, dp->link_rate, 
> > link->num_lanes);
> >  
> >     /* Enable the associated PLL (cmn_pll0_en or cmn_pll1_en) */
> >     tp_reg_set_bits(reg_base, PHY_PMA_PLL_RAW_CTRL, pll_mask);
> [ ... ]
> > @@ -1286,58 +1295,53 @@ static void cdns_torrent_dp_set_a0_pll(struct 
> > tp_data *tp_data,
> [ ... ]
> > +   /* release master lane reset */
> > +   value |= 1 << mlane;
> >     tp_reg_dptx_write(tp_data, PHY_RESET, value);
> >  
> > +   /* update the number of used lanes */
> > +   link->num_lanes = num_lanes;
> > +
> >     /* Wait, until PHY gets ready after releasing PHY reset signal. */
> >     ret = tp_dptx_wait_pma_cmn_ready(tp_data);
> 
> [Severity: Medium]
> Does updating link->num_lanes to the active DisplayPort lane count leave
> upper physical lanes unconfigured when the lane count is later increased?

This indeed could be an issue. A lot of registers should be programmed by
using the max_lanes instead of num_lanes. This will be fixed in v3.
 
> After tp_dp_set_lanes() reduces link->num_lanes below link->max_lanes (for
> example from 4 lanes to 1 or 2), cdns_torrent_phy_configure_multilink()
> (called on system resume by tp_resume_noirq() after reset assertion) and
> tp_phy_init() still loop up to link->num_lanes instead of link->max_lanes
> when programming per-lane CDB tables (xcvr_diag_vals, tx_ln_vals,
> rx_ln_vals):
> 
> drivers/phy/cadence/phy-cadence-torrent.c:cdns_torrent_phy_configure_multilink()
>  {
>     ...
>                       mlane = tp_data->links[node].mlane;
>                       ssc = tp_data->links[node].ssc_mode;
>                       num_lanes = tp_data->links[node].num_lanes;
>     ...
>                       if (xcvr_diag_vals) {
>                               reg_pairs = xcvr_diag_vals->reg_pairs;
>                               num_regs = xcvr_diag_vals->num_regs;
>                               for (i = 0; i < num_lanes; i++) {
>     ...
> }
> 
> If the system suspends and resumes while fewer than max_lanes are active
> and a later phy_configure() increases dp->lanes back to 4,
> tp_dp_set_lanes() releases the upper lanes from reset without their
> per-lane CDB registers initialized (which also remains the case in
> tp_configure_links() after commit "phy: cadence-torrent: rewrite Torrent
> PHY driver").
> 
> Similarly, tp_dp_configure_rate() passes link->num_lanes to
> cdns_torrent_dp_pma_cmn_rate(), which only writes XCVR_DIAG_HSCLK_DIV for
> 0 .. link->num_lanes - 1; if a rate change happens at 1 or 2 lanes and a
> subsequent phy_configure() increases the lane count via set_lanes without
> set_rate, the newly enabled lanes keep stale XCVR_DIAG_HSCLK_DIV values
> (though commit "phy: cadence-torrent: rewrite Torrent PHY driver" later
> updates the XCVR_DIAG_HSCLK_DIV write to use link->max_lanes).



-- 
Benjamin Robin, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



Reply via email to