Re: [PATCH 3/3] scsi: pm: Only runtime resume if necessary
From: Alan Stern <stern@rowland.harvard.edu>
Date: 2021-10-07 16:24:10
On Wed, Oct 06, 2021 at 02:54:53PM -0700, Bart Van Assche wrote:
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.You may already be aware of this, but in case you aren't... The PM core already contains some provisions for handling these kinds of things. They are described in Documentation/driver-api/pm/devices.rst. See particularly the parts relating to the DPM_FLAG_NO_DIRECT_COMPLETE, DPM_FLAG_SMART_PREPARE, DPM_FLAG_SMART_SUSPEND, DPM_FLAG_MAY_SKIP_RESUME, and power.direct_complete flags. A follow-up patch after this series might be able to take advantage of these facilities. Alan Stern