Skip to content

Commit 3a7b457

Browse files
mikechristiemartinkpetersen
authored andcommitted
scsi: ses: Have midlayer retry scsi_execute_cmd() errors
This has ses have the SCSI midlayer retry scsi_execute_cmd() errors instead of driving them itself. Signed-off-by: Mike Christie <michael.christie@oracle.com> Link: https://lore.kernel.org/r/20240123002220.129141-17-michael.christie@oracle.com Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 0f11328 commit 3a7b457

File tree

1 file changed

+46
-20
lines changed

1 file changed

+46
-20
lines changed

drivers/scsi/ses.c

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,32 @@ static int ses_recv_diag(struct scsi_device *sdev, int page_code,
8787
0
8888
};
8989
unsigned char recv_page_code;
90-
unsigned int retries = SES_RETRIES;
91-
struct scsi_sense_hdr sshdr;
90+
struct scsi_failure failure_defs[] = {
91+
{
92+
.sense = UNIT_ATTENTION,
93+
.asc = 0x29,
94+
.ascq = SCMD_FAILURE_ASCQ_ANY,
95+
.allowed = SES_RETRIES,
96+
.result = SAM_STAT_CHECK_CONDITION,
97+
},
98+
{
99+
.sense = NOT_READY,
100+
.asc = SCMD_FAILURE_ASC_ANY,
101+
.ascq = SCMD_FAILURE_ASCQ_ANY,
102+
.allowed = SES_RETRIES,
103+
.result = SAM_STAT_CHECK_CONDITION,
104+
},
105+
{}
106+
};
107+
struct scsi_failures failures = {
108+
.failure_definitions = failure_defs,
109+
};
92110
const struct scsi_exec_args exec_args = {
93-
.sshdr = &sshdr,
111+
.failures = &failures,
94112
};
95113

96-
do {
97-
ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen,
98-
SES_TIMEOUT, 1, &exec_args);
99-
} while (ret > 0 && --retries && scsi_sense_valid(&sshdr) &&
100-
(sshdr.sense_key == NOT_READY ||
101-
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
102-
114+
ret = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_IN, buf, bufflen,
115+
SES_TIMEOUT, 1, &exec_args);
103116
if (unlikely(ret))
104117
return ret;
105118

@@ -131,19 +144,32 @@ static int ses_send_diag(struct scsi_device *sdev, int page_code,
131144
bufflen & 0xff,
132145
0
133146
};
134-
struct scsi_sense_hdr sshdr;
135-
unsigned int retries = SES_RETRIES;
147+
struct scsi_failure failure_defs[] = {
148+
{
149+
.sense = UNIT_ATTENTION,
150+
.asc = 0x29,
151+
.ascq = SCMD_FAILURE_ASCQ_ANY,
152+
.allowed = SES_RETRIES,
153+
.result = SAM_STAT_CHECK_CONDITION,
154+
},
155+
{
156+
.sense = NOT_READY,
157+
.asc = SCMD_FAILURE_ASC_ANY,
158+
.ascq = SCMD_FAILURE_ASCQ_ANY,
159+
.allowed = SES_RETRIES,
160+
.result = SAM_STAT_CHECK_CONDITION,
161+
},
162+
{}
163+
};
164+
struct scsi_failures failures = {
165+
.failure_definitions = failure_defs,
166+
};
136167
const struct scsi_exec_args exec_args = {
137-
.sshdr = &sshdr,
168+
.failures = &failures,
138169
};
139170

140-
do {
141-
result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf,
142-
bufflen, SES_TIMEOUT, 1, &exec_args);
143-
} while (result > 0 && --retries && scsi_sense_valid(&sshdr) &&
144-
(sshdr.sense_key == NOT_READY ||
145-
(sshdr.sense_key == UNIT_ATTENTION && sshdr.asc == 0x29)));
146-
171+
result = scsi_execute_cmd(sdev, cmd, REQ_OP_DRV_OUT, buf, bufflen,
172+
SES_TIMEOUT, 1, &exec_args);
147173
if (result)
148174
sdev_printk(KERN_ERR, sdev, "SEND DIAGNOSTIC result: %8x\n",
149175
result);

0 commit comments

Comments
 (0)