All of lore.kernel.org
 help / color / mirror / Atom feed
From: Can Guo <cang@codeaurora.org>
To: asutoshd@codeaurora.org, ziqichen@codeaurora.org,
	nguyenb@codeaurora.org, hongwus@codeaurora.org,
	linux-scsi@vger.kernel.org, kernel-team@android.com,
	cang@codeaurora.org
Cc: Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Stanley Chu <stanley.chu@mediatek.com>,
	Bean Huo <beanhuo@micron.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
	Subhash Jadavani <subhashj@codeaurora.org>,
	Gilad Broner <gbroner@codeaurora.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH v1 3/3] scsi: ufs: Narrow down fast pass in system suspend path
Date: Sun, 25 Apr 2021 19:24:37 -0700	[thread overview]
Message-ID: <1619403878-28330-4-git-send-email-cang@codeaurora.org> (raw)
In-Reply-To: <1619403878-28330-1-git-send-email-cang@codeaurora.org>

If spm_lvl is set to 0 or 1, when system suspend kicks start and hba is
runtime active, system suspend may just bail without doing anything (the
fast pass), leaving other contexts still running, e.g., clock gating and
clock scaling. When system resume kicks start, concurrency can happen btw
ufshcd_resume() and these contexts, leading to various stability issues.
Fix it by adding a check against hba's runtime status and allowing fast
pass only if hba is runtime suspended, otherwise let system suspend go
ahead call ufshcd_suspend(). This can guarantee that these contexts are
stopped by either runtime suspend or system suspend.

Fixes: 0b257734344aa ("scsi: ufs: optimize system suspend handling")
Signed-off-by: Can Guo <cang@codeaurora.org>
---
 drivers/scsi/ufs/ufshcd.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 090b654..1fd965f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -9060,7 +9060,8 @@ int ufshcd_system_suspend(struct ufs_hba *hba)
 
 	cancel_delayed_work_sync(&hba->rpm_dev_flush_recheck_work);
 
-	if ((ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) ==
+	if (pm_runtime_suspended(hba->dev) &&
+	    (ufs_get_pm_lvl_to_dev_pwr_mode(hba->spm_lvl) ==
 	     hba->curr_dev_pwr_mode) &&
 	    (ufs_get_pm_lvl_to_link_pwr_state(hba->spm_lvl) ==
 	     hba->uic_link_state))
-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.


  parent reply	other threads:[~2021-04-26  2:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26  2:24 [PATCH v1 0/3] Three minor fixes w.r.t suspend/resume Can Guo
2021-04-26  2:24 ` [PATCH v1 1/3] scsi: ufs: Do not put UFS power into LPM if link is broken Can Guo
2021-04-26  2:24 ` [PATCH v1 2/3] scsi: ufs: Cancel rpm_dev_flush_recheck_work during system suspend Can Guo
2021-04-26  2:24 ` Can Guo [this message]
     [not found] ` <CGME20210426022700epcas2p298d2b9e6dd30781db9bf1e998f80eca1@epcms2p2>
2021-04-26  3:17   ` Daejun Park
2021-04-26  3:33     ` 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=1619403878-28330-4-git-send-email-cang@codeaurora.org \
    --to=cang@codeaurora.org \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=gbroner@codeaurora.org \
    --cc=hongwus@codeaurora.org \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nguyenb@codeaurora.org \
    --cc=stanley.chu@mediatek.com \
    --cc=subhashj@codeaurora.org \
    --cc=ziqichen@codeaurora.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.