Skip to content

Commit a8598ae

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: sd: Retry START STOP UNIT commands
During system resume, sd_start_stop_device() submits a START STOP UNIT command to the SCSI device that is being resumed. That command is not retried in case of a unit attention and hence may fail. An example: [16575.983359] sd 0:0:0:3: [sdd] Starting disk [16575.983693] sd 0:0:0:3: [sdd] Start/Stop Unit failed: Result: hostbyte=0x00 driverbyte=DRIVER_OK [16575.983712] sd 0:0:0:3: [sdd] Sense Key : 0x6 [16575.983730] sd 0:0:0:3: [sdd] ASC=0x29 ASCQ=0x0 [16575.983738] sd 0:0:0:3: PM: dpm_run_callback(): scsi_bus_resume+0x0/0xa0 returns -5 [16575.983783] sd 0:0:0:3: PM: failed to resume async: error -5 Make the SCSI core retry the START STOP UNIT command if the device reports that it has been powered on or that it has been reset. Cc: Damien Le Moal <[email protected]> Cc: Mike Christie <[email protected]> Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 24d7071 commit a8598ae

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

drivers/scsi/sd.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4082,9 +4082,38 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
40824082
{
40834083
unsigned char cmd[6] = { START_STOP }; /* START_VALID */
40844084
struct scsi_sense_hdr sshdr;
4085+
struct scsi_failure failure_defs[] = {
4086+
{
4087+
/* Power on, reset, or bus device reset occurred */
4088+
.sense = UNIT_ATTENTION,
4089+
.asc = 0x29,
4090+
.ascq = 0,
4091+
.result = SAM_STAT_CHECK_CONDITION,
4092+
},
4093+
{
4094+
/* Power on occurred */
4095+
.sense = UNIT_ATTENTION,
4096+
.asc = 0x29,
4097+
.ascq = 1,
4098+
.result = SAM_STAT_CHECK_CONDITION,
4099+
},
4100+
{
4101+
/* SCSI bus reset */
4102+
.sense = UNIT_ATTENTION,
4103+
.asc = 0x29,
4104+
.ascq = 2,
4105+
.result = SAM_STAT_CHECK_CONDITION,
4106+
},
4107+
{}
4108+
};
4109+
struct scsi_failures failures = {
4110+
.total_allowed = 3,
4111+
.failure_definitions = failure_defs,
4112+
};
40854113
const struct scsi_exec_args exec_args = {
40864114
.sshdr = &sshdr,
40874115
.req_flags = BLK_MQ_REQ_PM,
4116+
.failures = &failures,
40884117
};
40894118
struct scsi_device *sdp = sdkp->device;
40904119
int res;

0 commit comments

Comments
 (0)