scsi: ufs: Add "index" in parameter list of ufshcd_query_flag()
authorStanley Chu <stanley.chu@mediatek.com>
Fri, 8 May 2020 08:01:12 +0000 (16:01 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 12 May 2020 02:48:44 +0000 (22:48 -0400)
For preparation of LU Dedicated buffer mode support on WriteBooster
feature, "index" parameter shall be added and allowed to be specified by
callers.

Link: https://lore.kernel.org/r/20200508080115.24233-6-stanley.chu@mediatek.com
Reviewed-by: Bean Huo <beanhuo@micron.com>
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Can Guo <cang@codeaurora.org>
Reviewed-by: Asutosh Das <asutoshd@codeaurora.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/ufs/ufs-sysfs.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/ufs/ufshcd.h

index 9348440..b86b6a4 100644 (file)
@@ -631,7 +631,7 @@ static ssize_t _name##_show(struct device *dev,                             \
        struct ufs_hba *hba = dev_get_drvdata(dev);                     \
        pm_runtime_get_sync(hba->dev);                                  \
        ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG,       \
-               QUERY_FLAG_IDN##_uname, &flag);                         \
+               QUERY_FLAG_IDN##_uname, 0, &flag);                      \
        pm_runtime_put_sync(hba->dev);                                  \
        if (ret)                                                        \
                return -EINVAL;                                         \
index c0b2cec..4053d24 100644 (file)
@@ -2782,13 +2782,13 @@ 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, bool *flag_res)
+       enum query_opcode opcode, enum flag_idn idn, u8 index, bool *flag_res)
 {
        int ret;
        int retries;
 
        for (retries = 0; retries < QUERY_REQ_RETRIES; retries++) {
-               ret = ufshcd_query_flag(hba, opcode, idn, flag_res);
+               ret = ufshcd_query_flag(hba, opcode, idn, index, flag_res);
                if (ret)
                        dev_dbg(hba->dev,
                                "%s: failed with error %d, retries %d\n",
@@ -2809,16 +2809,17 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
  * @hba: per-adapter instance
  * @opcode: flag query to perform
  * @idn: flag idn to access
+ * @index: flag index to access
  * @flag_res: the flag value after the query request completes
  *
  * 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, bool *flag_res)
+                       enum flag_idn idn, u8 index, bool *flag_res)
 {
        struct ufs_query_req *request = NULL;
        struct ufs_query_res *response = NULL;
-       int err, index = 0, selector = 0;
+       int err, selector = 0;
        int timeout = QUERY_REQ_TIMEOUT;
 
        BUG_ON(!hba);
@@ -4175,7 +4176,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba)
        bool flag_res = true;
 
        err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
-               QUERY_FLAG_IDN_FDEVICEINIT, NULL);
+               QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL);
        if (err) {
                dev_err(hba->dev,
                        "%s setting fDeviceInit flag failed with error %d\n",
@@ -4186,7 +4187,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba)
        /* poll for max. 1000 iterations for fDeviceInit flag to clear */
        for (i = 0; i < 1000 && !err && flag_res; i++)
                err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG,
-                       QUERY_FLAG_IDN_FDEVICEINIT, &flag_res);
+                       QUERY_FLAG_IDN_FDEVICEINIT, 0, &flag_res);
 
        if (err)
                dev_err(hba->dev,
@@ -5001,7 +5002,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, NULL);
+                       QUERY_FLAG_IDN_BKOPS_EN, 0, NULL);
        if (err) {
                dev_err(hba->dev, "%s: failed to enable bkops %d\n",
                                __func__, err);
@@ -5051,7 +5052,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, NULL);
+                       QUERY_FLAG_IDN_BKOPS_EN, 0, NULL);
        if (err) {
                dev_err(hba->dev, "%s: failed to disable bkops %d\n",
                                __func__, err);
@@ -5217,7 +5218,7 @@ static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable)
                opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
 
        ret = ufshcd_query_flag_retry(hba, opcode,
-                                     QUERY_FLAG_IDN_WB_EN, NULL);
+                                     QUERY_FLAG_IDN_WB_EN, 0, NULL);
        if (ret) {
                dev_err(hba->dev, "%s write booster %s failed %d\n",
                        __func__, enable ? "enable" : "disable", ret);
@@ -5241,7 +5242,7 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
                val = UPIU_QUERY_OPCODE_CLEAR_FLAG;
 
        return ufshcd_query_flag_retry(hba, val,
-                              QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8,
+                              QUERY_FLAG_IDN_WB_BUFF_FLUSH_DURING_HIBERN8, 0,
                                       NULL);
 }
 
@@ -5262,7 +5263,8 @@ static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba)
                return 0;
 
        ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
-                                     QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, NULL);
+                                     QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN,
+                                     0, NULL);
        if (ret)
                dev_err(hba->dev, "%s WB - buf flush enable failed %d\n",
                        __func__, ret);
@@ -5281,7 +5283,7 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba)
                return 0;
 
        ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG,
-                                     QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, NULL);
+                                     QUERY_FLAG_IDN_WB_BUFF_FLUSH_EN, 0, NULL);
        if (ret) {
                dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n",
                         __func__, ret);
@@ -7277,7 +7279,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, &flag))
+                       QUERY_FLAG_IDN_PWR_ON_WPE, 0, &flag))
                hba->dev_info.f_power_on_wp_en = flag;
 
        /* Probe maximum power mode co-supported by both UFS host and device */
index 4d296ac..8262a48 100644 (file)
@@ -948,7 +948,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, bool *flag_res);
+       enum flag_idn idn, u8 index, bool *flag_res);
 
 void ufshcd_auto_hibern8_enable(struct ufs_hba *hba);
 void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);