Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp2582367rdd; Fri, 12 Jan 2024 14:29:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IHvJEKqFOIptCwpig3LGK+O6pVcd+1PqIB4txoMQkc4h7nedOgRE7QCk6bEcfooxWUHKrCH X-Received: by 2002:a05:6214:1d2f:b0:67f:b58b:6b0a with SMTP id f15-20020a0562141d2f00b0067fb58b6b0amr1656886qvd.114.1705098543389; Fri, 12 Jan 2024 14:29:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705098543; cv=none; d=google.com; s=arc-20160816; b=y/zDwEU8QKbvQtmHMbmWEL3Iz94Tvv3iKgW8uiBjW2m2MqH3NvIJ5q3bv8gzSumXMG Wjzj8pa9/ihS0d9mYO9m7qeCt0977FjlKou3hvkenEjhhiKIrH+Bh0JOwUlpVMp54HcI wyHWQC64pN3y92YeXa5UogGRSz0yFCJeSCyFlAtsUgFT3LaWdsX9TWCe9Nd5oM6aFqM0 nGKBV/C+IfXt7v9/rRKTrez+k6sdM7xES/+eyThahcSx8JXSco4TXuJ764LPgW6wQPe6 LbDE0DLmi2vLuEBMRpQJrkXyZCWXyywJr5RVxF11YM8g8+d8a/YAsn2isIegIPQkS4/t wp1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature; bh=k+g8KAN/GocAbP+Hjj0VU3R5oOrMC5lRs+LQJKDyZbc=; fh=qT65CfNDEqGP0jbxHAOSGrmFbiJJX08fRzrkeDjYjbg=; b=eAnMtrTpfxRsZcJOESKy8yVnwPq+4avP557O/nm20S79BW8kQpPmE6D1zXcJqoGbaE ezf2pMlkf/oJs32CIE7aXCLXhsCM36qwFslWT10GV0BsVMUv+K7agKA7/KltQMA6PXwN rBValu+80bWKnpTl0YFqI93lwY4OlazZeqfjJyCDIYCyvpQEO/ABHxbb0cIYf35tuG0I MWE5XAL0Av91JsDw/D05iMOe400sECgPMeu6fWeqm34biaboM1AC8dv2SOTtvzDI9jaU 88ELwiizpA5yzagyvvVT/0LE3Sq4Eh9yPAf9l0KjZFNOxrCeOK84YE2eAeO+6v70X4/N pQug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K+jkxS/H"; spf=pass (google.com: domain of linux-kernel+bounces-25078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z19-20020a05622a029300b00429d8c24d32si345894qtw.437.2024.01.12.14.29.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jan 2024 14:29:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="K+jkxS/H"; spf=pass (google.com: domain of linux-kernel+bounces-25078-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25078-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 084301C2238C for ; Fri, 12 Jan 2024 22:29:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1223017747; Fri, 12 Jan 2024 22:28:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="K+jkxS/H" Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 500161773D for ; Fri, 12 Jan 2024 22:28:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a2c29418ad5so341257066b.0 for ; Fri, 12 Jan 2024 14:28:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1705098529; x=1705703329; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to; bh=k+g8KAN/GocAbP+Hjj0VU3R5oOrMC5lRs+LQJKDyZbc=; b=K+jkxS/HFNwjqGT47Hes14wV4POIlXFMqJjU2r06BY6/ANnvSE/NxIER3GEbt2Rci1 G+ySvp3yP92iSYndcPdgTP6X5prn6o3ewq88l+pzFuU03dwGecfVMjOmfuEpRysp9Yj1 8qWmc0Tk1lZOZowmMKuoQFig+tFKJ1SqxL/E2g/E2jlzOmhwnrtaFsPKrgKw9WCtQYeG YMpeul7CqohG4wU/WwjK4J44hX9fdGvKBTkEd7AfkKlNtGJhIJN8jo6zJT2Yp1OCBJ/7 HIWvt7IxJcpOpQyV6MVmy/6XytdULTSKDcX2uO08U9GsBAgOJREQ8gmSKZUmQWhUMnhl SKgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705098529; x=1705703329; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=k+g8KAN/GocAbP+Hjj0VU3R5oOrMC5lRs+LQJKDyZbc=; b=sWphJDGZkt1Np22n/02zs8ZwZTvFFk22mGs2b6to1Dqh9vQm1iz4m3Zn5Ry6Ayq+mN Mk7WUl9kzUVtCiuXKLpGDCJoeXVScw7ut7/tJPyVIxTg69wizUW5zDNO8x5n6PpnSrYI lRAlnB41ePeAQ2d6CIghVW7hn2U4akUSn5iRgsgaAwiIlMfuOLQZgQyKohyP/ZkpkkHc 6NW4mT2u/Wa9GmWzUU5Yp5JYdOSogDRwgYlW4xMucpqU4WamNO5M9gulk+STvhnfbBV1 TE4e8AUSXVfxKfa211N8+LE9ECiCdpBPj3Ysd4LFrIg5hZGkbIyYWJMQ0KsQcbsRLeEs IuTQ== X-Gm-Message-State: AOJu0YxF+UeVPJ9NJBMNBqvtzSEzb3mQogq70AQ7/mP/ExCgn24ffg9k Yhhk6TAUfHUfZo3h9f6dcPAa97hNSV4EwA== X-Received: by 2002:a17:906:a202:b0:a2c:4b7d:69db with SMTP id r2-20020a170906a20200b00a2c4b7d69dbmr1054995ejy.18.1705098529417; Fri, 12 Jan 2024 14:28:49 -0800 (PST) Received: from [192.168.174.25] (178235179017.dynamic-4-waw-k-1-3-0.vectranet.pl. [178.235.179.17]) by smtp.gmail.com with ESMTPSA id hx25-20020a170906847900b00a26ac57b951sm2215051ejc.23.2024.01.12.14.28.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Jan 2024 14:28:48 -0800 (PST) Message-ID: <2a8ad790-6f3b-43d8-af31-0e6dcca72c54@linaro.org> Date: Fri, 12 Jan 2024 23:28:46 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH V1 1/2] scsi: ufs: qcom : Refactor phy_power_on/off calls To: Nitin Rawat , Bjorn Andersson , Vinod Koul , Kishon Vijay Abraham I , Manivannan Sadhasivam , "James E.J. Bottomley" , "Martin K. Petersen" , Philipp Zabel Cc: linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, Can Guo , Naveen Kumar Goud Arepalli References: <20240112153348.2778-1-quic_nitirawa@quicinc.com> <20240112153348.2778-2-quic_nitirawa@quicinc.com> Content-Language: en-US From: Konrad Dybcio Autocrypt: addr=konrad.dybcio@linaro.org; keydata= xsFNBF9ALYUBEADWAhxdTBWrwAgDQQzc1O/bJ5O7b6cXYxwbBd9xKP7MICh5YA0DcCjJSOum BB/OmIWU6X+LZW6P88ZmHe+KeyABLMP5s1tJNK1j4ntT7mECcWZDzafPWF4F6m4WJOG27kTJ HGWdmtO+RvadOVi6CoUDqALsmfS3MUG5Pj2Ne9+0jRg4hEnB92AyF9rW2G3qisFcwPgvatt7 TXD5E38mLyOPOUyXNj9XpDbt1hNwKQfiidmPh5e7VNAWRnW1iCMMoKqzM1Anzq7e5Afyeifz zRcQPLaqrPjnKqZGL2BKQSZDh6NkI5ZLRhhHQf61fkWcUpTp1oDC6jWVfT7hwRVIQLrrNj9G MpPzrlN4YuAqKeIer1FMt8cq64ifgTzxHzXsMcUdclzq2LTk2RXaPl6Jg/IXWqUClJHbamSk t1bfif3SnmhA6TiNvEpDKPiT3IDs42THU6ygslrBxyROQPWLI9IL1y8S6RtEh8H+NZQWZNzm UQ3imZirlPjxZtvz1BtnnBWS06e7x/UEAguj7VHCuymVgpl2Za17d1jj81YN5Rp5L9GXxkV1 aUEwONM3eCI3qcYm5JNc5X+JthZOWsbIPSC1Rhxz3JmWIwP1udr5E3oNRe9u2LIEq+wH/toH kpPDhTeMkvt4KfE5m5ercid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dfilEDLe0jKJY0RJErbdRHsalwQCrtq/1ewQpMpsRxXzAjgfRN jc4tgxRWmI+aVTzSRpywNahzZBT695hMz81cVZJoZzaV0KaMTlSnBkrviPz1nIGHYCHJxF9r cIu0GSIyUjZ/7xslxdvjpLth16H27JCWDzDqIQMtg61063gNyEyWgt1qRSaK14JIH/DoYRfn jfFQSC8bffFjat7BQGFz4ZpRavkMUFuDirn5Tf28oc5ebe2cIHp4/kajTx/7JOxWZ80U70mA cBgEeYSrYYnX+UJsSxpzLc/0sT1eRJDEhI4XIQM4ClIzpsCIN5HnVF76UQXh3a9zpwh3dk8i bhN/URmCOTH+LHNJYN/MxY8wuukq877DWB7k86pBs5IDLAXmW8v3gIDWyIcgYqb2v8QO2Mqx YMqL7UZxVLul4/JbllsQB8F/fNI8AfttmAQL9cwo6C8yDTXKdho920W4WUR9k8NT/OBqWSyk bGqMHex48FVZhexNPYOd58EY9/7mL5u0sJmo+jTeb4JBgIbFPJCFyng4HwbniWgQJZ1WqaUC nas9J77uICis2WH7N8Bs9jy0wQYezNzqS+FxoNXmDQg2jetX8en4bO2Di7Pmx0jXA4TOb9TM izWDgYvmBE8= In-Reply-To: <20240112153348.2778-2-quic_nitirawa@quicinc.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit 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 > Signed-off-by: Can Guo > Co-developed-by: Naveen Kumar Goud Arepalli > Signed-off-by: Naveen Kumar Goud Arepalli > Signed-off-by: Nitin Rawat > --- > 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