From: Manivannan Sadhasivam <mani@kernel.org>
To: Can Guo <quic_cang@quicinc.com>
Cc: bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.com,
beanhuo@micron.com, avri.altman@wdc.com,
junwoo80.lee@samsung.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org,
"Alim Akhtar" <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Stanley Chu" <stanley.chu@mediatek.com>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konrad.dybcio@linaro.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Andrew Halaney" <ahalaney@redhat.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Brian Masney" <bmasney@redhat.com>,
"moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-samsung-soc@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>,
"moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER
DRIVER..." <linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v5 01/10] scsi: ufs: host: Rename structure ufs_dev_params to ufs_host_params
Date: Tue, 28 Nov 2023 10:49:17 +0530 [thread overview]
Message-ID: <20231128051917.GB3088@thinkpad> (raw)
In-Reply-To: <1700729190-17268-2-git-send-email-quic_cang@quicinc.com>
On Thu, Nov 23, 2023 at 12:46:21AM -0800, Can Guo wrote:
> Structure ufs_dev_params is actually used in UFS host vendor drivers to
> declare host specific power mode parameters, like ufs_<vendor>_params or
> host_cap, which makes the code not very straightforward to read. Rename the
> structure ufs_dev_params to ufs_host_params and unify the declarations in
> all vendor drivers to host_params.
>
> In addition, rename the two functions ufshcd_init_pwr_dev_param() and
> ufshcd_get_pwr_dev_param() which work based on the ufs_host_params to
> ufshcd_init_host_param() and ufshcd_negotiate_pwr_param() respectively to
> avoid confusions.
>
> This change does not change any functionalities or logic.
>
> Acked-by: Andrew Halaney <ahalaney@redhat.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/ufs/host/ufs-exynos.c | 7 ++--
> drivers/ufs/host/ufs-hisi.c | 11 +++----
> drivers/ufs/host/ufs-mediatek.c | 12 +++----
> drivers/ufs/host/ufs-qcom.c | 12 +++----
> drivers/ufs/host/ufshcd-pltfrm.c | 69 ++++++++++++++++++++--------------------
> drivers/ufs/host/ufshcd-pltfrm.h | 10 +++---
> 6 files changed, 57 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 71bd6db..674f2f4 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -765,7 +765,7 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> {
> struct exynos_ufs *ufs = ufshcd_get_variant(hba);
> struct phy *generic_phy = ufs->phy;
> - struct ufs_dev_params ufs_exynos_cap;
> + struct ufs_host_params host_params;
> int ret;
>
> if (!dev_req_params) {
> @@ -774,10 +774,9 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> goto out;
> }
>
> - ufshcd_init_pwr_dev_param(&ufs_exynos_cap);
> + ufshcd_init_host_param(&host_params);
>
> - ret = ufshcd_get_pwr_dev_param(&ufs_exynos_cap,
> - dev_max_params, dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> pr_err("%s: failed to determine capabilities\n", __func__);
> goto out;
> diff --git a/drivers/ufs/host/ufs-hisi.c b/drivers/ufs/host/ufs-hisi.c
> index 0229ac0..bb0c9a7 100644
> --- a/drivers/ufs/host/ufs-hisi.c
> +++ b/drivers/ufs/host/ufs-hisi.c
> @@ -293,9 +293,9 @@ static int ufs_hisi_link_startup_notify(struct ufs_hba *hba,
> return err;
> }
>
> -static void ufs_hisi_set_dev_cap(struct ufs_dev_params *hisi_param)
> +static void ufs_hisi_set_dev_cap(struct ufs_host_params *host_params)
> {
> - ufshcd_init_pwr_dev_param(hisi_param);
> + ufshcd_init_host_param(host_params);
> }
>
> static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)
> @@ -365,7 +365,7 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_max_params,
> struct ufs_pa_layer_attr *dev_req_params)
> {
> - struct ufs_dev_params ufs_hisi_cap;
> + struct ufs_host_params host_params;
> int ret = 0;
>
> if (!dev_req_params) {
> @@ -377,9 +377,8 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
>
> switch (status) {
> case PRE_CHANGE:
> - ufs_hisi_set_dev_cap(&ufs_hisi_cap);
> - ret = ufshcd_get_pwr_dev_param(&ufs_hisi_cap,
> - dev_max_params, dev_req_params);
> + ufs_hisi_set_dev_cap(&host_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> dev_err(hba->dev,
> "%s: failed to determine capabilities\n", __func__);
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index fc61790..016067d 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -996,16 +996,14 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_req_params)
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> - struct ufs_dev_params host_cap;
> + struct ufs_host_params host_params;
> int ret;
>
> - ufshcd_init_pwr_dev_param(&host_cap);
> - host_cap.hs_rx_gear = UFS_HS_G5;
> - host_cap.hs_tx_gear = UFS_HS_G5;
> + ufshcd_init_host_param(&host_params);
> + host_params.hs_rx_gear = UFS_HS_G5;
> + host_params.hs_tx_gear = UFS_HS_G5;
>
> - ret = ufshcd_get_pwr_dev_param(&host_cap,
> - dev_max_params,
> - dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> pr_info("%s: failed to determine capabilities\n",
> __func__);
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 96cb8b5..aee66a3 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -898,7 +898,7 @@ 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;
> + struct ufs_host_params host_params;
> int ret = 0;
>
> if (!dev_req_params) {
> @@ -908,15 +908,13 @@ 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;
> + ufshcd_init_host_param(&host_params);
> + host_params.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);
> + host_params.hs_tx_gear = host_params.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
>
> - ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap,
> - dev_max_params,
> - dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> dev_err(hba->dev, "%s: failed to determine capabilities\n",
> __func__);
> diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
> index da2558e..9ec11b9 100644
> --- a/drivers/ufs/host/ufshcd-pltfrm.c
> +++ b/drivers/ufs/host/ufshcd-pltfrm.c
> @@ -285,61 +285,60 @@ static int ufshcd_parse_operating_points(struct ufs_hba *hba)
> }
>
> /**
> - * ufshcd_get_pwr_dev_param - get finally agreed attributes for
> - * power mode change
> - * @pltfrm_param: pointer to platform parameters
> + * ufshcd_negotiate_pwr_param - find power mode settings that are supported by
> + both the controller and the device
> + * @host_param: pointer to host parameters
> * @dev_max: pointer to device attributes
> * @agreed_pwr: returned agreed attributes
> *
> * Return: 0 on success, non-zero value on failure.
> */
> -int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> - const struct ufs_pa_layer_attr *dev_max,
> - struct ufs_pa_layer_attr *agreed_pwr)
> +int ufshcd_negotiate_pwr_param(const struct ufs_host_params *host_param,
> + const struct ufs_pa_layer_attr *dev_max,
> + struct ufs_pa_layer_attr *agreed_pwr)
> {
> - int min_pltfrm_gear;
> + int min_host_gear;
> int min_dev_gear;
> bool is_dev_sup_hs = false;
> - bool is_pltfrm_max_hs = false;
> + bool is_host_max_hs = false;
>
> if (dev_max->pwr_rx == FAST_MODE)
> is_dev_sup_hs = true;
>
> - if (pltfrm_param->desired_working_mode == UFS_HS_MODE) {
> - is_pltfrm_max_hs = true;
> - min_pltfrm_gear = min_t(u32, pltfrm_param->hs_rx_gear,
> - pltfrm_param->hs_tx_gear);
> + if (host_param->desired_working_mode == UFS_HS_MODE) {
> + is_host_max_hs = true;
> + min_host_gear = min_t(u32, host_param->hs_rx_gear,
> + host_param->hs_tx_gear);
> } else {
> - min_pltfrm_gear = min_t(u32, pltfrm_param->pwm_rx_gear,
> - pltfrm_param->pwm_tx_gear);
> + min_host_gear = min_t(u32, host_param->pwm_rx_gear,
> + host_param->pwm_tx_gear);
> }
>
> /*
> - * device doesn't support HS but
> - * pltfrm_param->desired_working_mode is HS,
> - * thus device and pltfrm_param don't agree
> + * device doesn't support HS but host_param->desired_working_mode is HS,
> + * thus device and host_param don't agree
> */
> - if (!is_dev_sup_hs && is_pltfrm_max_hs) {
> + if (!is_dev_sup_hs && is_host_max_hs) {
> pr_info("%s: device doesn't support HS\n",
> __func__);
> return -ENOTSUPP;
> - } else if (is_dev_sup_hs && is_pltfrm_max_hs) {
> + } else if (is_dev_sup_hs && is_host_max_hs) {
> /*
> * since device supports HS, it supports FAST_MODE.
> - * since pltfrm_param->desired_working_mode is also HS
> + * since host_param->desired_working_mode is also HS
> * then final decision (FAST/FASTAUTO) is done according
> * to pltfrm_params as it is the restricting factor
> */
> - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_hs;
> + agreed_pwr->pwr_rx = host_param->rx_pwr_hs;
> agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
> } else {
> /*
> - * here pltfrm_param->desired_working_mode is PWM.
> + * here host_param->desired_working_mode is PWM.
> * it doesn't matter whether device supports HS or PWM,
> - * in both cases pltfrm_param->desired_working_mode will
> + * in both cases host_param->desired_working_mode will
> * determine the mode
> */
> - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_pwm;
> + agreed_pwr->pwr_rx = host_param->rx_pwr_pwm;
> agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
> }
>
> @@ -349,9 +348,9 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> * the same decision will be made for rx
> */
> agreed_pwr->lane_tx = min_t(u32, dev_max->lane_tx,
> - pltfrm_param->tx_lanes);
> + host_param->tx_lanes);
> agreed_pwr->lane_rx = min_t(u32, dev_max->lane_rx,
> - pltfrm_param->rx_lanes);
> + host_param->rx_lanes);
>
> /* device maximum gear is the minimum between device rx and tx gears */
> min_dev_gear = min_t(u32, dev_max->gear_rx, dev_max->gear_tx);
> @@ -364,26 +363,26 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> * what is the gear, as it is the one that also decided previously what
> * pwr the device will be configured to.
> */
> - if ((is_dev_sup_hs && is_pltfrm_max_hs) ||
> - (!is_dev_sup_hs && !is_pltfrm_max_hs)) {
> + if ((is_dev_sup_hs && is_host_max_hs) ||
> + (!is_dev_sup_hs && !is_host_max_hs)) {
> agreed_pwr->gear_rx =
> - min_t(u32, min_dev_gear, min_pltfrm_gear);
> + min_t(u32, min_dev_gear, min_host_gear);
> } else if (!is_dev_sup_hs) {
> agreed_pwr->gear_rx = min_dev_gear;
> } else {
> - agreed_pwr->gear_rx = min_pltfrm_gear;
> + agreed_pwr->gear_rx = min_host_gear;
> }
> agreed_pwr->gear_tx = agreed_pwr->gear_rx;
>
> - agreed_pwr->hs_rate = pltfrm_param->hs_rate;
> + agreed_pwr->hs_rate = host_param->hs_rate;
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
> +EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_param);
>
> -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
> +void ufshcd_init_host_param(struct ufs_host_params *host_param)
> {
> - *dev_param = (struct ufs_dev_params){
> + *host_param = (struct ufs_host_params){
> .tx_lanes = UFS_LANE_2,
> .rx_lanes = UFS_LANE_2,
> .hs_rx_gear = UFS_HS_G3,
> @@ -398,7 +397,7 @@ void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
> .desired_working_mode = UFS_HS_MODE,
> };
> }
> -EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
> +EXPORT_SYMBOL_GPL(ufshcd_init_host_param);
>
> /**
> * ufshcd_pltfrm_init - probe routine of the driver
> diff --git a/drivers/ufs/host/ufshcd-pltfrm.h b/drivers/ufs/host/ufshcd-pltfrm.h
> index a86a3ad..2d4d047 100644
> --- a/drivers/ufs/host/ufshcd-pltfrm.h
> +++ b/drivers/ufs/host/ufshcd-pltfrm.h
> @@ -10,7 +10,7 @@
> #define UFS_PWM_MODE 1
> #define UFS_HS_MODE 2
>
> -struct ufs_dev_params {
> +struct ufs_host_params {
> u32 pwm_rx_gear; /* pwm rx gear to work in */
> u32 pwm_tx_gear; /* pwm tx gear to work in */
> u32 hs_rx_gear; /* hs rx gear to work in */
> @@ -25,10 +25,10 @@ struct ufs_dev_params {
> u32 desired_working_mode;
> };
>
> -int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *dev_param,
> - const struct ufs_pa_layer_attr *dev_max,
> - struct ufs_pa_layer_attr *agreed_pwr);
> -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param);
> +int ufshcd_negotiate_pwr_param(const struct ufs_host_params *host_param,
> + const struct ufs_pa_layer_attr *dev_max,
> + struct ufs_pa_layer_attr *agreed_pwr);
> +void ufshcd_init_host_param(struct ufs_host_params *host_param);
> int ufshcd_pltfrm_init(struct platform_device *pdev,
> const struct ufs_hba_variant_ops *vops);
> int ufshcd_populate_vreg(struct device *dev, const char *name,
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
WARNING: multiple messages have this Message-ID (diff)
From: Manivannan Sadhasivam <mani@kernel.org>
To: Can Guo <quic_cang@quicinc.com>
Cc: bvanassche@acm.org, mani@kernel.org, adrian.hunter@intel.com,
beanhuo@micron.com, avri.altman@wdc.com,
junwoo80.lee@samsung.com, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org, linux-arm-msm@vger.kernel.org,
"Alim Akhtar" <alim.akhtar@samsung.com>,
"James E.J. Bottomley" <jejb@linux.ibm.com>,
"Krzysztof Kozlowski" <krzysztof.kozlowski@linaro.org>,
"Stanley Chu" <stanley.chu@mediatek.com>,
"Andy Gross" <agross@kernel.org>,
"Bjorn Andersson" <andersson@kernel.org>,
"Konrad Dybcio" <konrad.dybcio@linaro.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Andrew Halaney" <ahalaney@redhat.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Brian Masney" <bmasney@redhat.com>,
"moderated list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-arm-kernel@lists.infradead.org>,
"open list:ARM/SAMSUNG S3C,
S5P AND EXYNOS ARM ARCHITECTURES"
<linux-samsung-soc@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>,
"moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER
DRIVER..." <linux-mediatek@lists.infradead.org>
Subject: Re: [PATCH v5 01/10] scsi: ufs: host: Rename structure ufs_dev_params to ufs_host_params
Date: Tue, 28 Nov 2023 10:49:17 +0530 [thread overview]
Message-ID: <20231128051917.GB3088@thinkpad> (raw)
In-Reply-To: <1700729190-17268-2-git-send-email-quic_cang@quicinc.com>
On Thu, Nov 23, 2023 at 12:46:21AM -0800, Can Guo wrote:
> Structure ufs_dev_params is actually used in UFS host vendor drivers to
> declare host specific power mode parameters, like ufs_<vendor>_params or
> host_cap, which makes the code not very straightforward to read. Rename the
> structure ufs_dev_params to ufs_host_params and unify the declarations in
> all vendor drivers to host_params.
>
> In addition, rename the two functions ufshcd_init_pwr_dev_param() and
> ufshcd_get_pwr_dev_param() which work based on the ufs_host_params to
> ufshcd_init_host_param() and ufshcd_negotiate_pwr_param() respectively to
> avoid confusions.
>
> This change does not change any functionalities or logic.
>
> Acked-by: Andrew Halaney <ahalaney@redhat.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
- Mani
> ---
> drivers/ufs/host/ufs-exynos.c | 7 ++--
> drivers/ufs/host/ufs-hisi.c | 11 +++----
> drivers/ufs/host/ufs-mediatek.c | 12 +++----
> drivers/ufs/host/ufs-qcom.c | 12 +++----
> drivers/ufs/host/ufshcd-pltfrm.c | 69 ++++++++++++++++++++--------------------
> drivers/ufs/host/ufshcd-pltfrm.h | 10 +++---
> 6 files changed, 57 insertions(+), 64 deletions(-)
>
> diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
> index 71bd6db..674f2f4 100644
> --- a/drivers/ufs/host/ufs-exynos.c
> +++ b/drivers/ufs/host/ufs-exynos.c
> @@ -765,7 +765,7 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> {
> struct exynos_ufs *ufs = ufshcd_get_variant(hba);
> struct phy *generic_phy = ufs->phy;
> - struct ufs_dev_params ufs_exynos_cap;
> + struct ufs_host_params host_params;
> int ret;
>
> if (!dev_req_params) {
> @@ -774,10 +774,9 @@ static int exynos_ufs_pre_pwr_mode(struct ufs_hba *hba,
> goto out;
> }
>
> - ufshcd_init_pwr_dev_param(&ufs_exynos_cap);
> + ufshcd_init_host_param(&host_params);
>
> - ret = ufshcd_get_pwr_dev_param(&ufs_exynos_cap,
> - dev_max_params, dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> pr_err("%s: failed to determine capabilities\n", __func__);
> goto out;
> diff --git a/drivers/ufs/host/ufs-hisi.c b/drivers/ufs/host/ufs-hisi.c
> index 0229ac0..bb0c9a7 100644
> --- a/drivers/ufs/host/ufs-hisi.c
> +++ b/drivers/ufs/host/ufs-hisi.c
> @@ -293,9 +293,9 @@ static int ufs_hisi_link_startup_notify(struct ufs_hba *hba,
> return err;
> }
>
> -static void ufs_hisi_set_dev_cap(struct ufs_dev_params *hisi_param)
> +static void ufs_hisi_set_dev_cap(struct ufs_host_params *host_params)
> {
> - ufshcd_init_pwr_dev_param(hisi_param);
> + ufshcd_init_host_param(host_params);
> }
>
> static void ufs_hisi_pwr_change_pre_change(struct ufs_hba *hba)
> @@ -365,7 +365,7 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_max_params,
> struct ufs_pa_layer_attr *dev_req_params)
> {
> - struct ufs_dev_params ufs_hisi_cap;
> + struct ufs_host_params host_params;
> int ret = 0;
>
> if (!dev_req_params) {
> @@ -377,9 +377,8 @@ static int ufs_hisi_pwr_change_notify(struct ufs_hba *hba,
>
> switch (status) {
> case PRE_CHANGE:
> - ufs_hisi_set_dev_cap(&ufs_hisi_cap);
> - ret = ufshcd_get_pwr_dev_param(&ufs_hisi_cap,
> - dev_max_params, dev_req_params);
> + ufs_hisi_set_dev_cap(&host_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> dev_err(hba->dev,
> "%s: failed to determine capabilities\n", __func__);
> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index fc61790..016067d 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
> @@ -996,16 +996,14 @@ static int ufs_mtk_pre_pwr_change(struct ufs_hba *hba,
> struct ufs_pa_layer_attr *dev_req_params)
> {
> struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> - struct ufs_dev_params host_cap;
> + struct ufs_host_params host_params;
> int ret;
>
> - ufshcd_init_pwr_dev_param(&host_cap);
> - host_cap.hs_rx_gear = UFS_HS_G5;
> - host_cap.hs_tx_gear = UFS_HS_G5;
> + ufshcd_init_host_param(&host_params);
> + host_params.hs_rx_gear = UFS_HS_G5;
> + host_params.hs_tx_gear = UFS_HS_G5;
>
> - ret = ufshcd_get_pwr_dev_param(&host_cap,
> - dev_max_params,
> - dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> pr_info("%s: failed to determine capabilities\n",
> __func__);
> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index 96cb8b5..aee66a3 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -898,7 +898,7 @@ 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;
> + struct ufs_host_params host_params;
> int ret = 0;
>
> if (!dev_req_params) {
> @@ -908,15 +908,13 @@ 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;
> + ufshcd_init_host_param(&host_params);
> + host_params.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);
> + host_params.hs_tx_gear = host_params.hs_rx_gear = ufs_qcom_get_hs_gear(hba);
>
> - ret = ufshcd_get_pwr_dev_param(&ufs_qcom_cap,
> - dev_max_params,
> - dev_req_params);
> + ret = ufshcd_negotiate_pwr_param(&host_params, dev_max_params, dev_req_params);
> if (ret) {
> dev_err(hba->dev, "%s: failed to determine capabilities\n",
> __func__);
> diff --git a/drivers/ufs/host/ufshcd-pltfrm.c b/drivers/ufs/host/ufshcd-pltfrm.c
> index da2558e..9ec11b9 100644
> --- a/drivers/ufs/host/ufshcd-pltfrm.c
> +++ b/drivers/ufs/host/ufshcd-pltfrm.c
> @@ -285,61 +285,60 @@ static int ufshcd_parse_operating_points(struct ufs_hba *hba)
> }
>
> /**
> - * ufshcd_get_pwr_dev_param - get finally agreed attributes for
> - * power mode change
> - * @pltfrm_param: pointer to platform parameters
> + * ufshcd_negotiate_pwr_param - find power mode settings that are supported by
> + both the controller and the device
> + * @host_param: pointer to host parameters
> * @dev_max: pointer to device attributes
> * @agreed_pwr: returned agreed attributes
> *
> * Return: 0 on success, non-zero value on failure.
> */
> -int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> - const struct ufs_pa_layer_attr *dev_max,
> - struct ufs_pa_layer_attr *agreed_pwr)
> +int ufshcd_negotiate_pwr_param(const struct ufs_host_params *host_param,
> + const struct ufs_pa_layer_attr *dev_max,
> + struct ufs_pa_layer_attr *agreed_pwr)
> {
> - int min_pltfrm_gear;
> + int min_host_gear;
> int min_dev_gear;
> bool is_dev_sup_hs = false;
> - bool is_pltfrm_max_hs = false;
> + bool is_host_max_hs = false;
>
> if (dev_max->pwr_rx == FAST_MODE)
> is_dev_sup_hs = true;
>
> - if (pltfrm_param->desired_working_mode == UFS_HS_MODE) {
> - is_pltfrm_max_hs = true;
> - min_pltfrm_gear = min_t(u32, pltfrm_param->hs_rx_gear,
> - pltfrm_param->hs_tx_gear);
> + if (host_param->desired_working_mode == UFS_HS_MODE) {
> + is_host_max_hs = true;
> + min_host_gear = min_t(u32, host_param->hs_rx_gear,
> + host_param->hs_tx_gear);
> } else {
> - min_pltfrm_gear = min_t(u32, pltfrm_param->pwm_rx_gear,
> - pltfrm_param->pwm_tx_gear);
> + min_host_gear = min_t(u32, host_param->pwm_rx_gear,
> + host_param->pwm_tx_gear);
> }
>
> /*
> - * device doesn't support HS but
> - * pltfrm_param->desired_working_mode is HS,
> - * thus device and pltfrm_param don't agree
> + * device doesn't support HS but host_param->desired_working_mode is HS,
> + * thus device and host_param don't agree
> */
> - if (!is_dev_sup_hs && is_pltfrm_max_hs) {
> + if (!is_dev_sup_hs && is_host_max_hs) {
> pr_info("%s: device doesn't support HS\n",
> __func__);
> return -ENOTSUPP;
> - } else if (is_dev_sup_hs && is_pltfrm_max_hs) {
> + } else if (is_dev_sup_hs && is_host_max_hs) {
> /*
> * since device supports HS, it supports FAST_MODE.
> - * since pltfrm_param->desired_working_mode is also HS
> + * since host_param->desired_working_mode is also HS
> * then final decision (FAST/FASTAUTO) is done according
> * to pltfrm_params as it is the restricting factor
> */
> - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_hs;
> + agreed_pwr->pwr_rx = host_param->rx_pwr_hs;
> agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
> } else {
> /*
> - * here pltfrm_param->desired_working_mode is PWM.
> + * here host_param->desired_working_mode is PWM.
> * it doesn't matter whether device supports HS or PWM,
> - * in both cases pltfrm_param->desired_working_mode will
> + * in both cases host_param->desired_working_mode will
> * determine the mode
> */
> - agreed_pwr->pwr_rx = pltfrm_param->rx_pwr_pwm;
> + agreed_pwr->pwr_rx = host_param->rx_pwr_pwm;
> agreed_pwr->pwr_tx = agreed_pwr->pwr_rx;
> }
>
> @@ -349,9 +348,9 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> * the same decision will be made for rx
> */
> agreed_pwr->lane_tx = min_t(u32, dev_max->lane_tx,
> - pltfrm_param->tx_lanes);
> + host_param->tx_lanes);
> agreed_pwr->lane_rx = min_t(u32, dev_max->lane_rx,
> - pltfrm_param->rx_lanes);
> + host_param->rx_lanes);
>
> /* device maximum gear is the minimum between device rx and tx gears */
> min_dev_gear = min_t(u32, dev_max->gear_rx, dev_max->gear_tx);
> @@ -364,26 +363,26 @@ int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *pltfrm_param,
> * what is the gear, as it is the one that also decided previously what
> * pwr the device will be configured to.
> */
> - if ((is_dev_sup_hs && is_pltfrm_max_hs) ||
> - (!is_dev_sup_hs && !is_pltfrm_max_hs)) {
> + if ((is_dev_sup_hs && is_host_max_hs) ||
> + (!is_dev_sup_hs && !is_host_max_hs)) {
> agreed_pwr->gear_rx =
> - min_t(u32, min_dev_gear, min_pltfrm_gear);
> + min_t(u32, min_dev_gear, min_host_gear);
> } else if (!is_dev_sup_hs) {
> agreed_pwr->gear_rx = min_dev_gear;
> } else {
> - agreed_pwr->gear_rx = min_pltfrm_gear;
> + agreed_pwr->gear_rx = min_host_gear;
> }
> agreed_pwr->gear_tx = agreed_pwr->gear_rx;
>
> - agreed_pwr->hs_rate = pltfrm_param->hs_rate;
> + agreed_pwr->hs_rate = host_param->hs_rate;
>
> return 0;
> }
> -EXPORT_SYMBOL_GPL(ufshcd_get_pwr_dev_param);
> +EXPORT_SYMBOL_GPL(ufshcd_negotiate_pwr_param);
>
> -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
> +void ufshcd_init_host_param(struct ufs_host_params *host_param)
> {
> - *dev_param = (struct ufs_dev_params){
> + *host_param = (struct ufs_host_params){
> .tx_lanes = UFS_LANE_2,
> .rx_lanes = UFS_LANE_2,
> .hs_rx_gear = UFS_HS_G3,
> @@ -398,7 +397,7 @@ void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param)
> .desired_working_mode = UFS_HS_MODE,
> };
> }
> -EXPORT_SYMBOL_GPL(ufshcd_init_pwr_dev_param);
> +EXPORT_SYMBOL_GPL(ufshcd_init_host_param);
>
> /**
> * ufshcd_pltfrm_init - probe routine of the driver
> diff --git a/drivers/ufs/host/ufshcd-pltfrm.h b/drivers/ufs/host/ufshcd-pltfrm.h
> index a86a3ad..2d4d047 100644
> --- a/drivers/ufs/host/ufshcd-pltfrm.h
> +++ b/drivers/ufs/host/ufshcd-pltfrm.h
> @@ -10,7 +10,7 @@
> #define UFS_PWM_MODE 1
> #define UFS_HS_MODE 2
>
> -struct ufs_dev_params {
> +struct ufs_host_params {
> u32 pwm_rx_gear; /* pwm rx gear to work in */
> u32 pwm_tx_gear; /* pwm tx gear to work in */
> u32 hs_rx_gear; /* hs rx gear to work in */
> @@ -25,10 +25,10 @@ struct ufs_dev_params {
> u32 desired_working_mode;
> };
>
> -int ufshcd_get_pwr_dev_param(const struct ufs_dev_params *dev_param,
> - const struct ufs_pa_layer_attr *dev_max,
> - struct ufs_pa_layer_attr *agreed_pwr);
> -void ufshcd_init_pwr_dev_param(struct ufs_dev_params *dev_param);
> +int ufshcd_negotiate_pwr_param(const struct ufs_host_params *host_param,
> + const struct ufs_pa_layer_attr *dev_max,
> + struct ufs_pa_layer_attr *agreed_pwr);
> +void ufshcd_init_host_param(struct ufs_host_params *host_param);
> int ufshcd_pltfrm_init(struct platform_device *pdev,
> const struct ufs_hba_variant_ops *vops);
> int ufshcd_populate_vreg(struct device *dev, const char *name,
> --
> 2.7.4
>
--
மணிவண்ணன் சதாசிவம்
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-11-28 5:19 UTC|newest]
Thread overview: 61+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 8:46 [PATCH v5 00/10] Enable HS-G5 support on SM8550 Can Guo
2023-11-23 8:46 ` Can Guo
2023-11-23 8:46 ` [PATCH v5 01/10] scsi: ufs: host: Rename structure ufs_dev_params to ufs_host_params Can Guo
2023-11-23 8:46 ` Can Guo
2023-11-28 5:19 ` Manivannan Sadhasivam [this message]
2023-11-28 5:19 ` Manivannan Sadhasivam
2023-11-28 5:31 ` Manivannan Sadhasivam
2023-11-28 5:31 ` Manivannan Sadhasivam
2023-11-28 7:49 ` Can Guo
2023-11-28 7:49 ` Can Guo
2023-11-28 5:31 ` Nitin Rawat
2023-11-28 5:31 ` Nitin Rawat
2023-11-23 8:46 ` [PATCH v5 02/10] scsi: ufs: ufs-qcom: No need to set hs_rate after ufshcd_init_host_param() Can Guo
2023-11-28 5:10 ` Nitin Rawat
2023-11-28 5:22 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 03/10] scsi: ufs: ufs-qcom: Setup host power mode during init Can Guo
2023-11-28 5:06 ` Nitin Rawat
2023-11-28 5:24 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 04/10] scsi: ufs: ufs-qcom: Limit negotiated gear to selected PHY gear Can Guo
2023-11-28 5:45 ` Manivannan Sadhasivam
2023-11-28 8:05 ` Can Guo
2023-11-28 10:52 ` Manivannan Sadhasivam
2023-11-28 11:03 ` Can Guo
2023-11-28 11:20 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 05/10] scsi: ufs: ufs-qcom: Allow the first init start with the maximum supported gear Can Guo
2023-11-23 8:46 ` [PATCH v5 06/10] scsi: ufs: ufs-qcom: Limit HS-G5 Rate-A to hosts with HW version 5 Can Guo
2023-11-28 5:15 ` Nitin Rawat
2023-11-28 5:55 ` Manivannan Sadhasivam
2023-11-28 7:48 ` Can Guo
2023-11-28 10:55 ` Manivannan Sadhasivam
2023-11-28 10:59 ` Can Guo
2023-11-28 11:24 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 07/10] scsi: ufs: ufs-qcom: Set initial PHY gear to max HS gear for HW ver 5 and newer Can Guo
2023-11-28 6:00 ` Manivannan Sadhasivam
2023-11-28 7:58 ` Can Guo
2023-11-28 10:59 ` Manivannan Sadhasivam
2023-11-28 11:01 ` Can Guo
2023-11-28 11:22 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 08/10] phy: qualcomm: phy-qcom-qmp-ufs: Rectify SM8550 UFS HS-G4 PHY Settings Can Guo
2023-11-23 8:46 ` Can Guo
2023-11-27 11:07 ` Vinod Koul
2023-11-27 11:07 ` Vinod Koul
2023-11-28 1:50 ` Can Guo
2023-11-28 1:50 ` Can Guo
2023-11-28 6:02 ` Manivannan Sadhasivam
2023-11-28 6:02 ` Manivannan Sadhasivam
2023-11-23 8:46 ` [PATCH v5 09/10] phy: qualcomm: phy-qcom-qmp-ufs: Add High Speed Gear 5 support for SM8550 Can Guo
2023-11-23 8:46 ` Can Guo
2023-11-23 12:35 ` Dmitry Baryshkov
2023-11-23 12:35 ` Dmitry Baryshkov
2023-11-24 1:55 ` Can Guo
2023-11-24 1:55 ` Can Guo
2023-11-28 6:47 ` Manivannan Sadhasivam
2023-11-28 6:47 ` Manivannan Sadhasivam
2023-11-28 9:00 ` Can Guo
2023-11-28 9:00 ` Can Guo
2023-11-28 9:59 ` neil.armstrong
2023-11-28 9:59 ` neil.armstrong
2023-11-28 10:03 ` Can Guo
2023-11-28 10:03 ` Can Guo
2023-11-23 8:46 ` [PATCH v5 10/10] scsi: ufs: ufs-qcom: Add support for UFS device version detection 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=20231128051917.GB3088@thinkpad \
--to=mani@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=agross@kernel.org \
--cc=ahalaney@redhat.com \
--cc=alim.akhtar@samsung.com \
--cc=andersson@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=avri.altman@wdc.com \
--cc=beanhuo@micron.com \
--cc=bmasney@redhat.com \
--cc=bvanassche@acm.org \
--cc=jejb@linux.ibm.com \
--cc=junwoo80.lee@samsung.com \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=matthias.bgg@gmail.com \
--cc=quic_cang@quicinc.com \
--cc=stanley.chu@mediatek.com \
--cc=u.kleine-koenig@pengutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.