Merge tag 'isci-for-3.5' into misc
[firefly-linux-kernel-4.4.55.git] / drivers / scsi / scsi_lib.c
index 5dfd7495d1a1bc4231123760090aa3d38eb9a764..62ddfd31d4ce3539b129ee3f7763d9422ab32f5e 100644 (file)
@@ -2348,10 +2348,14 @@ EXPORT_SYMBOL(scsi_device_quiesce);
  *
  *     Must be called with user context, may sleep.
  */
-void
-scsi_device_resume(struct scsi_device *sdev)
+void scsi_device_resume(struct scsi_device *sdev)
 {
-       if(scsi_device_set_state(sdev, SDEV_RUNNING))
+       /* check if the device state was mutated prior to resume, and if
+        * so assume the state is being managed elsewhere (for example
+        * device deleted during suspend)
+        */
+       if (sdev->sdev_state != SDEV_QUIESCE ||
+           scsi_device_set_state(sdev, SDEV_RUNNING))
                return;
        scsi_run_queue(sdev->request_queue);
 }