linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating
@ 2020-10-27 19:10 Asutosh Das
  2020-10-27 19:10 ` [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba Asutosh Das
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Asutosh Das @ 2020-10-27 19:10 UTC (permalink / raw)
  To: cang, martin.petersen, linux-scsi
  Cc: linux-arm-msm, Asutosh Das, Alim Akhtar, Avri Altman,
	James E.J. Bottomley, Matthias Brugger, Stanley Chu, Bean Huo,
	Bart Van Assche, Satya Tangirala, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support

From: Can Guo <cang@codeaurora.org>

During clock gating, after clocks are disabled,
put hba into LPM to save more power.

Acked-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
---
 drivers/scsi/ufs/ufshcd.c |  9 +++++++--
 drivers/scsi/ufs/ufshcd.h | 13 +++++++++++++
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 47c544d..9fc1bac 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -245,6 +245,8 @@ static int ufshcd_wb_buf_flush_disable(struct ufs_hba *hba);
 static int ufshcd_wb_ctrl(struct ufs_hba *hba, bool enable);
 static int ufshcd_wb_toggle_flush_during_h8(struct ufs_hba *hba, bool set);
 static inline void ufshcd_wb_toggle_flush(struct ufs_hba *hba, bool enable);
+static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba);
+static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba);
 
 static inline bool ufshcd_valid_tag(struct ufs_hba *hba, int tag)
 {
@@ -1548,6 +1550,7 @@ static void ufshcd_ungate_work(struct work_struct *work)
 	}
 
 	spin_unlock_irqrestore(hba->host->host_lock, flags);
+	ufshcd_hba_vreg_set_hpm(hba);
 	ufshcd_setup_clocks(hba, true);
 
 	ufshcd_enable_irq(hba);
@@ -1713,6 +1716,8 @@ static void ufshcd_gate_work(struct work_struct *work)
 		/* If link is active, device ref_clk can't be switched off */
 		__ufshcd_setup_clocks(hba, false, true);
 
+	/* Put the host controller in low power mode if possible */
+	ufshcd_hba_vreg_set_lpm(hba);
 	/*
 	 * In case you are here to cancel this work the gating state
 	 * would be marked as REQ_CLKS_ON. In this case keep the state
@@ -8405,13 +8410,13 @@ static int ufshcd_vreg_set_hpm(struct ufs_hba *hba)
 
 static void ufshcd_hba_vreg_set_lpm(struct ufs_hba *hba)
 {
-	if (ufshcd_is_link_off(hba))
+	if (ufshcd_is_link_off(hba) || ufshcd_can_aggressive_pc(hba))
 		ufshcd_setup_hba_vreg(hba, false);
 }
 
 static void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba)
 {
-	if (ufshcd_is_link_off(hba))
+	if (ufshcd_is_link_off(hba) || ufshcd_can_aggressive_pc(hba))
 		ufshcd_setup_hba_vreg(hba, true);
 }
 
diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index 47eb143..0fbb735 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -592,6 +592,13 @@ enum ufshcd_caps {
 	 * inline crypto engine, if it is present
 	 */
 	UFSHCD_CAP_CRYPTO				= 1 << 8,
+
+	/*
+	 * This capability allows the controller regulators to be put into
+	 * lpm mode aggressively during clock gating.
+	 * This would increase power savings.
+	 */
+	UFSHCD_CAP_AGGR_POWER_COLLAPSE			= 1 << 9,
 };
 
 struct ufs_hba_variant_params {
@@ -829,6 +836,12 @@ return true;
 #endif
 }
 
+static inline bool ufshcd_can_aggressive_pc(struct ufs_hba *hba)
+{
+	return !!(ufshcd_is_link_hibern8(hba) &&
+		  (hba->caps & UFSHCD_CAP_AGGR_POWER_COLLAPSE));
+}
+
 static inline bool ufshcd_is_auto_hibern8_supported(struct ufs_hba *hba)
 {
 	return (hba->capabilities & MASK_AUTO_HIBERN8_SUPPORT) &&
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

* [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba
  2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
@ 2020-10-27 19:10 ` Asutosh Das
  2020-10-28  6:18   ` Avri Altman
  2020-10-28  6:17 ` [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Avri Altman
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Asutosh Das @ 2020-10-27 19:10 UTC (permalink / raw)
  To: cang, martin.petersen, linux-scsi
  Cc: Asutosh Das, linux-arm-msm, Andy Gross, Bjorn Andersson,
	Alim Akhtar, Avri Altman, James E.J. Bottomley, open list

Enabling this capability to let hba power-collapse
more often to save power.

Reviewed-by: Can Guo <cang@codeaurora.org>
Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
---
 drivers/scsi/ufs/ufs-qcom.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/ufs/ufs-qcom.c b/drivers/scsi/ufs/ufs-qcom.c
index f9d6ef3..9a19c6d 100644
--- a/drivers/scsi/ufs/ufs-qcom.c
+++ b/drivers/scsi/ufs/ufs-qcom.c
@@ -863,6 +863,7 @@ static void ufs_qcom_set_caps(struct ufs_hba *hba)
 	hba->caps |= UFSHCD_CAP_AUTO_BKOPS_SUSPEND;
 	hba->caps |= UFSHCD_CAP_WB_EN;
 	hba->caps |= UFSHCD_CAP_CRYPTO;
+	hba->caps |= UFSHCD_CAP_AGGR_POWER_COLLAPSE;
 
 	if (host->hw_ver.major >= 0x2) {
 		host->caps = UFS_QCOM_CAP_QUNIPRO |
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


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

* RE: [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating
  2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
  2020-10-27 19:10 ` [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba Asutosh Das
@ 2020-10-28  6:17 ` Avri Altman
  2020-10-30  1:57 ` Martin K. Petersen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Avri Altman @ 2020-10-28  6:17 UTC (permalink / raw)
  To: Asutosh Das, cang, martin.petersen, linux-scsi
  Cc: linux-arm-msm, Alim Akhtar, James E.J. Bottomley,
	Matthias Brugger, Stanley Chu, Bean Huo, Bart Van Assche,
	Satya Tangirala, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support



> 
> 
> From: Can Guo <cang@codeaurora.org>
> 
> During clock gating, after clocks are disabled,
> put hba into LPM to save more power.
> 
> Acked-by: Stanley Chu <stanley.chu@mediatek.com>
> Signed-off-by: Can Guo <cang@codeaurora.org>
> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

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

* RE: [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba
  2020-10-27 19:10 ` [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba Asutosh Das
@ 2020-10-28  6:18   ` Avri Altman
  0 siblings, 0 replies; 7+ messages in thread
From: Avri Altman @ 2020-10-28  6:18 UTC (permalink / raw)
  To: Asutosh Das, cang, martin.petersen, linux-scsi
  Cc: linux-arm-msm, Andy Gross, Bjorn Andersson, Alim Akhtar,
	James E.J. Bottomley, open list

> 
> Enabling this capability to let hba power-collapse
> more often to save power.
> 
> Reviewed-by: Can Guo <cang@codeaurora.org>
> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
Reviewed-by: Avri Altman <avri.altman@wdc.com>

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

* Re: [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating
  2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
  2020-10-27 19:10 ` [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba Asutosh Das
  2020-10-28  6:17 ` [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Avri Altman
@ 2020-10-30  1:57 ` Martin K. Petersen
  2020-11-05  4:21 ` Martin K. Petersen
  2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2020-10-30  1:57 UTC (permalink / raw)
  To: Asutosh Das
  Cc: cang, martin.petersen, linux-scsi, linux-arm-msm, Alim Akhtar,
	Avri Altman, James E.J. Bottomley, Matthias Brugger, Stanley Chu,
	Bean Huo, Bart Van Assche, Satya Tangirala, open list,
	moderated list:ARM/Mediatek SoC support,
	moderated list:ARM/Mediatek SoC support


Asutosh,

> During clock gating, after clocks are disabled, put hba into LPM to
> save more power.

Applied to 5.11/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating
  2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
                   ` (2 preceding siblings ...)
  2020-10-30  1:57 ` Martin K. Petersen
@ 2020-11-05  4:21 ` Martin K. Petersen
  2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2020-11-05  4:21 UTC (permalink / raw)
  To: cang, Asutosh Das, linux-scsi
  Cc: Martin K . Petersen, Stanley Chu, linux-arm-msm,
	moderated list:ARM/Mediatek SoC support, Bart Van Assche,
	Matthias Brugger, James E.J. Bottomley,
	moderated list:ARM/Mediatek SoC support, open list, Alim Akhtar,
	Avri Altman, Satya Tangirala, Bean Huo

On Tue, 27 Oct 2020 12:10:36 -0700, Asutosh Das wrote:

> During clock gating, after clocks are disabled,
> put hba into LPM to save more power.

Applied to 5.11/scsi-queue, thanks!

[1/2] scsi: ufs: Put HBA into LPM during clk gating
      https://git.kernel.org/mkp/scsi/c/dd7143e27cb7
[2/2] scsi: ufs: qcom: Enable aggressive power collapse for ufs HBA
      https://git.kernel.org/mkp/scsi/c/61906fd465c0

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating
  2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
                   ` (3 preceding siblings ...)
  2020-11-05  4:21 ` Martin K. Petersen
@ 2020-12-29 20:15 ` patchwork-bot+linux-arm-msm
  4 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+linux-arm-msm @ 2020-12-29 20:15 UTC (permalink / raw)
  To: Asutosh Das; +Cc: linux-arm-msm

Hello:

This series was applied to qcom/linux.git (refs/heads/for-next):

On Tue, 27 Oct 2020 12:10:36 -0700 you wrote:
> From: Can Guo <cang@codeaurora.org>
> 
> During clock gating, after clocks are disabled,
> put hba into LPM to save more power.
> 
> Acked-by: Stanley Chu <stanley.chu@mediatek.com>
> Signed-off-by: Can Guo <cang@codeaurora.org>
> Signed-off-by: Asutosh Das <asutoshd@codeaurora.org>
> 
> [...]

Here is the summary with links:
  - [v2,1/2] scsi: ufs: Put hba into LPM during clk gating
    https://git.kernel.org/qcom/c/dd7143e27cb7
  - [v2,2/2] ufs: qcom: Enable aggressive power collapse for ufs hba
    https://git.kernel.org/qcom/c/61906fd465c0

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2020-12-29 20:17 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 19:10 [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Asutosh Das
2020-10-27 19:10 ` [PATCH v2 2/2] ufs: qcom: Enable aggressive power collapse for ufs hba Asutosh Das
2020-10-28  6:18   ` Avri Altman
2020-10-28  6:17 ` [PATCH v2 1/2] scsi: ufs: Put hba into LPM during clk gating Avri Altman
2020-10-30  1:57 ` Martin K. Petersen
2020-11-05  4:21 ` Martin K. Petersen
2020-12-29 20:15 ` patchwork-bot+linux-arm-msm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).