@@ -73,13 +73,22 @@ static int scsi_dev_type_resume(struct device *dev,
int (*cb)(struct device *, const struct dev_pm_ops *))
{
const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL;
+ struct scsi_device *sdev = NULL;
+ bool preserve_rpm = false;
int err = 0;
+ if (scsi_is_sdev_device(dev)) {
+ sdev = to_scsi_device(dev);
+ preserve_rpm = sdev->preserve_rpm;
+ if (preserve_rpm && pm_runtime_suspended(dev))
+ return 0;
+ }
+
err = cb(dev, pm);
scsi_device_resume(to_scsi_device(dev));
dev_dbg(dev, "scsi resume: %d\n", err);
- if (err == 0) {
+ if (err == 0 && !preserve_rpm) {
pm_runtime_disable(dev);
err = pm_runtime_set_active(dev);
pm_runtime_enable(dev);
@@ -91,11 +100,8 @@ static int scsi_dev_type_resume(struct device *dev,
*
* The resume hook will correct runtime PM status of the disk.
*/
- if (!err && scsi_is_sdev_device(dev)) {
- struct scsi_device *sdev = to_scsi_device(dev);
-
+ if (!err && sdev)
blk_set_runtime_active(sdev->request_queue);
- }
}
return err;
@@ -5016,6 +5016,7 @@ static int ufshcd_slave_configure(struct scsi_device *sdev)
pm_runtime_get_noresume(&sdev->sdev_gendev);
else if (ufshcd_is_rpm_autosuspend_allowed(hba))
sdev->rpm_autosuspend = 1;
+ sdev->preserve_rpm = 1;
ufshcd_crypto_setup_rq_keyslot_manager(hba, q);
@@ -197,6 +197,7 @@ struct scsi_device {
unsigned no_read_disc_info:1; /* Avoid READ_DISC_INFO cmds */
unsigned no_read_capacity_16:1; /* Avoid READ_CAPACITY_16 cmds */
unsigned try_rc_10_first:1; /* Try READ_CAPACACITY_10 first */
+ unsigned preserve_rpm:1; /* Preserve runtime PM */
unsigned security_supported:1; /* Supports Security Protocols */
unsigned is_visible:1; /* is the device visible in sysfs */
unsigned wce_default_on:1; /* Cache is ON by default */
UFS SCSI devices make use of device links to establish PM dependencies. However, SCSI PM will force devices' runtime PM state to be active during system resume. That can break runtime PM dependencies for UFS devices. Fix by adding a flag 'preserve_rpm' to let UFS SCSI devices opt-out of the unwanted behaviour. Fixes: b294ff3e34490f ("scsi: ufs: core: Enable power management for wlun") Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter <adrian.hunter@intel.com> --- drivers/scsi/scsi_pm.c | 16 +++++++++++----- drivers/scsi/ufs/ufshcd.c | 1 + include/scsi/scsi_device.h | 1 + 3 files changed, 13 insertions(+), 5 deletions(-)