public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Can Guo <cang@codeaurora.org>
To: asutoshd@codeaurora.org, nguyenb@codeaurora.org,
	hongwus@codeaurora.org, ziqichen@codeaurora.org,
	rnayak@codeaurora.org, linux-scsi@vger.kernel.org,
	kernel-team@android.com, saravanak@google.com,
	salyzyn@google.com, cang@codeaurora.org
Subject: [PATCH RFC v1 0/1] scsi: pm: Leave runtime resume along if block layer PM is enabled
Date: Thu, 12 Nov 2020 22:30:07 -0800	[thread overview]
Message-ID: <1605249009-13752-1-git-send-email-cang@codeaurora.org> (raw)

In current UFS driver, if the hba device is in RPM_SUSPENDED status when system suspend
happens, UFS driver chooses not to resume hba device during system resume [1], which is
to achieve power efficiency by leaving the runtime PM to block layer PM.

Similarly, if block layer runtime PM is enabled for one SCSI device, then there is no
need to forcibly change the SCSI device and its request queue's runtime PM status to
RPM_ACTIVE in scsi_dev_type_resume(), since block layer PM shall resume the SCSI device
on the demand of bios.

Without this change, if situation [1] happens, when scsi_dev_type_resume() invokes
blk_pm_set_active(), we will get an error since it is trying to set the SCSI device's
runtime PM status to RPM_ACTIVE even when its parent is not RPM_ACTIVE, which actually
is not fatal. This change can avoid the annoying error logs when situation [1] happens.

However, there are some rare cases where upper layers start to submit bios into the
request queue of one SCSI device even when scsi_dev_type_resume() is still running on
that SCSI device. In these rare cases, if situation [1] happens, when a bio is sent to
block layer, block layer runtime PM shall try to runtime resume the SCSI device
(invoked from blk_queue_enter()) and if meanwhile scsi_dev_type_resume() has ran over
line #83 but before #85 (see below code snippet), block layer runtime PM won't be able
to resume it due to runtime PM is disabled on this device at this moment. And later if
no more bios kick blk_queue_enter(), the bio will be stuck at blk_queue_enter() forever.
This change can fix the problem too.

<--code snippet-->
72 static int scsi_dev_type_resume(struct device *dev,
73 		int (*cb)(struct device *, const struct dev_pm_ops *))
74 {
...
83 		pm_runtime_disable(dev);
84 		err = pm_runtime_set_active(dev);
85 		pm_runtime_enable(dev);
...
<--code snippet-->

Can Guo (1):
  scsi: pm: Leave runtime resume along if block layer PM is enabled

 drivers/scsi/scsi_pm.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

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


             reply	other threads:[~2020-11-13  6:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-13  6:30 Can Guo [this message]
2020-11-13  6:30 ` [PATCH RFC v1 1/1] scsi: pm: Leave runtime resume along if block layer PM is enabled Can Guo
2020-11-14 20:57   ` Bart Van Assche
2020-11-16  1:19     ` Can Guo
2020-11-16  1:42     ` Can Guo
2020-11-18  4:38       ` Bart Van Assche
2020-11-18  8:49         ` 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=1605249009-13752-1-git-send-email-cang@codeaurora.org \
    --to=cang@codeaurora.org \
    --cc=asutoshd@codeaurora.org \
    --cc=hongwus@codeaurora.org \
    --cc=kernel-team@android.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=nguyenb@codeaurora.org \
    --cc=rnayak@codeaurora.org \
    --cc=salyzyn@google.com \
    --cc=saravanak@google.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox