scsi: ufs: qcom: avoid re-init quirk when gears match
Subsystems (3)
PATCH v2 1/1 scsi: ufs: qcom: avoid re-init quirk when gears match
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.
---
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/[email protected]/
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(-)
drivers/ufs/host/ufs-qcom.c +11 -2
@@ -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) &&
Signature · 1 line
2.43.0
Quoted 11 lines · Eric Chanudet
On sa8775p-ride, probing the hba will go through the
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCHpath 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 thehost_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 <[email protected]>
- Mani
Quoted 46 lines
---
v1 -> v2:
* drop test againsthost->hw_ver.major>= 4 and amend description as a
result (Andrew/Mani)
* add comment, test device gear againsthost->phy_gearand reset
host->phy_gearonly if necessary (Mani)
* Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/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 0drivers/ufs/host/ufs-qcom.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/ufs/host/ufs-qcom.c +11
-2@@ -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) &&Signature · 1 line
2.43.0
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Quoted 11 lines · Eric Chanudet
On sa8775p-ride, probing the hba will go through the
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCHpath 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 thehost_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 <[email protected]>
On the sa8775p-ride I have I see similar results to what you mention! Thanks.
Quoted 47 lines
---
v1 -> v2:
* drop test againsthost->hw_ver.major>= 4 and amend description as a
result (Andrew/Mani)
* add comment, test device gear againsthost->phy_gearand reset
host->phy_gearonly if necessary (Mani)
* Link to v1: https://lore.kernel.org/linux-arm-msm/[email protected]/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 0drivers/ufs/host/ufs-qcom.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)drivers/ufs/host/ufs-qcom.c +11
-2@@ -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) &&Signature · 1 line
2.43.0
Martin K. Petersen
AppliedEric,
Quoted 3 lines
On sa8775p-ride, probing the hba will go through the
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCHpath although the power info are same during the second init.
Applied to 6.9/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 11 lines · Eric Chanudet
On sa8775p-ride, probing the hba will go through the
UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCHpath 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 thehost_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
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering