[PATCH 2/3] scsi: ufs: core: allow host driver to enable wb buffer resize function

From: Lu Hongfei
Date: Thu Sep 07 2023 - 11:26:40 EST


Since UFS4.1 will support the WB buffer resize function, the host could
choose to enable or disable it as needed.

Introduce a flag UFSHCD_CAP_WB_BUF_RESIZE to provide the host with the
ability to enable or disable WB buffer resize function.

UFSHCD_CAP_WB_BUF_RESIZE is only valid when UFSHCD_CAP_WB_EN is set.

Signed-off-by: Lu Hongfei <luhongfei@xxxxxxxx>
---
include/ufs/ufshcd.h | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index 7d07b256e906..7ea226b69e79 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -720,6 +720,13 @@ enum ufshcd_caps {
* WriteBooster when scaling the clock down.
*/
UFSHCD_CAP_WB_WITH_CLK_SCALING = 1 << 12,
+
+ /*
+ * This capability allows the host controller driver to
+ * resize (increase or decrease) WriteBooster Buffer,
+ * if the underlying device supports it and is provisioned to be used.
+ */
+ UFSHCD_CAP_WB_BUF_RESIZE = 1 << 13,
};

struct ufs_hba_variant_params {
@@ -1193,6 +1200,11 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
return hba->caps & UFSHCD_CAP_WB_EN;
}

+static inline bool ufshcd_is_wb_buf_resize_allowed(struct ufs_hba *hba)
+{
+ return hba->caps & UFSHCD_CAP_WB_BUF_RESIZE;
+}
+
static inline bool ufshcd_enable_wb_if_scaling_up(struct ufs_hba *hba)
{
return hba->caps & UFSHCD_CAP_WB_WITH_CLK_SCALING;
--
2.39.0