linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kiwoong Kim <kwmad.kim@samsung.com>
To: linux-scsi@vger.kernel.org, alim.akhtar@samsung.com,
	avri.altman@wdc.com, jejb@linux.ibm.com,
	martin.petersen@oracle.com, beanhuo@micron.com,
	asutoshd@codeaurora.org, cang@codeaurora.org, bvanassche@acm.org,
	grant.jung@samsung.com, sc.suh@samsung.com, hy50.seo@samsung.com,
	sh425.lee@samsung.com, bhoon95.kim@samsung.com
Cc: Kiwoong Kim <kwmad.kim@samsung.com>
Subject: [RFC PATCH v1] ufs: relocate turning off device power sources
Date: Sat, 19 Dec 2020 15:27:28 +0900	[thread overview]
Message-ID: <1608359248-16079-1-git-send-email-kwmad.kim@samsung.com> (raw)
In-Reply-To: CGME20201219063815epcas2p1ffd277f7e53d9680abb460f55a53c599@epcas2p1.samsung.com

UFS specification says that while powering off the device,
RST_n signal and REF_CLK signal should be between VSS and VCCQ.
One of ways to make it is to drive both RST_n and REF_CLK to low.

However, the current location of turning off them doesn't
guarantee that. ufshcd_link_state_transition make enter hibern8
but it's not supposed to adjust the level of REF_CLK. Adding
ufshcd_vops_device_reset isn't proper because it just drives the
level of RST_n to low and then to high, not keep low.
In this situation, it could make those levels be
diverged from those proper ranges with actual hardware situations,
especially right when the driver turns off power.

The easist way to make it is just to move the location of turning
off because lowering the levels can be enabled through
the callbacks named suspend and setup_clocks.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/scsi/ufs/ufshcd.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 92d433d..dab9840 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8633,8 +8633,6 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 	if (ret)
 		goto set_dev_active;
 
-	ufshcd_vreg_set_lpm(hba);
-
 disable_clks:
 	/*
 	 * Call vendor specific suspend callback. As these callbacks may access
@@ -8662,6 +8660,13 @@ static int ufshcd_suspend(struct ufs_hba *hba, enum ufs_pm_op pm_op)
 					hba->clk_gating.state);
 	}
 
+	/*
+	 * It should follows driving RST_n and REF_CLK
+	 * in the range specified in UFS specification
+	 */
+	if (!ufshcd_is_ufs_dev_active(hba))
+		ufshcd_vreg_set_lpm(hba);
+
 	/* Put the host controller in low power mode if possible */
 	ufshcd_hba_vreg_set_lpm(hba);
 	goto out;
-- 
2.7.4


       reply	other threads:[~2020-12-19  6:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20201219063815epcas2p1ffd277f7e53d9680abb460f55a53c599@epcas2p1.samsung.com>
2020-12-19  6:27 ` Kiwoong Kim [this message]
2020-12-20  5:34   ` [RFC PATCH v1] ufs: relocate turning off device power sources Can Guo
2020-12-21  1:44     ` Kiwoong Kim
2020-12-21  2:37       ` Can Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1608359248-16079-1-git-send-email-kwmad.kim@samsung.com \
    --to=kwmad.kim@samsung.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bhoon95.kim@samsung.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=grant.jung@samsung.com \
    --cc=hy50.seo@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sc.suh@samsung.com \
    --cc=sh425.lee@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).