From: Manivannan Sadhasivam <mani@kernel.org>
To: Can Guo <quic_cang@quicinc.com>
Cc: quic_nguyenb@quicinc.com, quic_nitirawa@quicinc.com,
martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"open list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER..."
<linux-arm-msm@vger.kernel.org>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/6] scsi: ufs: ufs-qcom: Setup host power mode during init
Date: Tue, 19 Sep 2023 12:36:07 +0200 [thread overview]
Message-ID: <20230919103607.GA4732@thinkpad> (raw)
In-Reply-To: <1694411968-14413-2-git-send-email-quic_cang@quicinc.com>
On Sun, Sep 10, 2023 at 10:59:22PM -0700, Can Guo wrote:
> Setup host power mode and its limitations during UFS host driver init to
> avoid repetitive work during every power mode change.
>
> Co-developed-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
> ---
> drivers/ufs/host/ufs-qcom.c | 27 ++++++++++++++++++---------
> drivers/ufs/host/ufs-qcom.h | 1 +
> 2 files changed, 19 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index c3215d3..710f079 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -443,7 +443,11 @@ static u32 ufs_qcom_get_hs_gear(struct ufs_hba *hba)
> static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> + struct ufs_dev_params *host_pwr_cap = &host->host_pwr_cap;
> struct phy *phy = host->generic_phy;
> + enum phy_mode mode = host_pwr_cap->hs_rate == PA_HS_MODE_B ?
> + PHY_MODE_UFS_HS_B :
> + PHY_MODE_UFS_HS_A;
I do not see anyone passing PA_HS_MODE_A in this patch, so this change is not
required now. If you are doing this as a preparatory work, please do it in a
separate patch.
> int ret;
>
> /* Reset UFS Host Controller and PHY */
> @@ -460,7 +464,7 @@ static int ufs_qcom_power_up_sequence(struct ufs_hba *hba)
> return ret;
> }
>
> - phy_set_mode_ext(phy, PHY_MODE_UFS_HS_B, host->phy_gear);
> + phy_set_mode_ext(phy, mode, host->phy_gear);
Same as above.
>
> /* power on phy - start serdes and phy's power and clocks */
> ret = phy_power_on(phy);
> @@ -884,7 +888,6 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_req_params)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> - struct ufs_dev_params ufs_qcom_cap;
> int ret = 0;
>
> if (!dev_req_params) {
> @@ -894,13 +897,7 @@ static int ufs_qcom_pwr_change_notify(struct ufs_hba *hba,
>
> switch (status) {
> case PRE_CHANGE:
> - ufshcd_init_pwr_dev_param(&ufs_qcom_cap);
> - ufs_qcom_cap.hs_rate = UFS_QCOM_LIMIT_HS_RATE;
> -
> - /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */
> - ufs_qcom_cap.hs_tx_gear = ufs_qcom_cap.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
> -
> - ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap,
> + ret = ufshcd_get_pwr_dev_param(&host->host_pwr_cap,
> dev_max_params,
> dev_req_params);
> if (ret) {
> @@ -1037,6 +1034,17 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
> hba->quirks |= UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH;
> }
>
> +static void ufs_qcom_set_pwr_mode_limits(struct ufs_hba *hba)
It's good that you are moving the setting to init() as they are static, but I'm
worried about the different naming conventions used all over the place.
The intention here is to set host parameters and then get the agreed one between
host and the device. But different names are being used. The structure itself is
named as "ufs_dev_params" even though it targets host and the vendor drivers are
naming it as "ufs_<vendor>_cap" or "host_cap". And now you've given a new name,
"host_pwr_cap", which makes things even worse.
So we should rename the struct itself as "ufs_host_params" and all the vendor
drivers should stick to "host_params".
If you do not want to do it in this series, please use existing "host_cap",
since you are embedding it within "ufs_qcom_host" struct.
Also, it'd be good to make this change for other vendor drivers as well (moving
to init()).
- Mani
> +{
> + struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> + struct ufs_dev_params *host_pwr_cap = &host->host_pwr_cap;
> +
> + ufshcd_init_pwr_dev_param(host_pwr_cap);
> +
> + /* This driver only supports symmetic gear setting i.e., hs_tx_gear == hs_rx_gear */
> + host_pwr_cap->hs_tx_gear = host_pwr_cap->hs_rx_gear = ufs_qcom_get_hs_gear(hba);
> +}
> +
> static void ufs_qcom_set_caps(struct ufs_hba *hba)
> {
> struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> @@ -1259,6 +1267,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
> if (err)
> goto out_variant_clear;
>
> + ufs_qcom_set_pwr_mode_limits(hba);
> ufs_qcom_set_caps(hba);
> ufs_qcom_advertise_quirks(hba);
>
> diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
> index fa54248..4db64d9 100644
> --- a/drivers/ufs/host/ufs-qcom.h
> +++ b/drivers/ufs/host/ufs-qcom.h
> @@ -227,6 +227,7 @@ struct ufs_qcom_host {
>
> struct gpio_desc *device_reset;
>
> + struct ufs_dev_params host_pwr_cap;
> u32 phy_gear;
>
> bool esi_enabled;
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
next prev parent reply other threads:[~2023-09-19 10:36 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1694411968-14413-1-git-send-email-quic_cang@quicinc.com>
2023-09-11 5:59 ` [PATCH 1/6] scsi: ufs: ufs-qcom: Setup host power mode during init Can Guo
2023-09-14 12:40 ` Nitin Rawat
2023-09-19 10:36 ` Manivannan Sadhasivam [this message]
2023-10-31 13:09 ` Can Guo
2023-09-11 5:59 ` [PATCH 2/6] scsi: ufs: ufs-qcom: Add support for UFS device version detection Can Guo
2023-09-11 9:17 ` Konrad Dybcio
2023-09-11 9:42 ` Can Guo
2023-09-11 9:46 ` Konrad Dybcio
2023-09-11 10:02 ` Can Guo
2023-09-15 2:31 ` Dmitry Baryshkov
2023-09-19 12:08 ` Manivannan Sadhasivam
2023-09-19 22:27 ` Dmitry Baryshkov
2023-09-20 10:23 ` Manivannan Sadhasivam
2023-09-20 11:13 ` Dmitry Baryshkov
2023-09-20 11:51 ` Manivannan Sadhasivam
2023-10-18 12:47 ` Manivannan Sadhasivam
2023-10-26 19:31 ` Konrad Dybcio
2023-10-27 12:22 ` Manivannan Sadhasivam
2023-09-15 12:48 ` Konrad Dybcio
2023-10-18 14:02 ` Neil Armstrong
[not found] ` <059cc112-7fb6-4da4-bc25-4eede0252f0e@linaro.org>
2023-10-31 5:06 ` Can Guo
2023-10-31 9:30 ` neil.armstrong
2023-09-11 5:59 ` [PATCH 3/6] phy: qualcomm: phy-qcom-qmp-ufs: Add High Speed Gear 5 support for SM8550 Can Guo
2023-09-14 12:26 ` Nitin Rawat
2023-09-15 2:07 ` Can Guo
2023-09-19 12:10 ` Manivannan Sadhasivam
2023-09-11 5:59 ` [PATCH 4/6] phy: qualcomm: phy-qcom-qmp-ufs: Move data structs and setting tables to header Can Guo
2023-09-14 11:44 ` Nitin Rawat
2023-09-14 12:28 ` Dmitry Baryshkov
2023-09-19 12:15 ` Manivannan Sadhasivam
2023-09-19 22:30 ` Dmitry Baryshkov
2023-09-20 10:19 ` Manivannan Sadhasivam
2023-09-21 14:02 ` Bjorn Andersson
2023-09-22 18:23 ` Manivannan Sadhasivam
2023-09-21 13:58 ` Bjorn Andersson
2023-09-11 5:59 ` [PATCH 5/6] scsi: ufs: ufs-sysfs: Expose UFS power info Can Guo
2023-09-14 11:33 ` Nitin Rawat
2023-09-15 1:59 ` Can Guo
2023-09-19 12:16 ` Manivannan Sadhasivam
2023-10-31 8:08 ` Can Guo
2023-10-26 19:53 ` Bart Van Assche
2023-10-31 4:46 ` Can Guo
2023-09-11 5:59 ` [PATCH 6/6] scsi: ufs: ufs-sysfs: Introduce UFS power info sysfs nodes Can Guo
2023-09-14 11:35 ` Nitin Rawat
2023-09-15 2:00 ` Can Guo
2023-09-18 15:36 ` Bart Van Assche
2023-10-31 4:53 ` Can Guo
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=20230919103607.GA4732@thinkpad \
--to=mani@kernel.org \
--cc=agross@kernel.org \
--cc=andersson@kernel.org \
--cc=jejb@linux.ibm.com \
--cc=konrad.dybcio@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=quic_cang@quicinc.com \
--cc=quic_nguyenb@quicinc.com \
--cc=quic_nitirawa@quicinc.com \
/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