Re: [PATCH V4 10/11] scsi: ufs: qcom : Introduce phy_power_on/off wrapper function

From: Nitin Rawat
Date: Fri May 09 2025 - 07:50:00 EST




On 5/9/2025 5:07 PM, Konrad Dybcio wrote:
On 5/3/25 6:24 PM, Nitin Rawat wrote:
Introduce ufs_qcom_phy_power_on and ufs_qcom_phy_power_off wrapper
functions with mutex protection to ensure safe usage of is_phy_pwr_on
and prevent possible race conditions.

Co-developed-by: Can Guo <quic_cang@xxxxxxxxxxx>
Signed-off-by: Can Guo <quic_cang@xxxxxxxxxxx>
Signed-off-by: Nitin Rawat <quic_nitirawa@xxxxxxxxxxx>
---

The PHY framework does the same thing internally already, this seems
unnecessary

Hi Konrad,

Thanks for the review. There are scenarios where ufshcd_link_startup() can call ufshcd_vops_link_startup_notify() multiple times during retries. This leads to the PHY reference count increasing continuously, preventing proper re-initialization of the PHY.

Recently, this issue was addressed with patch 7bac65687510 ("scsi: ufs:
qcom: Power off the PHY if it was already powered on in ufs_qcom_power_up_sequence()"). However, I still want to maintain a reference count (ref_cnt) to safeguard against similar conditions in the code. Additionally, this approach helps avoid unnecessary phy_power_on and phy_power_off calls. Please let me know your thoughts.

Regards,
Nitin



Konrad