All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bean Huo <huobean@gmail.com>
To: alim.akhtar@samsung.com, avri.altman@wdc.com,
	asutoshd@codeaurora.org, jejb@linux.ibm.com,
	martin.petersen@oracle.com, stanley.chu@mediatek.com,
	beanhuo@micron.com, bvanassche@acm.org, tomas.winkler@intel.com,
	cang@codeaurora.org
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	rjw@rjwysocki.net
Subject: [PATCH v2 3/3] scsi: ufs: Let resume callback return -EBUSY after ufshcd_shutdown
Date: Thu, 24 Dec 2020 18:20:10 +0100	[thread overview]
Message-ID: <20201224172010.10701-4-huobean@gmail.com> (raw)
In-Reply-To: <20201224172010.10701-1-huobean@gmail.com>

From: Bean Huo <beanhuo@micron.com>

After ufshcd_shutdown(), both UFS device and UFS LINk are powered off,
return '0' will mislead the upper PM layer since the device has not been
successfully resumed yet. This will let pm_runtime_get_sync() caller
mistakenly believe the device/LINK has been resumed, which leads to
request processing timeout that was en-queued later.

To fix this, let ufshcd_system/runtimie_resume() return -EBUSY in case of
hba->is_powered == false.

Signed-off-by: Bean Huo <beanhuo@micron.com>
---
 drivers/scsi/ufs/ufshcd.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index e221add25a7e..e1bcac51c01f 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8950,14 +8950,16 @@ int ufshcd_system_resume(struct ufs_hba *hba)
 		return -EINVAL;
 	}
 
-	if (!hba->is_powered || pm_runtime_suspended(hba->dev))
+	if (!hba->is_powered || pm_runtime_suspended(hba->dev)) {
 		/*
 		 * Let the runtime resume take care of resuming
 		 * if runtime suspended.
 		 */
+		ret = -EBUSY;
 		goto out;
-	else
+	} else {
 		ret = ufshcd_resume(hba, UFS_SYSTEM_PM);
+	}
 out:
 	trace_ufshcd_system_resume(dev_name(hba->dev), ret,
 		ktime_to_us(ktime_sub(ktime_get(), start)),
@@ -9026,10 +9028,12 @@ int ufshcd_runtime_resume(struct ufs_hba *hba)
 	if (!hba)
 		return -EINVAL;
 
-	if (!hba->is_powered)
+	if (!hba->is_powered) {
+		ret = -EBUSY;
 		goto out;
-	else
+	} else {
 		ret = ufshcd_resume(hba, UFS_RUNTIME_PM);
+	}
 out:
 	trace_ufshcd_runtime_resume(dev_name(hba->dev), ret,
 		ktime_to_us(ktime_sub(ktime_get(), start)),
-- 
2.17.1


  parent reply	other threads:[~2020-12-24 17:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-24 17:20 [PATCH v2 0/3] Two changes of UFS sysfs Bean Huo
2020-12-24 17:20 ` [PATCH v2 1/3] scsi: ufs: Replace sprintf and snprintf with sysfs_emit Bean Huo
2020-12-24 17:20 ` [PATCH v2 2/3] scsi: ufs: Add handling of the return value of pm_runtime_get_sync() Bean Huo
2020-12-28  1:50   ` Can Guo
2021-01-04 17:39     ` Bean Huo
2020-12-24 17:20 ` Bean Huo [this message]
2021-01-04 19:26   ` [PATCH v2 3/3] scsi: ufs: Let resume callback return -EBUSY after ufshcd_shutdown Bean Huo
2021-01-05  1:10   ` 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=20201224172010.10701-4-huobean@gmail.com \
    --to=huobean@gmail.com \
    --cc=alim.akhtar@samsung.com \
    --cc=asutoshd@codeaurora.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=cang@codeaurora.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=rjw@rjwysocki.net \
    --cc=stanley.chu@mediatek.com \
    --cc=tomas.winkler@intel.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 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.