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@xxxxxxxxxxxxxxxxxxx> > > Cc: Dan Williams <dan.j.williams@xxxxxxxxx> > > Cc: Hannes Reinecke <hare@xxxxxxxx> > > Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> > > Cc: Martin Kepplinger <martin.kepplinger@xxxxxxx> > > Signed-off-by: Bart Van Assche <bvanassche@xxxxxxx> > > --- > > drivers/scsi/scsi_pm.c | 69 +++++++++----------------------------- > > -- > > -- > > drivers/scsi/sd.c | 6 ++++ > > 2 files changed, 20 insertions(+), 55 deletions(-) > > > > > Tested-by: Martin Kepplinger <martin.kepplinger@xxxxxxx> > > 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