2022-07-29 05:25:23

by Jinyoung Choi

[permalink] [raw]
Subject: [PATCH v5 4/6] scsi: ufs: wb: Add ufshcd_is_wb_buf_flush_allowed()

The explicit flushing should check the following.
- UFSHCD_CAP_WB_EN
- UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL

Changed to improve readability.

Acked-by: Bean Huo <[email protected]>
Reviewed-by: Avri Altman <[email protected]>
Signed-off-by: Jinyoung Choi <[email protected]>
---
drivers/ufs/core/ufs-sysfs.c | 3 +--
drivers/ufs/core/ufshcd-priv.h | 6 ++++++
drivers/ufs/core/ufshcd.c | 5 +++--
3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 920094665f4d..63b02b2541c8 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -271,8 +271,7 @@ static ssize_t wb_buf_flush_en_store(struct device *dev,
unsigned int wb_buf_flush_en;
ssize_t res;

- if (!ufshcd_is_wb_allowed(hba) ||
- (hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL)) {
+ if (!ufshcd_is_wb_buf_flush_allowed(hba)) {
dev_warn(dev, "It is not allowed to configure WB buf flush!\n");
return -EOPNOTSUPP;
}
diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
index 8f67db202d7b..d00dba17297d 100644
--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -26,6 +26,12 @@ static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba)
return 0;
}

+static inline bool ufshcd_is_wb_buf_flush_allowed(struct ufs_hba *hba)
+{
+ return ufshcd_is_wb_allowed(hba) &&
+ !(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL);
+}
+
#ifdef CONFIG_SCSI_UFS_HWMON
void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
void ufs_hwmon_remove(struct ufs_hba *hba);
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 36d4708eaee0..584e246c769a 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -294,7 +294,8 @@ static void ufshcd_wb_set_default_flags(struct ufs_hba *hba)
ufshcd_wb_toggle(hba, true);

ufshcd_wb_toggle_buf_flush_during_h8(hba, true);
- if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL))
+
+ if (ufshcd_is_wb_buf_flush_allowed(hba))
ufshcd_wb_toggle_buf_flush(hba, true);
}

@@ -5815,7 +5816,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,

static void ufshcd_wb_force_disable(struct ufs_hba *hba)
{
- if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL))
+ if (ufshcd_is_wb_buf_flush_allowed(hba))
ufshcd_wb_toggle_buf_flush(hba, false);

ufshcd_wb_toggle_buf_flush_during_h8(hba, false);
--
2.25.1


2022-07-29 05:25:37

by Jinyoung Choi

[permalink] [raw]
Subject: [PATCH v5 5/6] scsi: ufs: wb: Modify messages

Messages are modified to fit the format of others.

Reviewed-by: Avri Altman <[email protected]>
Signed-off-by: Jinyoung Choi <[email protected]>
---
drivers/ufs/core/ufs-sysfs.c | 2 +-
drivers/ufs/core/ufshcd.c | 15 +++++++--------
2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index 63b02b2541c8..35e4f0056de6 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -230,7 +230,7 @@ static ssize_t wb_on_store(struct device *dev, struct device_attribute *attr,
* If the platform supports UFSHCD_CAP_CLK_SCALING, turn WB
* on/off will be done while clock scaling up/down.
*/
- dev_warn(dev, "To control WB through wb_on is not allowed!\n");
+ dev_warn(dev, "It is not allowed to configure WB!\n");
return -EOPNOTSUPP;
}

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 584e246c769a..309f93122078 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -5737,13 +5737,13 @@ int ufshcd_wb_toggle(struct ufs_hba *hba, bool enable)

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_info(hba->dev, "%s Write Booster %s\n",
+ dev_info(hba->dev, "%s: Write Booster %s\n",
__func__, enable ? "enabled" : "disabled");

return ret;
@@ -5761,7 +5761,7 @@ static void ufshcd_wb_toggle_buf_flush_during_h8(struct ufs_hba *hba,
__func__, enable ? "enable" : "disable", ret);
return;
}
- dev_dbg(hba->dev, "%s WB-Buf Flush during H8 %s\n",
+ dev_info(hba->dev, "%s: WB-Buf Flush during H8 %s\n",
__func__, enable ? "enabled" : "disabled");
}

@@ -5775,14 +5775,13 @@ int ufshcd_wb_toggle_buf_flush(struct ufs_hba *hba, bool enable)

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__,
+ dev_err(hba->dev, "%s: WB-Buf Flush %s failed %d\n", __func__,
enable ? "enable" : "disable", ret);
return ret;
}

hba->dev_info.wb_buf_flush_enabled = enable;
-
- dev_dbg(hba->dev, "%s WB-Buf Flush %s\n",
+ dev_info(hba->dev, "%s: WB-Buf Flush %s\n",
__func__, enable ? "enabled" : "disabled");

return ret;
@@ -5800,7 +5799,7 @@ static bool ufshcd_wb_presrv_usrspc_keep_vcc_on(struct ufs_hba *hba,
QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE,
index, 0, &cur_buf);
if (ret) {
- dev_err(hba->dev, "%s dCurWriteBoosterBufferSize read failed %d\n",
+ dev_err(hba->dev, "%s: dCurWriteBoosterBufferSize read failed %d\n",
__func__, ret);
return false;
}
@@ -5885,7 +5884,7 @@ static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
QUERY_ATTR_IDN_AVAIL_WB_BUFF_SIZE,
index, 0, &avail_buf);
if (ret) {
- dev_warn(hba->dev, "%s dAvailableWriteBoosterBufferSize read failed %d\n",
+ dev_warn(hba->dev, "%s: dAvailableWriteBoosterBufferSize read failed %d\n",
__func__, ret);
return false;
}
--
2.25.1

2022-07-29 05:51:59

by Jinyoung Choi

[permalink] [raw]
Subject: [PATCH v5 6/6] scsi: ufs: wb: Move the comment to the right position

The location of the comment is wrong. so fix it.

Reviewed-by: Avri Altman <[email protected]>
Signed-off-by: Jinyoung Choi <[email protected]>
---
drivers/ufs/core/ufshcd.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 309f93122078..4120617ff7a6 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -1298,9 +1298,10 @@ static int ufshcd_devfreq_scale(struct ufs_hba *hba, bool scale_up)
}
}

- /* Enable Write Booster if we have scaled up else disable it */
downgrade_write(&hba->clk_scaling_lock);
is_writelock = false;
+
+ /* Enable Write Booster if we have scaled up else disable it */
ufshcd_wb_toggle(hba, scale_up);

out_unprepare:
--
2.25.1

2022-07-29 20:43:55

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v5 6/6] scsi: ufs: wb: Move the comment to the right position

On 7/28/22 21:59, Jinyoung CHOI wrote:
> The location of the comment is wrong. so fix it.

Reviewed-by: Bart Van Assche <[email protected]>

2022-07-29 20:46:51

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v5 4/6] scsi: ufs: wb: Add ufshcd_is_wb_buf_flush_allowed()

On 7/28/22 21:56, Jinyoung CHOI wrote:
> The explicit flushing should check the following.
> - UFSHCD_CAP_WB_EN
> - UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL
>
> Changed to improve readability.

Reviewed-by: Bart Van Assche <[email protected]>

2022-07-29 21:21:37

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v5 5/6] scsi: ufs: wb: Modify messages

On 7/28/22 21:57, Jinyoung CHOI wrote:
> 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;
> }

Please also fix the grammar (enable -> enabling; disable -> disabling).

Otherwise this patch looks good to me.

Thanks,

Bart.

2022-08-01 06:02:42

by Jinyoung Choi

[permalink] [raw]
Subject: RE:(2) [PATCH v5 5/6] scsi: ufs: wb: Modify messages

>On 7/28/22 21:57, Jinyoung CHOI wrote:
>> 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;
>> }
>
>Please also fix the grammar (enable -> enabling; disable -> disabling).
>
>Otherwise this patch looks good to me.
>
>Thanks,
>
>Bart.

OK, I will fix it.

Thanks,
Jinyoung.