diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2021-06-02 01:33:12 -0400 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2021-06-02 01:37:04 -0400 |
commit | 1ff28f229bc7fe36735684b25e63b528dbb962a5 (patch) | |
tree | 2c1371434da0e190d8dfdb7709b41b643ce5635e /drivers | |
parent | ed1b86ba0fba3d586cd53057551a95197b0a37ad (diff) | |
parent | 3d45cefc8edd7f560e6c97a8d9928ad571f76dec (diff) | |
download | linux-1ff28f229bc7fe36735684b25e63b528dbb962a5.tar.gz linux-1ff28f229bc7fe36735684b25e63b528dbb962a5.tar.bz2 linux-1ff28f229bc7fe36735684b25e63b528dbb962a5.zip |
Merge branch '5.14/scsi-result' into 5.14/scsi-staging
Include Hannes' SCSI command result rework in the staging branch.
[mkp: remove DRIVER_SENSE from mpi3mr]
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers')
75 files changed, 810 insertions, 981 deletions
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index fd8b6febbf70..b9588c52815d 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -196,9 +196,7 @@ void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd, if (!cmd) return; - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - - scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq); + scsi_build_sense(cmd, d_sense, sk, asc, ascq); } void ata_scsi_set_sense_information(struct ata_device *dev, @@ -409,13 +407,16 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg) cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize, sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ + if (cmd_result < 0) { + rc = cmd_result; + goto error; + } + if (scsi_sense_valid(&sshdr)) {/* sense data available */ u8 *desc = sensebuf + 8; - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ /* If we set cc then ATA pass-through will cause a * check condition even if no error. Filter that. */ - if (cmd_result & SAM_STAT_CHECK_CONDITION) { + if (scsi_status_is_check_condition(cmd_result)) { if (sshdr.sense_key == RECOVERED_ERROR && sshdr.asc == 0 && sshdr.ascq == 0x1d) cmd_result &= ~SAM_STAT_CHECK_CONDITION; @@ -490,9 +491,12 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg) cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0, sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL); - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ + if (cmd_result < 0) { + rc = cmd_result; + goto error; + } + if (scsi_sense_valid(&sshdr)) {/* sense data available */ u8 *desc = sensebuf + 8; - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ /* If we set cc then ATA pass-through will cause a * check condition even if no error. Filter that. */ @@ -638,7 +642,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev, if (cmd->request->rq_flags & RQF_QUIET) qc->flags |= ATA_QCFLAG_QUIET; } else { - cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1); + cmd->result = (DID_OK << 16) | SAM_STAT_TASK_SET_FULL; cmd->scsi_done(cmd); } @@ -858,8 +862,6 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - /* * Use ata_to_sense_error() to map status register bits * onto sense key, asc & ascq. @@ -874,8 +876,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) * ATA PASS-THROUGH INFORMATION AVAILABLE * Always in descriptor format sense. */ - scsi_build_sense_buffer(1, cmd->sense_buffer, - RECOVERED_ERROR, 0, 0x1D); + scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D); } if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) { @@ -957,8 +958,6 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc) memset(sb, 0, SCSI_SENSE_BUFFERSIZE); - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; - if (ata_dev_disabled(dev)) { /* Device disabled after error recovery */ /* LOGICAL UNIT NOT READY, HARD RESET REQUIRED */ @@ -4196,7 +4195,6 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) case REQUEST_SENSE: ata_scsi_set_sense(dev, cmd, 0, 0, 0); - cmd->result = (DRIVER_SENSE << 24); break; /* if we reach this, then writeback caching is disabled, diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index 31f8aa2c40ed..62d9b70f7c63 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c @@ -2232,7 +2232,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) * to reduce queue depth temporarily. */ scmnd->result = len == -ENOMEM ? - DID_OK << 16 | QUEUE_FULL << 1 : DID_ERROR << 16; + DID_OK << 16 | SAM_STAT_TASK_SET_FULL : DID_ERROR << 16; goto err_iu; } diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c index d58bf79892f2..9da9b2b2a580 100644 --- a/drivers/s390/scsi/zfcp_scsi.c +++ b/drivers/s390/scsi/zfcp_scsi.c @@ -856,10 +856,7 @@ void zfcp_scsi_set_prot(struct zfcp_adapter *adapter) */ void zfcp_scsi_dif_sense_error(struct scsi_cmnd *scmd, int ascq) { - scsi_build_sense_buffer(1, scmd->sense_buffer, - ILLEGAL_REQUEST, 0x10, ascq); - set_driver_byte(scmd, DRIVER_SENSE); - scmd->result |= SAM_STAT_CHECK_CONDITION; + scsi_build_sense(scmd, 1, ILLEGAL_REQUEST, 0x10, ascq); set_host_byte(scmd, DID_SOFT_ERROR); } diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c index 2b4b629a6e96..e41cc354cc8a 100644 --- a/drivers/scsi/3w-9xxx.c +++ b/drivers/scsi/3w-9xxx.c @@ -1338,7 +1338,7 @@ static irqreturn_t twa_interrupt(int irq, void *dev_instance) /* If error, command failed */ if (error == 1) { /* Ask for a host reset */ - cmd->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + cmd->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; } /* Report residual bytes for single sgl */ diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c index a7292883b72b..4ee485ab2714 100644 --- a/drivers/scsi/3w-xxxx.c +++ b/drivers/scsi/3w-xxxx.c @@ -429,7 +429,7 @@ static int tw_decode_sense(TW_Device_Extension *tw_dev, int request_id, int fill /* Additional sense code qualifier */ tw_dev->srb[request_id]->sense_buffer[13] = tw_sense_table[i][3]; - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; return TW_ISR_DONT_RESULT; /* Special case for isr to not over-write result */ } } @@ -1977,7 +1977,7 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_c printk(KERN_NOTICE "3w-xxxx: scsi%d: Unknown scsi opcode: 0x%x\n", tw_dev->host->host_no, *command); tw_dev->state[request_id] = TW_S_COMPLETED; tw_state_request_finish(tw_dev, request_id); - scsi_build_sense_buffer(1, SCpnt->sense_buffer, ILLEGAL_REQUEST, 0x20, 0); + scsi_build_sense(SCpnt, 1, ILLEGAL_REQUEST, 0x20, 0); done(SCpnt); retval = 0; } @@ -2159,7 +2159,7 @@ static irqreturn_t tw_interrupt(int irq, void *dev_instance) /* If error, command failed */ if (error == 1) { /* Ask for a host reset */ - tw_dev->srb[request_id]->result = (DID_OK << 16) | (CHECK_CONDITION << 1); + tw_dev->srb[request_id]->result = (DID_OK << 16) | SAM_STAT_CHECK_CONDITION; } /* Now complete the io */ diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c index 77ccb96e5ed4..1c6b4e672687 100644 --- a/drivers/scsi/53c700.c +++ b/drivers/scsi/53c700.c @@ -978,10 +978,10 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, if (NCR_700_get_tag_neg_state(SCp->device) == NCR_700_DURING_TAG_NEGOTIATION) NCR_700_set_tag_neg_state(SCp->device, NCR_700_FINISHED_TAG_NEGOTIATION); - + /* check for contingent allegiance conditions */ - if (hostdata->status[0] >> 1 == CHECK_CONDITION || - hostdata->status[0] >> 1 == COMMAND_TERMINATED) { + if (hostdata->status[0] == SAM_STAT_CHECK_CONDITION || + hostdata->status[0] == SAM_STAT_COMMAND_TERMINATED) { struct NCR_700_command_slot *slot = (struct NCR_700_command_slot *)SCp->host_scribble; if(slot->flags == NCR_700_FLAG_AUTOSENSE) { diff --git a/drivers/scsi/FlashPoint.c b/drivers/scsi/FlashPoint.c index 2e25ef67825a..90253208a72f 100644 --- a/drivers/scsi/FlashPoint.c +++ b/drivers/scsi/FlashPoint.c @@ -304,40 +304,12 @@ typedef struct SCCBscam_info { } SCCBSCAM_INFO; -#define SCSI_REQUEST_SENSE 0x03 -#define SCSI_READ 0x08 -#define SCSI_WRITE 0x0A -#define SCSI_START_STOP_UNIT 0x1B -#define SCSI_READ_EXTENDED 0x28 -#define SCSI_WRITE_EXTENDED 0x2A -#define SCSI_WRITE_AND_VERIFY 0x2E - -#define SSGOOD 0x00 -#define SSCHECK 0x02 -#define SSQ_FULL 0x28 - -#define SMCMD_COMP 0x00 -#define SMEXT 0x01 -#define SMSAVE_DATA_PTR 0x02 -#define SMREST_DATA_PTR 0x03 -#define SMDISC 0x04 -#define SMABORT 0x06 -#define SMREJECT 0x07 -#define SMNO_OP 0x08 -#define SMPARITY 0x09 -#define SMDEV_RESET 0x0C -#define SMABORT_TAG 0x0D -#define SMINIT_RECOVERY 0x0F -#define SMREL_RECOVERY 0x10 #define SMIDENT 0x80 #define DISC_PRIV 0x40 -#define SMSYNC 0x01 -#define SMWDTR 0x03 #define SM8BIT 0x00 #define SM16BIT 0x01 -#define SMIGNORWR 0x23 /* Ignore Wide Residue */ #define SIX_BYTE_CMD 0x06 #define TWELVE_BYTE_CMD 0x0C @@ -1660,7 +1632,7 @@ static int FlashPoint_AbortCCB(void *pCurrCard, struct sccb *p_Sccb) p_Sccb->Sccb_scsistat = ABORT_ST; p_Sccb->Sccb_scsimsg = - SMABORT_TAG; + ABORT_TASK; if (((struct sccb_card *) pCurrCard)->currentSCCB == @@ -1812,7 +1784,7 @@ static int FlashPoint_HandleInterrupt(void *pcard) FPT_phaseChkFifo(ioport, thisCard); if (RD_HARPOON(ioport + hp_gp_reg_1) == - SMSAVE_DATA_PTR) { + SAVE_POINTERS) { WR_HARPOON(ioport + hp_gp_reg_1, 0x00); currSCCB->Sccb_XferState |= F_NO_DATA_YET; @@ -1865,7 +1837,7 @@ static int FlashPoint_HandleInterrupt(void *pcard) FPT_phaseChkFifo(ioport, thisCard); if (RD_HARPOON(ioport + hp_gp_reg_1) == - SMSAVE_DATA_PTR) { + SAVE_POINTERS) { WR_HARPOON(ioport + hp_gp_reg_1, 0x00); currSCCB->Sccb_XferState |= F_NO_DATA_YET; @@ -2258,7 +2230,7 @@ static unsigned char FPT_sfm(u32 port, struct sccb *pCurrSCCB) WR_HARPOON(port + hp_fiforead, 0); WR_HARPOON(port + hp_fifowrite, 0); if (pCurrSCCB != NULL) { - pCurrSCCB->Sccb_scsimsg = SMPARITY; + pCurrSCCB->Sccb_scsimsg = MSG_PARITY_ERROR; } message = 0x00; do { @@ -2411,7 +2383,7 @@ static void FPT_ssel(u32 port, unsigned char p_card) WRW_HARPOON((port + ID_MSG_STRT + 2), BRH_OP + ALWAYS + NP); - currSCCB->Sccb_scsimsg = SMDEV_RESET; + currSCCB->Sccb_scsimsg = TARGET_RESET; WR_HARPOON(port + hp_autostart_3, (SELECT + SELCHK_STRT)); auto_loaded = 1; @@ -2758,9 +2730,9 @@ static void FPT_sres(u32 port, unsigned char p_card, if (message == 0) { msgRetryCount++; if (msgRetryCount == 1) { - FPT_SendMsg(port, SMPARITY); + FPT_SendMsg(port, MSG_PARITY_ERROR); } else { - FPT_SendMsg(port, SMDEV_RESET); + FPT_SendMsg(port, TARGET_RESET); FPT_sssyncv(port, our_target, NARROW_SCSI, currTar_Info); @@ -2860,8 +2832,8 @@ static void FPT_SendMsg(u32 port, unsigned char message) WR_HARPOON(port + hp_portctrl_0, 0x00); - if ((message == SMABORT) || (message == SMDEV_RESET) || - (message == SMABORT_TAG)) { + if ((message == ABORT_TASK_SET) || (message == TARGET_RESET) || + (message == ABORT_TASK)) { while (! (RDW_HARPOON((port + hp_intstat)) & (BUS_FREE | PHASE))) { @@ -2893,7 +2865,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) currTar_Info = &FPT_sccbMgrTbl[p_card][currSCCB->TargID]; - if (message == SMREST_DATA_PTR) { + if (message == RESTORE_POINTERS) { if (!(currSCCB->Sccb_XferState & F_NO_DATA_YET)) { currSCCB->Sccb_ATC = currSCCB->Sccb_savedATC; @@ -2905,7 +2877,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) (AUTO_IMMED + DISCONNECT_START)); } - else if (message == SMCMD_COMP) { + else if (message == COMMAND_COMPLETE) { if (currSCCB->Sccb_scsistat == SELECT_Q_ST) { currTar_Info->TarStatus &= @@ -2917,15 +2889,16 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) } - else if ((message == SMNO_OP) || (message >= SMIDENT) - || (message == SMINIT_RECOVERY) || (message == SMREL_RECOVERY)) { + else if ((message == NOP) || (message >= IDENTIFY_BASE) || + (message == INITIATE_RECOVERY) || + (message == RELEASE_RECOVERY)) { ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); } - else if (message == SMREJECT) { + else if (message == MESSAGE_REJECT) { if ((currSCCB->Sccb_scsistat == SELECT_SN_ST) || (currSCCB->Sccb_scsistat == SELECT_WN_ST) || @@ -3026,19 +2999,19 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) } } - else if (message == SMEXT) { + else if (message == EXTENDED_MESSAGE) { ACCEPT_MSG(port); FPT_shandem(port, p_card, currSCCB); } - else if (message == SMIGNORWR) { + else if (message == IGNORE_WIDE_RESIDUE) { ACCEPT_MSG(port); /* ACK the RESIDUE MSG */ message = FPT_sfm(port, currSCCB); - if (currSCCB->Sccb_scsimsg != SMPARITY) + if (currSCCB->Sccb_scsimsg != MSG_PARITY_ERROR) ACCEPT_MSG(port); WR_HARPOON(port + hp_autostart_1, (AUTO_IMMED + DISCONNECT_START)); @@ -3047,7 +3020,7 @@ static void FPT_sdecm(unsigned char message, u32 port, unsigned char p_card) else { currSCCB->HostStatus = SCCB_PHASE_SEQUENCE_FAIL; - currSCCB->Sccb_scsimsg = SMREJECT; + currSCCB->Sccb_scsimsg = MESSAGE_REJECT; ACCEPT_MSG_ATN(port); WR_HARPOON(port + hp_autostart_1, @@ -3073,7 +3046,7 @@ static void FPT_shandem(u32 port, unsigned char p_card, struct sccb *pCurrSCCB) message = FPT_sfm(port, pCurrSCCB); < |