/* WriteBooster buffer is available only for the logical unit from 0 to 7 */
 #define UFS_UPIU_MAX_WB_LUN_ID 8
 
+/*
+ * WriteBooster buffer lifetime has a limit setted by vendor.
+ * If it is over the limit, WriteBooster feature will be disabled.
+ */
+#define UFS_WB_EXCEED_LIFETIME         0x0B
+
 /* Well known logical unit id in LUN field of UPIU */
 enum {
        UFS_UPIU_REPORT_LUNS_WLUN       = 0x81,
 
        return false;
 }
 
+static void ufshcd_wb_force_disable(struct ufs_hba *hba)
+{
+       if (!(hba->quirks & UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL))
+               ufshcd_wb_toggle_flush(hba, false);
+
+       ufshcd_wb_toggle_flush_during_h8(hba, false);
+       ufshcd_wb_toggle(hba, false);
+       hba->caps &= ~UFSHCD_CAP_WB_EN;
+
+       dev_info(hba->dev, "%s: WB force disabled\n", __func__);
+}
+
+static bool ufshcd_is_wb_buf_lifetime_available(struct ufs_hba *hba)
+{
+       u32 lifetime;
+       int ret;
+       u8 index;
+
+       index = ufshcd_wb_get_query_index(hba);
+       ret = ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+                                     QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST,
+                                     index, 0, &lifetime);
+       if (ret) {
+               dev_err(hba->dev,
+                       "%s: bWriteBoosterBufferLifeTimeEst read failed %d\n",
+                       __func__, ret);
+               return false;
+       }
+
+       if (lifetime == UFS_WB_EXCEED_LIFETIME) {
+               dev_err(hba->dev, "%s: WB buf lifetime is exhausted 0x%02X\n",
+                       __func__, lifetime);
+               return false;
+       }
+
+       dev_dbg(hba->dev, "%s: WB buf lifetime is 0x%02X\n",
+               __func__, lifetime);
+
+       return true;
+}
+
 static bool ufshcd_wb_need_flush(struct ufs_hba *hba)
 {
        int ret;
 
        if (!ufshcd_is_wb_allowed(hba))
                return false;
+
+       if (!ufshcd_is_wb_buf_lifetime_available(hba)) {
+               ufshcd_wb_force_disable(hba);
+               return false;
+       }
+
        /*
         * The ufs device needs the vcc to be ON to flush.
         * With user-space reduction enabled, it's enough to enable flush
 
        if (!ufshcd_is_wb_allowed(hba))
                return;
+
        /*
         * Probe WB only for UFS-2.2 and UFS-3.1 (and later) devices or
         * UFS devices with quirk UFS_DEVICE_QUIRK_SUPPORT_EXTENDED_FEATURES
                if (!d_lu_wb_buf_alloc)
                        goto wb_disabled;
        }
+
+       if (!ufshcd_is_wb_buf_lifetime_available(hba))
+               goto wb_disabled;
+
        return;
 
 wb_disabled: