Linux-PHY Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Nitin Rawat <quic_nitirawa@quicinc.com>
To: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>,
	<vkoul@kernel.org>, <kishon@kernel.org>,
	<manivannan.sadhasivam@linaro.org>,
	<James.Bottomley@HansenPartnership.com>,
	<martin.petersen@oracle.com>, <bvanassche@acm.org>,
	<andersson@kernel.org>, <neil.armstrong@linaro.org>
Cc: <quic_rdwivedi@quicinc.com>, <quic_cang@quicinc.com>,
	<linux-arm-msm@vger.kernel.org>, <linux-phy@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH V4 09/11] scsi: ufs: qcom : Refactor phy_power_on/off calls
Date: Sat, 10 May 2025 19:19:31 +0530	[thread overview]
Message-ID: <812a9905-a8f6-40b2-a603-6c0be18239da@quicinc.com> (raw)
In-Reply-To: <780d84ca-4004-41ef-a9ae-17532053f8a5@oss.qualcomm.com>



On 5/9/2025 5:05 PM, Konrad Dybcio wrote:
> On 5/3/25 6:24 PM, Nitin Rawat wrote:
>> Commit 3f6d1767b1a0 ("phy: ufs-qcom: Refactor all init steps into
>> phy_poweron") removes the phy_power_on/off from ufs_qcom_setup_clocks
>> to suspend/resume func.
>>
>> To have a better power saving, remove the phy_power_on/off calls from
>> resume/suspend path and put them back to ufs_qcom_setup_clocks, so that
>> PHY regulators & clks can be turned on/off along with UFS's clocks.
>>
>> Since phy phy_power_on is separated out from phy calibrate, make
>> separate calls to phy_power_on and phy_calibrate calls from ufs qcom
>> driver.
>>
>> Co-developed-by: Can Guo <quic_cang@quicinc.com>
>> Signed-off-by: Can Guo <quic_cang@quicinc.com>
>> Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
>> ---
>>   drivers/ufs/host/ufs-qcom.c | 55 ++++++++++++++++---------------------
>>   1 file changed, 23 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
>> index 2cd44ee522b8..ff35cd15c72f 100644
>> --- a/drivers/ufs/host/ufs-qcom.c
>> +++ b/drivers/ufs/host/ufs-qcom.c
>> @@ -639,26 +639,17 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
>>   	enum ufs_notify_change_status status)
>>   {
>>   	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>> -	struct phy *phy = host->generic_phy;
>>   
>>   	if (status == PRE_CHANGE)
>>   		return 0;
>>   
>> -	if (ufs_qcom_is_link_off(hba)) {
>> -		/*
>> -		 * Disable the tx/rx lane symbol clocks before PHY is
>> -		 * powered down as the PLL source should be disabled
>> -		 * after downstream clocks are disabled.
>> -		 */
>> +	if (!ufs_qcom_is_link_active(hba))
> 
> so is_link_off and !is_link_active are not the same thing - this also allows
> for disabling the resources when in hibern8/broken states - is that intended?

Yes is_link_off and !is_link_Active is not same thing. !is_link_active 
also include link in hibern8 state where lane clock is intended to be
disabled because PHY is powered down in hibern8.



> 
>>   		ufs_qcom_disable_lane_clks(host);
>> -		phy_power_off(phy);
>>   
>> -		/* reset the connected UFS device during power down */
>> -		ufs_qcom_device_reset_ctrl(hba, true);
>>   
>> -	} else if (!ufs_qcom_is_link_active(hba)) {
>> -		ufs_qcom_disable_lane_clks(host);
>> -	}
>> +	/* reset the connected UFS device during power down */
>> +	if (ufs_qcom_is_link_off(hba) && host->device_reset)
>> +		ufs_qcom_device_reset_ctrl(hba, true);
> 
> similarly this will not be allowed in hibern8/broken states now
> 
>>   
>>   	return ufs_qcom_ice_suspend(host);
>>   }
>> @@ -666,26 +657,11 @@ static int ufs_qcom_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op,
>>   static int ufs_qcom_resume(struct ufs_hba *hba, enum ufs_pm_op pm_op)
>>   {
>>   	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>> -	struct phy *phy = host->generic_phy;
>>   	int err;
>>   
>> -	if (ufs_qcom_is_link_off(hba)) {
>> -		err = phy_power_on(phy);
>> -		if (err) {
>> -			dev_err(hba->dev, "%s: failed PHY power on: %d\n",
>> -				__func__, err);
>> -			return err;
>> -		}
>> -
>> -		err = ufs_qcom_enable_lane_clks(host);
>> -		if (err)
>> -			return err;
>> -
>> -	} else if (!ufs_qcom_is_link_active(hba)) {
>> -		err = ufs_qcom_enable_lane_clks(host);
>> -		if (err)
>> -			return err;
>> -	}
>> +	err = ufs_qcom_enable_lane_clks(host);
>> +	if (err)
>> +		return err;
>>   
>>   	return ufs_qcom_ice_resume(host);
>>   }
>> @@ -1042,6 +1018,8 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
>>   				 enum ufs_notify_change_status status)
>>   {
>>   	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
>> +	struct phy *phy = host->generic_phy;
>> +	int err;
>>   
>>   	/*
>>   	 * In case ufs_qcom_init() is not yet done, simply ignore.
>> @@ -1060,10 +1038,22 @@ static int ufs_qcom_setup_clocks(struct ufs_hba *hba, bool on,
>>   				/* disable device ref_clk */
>>   				ufs_qcom_dev_ref_clk_ctrl(host, false);
>>   			}
>> +			err = phy_power_off(phy);
> 
> a newline to separate the blocks would improve readability> +			if (err) {
>> +				dev_err(hba->dev, "%s: phy power off failed, ret=%d\n",
>> +					__func__, err);
>> +					return err;

Sure will add in next patchset.

> 
> please indent the return statement a tab earlier so it doesn't look
> like it's an argument to dev_err()

Sure will add in next patchset.

> 
> putting PHY calls in the function that promises to toggle clocks could
> also use a comment, maybe extending the kerneldoc to say that certain
> clocks come from the PHY so it needs to be managed together
> 
Sure will add a comment or update in kernel doc in next patchset.

> Konrad


-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  reply	other threads:[~2025-05-10 13:56 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-03 16:24 [PATCH V4 00/11] Refactor ufs phy powerup sequence Nitin Rawat
2025-05-03 16:24 ` [PATCH V4 01/11] scsi: ufs: qcom: add a new phy calibrate API call Nitin Rawat
2025-05-09 12:06   ` Konrad Dybcio
2025-05-03 16:24 ` [PATCH V4 02/11] phy: qcom-qmp-ufs: Rename qmp_ufs_enable and qmp_ufs_power_on Nitin Rawat
2025-05-03 16:24 ` [PATCH V4 03/11] phy: qcom-qmp-ufs: Refactor phy_power_on and phy_calibrate callbacks Nitin Rawat
2025-05-03 16:24 ` [PATCH V4 04/11] phy: qcom-qmp-ufs: Refactor UFS PHY reset Nitin Rawat
2025-05-04 15:27   ` Dmitry Baryshkov
2025-05-03 16:24 ` [PATCH V4 05/11] phy: qcom-qmp-ufs: Remove qmp_ufs_com_init() Nitin Rawat
2025-05-03 16:24 ` [PATCH V4 06/11] phy: qcom-qmp-ufs: Rename qmp_ufs_power_off Nitin Rawat
2025-05-04 15:37   ` Dmitry Baryshkov
2025-05-04 15:52     ` Nitin Rawat
2025-05-06 11:53       ` Dmitry Baryshkov
2025-05-07 15:05         ` Nitin Rawat
2025-05-04 15:57     ` Dmitry Baryshkov
2025-05-03 16:24 ` [PATCH V4 07/11] phy: qcom-qmp-ufs: Remove qmp_ufs_exit() and Inline qmp_ufs_com_exit() Nitin Rawat
2025-05-04 15:56   ` Dmitry Baryshkov
2025-05-03 16:24 ` [PATCH V4 08/11] phy: qcom-qmp-ufs: refactor qmp_ufs_power_off Nitin Rawat
2025-05-04 15:57   ` Dmitry Baryshkov
2025-05-03 16:24 ` [PATCH V4 09/11] scsi: ufs: qcom : Refactor phy_power_on/off calls Nitin Rawat
2025-05-09 11:35   ` Konrad Dybcio
2025-05-10 13:49     ` Nitin Rawat [this message]
2025-05-03 16:24 ` [PATCH V4 10/11] scsi: ufs: qcom : Introduce phy_power_on/off wrapper function Nitin Rawat
2025-05-09 11:37   ` Konrad Dybcio
2025-05-09 11:49     ` Nitin Rawat
2025-05-09 12:00       ` Konrad Dybcio
2025-05-13 13:12         ` Nitin Rawat
2025-05-03 16:24 ` [PATCH V4 11/11] scsi: ufs: qcom: Prevent calling phy_exit before phy_init Nitin Rawat
2025-05-09 11:38   ` Konrad Dybcio
2025-05-09 11:50     ` Nitin Rawat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=812a9905-a8f6-40b2-a603-6c0be18239da@quicinc.com \
    --to=quic_nitirawa@quicinc.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=andersson@kernel.org \
    --cc=bvanassche@acm.org \
    --cc=kishon@kernel.org \
    --cc=konrad.dybcio@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=martin.petersen@oracle.com \
    --cc=neil.armstrong@linaro.org \
    --cc=quic_cang@quicinc.com \
    --cc=quic_rdwivedi@quicinc.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox