Re: [PATCH V6 1/2] ufs: core: Configure only active lanes during link
From: Manivannan Sadhasivam
Date: Thu Apr 23 2026 - 04:10:49 EST
On Thu, Apr 23, 2026 at 11:29:13AM +0530, palash.kambar@xxxxxxxxxxxxxxxx wrote:
> From: Palash Kambar <palash.kambar@xxxxxxxxxxxxxxxx>
>
> The number of connected lanes detected during UFS link startup can be
> fewer than the lanes specified in the device tree. The current driver
> logic attempts to configure all lanes defined in the device tree,
> regardless of their actual availability. This mismatch may cause
> failures during power mode changes.
>
> Hence, Add a check during link startup to ensure that only the lanes
> actually discovered are considered valid. If a mismatch is detected,
> fail the initialization early, preventing the driver from entering
> an unsupported configuration that could cause power mode transition
> failures.
>
> Reviewed-by: Bart Van Assche <bvanassche@xxxxxxx>
> Reviewed-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
> Reviewed-by: Manivannan Sadhasivam <mani@xxxxxxxxxx>
> Signed-off-by: Palash Kambar <palash.kambar@xxxxxxxxxxxxxxxx>
> ---
> drivers/ufs/core/ufshcd.c | 35 +++++++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 31950fc51a4c..fe5bc85c6870 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -5035,6 +5035,37 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val)
> }
> EXPORT_SYMBOL_GPL(ufshcd_update_evt_hist);
>
> +static int ufshcd_validate_link_params(struct ufs_hba *hba)
> +{
> + int ret, val;
> +
> + ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDTXDATALANES),
> + &val);
> + if (ret)
> + return ret;
> +
> + if (val != hba->lanes_per_direction) {
> + dev_err(hba->dev, "Tx lane mismatch [config,reported] [%d,%d]\n",
> + hba->lanes_per_direction, val);
> + ret = -ENOLINK;
> + return ret;
Really? If you had spent a minute in reading the patch after writing, you
would've seen this obvious mistake.
> + }
> +
> + ret = ufshcd_dme_get(hba, UIC_ARG_MIB(PA_CONNECTEDRXDATALANES),
> + &val);
> + if (ret)
> + return ret;
> +
> + if (val != hba->lanes_per_direction) {
> + dev_err(hba->dev, "Rx lane mismatch [config,reported] [%d,%d]\n",
> + hba->lanes_per_direction, val);
> + ret = -ENOLINK;
> + return ret;
Same here.
- Mani
--
மணிவண்ணன் சதாசிவம்