public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: ufs: Optimize the WB flush process to save device power consumption
@ 2023-06-28  7:02 Lu Hongfei
  2023-06-28 11:00 ` Avri Altman
  0 siblings, 1 reply; 3+ messages in thread
From: Lu Hongfei @ 2023-06-28  7:02 UTC (permalink / raw)
  To: Alim Akhtar, Avri Altman, Bart Van Assche, James E.J. Bottomley,
	Martin K. Petersen, Stanley Chu, Bean Huo, Asutosh Das,
	Bao D. Nguyen, Keoseong Park, Arthur Simchaev, linux-scsi,
	linux-kernel
  Cc: opensource.kernel, luhongfei, Tang Huan

In the original logic, WB Hibern Flush was always on.
During suspend flow, the host will determine whether the device needs
BKOP or WB flush, and if so, it will keep VCC supply.
WB flush is only a part of BKOP, and device that needs BKOP do not
necessarily need WB flush if the conditions are not met. Therefore,
if WB flush is not needed, it will be better to disable WB Hibern
Flush, which could save device power consumption. When WB Hibern
Flush is needed, enable it again.

In this way, the WB Hibern Flush always on strategy is changed to a dynamic
on/off strategy.

Signed-off-by: Lu Hongfei <luhongfei@vivo.com>
Signed-off-by: Tang Huan <tanghuan@vivo.com>
---
 drivers/ufs/core/ufshcd.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 983fae84d9e8..484d7fa96407 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -9592,13 +9592,20 @@ static int __ufshcd_wl_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 		 * If device needs to do BKOP or WB buffer flush during
 		 * Hibern8, keep device power mode as "active power mode"
 		 * and VCC supply.
+		 * If device does not need WB buffer flush now, it's better
+		 * to disable WB flush during H8 to save power consumption.
 		 */
-		hba->dev_info.b_rpm_dev_flush_capable =
-			hba->auto_bkops_enabled ||
-			(((req_link_state == UIC_LINK_HIBERN8_STATE) ||
-			((req_link_state == UIC_LINK_ACTIVE_STATE) &&
-			ufshcd_is_auto_hibern8_enabled(hba))) &&
-			ufshcd_wb_need_flush(hba));
+		hba->dev_info.b_rpm_dev_flush_capable = hba->auto_bkops_enabled;
+		if (((req_link_state == UIC_LINK_HIBERN8_STATE) ||
+		    ((req_link_state == UIC_LINK_ACTIVE_STATE) &&
+		    ufshcd_is_auto_hibern8_enabled(hba))) &&
+		    ufshcd_wb_need_flush(hba)) {
+			ufshcd_wb_toggle_buf_flush_during_h8(hba, true);
+			hba->dev_info.b_rpm_dev_flush_capable = true;
+		} else {
+			ufshcd_wb_toggle_buf_flush_during_h8(hba, false);
+		}
+
 	}
 
 	flush_work(&hba->eeh_work);
-- 
2.39.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-29  3:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-28  7:02 [PATCH] scsi: ufs: Optimize the WB flush process to save device power consumption Lu Hongfei
2023-06-28 11:00 ` Avri Altman
2023-06-29  3:11   ` Jinyoung CHOI

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox