Commit 1f34eedf authored by Stanley Chu's avatar Stanley Chu Committed by Martin K. Petersen

scsi: ufs: Add "index" in parameter list of ufshcd_query_flag()

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.comReviewed-by: default avatarBean Huo <beanhuo@micron.com>
Reviewed-by: default avatarAvri Altman <avri.altman@wdc.com>
Reviewed-by: default avatarCan Guo <cang@codeaurora.org>
Reviewed-by: default avatarAsutosh Das <asutoshd@codeaurora.org>
Signed-off-by: default avatarStanley Chu <stanley.chu@mediatek.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 62c2f503
...@@ -631,7 +631,7 @@ static ssize_t _name##_show(struct device *dev, \ ...@@ -631,7 +631,7 @@ static ssize_t _name##_show(struct device *dev, \
struct ufs_hba *hba = dev_get_drvdata(dev); \ struct ufs_hba *hba = dev_get_drvdata(dev); \
pm_runtime_get_sync(hba->dev); \ pm_runtime_get_sync(hba->dev); \
ret = ufshcd_query_flag(hba, UPIU_QUERY_OPCODE_READ_FLAG, \ 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); \ pm_runtime_put_sync(hba->dev); \
if (ret) \ if (ret) \
return -EINVAL; \ return -EINVAL; \
......
...@@ -2782,13 +2782,13 @@ static inline void ufshcd_init_query(struct ufs_hba *hba, ...@@ -2782,13 +2782,13 @@ static inline void ufshcd_init_query(struct ufs_hba *hba,
} }
static int ufshcd_query_flag_retry(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 ret;
int retries; int retries;
for (retries = 0; retries < QUERY_REQ_RETRIES; 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) if (ret)
dev_dbg(hba->dev, dev_dbg(hba->dev,
"%s: failed with error %d, retries %d\n", "%s: failed with error %d, retries %d\n",
...@@ -2809,16 +2809,17 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba, ...@@ -2809,16 +2809,17 @@ static int ufshcd_query_flag_retry(struct ufs_hba *hba,
* @hba: per-adapter instance * @hba: per-adapter instance
* @opcode: flag query to perform * @opcode: flag query to perform
* @idn: flag idn to access * @idn: flag idn to access
* @index: flag index to access
* @flag_res: the flag value after the query request completes * @flag_res: the flag value after the query request completes
* *
* Returns 0 for success, non-zero in case of failure * Returns 0 for success, non-zero in case of failure
*/ */
int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, 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_req *request = NULL;
struct ufs_query_res *response = NULL; struct ufs_query_res *response = NULL;
int err, index = 0, selector = 0; int err, selector = 0;
int timeout = QUERY_REQ_TIMEOUT; int timeout = QUERY_REQ_TIMEOUT;
BUG_ON(!hba); BUG_ON(!hba);
...@@ -4175,7 +4176,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) ...@@ -4175,7 +4176,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba)
bool flag_res = true; bool flag_res = true;
err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG,
QUERY_FLAG_IDN_FDEVICEINIT, NULL); QUERY_FLAG_IDN_FDEVICEINIT, 0, NULL);
if (err) { if (err) {
dev_err(hba->dev, dev_err(hba->dev,
"%s setting fDeviceInit flag failed with error %d\n", "%s setting fDeviceInit flag failed with error %d\n",
...@@ -4186,7 +4187,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba) ...@@ -4186,7 +4187,7 @@ static int ufshcd_complete_dev_init(struct ufs_hba *hba)
/* poll for max. 1000 iterations for fDeviceInit flag to clear */ /* poll for max. 1000 iterations for fDeviceInit flag to clear */
for (i = 0; i < 1000 && !err && flag_res; i++) for (i = 0; i < 1000 && !err && flag_res; i++)
err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG, 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) if (err)
dev_err(hba->dev, dev_err(hba->dev,
...@@ -5001,7 +5002,7 @@ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba) ...@@ -5001,7 +5002,7 @@ static int ufshcd_enable_auto_bkops(struct ufs_hba *hba)
goto out; goto out;
err = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, 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) { if (err) {
dev_err(hba->dev, "%s: failed to enable bkops %d\n", dev_err(hba->dev, "%s: failed to enable bkops %d\n",
__func__, err); __func__, err);
...@@ -5051,7 +5052,7 @@ static int ufshcd_disable_auto_bkops(struct ufs_hba *hba) ...@@ -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, 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) { if (err) {
dev_err(hba->dev, "%s: failed to disable bkops %d\n", dev_err(hba->dev, "%s: failed to disable bkops %d\n",
__func__, err); __func__, err);
...@@ -5217,7 +5218,7 @@ static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable) ...@@ -5217,7 +5218,7 @@ static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable)
opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG; opcode = UPIU_QUERY_OPCODE_CLEAR_FLAG;
ret = ufshcd_query_flag_retry(hba, opcode, ret = ufshcd_query_flag_retry(hba, opcode,
QUERY_FLAG_IDN_WB_EN, NULL); QUERY_FLAG_IDN_WB_EN, 0, NULL);
if (ret) { 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); __func__, enable ? "enable" : "disable", ret);
...@@ -5241,7 +5242,7 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set) ...@@ -5241,7 +5242,7 @@ static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set)
val = UPIU_QUERY_OPCODE_CLEAR_FLAG; val = UPIU_QUERY_OPCODE_CLEAR_FLAG;
return ufshcd_query_flag_retry(hba, val, 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); NULL);
} }
...@@ -5262,7 +5263,8 @@ static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba) ...@@ -5262,7 +5263,8 @@ static int ufshcd_wb_buf_flush_enable(struct ufs_hba *hba)
return 0; return 0;
ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_SET_FLAG, 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) if (ret)
dev_err(hba->dev, "%s WB - buf flush enable failed %d\n", dev_err(hba->dev, "%s WB - buf flush enable failed %d\n",
__func__, ret); __func__, ret);
...@@ -5281,7 +5283,7 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba) ...@@ -5281,7 +5283,7 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba)
return 0; return 0;
ret = ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_CLEAR_FLAG, 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) { if (ret) {
dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n", dev_warn(hba->dev, "%s: WB - buf flush disable failed %d\n",
__func__, ret); __func__, ret);
...@@ -7277,7 +7279,7 @@ static int ufshcd_device_params_init(struct ufs_hba *hba) ...@@ -7277,7 +7279,7 @@ static int ufshcd_device_params_init(struct ufs_hba *hba)
ufshcd_get_ref_clk_gating_wait(hba); ufshcd_get_ref_clk_gating_wait(hba);
if (!ufshcd_query_flag_retry(hba, UPIU_QUERY_OPCODE_READ_FLAG, 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; hba->dev_info.f_power_on_wp_en = flag;
/* Probe maximum power mode co-supported by both UFS host and device */ /* Probe maximum power mode co-supported by both UFS host and device */
......
...@@ -948,7 +948,7 @@ int ufshcd_read_desc_param(struct ufs_hba *hba, ...@@ -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, int ufshcd_query_attr(struct ufs_hba *hba, enum query_opcode opcode,
enum attr_idn idn, u8 index, u8 selector, u32 *attr_val); enum attr_idn idn, u8 index, u8 selector, u32 *attr_val);
int ufshcd_query_flag(struct ufs_hba *hba, enum query_opcode opcode, 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_enable(struct ufs_hba *hba);
void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit); void ufshcd_auto_hibern8_update(struct ufs_hba *hba, u32 ahit);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment