From: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
To: Nitin Rawat <quic_nitirawa@quicinc.com>
Cc: Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Vinod Koul <vkoul@kernel.org>,
Kishon Vijay Abraham I <kishon@kernel.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org,
Can Guo <quic_cang@quicinc.com>,
Naveen Kumar Goud Arepalli <quic_narepall@quicinc.com>
Subject: Re: [PATCH V1 1/2] scsi: ufs: qcom : Refactor phy_power_on/off calls
Date: Wed, 24 Jan 2024 13:52:31 +0530 [thread overview]
Message-ID: <20240124082231.GA4906@thinkpad> (raw)
In-Reply-To: <20240112153348.2778-2-quic_nitirawa@quicinc.com>
On Fri, Jan 12, 2024 at 09:03:47PM +0530, 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
s/removes/moved
> 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's 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.
>
Above change should be in a separate patch.
> Also add a mutex lock to protect the usage of is_phy_pwr_on against
> possible racing.
>
> Co-developed-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Co-developed-by: Naveen Kumar Goud Arepalli <quic_narepall@quicinc.com>
> Signed-off-by: Naveen Kumar Goud Arepalli <quic_narepall@quicinc.com>
> Signed-off-by: Nitin Rawat <quic_nitirawa@quicinc.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 104 +++++++++++++++++++++++-------------
> drivers/ufs/host/ufs-qcom.h | 4 ++
> 2 files changed, 72 insertions(+), 36 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 39eef470f8fa..2721a30f0db8 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -338,6 +338,46 @@ static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba)
> return UFS_HS_G3;
> }
>
> +static int ufs_qcom_phy_power_on(struct ufs_hba *hba)
> +{
> + struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> + struct phy *phy = host->generic_phy;
> + int ret = 0;
> +
> + mutex_lock(&host->phy_mutex);
You do not need mutex to protect a variable. If you want to ensure that the
access to the flag is atomic, you can use test_and_{set/clear}_bit helpers.
> + if (!host->is_phy_pwr_on) {
> + ret = phy_power_on(phy);
> + if (ret) {
> + mutex_unlock(&host->phy_mutex);
> + return ret;
> + }
> + host->is_phy_pwr_on = true;
> + }
> + mutex_unlock(&host->phy_mutex);
> +
> + return ret;
> +}
> +
> +static int ufs_qcom_phy_power_off(struct ufs_hba *hba)
> +{
> + struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> + struct phy *phy = host->generic_phy;
> + int ret = 0;
> +
> + mutex_lock(&host->phy_mutex);
> + if (host->is_phy_pwr_on) {
> + ret = phy_power_off(phy);
> + if (ret) {
> + mutex_unlock(&host->phy_mutex);
> + return ret;
> + }
> + host->is_phy_pwr_on = false;
> + }
> + mutex_unlock(&host->phy_mutex);
> +
> + return ret;
> +}
> +
> static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> @@ -378,13 +418,18 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
> goto out_disable_phy;
>
> /* power on phy - start serdes and phy's power and clocks */
> - ret = phy_power_on(phy);
> + ret = ufs_qcom_phy_power_on(hba);
> if (ret) {
> dev_err(hba->dev, "%s: phy power on failed, ret = %d\n",
> __func__, ret);
> goto out_disable_phy;
> }
>
> + ret = phy_calibrate(phy);
> + if (ret) {
> + dev_err(hba->dev, "%s: Failed to calibrate PHY %d\n",
> + __func__, ret);
Even though the driver already has a lot of "__func__" to print the function
names in error log, please do not add more. I will get rid of the existing ones
at some point.
- Mani
--
மணிவண்ணன் சதாசிவம்
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2024-01-24 8:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 15:33 [PATCH V1 0/2] Refactor phy powerup sequence Nitin Rawat
2024-01-12 15:33 ` [PATCH V1 1/2] scsi: ufs: qcom : Refactor phy_power_on/off calls Nitin Rawat
2024-01-12 22:28 ` Konrad Dybcio
2024-01-24 8:22 ` Manivannan Sadhasivam [this message]
2024-01-12 15:33 ` [PATCH V1 2/2] phy: qcom: Refactor phy_power_on and phy_calibrate callbacks Nitin Rawat
2024-01-24 5:37 ` Vinod Koul
2024-01-24 8:33 ` Manivannan Sadhasivam
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=20240124082231.GA4906@thinkpad \
--to=manivannan.sadhasivam@linaro.org \
--cc=andersson@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=kishon@kernel.org \
--cc=konrad.dybcio@linaro.org \
--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=martin.petersen@oracle.com \
--cc=p.zabel@pengutronix.de \
--cc=quic_cang@quicinc.com \
--cc=quic_narepall@quicinc.com \
--cc=quic_nitirawa@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;
as well as URLs for NNTP newsgroup(s).