@@ -117,12 +117,16 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
117
117
sshdr = & sshdr_tmp ;
118
118
119
119
for (i = 0 ; i < DV_RETRIES ; i ++ ) {
120
+ /*
121
+ * The purpose of the RQF_PM flag below is to bypass the
122
+ * SDEV_QUIESCE state.
123
+ */
120
124
result = scsi_execute (sdev , cmd , dir , buffer , bufflen , sense ,
121
125
sshdr , DV_TIMEOUT , /* retries */ 1 ,
122
126
REQ_FAILFAST_DEV |
123
127
REQ_FAILFAST_TRANSPORT |
124
128
REQ_FAILFAST_DRIVER ,
125
- 0 , NULL );
129
+ RQF_PM , NULL );
126
130
if (driver_byte (result ) != DRIVER_SENSE ||
127
131
sshdr -> sense_key != UNIT_ATTENTION )
128
132
break ;
@@ -1005,23 +1009,26 @@ spi_dv_device(struct scsi_device *sdev)
1005
1009
*/
1006
1010
lock_system_sleep ();
1007
1011
1012
+ if (scsi_autopm_get_device (sdev ))
1013
+ goto unlock_system_sleep ;
1014
+
1008
1015
if (unlikely (spi_dv_in_progress (starget )))
1009
- goto unlock ;
1016
+ goto put_autopm ;
1010
1017
1011
1018
if (unlikely (scsi_device_get (sdev )))
1012
- goto unlock ;
1019
+ goto put_autopm ;
1013
1020
1014
1021
spi_dv_in_progress (starget ) = 1 ;
1015
1022
1016
1023
buffer = kzalloc (len , GFP_KERNEL );
1017
1024
1018
1025
if (unlikely (!buffer ))
1019
- goto out_put ;
1026
+ goto put_sdev ;
1020
1027
1021
1028
/* We need to verify that the actual device will quiesce; the
1022
1029
* later target quiesce is just a nice to have */
1023
1030
if (unlikely (scsi_device_quiesce (sdev )))
1024
- goto out_free ;
1031
+ goto free_buffer ;
1025
1032
1026
1033
scsi_target_quiesce (starget );
1027
1034
@@ -1041,12 +1048,16 @@ spi_dv_device(struct scsi_device *sdev)
1041
1048
1042
1049
spi_initial_dv (starget ) = 1 ;
1043
1050
1044
- out_free :
1051
+ free_buffer :
1045
1052
kfree (buffer );
1046
- out_put :
1053
+
1054
+ put_sdev :
1047
1055
spi_dv_in_progress (starget ) = 0 ;
1048
1056
scsi_device_put (sdev );
1049
- unlock :
1057
+ put_autopm :
1058
+ scsi_autopm_put_device (sdev );
1059
+
1060
+ unlock_system_sleep :
1050
1061
unlock_system_sleep ();
1051
1062
}
1052
1063
EXPORT_SYMBOL (spi_dv_device );
0 commit comments