mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Avri Altman <Avri.Altman@wdc.com>
To: Yue Hu <zbestahu@gmail.com>,
	"alim.akhtar@samsung.com" <alim.akhtar@samsung.com>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>,
	"jejb@linux.ibm.com" <jejb@linux.ibm.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"huyue2@yulong.com" <huyue2@yulong.com>,
	"zbestahu@163.com" <zbestahu@163.com>
Subject: RE: [PATCH v2] scsi: ufs: Tidy up WB configuration code
Date: Thu, 18 Mar 2021 08:10:57 +0000	[thread overview]
Message-ID: <DM6PR04MB65756A57F0620AB2C107B349FC699@DM6PR04MB6575.namprd04.prod.outlook.com> (raw)
In-Reply-To: <20210318014544.1976-1-zbestahu@gmail.com>


> 
> -int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable)
> +static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn
> idn)
>  {
> -       int ret;
>         u8 index;
>         enum query_opcode opcode;
What I meant is:
	enum query_opcode opcode = set ? UPIU_QUERY_OPCODE_SET_FLAG : 
					       UPIU_QUERY_OPCODE_CLEAR_FLAG;

Either way, you can add my Reviewed-by tag.

Thanks,
Avri

> 
> +       if (set)
> +               opcode = UPIU_QUERY_OPCODE_SET_FLAG;
> +       else
> +               opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
> +
> +       index = ufshcd_wb_get_query_index(hba);
> +       return ufshcd_query_flag_retry(hba, opcode, idn, index, NULL);
> +}
> +
> +int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable)
> +{
> +       int ret;
> +
>         if (!ufshcd_is_wb_allowed(hba))
>                 return 0;
> 
>         if (!(enable ^ hba->dev_info.wb_enabled))
>                 return 0;
> -       if (enable)
> -               opcode = UPIU_QUERY_OPCODE_SET_FLAG;
> -       else
> -               opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
> 
> -       index = ufshcd_wb_get_query_index(hba);
> -       ret = ufshcd_query_flag_retry(hba, opcode,
> -                                     QUERY_FLAG_IDN_WB_EN, index, NULL);
> +       ret = __ufshcd_wb_toggle(hba, enable, QUERY_FLAG_IDN_WB_EN);
>         if (ret) {
> -               dev_err(hba->dev, "%s write booster %s failed %d\n",
> +               dev_err(hba->dev, "%s Write Booster %s failed %d\n",
>                         __func__, enable ? "enable" : "disable", ret);
>                 return ret;
>         }
> 
>         hba->dev_info.wb_enabled = enable;
> -       dev_dbg(hba->dev, "%s write booster %s %d\n",
> -                       __func__, enable ? "enable" : "disable", ret);
> +       dev_info(hba->dev, "%s Write Booster %s\n",
> +                       __func__, enable ? "enabled" : "disabled");
> 
>         return ret;
>  }
> 
> -static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
> +static void ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
>  {
> -       int val;
> -       u8 index;
> -
> -       if (set)
> -               val =  UPIU_QUERY_OPCODE_SET_FLAG;
> -       else
> -               val = UPIU_QUERY_OPCODE_CLEAR_FLAG;
> +       int ret;
> 
> -       index = ufshcd_wb_get_query_index(hba);
> -       return ufshcd_query_flag_retry(hba, val,
> -                               QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8,
> -                               index, NULL);
> +       ret = __ufshcd_wb_toggle(hba, set,
> +                       QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8);
> +       if (ret) {
> +               dev_err(hba->dev, "%s: WB-Buf Flush during H8 %s failed: %d\n",
> +                       __func__, set ? "enable" : "disable", ret);
> +               return;
> +       }
> +       dev_dbg(hba->dev, "%s WB-Buf Flush during H8 %s\n",
> +                       __func__, set ? "enabled" : "disabled");
>  }
> 
> -static inline int ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
> +static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable)
>  {
>         int ret;
> -       u8 index;
> -       enum query_opcode opcode;
> 
>         if (!ufshcd_is_wb_allowed(hba) ||
>             hba->dev_info.wb_buf_flush_enabled == enable)
> -               return 0;
> -
> -       if (enable)
> -               opcode = UPIU_QUERY_OPCODE_SET_FLAG;
> -       else
> -               opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
> +               return;
> 
> -       index = ufshcd_wb_get_query_index(hba);
> -       ret = ufshcd_query_flag_retry(hba, opcode,
> -                                     QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, index,
> -                                     NULL);
> +       ret = __ufshcd_wb_toggle(hba, enable,
> QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN);
>         if (ret) {
>                 dev_err(hba->dev, "%s WB-Buf Flush %s failed %d\n", __func__,
>                         enable ? "enable" : "disable", ret);
> -               goto out;
> +               return;
>         }
> 
>         hba->dev_info.wb_buf_flush_enabled = enable;
> 
> -       dev_dbg(hba->dev, "WB-Buf Flush %s\n", enable ? "enabled" : "disabled");
> -out:
> -       return ret;
> -
> +       dev_dbg(hba->dev, "%s WB-Buf Flush %s\n",
> +                       __func__, enable ? "enabled" : "disabled");
>  }
> 
>  static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
> diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
> index 18e56c1..eddc819 100644
> --- a/drivers/scsi/ufs/ufshcd.h
> +++ b/drivers/scsi/ufs/ufshcd.h
> @@ -1099,7 +1099,7 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba
> *hba,
>                              u8 *desc_buff, int *buff_len,
>                              enum query_opcode desc_op);
> 
> -int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable);
> +int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable);
> 
>  /* Wrapper functions for safely calling variant operations */
>  static inline const char *ufshcd_get_var_name(struct ufs_hba *hba)
> --
> 1.9.1


      reply	other threads:[~2021-03-18  8:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-18  1:45 Yue Hu
2021-03-18  8:10 ` Avri Altman [this message]

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=DM6PR04MB65756A57F0620AB2C107B349FC699@DM6PR04MB6575.namprd04.prod.outlook.com \
    --to=avri.altman@wdc.com \
    --cc=alim.akhtar@samsung.com \
    --cc=huyue2@yulong.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=zbestahu@163.com \
    --cc=zbestahu@gmail.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

all inboxes | Powered by JetHome®