Re: [PATCH v1 7/9] scsi: ufs: add UFS power collapse support during hibern8

From: Asutosh Das (asd)
Date: Sun Jul 22 2018 - 23:07:17 EST


On 7/21/2018 5:28 AM, Subhash Jadavani wrote:
On 2018-07-06 05:30, Asutosh Das wrote:
From: Subhash Jadavani <subhashj@xxxxxxxxxxxxxx>

UFS host controller hardware may allow the host controller
to be power collapsed when UFS link is hibern8 state, this
change allows the UFS host controller to be power collapsed
during hibern8.

Signed-off-by: Subhash Jadavani <subhashj@xxxxxxxxxxxxxx>
Signed-off-by: Venkat Gopalakrishnan <venkatg@xxxxxxxxxxxxxx>
Signed-off-by: Can Guo <cang@xxxxxxxxxxxxxx>
Signed-off-by: Asutosh Das <asutoshd@xxxxxxxxxxxxxx>
---
Âdrivers/scsi/ufs/ufshcd.c |Â 8 ++++++--
Âdrivers/scsi/ufs/ufshcd.h | 13 ++++++++++++-
Â2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 40d9c35..50588cf 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7673,13 +7673,17 @@ 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_is_link_hibern8(hba)
+ÂÂÂÂÂÂÂÂ && ufshcd_is_power_collapse_during_hibern8_allowed(hba)))
ÂÂÂÂÂÂÂÂ ufshcd_setup_hba_vreg(hba, false);

I guess we have to handle the UFS host controller power collapse via "power-domains" which would requires us to specify the "power-domains" attribute under UFS controller's DT node and then linux core power framework should automatically collapse the UFS controller post runtime suspend. This also means we can't power collapse UFS controller aggressively (as part of clock gating) but it should still be fine from power point of view.

Â}

Âstatic void ufshcd_hba_vreg_set_hpm(struct ufs_hba *hba)
Â{
-ÂÂÂ if (ufshcd_is_link_off(hba))
+ÂÂÂ if (ufshcd_is_link_off(hba) ||
+ÂÂÂÂÂÂÂ (ufshcd_is_link_hibern8(hba)
+ÂÂÂÂÂÂÂÂ && ufshcd_is_power_collapse_during_hibern8_allowed(hba)))
ÂÂÂÂÂÂÂÂ ufshcd_setup_hba_vreg(hba, true);
Â}

diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h
index f79a639..8c5f987 100644
--- a/drivers/scsi/ufs/ufshcd.h
+++ b/drivers/scsi/ufs/ufshcd.h
@@ -728,7 +728,12 @@ struct ufs_hba {
ÂÂÂÂÂ * to do background operation when it's active but it might degrade
ÂÂÂÂÂ * the performance of ongoing read/write operations.
ÂÂÂÂÂ */
-#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 5)
+#define UFSHCD_CAP_KEEP_AUTO_BKOPS_ENABLED_EXCEPT_SUSPEND (1 << 6)
+ÂÂÂ /*
+ÂÂÂÂ * If host controller hardware can be power collapsed when UFS link is
+ÂÂÂÂ * in hibern8 then enable this cap.
+ÂÂÂÂ */
+#define UFSHCD_CAP_POWER_COLLAPSE_DURING_HIBERN8 (1 << 7)

ÂÂÂÂ struct devfreq *devfreq;
ÂÂÂÂ struct ufs_clk_scaling clk_scaling;
@@ -764,6 +769,12 @@ static inline bool
ufshcd_is_hibern8_on_idle_allowed(struct ufs_hba *hba)
ÂÂÂÂ return hba->caps & UFSHCD_CAP_HIBERN8_ENTER_ON_IDLE;
Â}

+static inline bool ufshcd_is_power_collapse_during_hibern8_allowed(
+ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ struct ufs_hba *hba)
+{
+ÂÂÂ return !!(hba->caps & UFSHCD_CAP_POWER_COLLAPSE_DURING_HIBERN8);
+}
+
Âstatic inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba)
Â{
Â/* DWC UFS Core has the Interrupt aggregation feature but is not detectable*/


Thanks. I'll check the 'power-domains' part and get back with the changes.


--
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project