[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2a8ad790-6f3b-43d8-af31-0e6dcca72c54@linaro.org>
Date: Fri, 12 Jan 2024 23:28:46 +0100
From: Konrad Dybcio <konrad.dybcio@...aro.org>
To: Nitin Rawat <quic_nitirawa@...cinc.com>,
Bjorn Andersson <andersson@...nel.org>, Vinod Koul <vkoul@...nel.org>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
Philipp Zabel <p.zabel@...gutronix.de>
Cc: linux-arm-msm@...r.kernel.org, linux-phy@...ts.infradead.org,
linux-kernel@...r.kernel.org, linux-scsi@...r.kernel.org,
Can Guo <quic_cang@...cinc.com>,
Naveen Kumar Goud Arepalli <quic_narepall@...cinc.com>
Subject: Re: [PATCH V1 1/2] scsi: ufs: qcom : Refactor phy_power_on/off calls
On 12.01.2024 16:33, 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'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.
>
> Also add a mutex lock to protect the usage of is_phy_pwr_on against
> possible racing.
>
> Co-developed-by: Can Guo <quic_cang@...cinc.com>
> Signed-off-by: Can Guo <quic_cang@...cinc.com>
> Co-developed-by: Naveen Kumar Goud Arepalli <quic_narepall@...cinc.com>
> Signed-off-by: Naveen Kumar Goud Arepalli <quic_narepall@...cinc.com>
> Signed-off-by: Nitin Rawat <quic_nitirawa@...cinc.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);
guard(mutex)(&host->phy_mutex);
and you can drop the _unlock calls
> + if (!host->is_phy_pwr_on) {
> + ret = phy_power_on(phy);
> + if (ret) {
> + mutex_unlock(&host->phy_mutex);
> + return ret;
And with the _unlock now being unnecessary, you can rewrite this
as:
if (!host->is_phy_pwr_on) {
ret = phy_power_on(phy);
if (!ret)
host->is_phy_pwr_on = true;
}
return ret
> + }
> + host->is_phy_pwr_on = true;
> + }
> + 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);
> + }
You can drop the overly verbose __func__, unwrap the line and remove the
curly braces, similar for dev_err-s below
Actually, shouldn't this error out if calibrate fails??
Konrad
Powered by blists - more mailing lists