@@ -337,10 +337,32 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
u8 *scsi_cmd = NULL;
int rc = 0;
int result = 0;
- int retry_cnt = 0;
u32 to = CMD_TIMEOUT * HZ;
+ struct scsi_failure failures[] = {
+ {
+ .sense = UNIT_ATTENTION,
+ .asc = 0x29,
+ .ascq = SCMD_FAILURE_ASCQ_ANY,
+ .allowed = 1,
+ .result = SAM_STAT_CHECK_CONDITION,
+ },
+ {
+ .sense = UNIT_ATTENTION,
+ .asc = 0x2A,
+ .ascq = SCMD_FAILURE_ASCQ_ANY,
+ .allowed = 1,
+ .result = SAM_STAT_CHECK_CONDITION,
+ },
+ {
+ .sense = UNIT_ATTENTION,
+ .asc = 0x3F,
+ .ascq = SCMD_FAILURE_ASCQ_ANY,
+ .allowed = 1,
+ .result = SAM_STAT_CHECK_CONDITION,
+ },
+ {},
+ };
-retry:
cmd_buf = kzalloc(CMD_BUFSIZE, GFP_KERNEL);
scsi_cmd = kzalloc(MAX_COMMAND_SIZE, GFP_KERNEL);
if (unlikely(!cmd_buf || !scsi_cmd)) {
@@ -352,14 +374,13 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
scsi_cmd[1] = SAI_READ_CAPACITY_16; /* service action */
put_unaligned_be32(CMD_BUFSIZE, &scsi_cmd[10]);
- dev_dbg(dev, "%s: %ssending cmd(%02x)\n", __func__,
- retry_cnt ? "re" : "", scsi_cmd[0]);
+ dev_dbg(dev, "%s: sending cmd(%02x)\n", __func__, scsi_cmd[0]);
/* Drop the ioctl read semahpore across lengthy call */
up_read(&cfg->ioctl_rwsem);
result = scsi_execute(sdev, scsi_cmd, DMA_FROM_DEVICE, cmd_buf,
CMD_BUFSIZE, NULL, &sshdr, to, CMD_RETRIES,
- 0, 0, NULL, NULL);
+ 0, 0, NULL, failures);
down_read(&cfg->ioctl_rwsem);
rc = check_state(cfg);
if (rc) {
@@ -377,20 +398,6 @@ static int read_cap16(struct scsi_device *sdev, struct llun_info *lli)
case NOT_READY:
result &= ~SAM_STAT_CHECK_CONDITION;
break;
- case UNIT_ATTENTION:
- switch (sshdr.asc) {
- case 0x29: /* Power on Reset or Device Reset */
- fallthrough;
- case 0x2A: /* Device capacity changed */
- case 0x3F: /* Report LUNs changed */
- /* Retry the command once more */
- if (retry_cnt++ < 1) {
- kfree(cmd_buf);
- kfree(scsi_cmd);
- goto retry;
- }
- }
- break;
default:
break;
}
This has read_cap16 have scsi-ml retry errors instead of driving them itself. Signed-off-by: Mike Christie <michael.christie@oracle.com> --- drivers/scsi/cxlflash/superpipe.c | 45 ++++++++++++++++++------------- 1 file changed, 26 insertions(+), 19 deletions(-)