All of lore.kernel.org
 help / color / mirror / Atom feed
From: Can Guo <cang@codeaurora.org>
To: daejun7.park@samsung.com
Cc: avri.altman@wdc.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, asutoshd@codeaurora.org,
	stanley.chu@mediatek.com, bvanassche@acm.org, huobean@gmail.com,
	linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	ALIM AKHTAR <alim.akhtar@samsung.com>,
	JinHwan Park <jh.i.park@samsung.com>,
	SEUNGUK SHIN <seunguk.shin@samsung.com>,
	Sung-Jun Park <sungjun07.park@samsung.com>,
	Jinyoung CHOI <j-young.choi@samsung.com>,
	BoRam Shin <boram.shin@samsung.com>
Subject: Re: [PATCH] scsi: ufs: Add selector to ufshcd_query_flag* APIs
Date: Thu, 18 Mar 2021 13:48:14 +0800	[thread overview]
Message-ID: <8e49758427cb7ca42df36a67ab4b9fd9@codeaurora.org> (raw)
In-Reply-To: <20210317033143epcms2p25b37bba2bb515c1ce85bf555656ca3f2@epcms2p2>

On 2021-03-17 11:31, Daejun Park wrote:
> Unlike other query APIs in UFS, ufshcd_query_flag has a fixed selector
> as 0. This patch allows ufshcd_query_flag API to choose selector value
> by parameter.
> 
> Signed-off-by: Daejun Park <daejun7.park@samsung.com>

Reviewed-by: Can Guo <cang@codeaurora.org>

> ---
>  drivers/scsi/ufs/ufs-sysfs.c |  2 +-
>  drivers/scsi/ufs/ufshcd.c    | 29 +++++++++++++++++------------
>  drivers/scsi/ufs/ufshcd.h    |  2 +-
>  3 files changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-sysfs.c 
> b/drivers/scsi/ufs/ufs-sysfs.c
> index acc54f530f2d..606b058a3394 100644
> --- a/drivers/scsi/ufs/ufs-sysfs.c
> +++ b/drivers/scsi/ufs/ufs-sysfs.c
> @@ -746,7 +746,7 @@ static ssize_t _name##_show(struct device 
> *dev,				\
>  		index = ufshcd_wb_get_query_index(hba);			\
>  	pm_runtime_get_sync(hba->dev);					\
>  	ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,	\
> -		QUERY_FLAG_IDN##_uname, index, &flag);			\
> +		QUERY_FLAG_IDN##_uname, index, &flag, 0);		\
>  	pm_runtime_put_sync(hba->dev);					\
>  	if (ret) {							\
>  		ret = -EINVAL;						\
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 8c0ff024231c..c2fd9c58d6b8 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -2940,13 +2940,15 @@ static inline void ufshcd_init_query(struct
> ufs_hba *hba,
>  }
> 
>  static int ufshcd_query_flag_retry(struct ufs_hba *hba,
> -	enum query_opcode opcode, enum flag_idn idn, u8 index, bool 
> *flag_res)
> +	enum query_opcode opcode, enum flag_idn idn, u8 index, bool 
> *flag_res,
> +	u8 selector)
>  {
>  	int ret;
>  	int retries;
> 
>  	for (retries = 0; retries < QUERY_REQ_RETRIES; retries++) {
> -		ret = ufshcd_query_flag(hba, opcode, idn, index, flag_res);
> +		ret = ufshcd_query_flag(hba, opcode, idn, index, flag_res,
> +					selector);
>  		if (ret)
>  			dev_dbg(hba->dev,
>  				"%s: failed with error %d, retries %d\n",
> @@ -2969,15 +2971,17 @@ static int ufshcd_query_flag_retry(struct 
> ufs_hba *hba,
>   * @idn: flag idn to access
>   * @index: flag index to access
>   * @flag_res: the flag value after the query request completes
> + * @selector: selector field
>   *
>   * Returns 0 for success, non-zero in case of failure
>   */
>  int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
> -			enum flag_idn idn, u8 index, bool *flag_res)
> +			enum flag_idn idn, u8 index, bool *flag_res,
> +			u8 selector)
>  {
>  	struct ufs_query_req *request = NULL;
>  	struct ufs_query_res *response = NULL;
> -	int err, selector = 0;
> +	int err;
>  	int timeout = QUERY_REQ_TIMEOUT;
> 
>  	BUG_ON(!hba);
> @@ -4331,7 +4335,7 @@ static int ufshcd_complete_dev_init(struct 
> ufs_hba *hba)
>  	ktime_t timeout;
> 
>  	err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
> -		QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL);
> +		QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL, 0);
>  	if (err) {
>  		dev_err(hba->dev,
>  			"%s setting fDeviceInit flag failed with error %d\n",
> @@ -4343,7 +4347,8 @@ static int ufshcd_complete_dev_init(struct 
> ufs_hba *hba)
>  	timeout = ktime_add_ms(ktime_get(), FDEVICEINIT_COMPL_TIMEOUT);
>  	do {
>  		err = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,
> -					QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res);
> +					QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res,
> +					0);
>  		if (!flag_res)
>  			break;
>  		usleep_range(5000, 10000);
> @@ -5250,7 +5255,7 @@ static int ufshcd_enable_auto_bkops(struct 
> ufs_hba *hba)
>  		goto out;
> 
>  	err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
> -			QUERY_FLAG_IDN_BKOPS_EN, 0, NULL);
> +			QUERY_FLAG_IDN_BKOPS_EN, 0, NULL, 0);
>  	if (err) {
>  		dev_err(hba->dev, "%s: failed to enable bkops %d\n",
>  				__func__, err);
> @@ -5300,7 +5305,7 @@ static int ufshcd_disable_auto_bkops(struct 
> ufs_hba *hba)
>  	}
> 
>  	err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG,
> -			QUERY_FLAG_IDN_BKOPS_EN, 0, NULL);
> +			QUERY_FLAG_IDN_BKOPS_EN, 0, NULL, 0);
>  	if (err) {
>  		dev_err(hba->dev, "%s: failed to disable bkops %d\n",
>  				__func__, err);
> @@ -5463,7 +5468,7 @@ int ufshcd_wb_ctrl(struct ufs_hba *hba, bool 
> enable)
> 
>  	index = ufshcd_wb_get_query_index(hba);
>  	ret = ufshcd_query_flag_retry(hba, opcode,
> -				      QUERY_FLAG_IDN_WB_EN, index, NULL);
> +				      QUERY_FLAG_IDN_WB_EN, index, NULL, 0);
>  	if (ret) {
>  		dev_err(hba->dev, "%s write booster %s failed %d\n",
>  			__func__, enable ? "enable" : "disable", ret);
> @@ -5490,7 +5495,7 @@ static int
> ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
>  	index = ufshcd_wb_get_query_index(hba);
>  	return ufshcd_query_flag_retry(hba, val,
>  				QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8,
> -				index, NULL);
> +				index, NULL, 0);
>  }
> 
>  static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool 
> enable)
> @@ -5511,7 +5516,7 @@ static inline int ufshcd_wb_toggle_flush(struct
> ufs_hba *hba, bool enable)
>  	index = ufshcd_wb_get_query_index(hba);
>  	ret = ufshcd_query_flag_retry(hba, opcode,
>  				      QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index,
> -				      NULL);
> +				      NULL, 0);
>  	if (ret) {
>  		dev_err(hba->dev, "%s WB-Buf Flush %s failed %d\n", __func__,
>  			enable ? "enable" : "disable", ret);
> @@ -7751,7 +7756,7 @@ static int ufshcd_device_params_init(struct 
> ufs_hba *hba)
>  	ufshcd_get_ref_clk_gating_wait(hba);
> 
>  	if (!ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG,
> -			QUERY_FLAG_IDN_PWR_ON_WPE, 0, &flag))
> +			QUERY_FLAG_IDN_PWR_ON_WPE, 0, &flag, 0))
>  		hba->dev_info.f_power_on_wp_en = flag;
> 
>  	/* Probe maximum power mode co-supported by both UFS host and device 
> */
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 1af91661dc83..67a26b2be36f 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -1077,7 +1077,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba,
>  int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
>  		      enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
>  int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode,
> -	enum flag_idn idn, u8 index, bool *flag_res);
> +	enum flag_idn idn, u8 index, bool *flag_res, u8 selector);
> 
>  void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
>  void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);

  reply	other threads:[~2021-03-18  5:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20210317033143epcms2p25b37bba2bb515c1ce85bf555656ca3f2@epcms2p2>
2021-03-17  3:31 ` [PATCH] scsi: ufs: Add selector to ufshcd_query_flag* APIs Daejun Park
2021-03-18  5:48   ` Can Guo [this message]
2021-03-19  2:25   ` Martin K. Petersen
2021-03-19  2:51     ` Daejun Park

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=8e49758427cb7ca42df36a67ab4b9fd9@codeaurora.org \
    --to=cang@codeaurora.org \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=boram.shin@samsung.com \
    --cc=bvanassche@acm.org \
    --cc=daejun7.park@samsung.com \
    --cc=huobean@gmail.com \
    --cc=j-young.choi@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=jh.i.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=seunguk.shin@samsung.com \
    --cc=stanley.chu@mediatek.com \
    --cc=sungjun07.park@samsung.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 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.