* [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match
@ 2024-01-23 19:28 Eric Chanudet
2024-01-24 8:48 ` Manivannan Sadhasivam
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Eric Chanudet @ 2024-01-23 19:28 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen
Cc: linux-arm-msm, linux-scsi, linux-kernel, Eric Chanudet
On sa8775p-ride, probing the hba will go through the
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info
are same during the second init.
The REINIT quirk only applies starting with controller v4. For these,
ufs_qcom_get_hs_gear() reads the highest supported gear when setting the
host_params. After the negotiation, if the host and device are on the
same gear, it is the highest gear supported between the two. Skip REINIT
to save some time.
Signed-off-by: Eric Chanudet <echanude@redhat.com>
---
v1 -> v2:
* drop test against host->hw_ver.major >= 4 and amend description as a
result (Andrew/Mani)
* add comment, test device gear against host->phy_gear and reset
host->phy_gear only if necessary (Mani)
* Link to v1: https://lore.kernel.org/linux-arm-msm/20240119185537.3091366-11-echanude@redhat.com/
trace_event=ufs:ufshcd_init reports the time spent in ufshcd_probe_hba
where the re-init quirk is performed:
Currently:
0.355879: ufshcd_init: 1d84000.ufs: took 103377 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
With this patch:
0.297676: ufshcd_init: 1d84000.ufs: took 43553 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
drivers/ufs/host/ufs-qcom.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
index 39eef470f8fa..f7dba7236c6e 100644
--- a/drivers/ufs/host/ufs-qcom.c
+++ b/drivers/ufs/host/ufs-qcom.c
@@ -738,8 +738,17 @@ 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)
- host->phy_gear = dev_req_params->gear_tx;
+ if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
+ /*
+ * Skip REINIT if the negotiated gear matches with the
+ * initial phy_gear. Otherwise, update the phy_gear to
+ * program the optimal gear setting during REINIT.
+ */
+ if (host->phy_gear == dev_req_params->gear_tx)
+ hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
+ else
+ host->phy_gear = dev_req_params->gear_tx;
+ }
/* enable the device ref clock before changing to HS mode */
if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match
2024-01-23 19:28 [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match Eric Chanudet
@ 2024-01-24 8:48 ` Manivannan Sadhasivam
2024-01-24 13:55 ` Andrew Halaney
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Manivannan Sadhasivam @ 2024-01-24 8:48 UTC (permalink / raw)
To: Eric Chanudet
Cc: Bjorn Andersson, Konrad Dybcio, James E.J. Bottomley,
Martin K. Petersen, linux-arm-msm, linux-scsi, linux-kernel
On Tue, Jan 23, 2024 at 02:28:57PM -0500, Eric Chanudet wrote:
> On sa8775p-ride, probing the hba will go through the
> UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info
> are same during the second init.
>
> The REINIT quirk only applies starting with controller v4. For these,
> ufs_qcom_get_hs_gear() reads the highest supported gear when setting the
> host_params. After the negotiation, if the host and device are on the
> same gear, it is the highest gear supported between the two. Skip REINIT
> to save some time.
>
> Signed-off-by: Eric Chanudet <echanude@redhat.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
>
> v1 -> v2:
> * drop test against host->hw_ver.major >= 4 and amend description as a
> result (Andrew/Mani)
> * add comment, test device gear against host->phy_gear and reset
> host->phy_gear only if necessary (Mani)
> * Link to v1: https://lore.kernel.org/linux-arm-msm/20240119185537.3091366-11-echanude@redhat.com/
>
> trace_event=ufs:ufshcd_init reports the time spent in ufshcd_probe_hba
> where the re-init quirk is performed:
> Currently:
> 0.355879: ufshcd_init: 1d84000.ufs: took 103377 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
> With this patch:
> 0.297676: ufshcd_init: 1d84000.ufs: took 43553 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
>
> drivers/ufs/host/ufs-qcom.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 39eef470f8fa..f7dba7236c6e 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -738,8 +738,17 @@ 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)
> - host->phy_gear = dev_req_params->gear_tx;
> + if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
> + /*
> + * Skip REINIT if the negotiated gear matches with the
> + * initial phy_gear. Otherwise, update the phy_gear to
> + * program the optimal gear setting during REINIT.
> + */
> + if (host->phy_gear == dev_req_params->gear_tx)
> + hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
> + else
> + host->phy_gear = dev_req_params->gear_tx;
> + }
>
> /* enable the device ref clock before changing to HS mode */
> if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
> --
> 2.43.0
>
--
மணிவண்ணன் சதாசிவம்
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match
2024-01-23 19:28 [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match Eric Chanudet
2024-01-24 8:48 ` Manivannan Sadhasivam
@ 2024-01-24 13:55 ` Andrew Halaney
2024-01-25 2:36 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Andrew Halaney @ 2024-01-24 13:55 UTC (permalink / raw)
To: Eric Chanudet
Cc: Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, linux-arm-msm,
linux-scsi, linux-kernel
On Tue, Jan 23, 2024 at 02:28:57PM -0500, Eric Chanudet wrote:
> On sa8775p-ride, probing the hba will go through the
> UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info
> are same during the second init.
>
> The REINIT quirk only applies starting with controller v4. For these,
> ufs_qcom_get_hs_gear() reads the highest supported gear when setting the
> host_params. After the negotiation, if the host and device are on the
> same gear, it is the highest gear supported between the two. Skip REINIT
> to save some time.
>
> Signed-off-by: Eric Chanudet <echanude@redhat.com>
On the sa8775p-ride I have I see similar results to what you mention!
Thanks.
Tested-by: Andrew Halaney <ahalaney@redhat.com> # sa8775p-ride
> ---
>
> v1 -> v2:
> * drop test against host->hw_ver.major >= 4 and amend description as a
> result (Andrew/Mani)
> * add comment, test device gear against host->phy_gear and reset
> host->phy_gear only if necessary (Mani)
> * Link to v1: https://lore.kernel.org/linux-arm-msm/20240119185537.3091366-11-echanude@redhat.com/
>
> trace_event=ufs:ufshcd_init reports the time spent in ufshcd_probe_hba
> where the re-init quirk is performed:
> Currently:
> 0.355879: ufshcd_init: 1d84000.ufs: took 103377 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
> With this patch:
> 0.297676: ufshcd_init: 1d84000.ufs: took 43553 usecs, dev_state: UFS_ACTIVE_PWR_MODE, link_state: UIC_LINK_ACTIVE_STATE, err 0
>
> drivers/ufs/host/ufs-qcom.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 39eef470f8fa..f7dba7236c6e 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -738,8 +738,17 @@ 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)
> - host->phy_gear = dev_req_params->gear_tx;
> + if (hba->ufshcd_state == UFSHCD_STATE_RESET) {
> + /*
> + * Skip REINIT if the negotiated gear matches with the
> + * initial phy_gear. Otherwise, update the phy_gear to
> + * program the optimal gear setting during REINIT.
> + */
> + if (host->phy_gear == dev_req_params->gear_tx)
> + hba->quirks &= ~UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
> + else
> + host->phy_gear = dev_req_params->gear_tx;
> + }
>
> /* enable the device ref clock before changing to HS mode */
> if (!ufshcd_is_hs_mode(&hba->pwr_info) &&
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match
2024-01-23 19:28 [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match Eric Chanudet
2024-01-24 8:48 ` Manivannan Sadhasivam
2024-01-24 13:55 ` Andrew Halaney
@ 2024-01-25 2:36 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2024-01-25 2:36 UTC (permalink / raw)
To: Eric Chanudet
Cc: Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Martin K. Petersen, linux-arm-msm,
linux-scsi, linux-kernel
Eric,
> On sa8775p-ride, probing the hba will go through the
> UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info
> are same during the second init.
Applied to 6.9/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match
2024-01-23 19:28 [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match Eric Chanudet
` (2 preceding siblings ...)
2024-01-25 2:36 ` Martin K. Petersen
@ 2024-01-30 2:27 ` Martin K. Petersen
3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2024-01-30 2:27 UTC (permalink / raw)
To: Bjorn Andersson, Konrad Dybcio, Manivannan Sadhasivam,
James E.J. Bottomley, Eric Chanudet
Cc: Martin K . Petersen, linux-arm-msm, linux-scsi, linux-kernel
On Tue, 23 Jan 2024 14:28:57 -0500, Eric Chanudet wrote:
> On sa8775p-ride, probing the hba will go through the
> UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH path although the power info
> are same during the second init.
>
> The REINIT quirk only applies starting with controller v4. For these,
> ufs_qcom_get_hs_gear() reads the highest supported gear when setting the
> host_params. After the negotiation, if the host and device are on the
> same gear, it is the highest gear supported between the two. Skip REINIT
> to save some time.
>
> [...]
Applied to 6.9/scsi-queue, thanks!
[1/1] scsi: ufs: qcom: avoid re-init quirk when gears match
https://git.kernel.org/mkp/scsi/c/10a39667a117
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-30 2:27 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-23 19:28 [PATCH v2] scsi: ufs: qcom: avoid re-init quirk when gears match Eric Chanudet
2024-01-24 8:48 ` Manivannan Sadhasivam
2024-01-24 13:55 ` Andrew Halaney
2024-01-25 2:36 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).