Re: Re: Re: Re: [PATCH] scsi: ufs: qcom: avoid re-init quirk when gears match

From: Eric Chanudet
Date: Tue Jan 23 2024 - 10:18:38 EST


On Tue, Jan 23, 2024 at 08:06:15PM +0530, Manivannan Sadhasivam wrote:
> On Fri, Jan 19, 2024 at 04:33:10PM -0500, Eric Chanudet wrote:
> > On Fri, Jan 19, 2024 at 02:33:32PM -0600, Andrew Halaney wrote:
> > > On Fri, Jan 19, 2024 at 02:07:15PM -0600, Andrew Halaney wrote:
> > > > On Fri, Jan 19, 2024 at 01:55:47PM -0500, Eric Chanudet wrote:
> > > > > diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> > > > > index 39eef470f8fa..f9f161340e78 100644
> > > > > --- a/drivers/ufs/host/ufs-qcom.c
> > > > > +++ b/drivers/ufs/host/ufs-qcom.c
> > > > > @@ -738,8 +738,12 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
> > > > > * the second init can program the optimal PHY settings. This allows one to start
> > > > > * the first init with either the minimum or the maximum support gear.
> > > > > */
> > > > > - if (hba->ufshcd_state == UFSHCD_STATE_RESET)
> > > > > + if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
> > > > > + if (host->hw_ver.major >= 0x4 &&
> > > >
> > > > Is this check really necessary?
> >
> > I *think* so.
> >
> > For example, if hw_ver < 4, ufs_qcom_set_phy_gear() has a comment saying
> > "power up the PHY using minimum supported gear (UFS_HS_G2). Switching to
> > max gear will be performed during reinit if supported."
> >
> > > >
> > > > The initial phy_gear state is something like this (my phrasing of
> > > > ufs_qcom_set_phy_gear()):
> > > >
> > > > if hw_ver < 4:
> > > > # Comments about powering up with minimum gear (with no
> > > > # reasoning in the comment afaict), and mentions switching
> > > > # to higher gear in reinit quirk. This is opposite of the later
> > > > # versions which start at the max and scale down
> > > > phy_gear = UFS_HS_G2
> >
> > IIUC, the device would not be able to negotiate a gear higher than the
> > minimum set for the phy_gear on initialization.
> >
> > ufshcd_init_host_params() and ufs_qcom_get_hs_gear() both set the
> > controller <v4 host_params to G3. So if the device is HS capable, the
> > re-init would set G3, instead of the G2 selected by
> > ufs_qcom_set_phy_gear().
> >
>
> REINIT quirk is applicable for controllers starting from v4 only, because legacy
> controllers don't need separate PHY init sequences. So you can get rid of that
> check.

My bad, I overlooked the check in ufs_qcom_advertise_quirks().
Thank you, I'll send a v2 soon.

> - Mani
>
> --
> மணிவண்ணன் சதாசிவம்
>

--
Eric Chanudet