@@ -249,7 +249,8 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
249
249
250
250
req = blk_get_request (sdev -> request_queue ,
251
251
data_direction == DMA_TO_DEVICE ?
252
- REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN , BLK_MQ_REQ_PREEMPT );
252
+ REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN ,
253
+ rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0 );
253
254
if (IS_ERR (req ))
254
255
return ret ;
255
256
rq = scsi_req (req );
@@ -1206,6 +1207,8 @@ static blk_status_t
1206
1207
scsi_device_state_check (struct scsi_device * sdev , struct request * req )
1207
1208
{
1208
1209
switch (sdev -> sdev_state ) {
1210
+ case SDEV_CREATED :
1211
+ return BLK_STS_OK ;
1209
1212
case SDEV_OFFLINE :
1210
1213
case SDEV_TRANSPORT_OFFLINE :
1211
1214
/*
@@ -1232,18 +1235,18 @@ scsi_device_state_check(struct scsi_device *sdev, struct request *req)
1232
1235
return BLK_STS_RESOURCE ;
1233
1236
case SDEV_QUIESCE :
1234
1237
/*
1235
- * If the devices is blocked we defer normal commands.
1238
+ * If the device is blocked we only accept power management
1239
+ * commands.
1236
1240
*/
1237
- if (req && !(req -> rq_flags & RQF_PREEMPT ))
1241
+ if (req && WARN_ON_ONCE ( !(req -> rq_flags & RQF_PM ) ))
1238
1242
return BLK_STS_RESOURCE ;
1239
1243
return BLK_STS_OK ;
1240
1244
default :
1241
1245
/*
1242
1246
* For any other not fully online state we only allow
1243
- * special commands. In particular any user initiated
1244
- * command is not allowed.
1247
+ * power management commands.
1245
1248
*/
1246
- if (req && !(req -> rq_flags & RQF_PREEMPT ))
1249
+ if (req && !(req -> rq_flags & RQF_PM ))
1247
1250
return BLK_STS_IOERR ;
1248
1251
return BLK_STS_OK ;
1249
1252
}
@@ -2517,15 +2520,13 @@ void sdev_evt_send_simple(struct scsi_device *sdev,
2517
2520
EXPORT_SYMBOL_GPL (sdev_evt_send_simple );
2518
2521
2519
2522
/**
2520
- * scsi_device_quiesce - Block user issued commands.
2523
+ * scsi_device_quiesce - Block all commands except power management .
2521
2524
* @sdev: scsi device to quiesce.
2522
2525
*
2523
2526
* This works by trying to transition to the SDEV_QUIESCE state
2524
2527
* (which must be a legal transition). When the device is in this
2525
- * state, only special requests will be accepted, all others will
2526
- * be deferred. Since special requests may also be requeued requests,
2527
- * a successful return doesn't guarantee the device will be
2528
- * totally quiescent.
2528
+ * state, only power management requests will be accepted, all others will
2529
+ * be deferred.
2529
2530
*
2530
2531
* Must be called with user context, may sleep.
2531
2532
*
@@ -2587,12 +2588,12 @@ void scsi_device_resume(struct scsi_device *sdev)
2587
2588
* device deleted during suspend)
2588
2589
*/
2589
2590
mutex_lock (& sdev -> state_mutex );
2591
+ if (sdev -> sdev_state == SDEV_QUIESCE )
2592
+ scsi_device_set_state (sdev , SDEV_RUNNING );
2590
2593
if (sdev -> quiesced_by ) {
2591
2594
sdev -> quiesced_by = NULL ;
2592
2595
blk_clear_pm_only (sdev -> request_queue );
2593
2596
}
2594
- if (sdev -> sdev_state == SDEV_QUIESCE )
2595
- scsi_device_set_state (sdev , SDEV_RUNNING );
2596
2597
mutex_unlock (& sdev -> state_mutex );
2597
2598
}
2598
2599
EXPORT_SYMBOL (scsi_device_resume );
0 commit comments