Skip to content

Commit 5dbf104

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: spi: Have midlayer retry spi_execute() UAs
This has spi_execute() have the SCSI midlayer retry UAs instead of driving them. Signed-off-by: Mike Christie <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent f316ff4 commit 5dbf104

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

drivers/scsi/scsi_transport_spi.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,29 +108,30 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,
108108
enum req_op op, void *buffer, unsigned int bufflen,
109109
struct scsi_sense_hdr *sshdr)
110110
{
111-
int i, result;
112-
struct scsi_sense_hdr sshdr_tmp;
113111
blk_opf_t opf = op | REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT |
114112
REQ_FAILFAST_DRIVER;
113+
struct scsi_failure failure_defs[] = {
114+
{
115+
.sense = UNIT_ATTENTION,
116+
.asc = SCMD_FAILURE_ASC_ANY,
117+
.ascq = SCMD_FAILURE_ASCQ_ANY,
118+
.allowed = DV_RETRIES,
119+
.result = SAM_STAT_CHECK_CONDITION,
120+
},
121+
{}
122+
};
123+
struct scsi_failures failures = {
124+
.failure_definitions = failure_defs,
125+
};
115126
const struct scsi_exec_args exec_args = {
127+
/* bypass the SDEV_QUIESCE state with BLK_MQ_REQ_PM */
116128
.req_flags = BLK_MQ_REQ_PM,
117-
.sshdr = sshdr ? : &sshdr_tmp,
129+
.sshdr = sshdr,
130+
.failures = &failures,
118131
};
119132

120-
sshdr = exec_args.sshdr;
121-
122-
for(i = 0; i < DV_RETRIES; i++) {
123-
/*
124-
* The purpose of the RQF_PM flag below is to bypass the
125-
* SDEV_QUIESCE state.
126-
*/
127-
result = scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen,
128-
DV_TIMEOUT, 1, &exec_args);
129-
if (result < 0 || !scsi_sense_valid(sshdr) ||
130-
sshdr->sense_key != UNIT_ATTENTION)
131-
break;
132-
}
133-
return result;
133+
return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, DV_TIMEOUT, 1,
134+
&exec_args);
134135
}
135136

136137
static struct {

0 commit comments

Comments
 (0)