scsi: ufs: wb: Introduce ufshcd_is_wb_buf_flush_allowed()

The explicit flushing should check the following:

 - UFSHCD_CAP_WB_EN

 - UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL

Add helper to improve readability.

Link: https://lore.kernel.org/r/20220804075444epcms2p4a0520880262281f02be65ce0fe50602d@epcms2p4
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Acked-by: Bean Huo <beanhuo@micron.com>
Signed-off-by: Jinyoung Choi <j-young.choi@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Jinyoung Choi 2022-08-04 16:54:44 +09:00 коммит произвёл Martin K. Petersen
Родитель 6c4148ce7c
Коммит 42f8c5cdb0
3 изменённых файлов: 10 добавлений и 4 удалений

Просмотреть файл

@ -272,8 +272,7 @@ static ssize_t enable_wb_buf_flush_store(struct device *dev,
unsigned int enable_wb_buf_flush;
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 flushing!\n");
return -EOPNOTSUPP;
}

Просмотреть файл

@ -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);

Просмотреть файл

@ -295,7 +295,8 @@ static void ufshcd_configure_wb(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);
}
@ -5843,7 +5844,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);