[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <939d4d07-c055-4e99-9d56-19cb7fdfa1c9@quicinc.com>
Date: Tue, 13 May 2025 18:42:05 +0530
From: Nitin Rawat <quic_nitirawa@...cinc.com>
To: Konrad Dybcio <konrad.dybcio@....qualcomm.com>, <vkoul@...nel.org>,
<kishon@...nel.org>, <manivannan.sadhasivam@...aro.org>,
<James.Bottomley@...senPartnership.com>, <martin.petersen@...cle.com>,
<bvanassche@....org>, <andersson@...nel.org>,
<neil.armstrong@...aro.org>
CC: <quic_rdwivedi@...cinc.com>, <quic_cang@...cinc.com>,
<linux-arm-msm@...r.kernel.org>, <linux-phy@...ts.infradead.org>,
<linux-kernel@...r.kernel.org>, <linux-scsi@...r.kernel.org>
Subject: Re: [PATCH V4 10/11] scsi: ufs: qcom : Introduce phy_power_on/off
wrapper function
On 5/9/2025 5:30 PM, Konrad Dybcio wrote:
> On 5/9/25 1:49 PM, Nitin Rawat wrote:
>>
>>
>> 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@...cinc.com>
>>>> Signed-off-by: Can Guo <quic_cang@...cinc.com>
>>>> Signed-off-by: Nitin Rawat <quic_nitirawa@...cinc.com>
>>>> ---
>>>
>>> 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.
>
> I'm assuming you're talking about the scenario where it jumps into
> ufs_qcom_power_up_sequence() - you have a label in there called
> `out_disable_phy` - add a phy_power_off() after phy_calibrate if
> things fail and you should be good to go if I'm reading things right.
Hi Konrad,
I meant, ufs_qcom_power_up_sequence can be called multiple times from
ufshcd_link_startup as part of ufshcd_hba_enable calls for each
retries(max retries =3) and each attempt of ufs_qcom_power_up_sequence
is success increasing the power_count ref to value more than 1.
But this is handled using the patch 7bac65687510.
Similiar scenarios can be possible in ufs driver , where there can be 2
phy_power_on calls which may caused caused phy ref count to be more than
1 and this inconsistent behaviour may cause issue.
Hence having is_phy_pwr_on flag can help here.
Thanks,
Nitin
>
> Please include something resembling a call stack in the commit message,
> as currently everyone reviewing this has to make guesses about why this
> needs to be done
>
>
>> 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.
>
> These unnecessary calls only amount to a couple of jumps and compares,
> just like your wrappers, as the framework keeps track of the enable
> count as well
>
> Konrad
Powered by blists - more mailing lists