public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: hongwus@codeaurora.org
To: Can Guo <cang@codeaurora.org>
Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org,
	rnayak@codeaurora.org, linux-scsi@vger.kernel.org,
	kernel-team@android.com, saravanak@google.com,
	salyzyn@google.com, Andy Gross <agross@kernel.org>,
	Bjorn Andersson <bjorn.andersson@linaro.org>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v9 3/7] scsi: ufs-qcom: Adjust bus bandwidth voting and unvoting
Date: Tue, 11 Feb 2020 11:09:23 +0800	[thread overview]
Message-ID: <c0fdc3e7f3457544c987d296c3a26e35@codeaurora.org> (raw)
In-Reply-To: <1581388671-18078-4-git-send-email-cang@codeaurora.org>

Hi Can,


On 2020-02-11 10:37, Can Guo wrote:
> The bus bandwidth voting is required to be done before the bus clocks
> are enabled, and the unvoting is required to be done only after the bus
> clocks are disabled.
> 
> Signed-off-by: Can Guo <cang@codeaurora.org>
> Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
> ---
>  drivers/scsi/ufs/ufs-qcom.c | 78 
> ++++++++++++++++++++++++++++++---------------
>  1 file changed, 53 insertions(+), 25 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
> index c69c29a1c..ded08fb 100644
> --- a/drivers/scsi/ufs/ufs-qcom.c
> +++ b/drivers/scsi/ufs/ufs-qcom.c
> @@ -38,7 +38,6 @@ enum {
> 
>  static struct ufs_qcom_host *ufs_qcom_hosts[MAX_UFS_QCOM_HOSTS];
> 
> -static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int 
> vote);
>  static void ufs_qcom_get_default_testbus_cfg(struct ufs_qcom_host 
> *host);
>  static int ufs_qcom_set_dme_vs_core_clk_ctrl_clear_div(struct ufs_hba 
> *hba,
>  						       u32 clk_cycles);
> @@ -674,7 +673,7 @@ static void ufs_qcom_get_speed_mode(struct
> ufs_pa_layer_attr *p, char *result)
>  	}
>  }
> 
> -static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote)
> +static int __ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int 
> vote)
>  {
>  	int err = 0;
> 
> @@ -705,7 +704,7 @@ static int ufs_qcom_update_bus_bw_vote(struct
> ufs_qcom_host *host)
> 
>  	vote = ufs_qcom_get_bus_vote(host, mode);
>  	if (vote >= 0)
> -		err = ufs_qcom_set_bus_vote(host, vote);
> +		err = __ufs_qcom_set_bus_vote(host, vote);
>  	else
>  		err = vote;
> 
> @@ -716,6 +715,35 @@ static int ufs_qcom_update_bus_bw_vote(struct
> ufs_qcom_host *host)
>  	return err;
>  }
> 
> +static int ufs_qcom_set_bus_vote(struct ufs_hba *hba, bool on)
> +{
> +	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> +	int vote, err;
> +
> +	/*
> +	 * In case ufs_qcom_init() is not yet done, simply ignore.
> +	 * This ufs_qcom_set_bus_vote() shall be called from
> +	 * ufs_qcom_init() after init is done.
> +	 */
> +	if (!host)
> +		return 0;
> +
> +	if (on) {
> +		vote = host->bus_vote.saved_vote;
> +		if (vote == host->bus_vote.min_bw_vote)
> +			ufs_qcom_update_bus_bw_vote(host);
> +	} else {
> +		vote = host->bus_vote.min_bw_vote;
> +	}
> +
> +	err = __ufs_qcom_set_bus_vote(host, vote);
> +	if (err)
> +		dev_err(hba->dev, "%s: set bus vote failed %d\n",
> +				 __func__, err);
> +
> +	return err;
> +}
> +
>  static ssize_t
>  show_ufs_to_mem_max_bus_bw(struct device *dev, struct device_attribute 
> *attr,
>  			char *buf)
> @@ -792,7 +820,7 @@ static int ufs_qcom_update_bus_bw_vote(struct
> ufs_qcom_host *host)
>  	return 0;
>  }
> 
> -static int ufs_qcom_set_bus_vote(struct ufs_qcom_host *host, int vote)
> +static int ufs_qcom_set_bus_vote(struct ufs_hba *host, bool on)
>  {
>  	return 0;
>  }
> @@ -1030,8 +1058,7 @@ static int ufs_qcom_setup_clocks(struct ufs_hba
> *hba, bool on,
>  				 enum ufs_notify_change_status status)
>  {
>  	struct ufs_qcom_host *host = ufshcd_get_variant(hba);
> -	int err;
> -	int vote = 0;
> +	int err = 0;
> 
>  	/*
>  	 * In case ufs_qcom_init() is not yet done, simply ignore.
> @@ -1041,28 +1068,28 @@ static int ufs_qcom_setup_clocks(struct
> ufs_hba *hba, bool on,
>  	if (!host)
>  		return 0;
> 
> -	if (on && (status == POST_CHANGE)) {
> -		/* enable the device ref clock for HS mode*/
> -		if (ufshcd_is_hs_mode(&hba->pwr_info))
> -			ufs_qcom_dev_ref_clk_ctrl(host, true);
> -		vote = host->bus_vote.saved_vote;
> -		if (vote == host->bus_vote.min_bw_vote)
> -			ufs_qcom_update_bus_bw_vote(host);
> -
> -	} else if (!on && (status == PRE_CHANGE)) {
> -		if (!ufs_qcom_is_link_active(hba)) {
> -			/* disable device ref_clk */
> -			ufs_qcom_dev_ref_clk_ctrl(host, false);
> +	switch(status) {
> +	case PRE_CHANGE:
> +		if (on) {
> +			err = ufs_qcom_set_bus_vote(hba, true);
> +		} else {
> +			if (!ufs_qcom_is_link_active(hba)) {
> +				/* disable device ref_clk */
> +				ufs_qcom_dev_ref_clk_ctrl(host, false);
> +			}
>  		}
> -
> -		vote = host->bus_vote.min_bw_vote;
> +		break;
> +	case POST_CHANGE:
> +		if (on) {
> +			/* enable the device ref clock for HS mode*/
> +			if (ufshcd_is_hs_mode(&hba->pwr_info))
> +				ufs_qcom_dev_ref_clk_ctrl(host, true);
> +		} else {
> +			err = ufs_qcom_set_bus_vote(hba, false);
> +		}
> +		break;
>  	}
> 
> -	err = ufs_qcom_set_bus_vote(host, vote);
> -	if (err)
> -		dev_err(hba->dev, "%s: set bus vote failed %d\n",
> -				__func__, err);
> -
>  	return err;
>  }
> 
> @@ -1238,6 +1265,7 @@ static int ufs_qcom_init(struct ufs_hba *hba)
>  	ufs_qcom_set_caps(hba);
>  	ufs_qcom_advertise_quirks(hba);
> 
> +	ufs_qcom_set_bus_vote(hba, true);
>  	ufs_qcom_setup_clocks(hba, true, POST_CHANGE);
> 
>  	if (hba->dev->id < MAX_UFS_QCOM_HOSTS)


   Please add space after switch.
+    switch(status) {
+    case PRE_CHANGE


Reviewed-by: Hongwu Su <hongwus@codeaurora.org>

  reply	other threads:[~2020-02-11  3:09 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1581388671-18078-1-git-send-email-cang@codeaurora.org>
2020-02-11  2:37 ` [PATCH v9 1/7] scsi: ufs: Flush exception event before suspend Can Guo
2020-02-11  2:37 ` [PATCH v9 2/7] scsi: ufs: set load before setting voltage in regulators Can Guo
2020-02-11  2:37 ` [PATCH v9 3/7] scsi: ufs-qcom: Adjust bus bandwidth voting and unvoting Can Guo
2020-02-11  3:09   ` hongwus [this message]
2020-02-11  3:13     ` Can Guo
2020-02-11  2:37 ` [PATCH v9 4/7] scsi: ufs: Remove the check before call setup clock notify vops Can Guo
2020-02-11  2:37 ` [PATCH v9 5/7] scsi: ufs: Fix ufshcd_hold() caused scheduling while atomic Can Guo
2020-02-11  2:37 ` [PATCH v9 6/7] scsi: ufs: Add dev ref clock gating wait time support Can Guo
2020-02-11  2:37 ` [PATCH v9 7/7] scsi: ufs-qcom: Delay specific time before gate ref clk 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=c0fdc3e7f3457544c987d296c3a26e35@codeaurora.org \
    --to=hongwus@codeaurora.org \
    --cc=agross@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=cang@codeaurora.org \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-team@android.com \
    --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=nguyenb@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=salyzyn@google.com \
    --cc=saravanak@google.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