All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Kepplinger <martin.kepplinger@puri.sm>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, Jaegeuk Kim <jaegeuk@kernel.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Dan Williams <dan.j.williams@intel.com>,
	Hannes Reinecke <hare@suse.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>
Subject: Re: [PATCH 3/3] scsi: pm: Only runtime resume if necessary
Date: Thu, 07 Oct 2021 09:04:31 +0200	[thread overview]
Message-ID: <b2c1eee3bcc67158235584157771908564c82b5e.camel@puri.sm> (raw)
In-Reply-To: <905cf8dc63a2e909f61b8265f630d18a542ea62e.camel@puri.sm>

Am Donnerstag, dem 07.10.2021 um 08:59 +0200 schrieb Martin Kepplinger:
> Am Mittwoch, dem 06.10.2021 um 14:54 -0700 schrieb Bart Van Assche:
> > The following query shows which drivers define callbacks that are
> > called
> > by the power management support code in the SCSI core (scsi_pm.c):
> > 
> > $ git grep -nHEwA16 "$(echo $(git grep -h 'scsi_register_driver(&'
> > |
> >       sed 's/.*&//;s/\..*//') | sed 's/ /|/g')" |
> >     grep '\.pm[[:blank:]]*=[[:blank:]]'
> > drivers/scsi/sd.c-620-          .pm             = &sd_pm_ops,
> > drivers/scsi/sr.c-100-          .pm             = &sr_pm_ops,
> > drivers/scsi/ufs/ufshcd.c-9765-         .pm = &ufshcd_wl_pm_ops,
> > 
> > Since unconditionally runtime resuming a device during system
> > resume
> > is
> > not necessary, remove that code. Modify the SCSI disk (sd) driver
> > such
> > that it follows the same approach as the UFS driver, namely to skip
> > system suspend and resume for devices that are runtime suspended.
> > The
> > CD-ROM code does not need to be updated since its PM callbacks do
> > not
> > affect the device power state.
> > 
> > This patch has been tested as follows:
> > 
> > [ shell 1 ]
> > 
> > cd /sys/kernel/debug/tracing
> > grep -E
> > 'blk_(pre|post)_runtime|runtime_(suspend|resume)|autosuspend_delay|
> > pm
> > _runtime_(get|put)' available_filter_functions |
> >   while read a b; do echo "$a"; done |
> >   grep -v __pm_runtime_resume >set_ftrace_filter
> > echo function > current_tracer
> > echo 1 > tracing_on
> > cat trace_pipe
> > 
> > [ shell 2 ]
> > 
> > cd /sys/block/sr0
> >  # Increase the event poll interval to make it easier to derive
> > from
> > the
> >  # tracing output whether runtime power actions are the result of
> > sg_inq.
> > echo 30000 > events_poll_msecs
> > cd device/power
> >  # Enable runtime power management.
> > echo auto > control
> > echo 1000 > autosuspend_delay_ms
> > sleep 1
> >  # Verify in shell 1 that sr0 has been runtime suspended
> > sg_inq /dev/sr0
> > eject /dev/sr0
> > sg_inq /dev/sr0
> >  # Disable runtime power management.
> > echo on > control
> > 
> > cd /sys/block/sda/device/power
> > echo auto > control
> > echo 1000 > autosuspend_delay_ms
> > sleep 1
> >  # Verify in shell 1 that sr0 has been runtime suspended
> > sg_inq /dev/sda
> > 
> > Cc: Alan Stern <stern@rowland.harvard.edu>
> > Cc: Dan Williams <dan.j.williams@intel.com>
> > Cc: Hannes Reinecke <hare@suse.com>
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: Martin Kepplinger <martin.kepplinger@puri.sm>
> > Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> > ---
> >  drivers/scsi/scsi_pm.c | 69 +++++++++-----------------------------
> > --
> > --
> >  drivers/scsi/sd.c      |  6 ++++
> >  2 files changed, 20 insertions(+), 55 deletions(-)
> > 
> 
> 
> Tested-by: Martin Kepplinger <martin.kepplinger@puri.sm>
> 
> on my system with a runtime-suspend enabled sd cardreader.
> 
> thanks,
>                              martin
> 

Hi Bart,

I didn't get CC'd on the cover letter and just saw it. Code-wise I
think this makes sense, but what I tested was runtime-pm behaviour, not
(yet) together with system suspend. Just so you know.

thank you for improving this!

                             martin



  reply	other threads:[~2021-10-07  7:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-06 21:54 [PATCH 0/3] Rework SCSI runtime power management support Bart Van Assche
2021-10-06 21:54 ` [PATCH 1/3] scsi: pm: Rely on the device driver core for async power management Bart Van Assche
2021-10-06 21:54 ` [PATCH 2/3] scsi: sd: Rename sd_resume() into sd_resume_system() Bart Van Assche
2021-10-06 21:54 ` [PATCH 3/3] scsi: pm: Only runtime resume if necessary Bart Van Assche
2021-10-07  6:59   ` Martin Kepplinger
2021-10-07  7:04     ` Martin Kepplinger [this message]
2021-10-07 16:24   ` Alan Stern
2021-10-07 20:34     ` Bart Van Assche
2021-10-08  1:32       ` Alan Stern
2021-10-17  1:47 ` [PATCH 0/3] Rework SCSI runtime power management support Martin K. Petersen
2021-10-21  3:42 ` Martin K. Petersen

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=b2c1eee3bcc67158235584157771908564c82b5e.camel@puri.sm \
    --to=martin.kepplinger@puri.sm \
    --cc=adrian.hunter@intel.com \
    --cc=bvanassche@acm.org \
    --cc=dan.j.williams@intel.com \
    --cc=hare@suse.com \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=stern@rowland.harvard.edu \
    /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.