Skip to content

Commit cfefd9f

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: scsi_transport_spi: Set RQF_PM for domain validation commands
Disable runtime power management during domain validation. Since a later patch removes RQF_PREEMPT, set RQF_PM for domain validation commands such that these are executed in the quiesced SCSI device state. Link: https://lore.kernel.org/r/20201209052951.16136-6-bvanassche@acm.org Cc: Alan Stern <stern@rowland.harvard.edu> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Cc: Woody Suwalski <terraluna977@gmail.com> Cc: Can Guo <cang@codeaurora.org> Cc: Stanley Chu <stanley.chu@mediatek.com> Cc: Ming Lei <ming.lei@redhat.com> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: Stan Johnson <userm57@yahoo.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Jens Axboe <axboe@kernel.dk> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 5ae6538 commit cfefd9f

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/scsi/scsi_transport_spi.c

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,16 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
117117
sshdr = &sshdr_tmp;
118118

119119
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+
*/
120124
result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense,
121125
sshdr, DV_TIMEOUT, /* retries */ 1,
122126
REQ_FAILFAST_DEV |
123127
REQ_FAILFAST_TRANSPORT |
124128
REQ_FAILFAST_DRIVER,
125-
0, NULL);
129+
RQF_PM, NULL);
126130
if (driver_byte(result) != DRIVER_SENSE ||
127131
sshdr->sense_key != UNIT_ATTENTION)
128132
break;
@@ -1005,23 +1009,26 @@ spi_dv_device(struct scsi_device *sdev)
10051009
*/
10061010
lock_system_sleep();
10071011

1012+
if (scsi_autopm_get_device(sdev))
1013+
goto unlock_system_sleep;
1014+
10081015
if (unlikely(spi_dv_in_progress(starget)))
1009-
goto unlock;
1016+
goto put_autopm;
10101017

10111018
if (unlikely(scsi_device_get(sdev)))
1012-
goto unlock;
1019+
goto put_autopm;
10131020

10141021
spi_dv_in_progress(starget) = 1;
10151022

10161023
buffer = kzalloc(len, GFP_KERNEL);
10171024

10181025
if (unlikely(!buffer))
1019-
goto out_put;
1026+
goto put_sdev;
10201027

10211028
/* We need to verify that the actual device will quiesce; the
10221029
* later target quiesce is just a nice to have */
10231030
if (unlikely(scsi_device_quiesce(sdev)))
1024-
goto out_free;
1031+
goto free_buffer;
10251032

10261033
scsi_target_quiesce(starget);
10271034

@@ -1041,12 +1048,16 @@ spi_dv_device(struct scsi_device *sdev)
10411048

10421049
spi_initial_dv(starget) = 1;
10431050

1044-
out_free:
1051+
free_buffer:
10451052
kfree(buffer);
1046-
out_put:
1053+
1054+
put_sdev:
10471055
spi_dv_in_progress(starget) = 0;
10481056
scsi_device_put(sdev);
1049-
unlock:
1057+
put_autopm:
1058+
scsi_autopm_put_device(sdev);
1059+
1060+
unlock_system_sleep:
10501061
unlock_system_sleep();
10511062
}
10521063
EXPORT_SYMBOL(spi_dv_device);

0 commit comments

Comments
 (0)