Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

scsi: core: Kill DRIVER_SENSE

Replace the check for DRIVER_SENSE with a check for
scsi_status_is_check_condition().

Audit all callsites to ensure the SAM status is set correctly. For
backwards compability move the DRIVER_SENSE definition to sg.h, and update
sg, bsg, and scsi_ioctl to set the DRIVER_SENSE driver_status whenever
SAM_STAT_CHECK_CONDITION is present.

[mkp: fix zeroday srp warning]

Link: https://lore.kernel.org/r/20210427083046.31620-10-hare@suse.de
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

fix

authored by

Hannes Reinecke and committed by
Martin K. Petersen
464a00c9 d0672a03

+76 -115
+2
block/bsg.c
··· 97 97 hdr->device_status = sreq->result & 0xff; 98 98 hdr->transport_status = host_byte(sreq->result); 99 99 hdr->driver_status = driver_byte(sreq->result); 100 + if (scsi_status_is_check_condition(sreq->result)) 101 + hdr->driver_status = DRIVER_SENSE; 100 102 hdr->info = 0; 101 103 if (hdr->device_status || hdr->transport_status || hdr->driver_status) 102 104 hdr->info |= SG_INFO_CHECK;
+2
block/scsi_ioctl.c
··· 257 257 hdr->msg_status = msg_byte(req->result); 258 258 hdr->host_status = host_byte(req->result); 259 259 hdr->driver_status = driver_byte(req->result); 260 + if (scsi_status_is_check_condition(hdr->status)) 261 + hdr->driver_status = DRIVER_SENSE; 260 262 hdr->info = 0; 261 263 if (hdr->masked_status || hdr->host_status || hdr->driver_status) 262 264 hdr->info |= SG_INFO_CHECK;
+3 -10
drivers/ata/libata-scsi.c
··· 411 411 rc = cmd_result; 412 412 goto error; 413 413 } 414 - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ 414 + if (scsi_sense_valid(&sshdr)) {/* sense data available */ 415 415 u8 *desc = sensebuf + 8; 416 - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 417 416 418 417 /* If we set cc then ATA pass-through will cause a 419 418 * check condition even if no error. Filter that. */ 420 - if (cmd_result & SAM_STAT_CHECK_CONDITION) { 419 + if (scsi_status_is_check_condition(cmd_result)) { 421 420 if (sshdr.sense_key == RECOVERED_ERROR && 422 421 sshdr.asc == 0 && sshdr.ascq == 0x1d) 423 422 cmd_result &= ~SAM_STAT_CHECK_CONDITION; ··· 495 496 rc = cmd_result; 496 497 goto error; 497 498 } 498 - if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */ 499 + if (scsi_sense_valid(&sshdr)) {/* sense data available */ 499 500 u8 *desc = sensebuf + 8; 500 - cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 501 501 502 502 /* If we set cc then ATA pass-through will cause a 503 503 * check condition even if no error. Filter that. */ ··· 862 864 863 865 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 864 866 865 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 866 - 867 867 /* 868 868 * Use ata_to_sense_error() to map status register bits 869 869 * onto sense key, asc & ascq. ··· 957 961 u8 sense_key, asc, ascq; 958 962 959 963 memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 960 - 961 - cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 962 964 963 965 if (ata_dev_disabled(dev)) { 964 966 /* Device disabled after error recovery */ ··· 4195 4201 4196 4202 case REQUEST_SENSE: 4197 4203 ata_scsi_set_sense(dev, cmd, 0, 0, 0); 4198 - cmd->result = (DRIVER_SENSE << 24); 4199 4204 break; 4200 4205 4201 4206 /* if we reach this, then writeback caching is disabled,
+1 -1
drivers/scsi/NCR5380.c
··· 542 542 scsi_eh_restore_cmnd(cmd, &hostdata->ses); 543 543 } else { 544 544 scsi_eh_restore_cmnd(cmd, &hostdata->ses); 545 - set_driver_byte(cmd, DRIVER_SENSE); 545 + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); 546 546 } 547 547 hostdata->sensing = NULL; 548 548 }
-2
drivers/scsi/advansys.c
··· 5964 5964 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 5965 5965 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 5966 5966 SCSI_SENSE_BUFFERSIZE); 5967 - set_driver_byte(scp, DRIVER_SENSE); 5968 5967 } 5969 5968 break; 5970 5969 ··· 6714 6715 ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); 6715 6716 ASC_DBG_PRT_SENSE(2, scp->sense_buffer, 6716 6717 SCSI_SENSE_BUFFERSIZE); 6717 - set_driver_byte(scp, DRIVER_SENSE); 6718 6718 } 6719 6719 break; 6720 6720
+7 -12
drivers/scsi/aic7xxx/aic79xx_osm.c
··· 1928 1928 memcpy(cmd->sense_buffer, 1929 1929 ahd_get_sense_buf(ahd, scb) 1930 1930 + sense_offset, sense_size); 1931 - cmd->result |= (DRIVER_SENSE << 24); 1931 + set_status_byte(cmd, SAM_STAT_CHECK_CONDITION); 1932 1932 1933 1933 #ifdef AHD_DEBUG 1934 1934 if (ahd_debug & AHD_SHOW_SENSE) { ··· 2018 2018 int new_status = DID_OK; 2019 2019 int do_fallback = 0; 2020 2020 int scsi_status; 2021 + struct scsi_sense_data *sense; 2021 2022 2022 2023 /* 2023 2024 * Map CAM error codes into Linux Error codes. We ··· 2042 2041 switch(scsi_status) { 2043 2042 case SAM_STAT_COMMAND_TERMINATED: 2044 2043 case SAM_STAT_CHECK_CONDITION: 2045 - if ((cmd->result >> 24) != DRIVER_SENSE) { 2044 + sense = (struct scsi_sense_data *) 2045 + cmd->sense_buffer; 2046 + if (sense->extra_len >= 5 && 2047 + (sense->add_sense_code == 0x47 2048 + || sense->add_sense_code == 0x48)) 2046 2049 do_fallback = 1; 2047 - } else { 2048 - struct scsi_sense_data *sense; 2049 - 2050 - sense = (struct scsi_sense_data *) 2051 - cmd->sense_buffer; 2052 - if (sense->extra_len >= 5 && 2053 - (sense->add_sense_code == 0x47 2054 - || sense->add_sense_code == 0x48)) 2055 - do_fallback = 1; 2056 - } 2057 2050 break; 2058 2051 default: 2059 2052 break;
-1
drivers/scsi/aic7xxx/aic7xxx_osm.c
··· 1838 1838 if (sense_size < SCSI_SENSE_BUFFERSIZE) 1839 1839 memset(&cmd->sense_buffer[sense_size], 0, 1840 1840 SCSI_SENSE_BUFFERSIZE - sense_size); 1841 - cmd->result |= (DRIVER_SENSE << 24); 1842 1841 #ifdef AHC_DEBUG 1843 1842 if (ahc_debug & AHC_SHOW_SENSE) { 1844 1843 int i;
-1
drivers/scsi/arcmsr/arcmsr_hba.c
··· 1335 1335 memcpy(sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length); 1336 1336 sensebuffer->ErrorCode = SCSI_SENSE_CURRENT_ERRORS; 1337 1337 sensebuffer->Valid = 1; 1338 - pcmd->result |= (DRIVER_SENSE << 24); 1339 1338 } 1340 1339 } 1341 1340
+1 -1
drivers/scsi/ch.c
··· 200 200 MAX_RETRIES, NULL); 201 201 if (result < 0) 202 202 return result; 203 - if (driver_byte(result) == DRIVER_SENSE) { 203 + if (scsi_sense_valid(&sshdr)) { 204 204 if (debug) 205 205 scsi_print_sense_hdr(ch->device, ch->name, &sshdr); 206 206 errno = ch_find_errno(&sshdr);
+1 -2
drivers/scsi/cxlflash/superpipe.c
··· 369 369 goto out; 370 370 } 371 371 372 - if (result > 0 && driver_byte(result) == DRIVER_SENSE) { 373 - result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */ 372 + if (result > 0 && scsi_sense_valid(&sshdr)) { 374 373 if (result & SAM_STAT_CHECK_CONDITION) { 375 374 switch (sshdr.sense_key) { 376 375 case NO_SENSE:
+3 -10
drivers/scsi/dc395x.c
··· 3239 3239 } 3240 3240 dprintkdbg(DBG_0, "srb_done: AUTO_REQSENSE2\n"); 3241 3241 3242 - if (srb->total_xfer_length 3243 - && srb->total_xfer_length >= cmd->underflow) 3244 - cmd->result = 3245 - MK_RES_LNX(DRIVER_SENSE, DID_OK, 3246 - srb->end_message, CHECK_CONDITION); 3247 - /*SET_RES_DID(cmd->result,DID_OK) */ 3248 - else 3249 - cmd->result = 3250 - MK_RES_LNX(DRIVER_SENSE, DID_OK, 3251 - srb->end_message, CHECK_CONDITION); 3242 + cmd->result = 3243 + MK_RES(0, DID_OK, 3244 + srb->end_message, SAM_STAT_CHECK_CONDITION); 3252 3245 3253 3246 goto ckc_e; 3254 3247 }
+1 -3
drivers/scsi/esp_scsi.c
··· 922 922 * saw originally. Also, report that we are providing 923 923 * the sense data. 924 924 */ 925 - cmd->result = ((DRIVER_SENSE << 24) | 926 - (DID_OK << 16) | 927 - (SAM_STAT_CHECK_CONDITION << 0)); 925 + cmd->result = SAM_STAT_CHECK_CONDITION; 928 926 929 927 ent->flags &= ~ESP_CMD_FLAG_AUTOSENSE; 930 928 if (esp_debug & ESP_DEBUG_AUTOSENSE) {
+2 -6
drivers/scsi/megaraid.c
··· 1583 1583 memcpy(cmd->sense_buffer, pthru->reqsensearea, 1584 1584 14); 1585 1585 1586 - cmd->result = (DRIVER_SENSE << 24) | 1587 - (DID_OK << 16) | 1588 - (CHECK_CONDITION << 1); 1586 + cmd->result = SAM_STAT_CHECK_CONDITION; 1589 1587 } 1590 1588 else { 1591 1589 if (mbox->m_out.cmd == MEGA_MBOXCMD_EXTPTHRU) { ··· 1591 1593 memcpy(cmd->sense_buffer, 1592 1594 epthru->reqsensearea, 14); 1593 1595 1594 - cmd->result = (DRIVER_SENSE << 24) | 1595 - (DID_OK << 16) | 1596 - (CHECK_CONDITION << 1); 1596 + cmd->result = SAM_STAT_CHECK_CONDITION; 1597 1597 } else 1598 1598 scsi_build_sense(cmd, 0, 1599 1599 ABORTED_COMMAND, 0, 0);
+2 -5
drivers/scsi/megaraid/megaraid_mbox.c
··· 2299 2299 memcpy(scp->sense_buffer, pthru->reqsensearea, 2300 2300 14); 2301 2301 2302 - scp->result = DRIVER_SENSE << 24 | 2303 - DID_OK << 16 | CHECK_CONDITION << 1; 2302 + scp->result = SAM_STAT_CHECK_CONDITION; 2304 2303 } 2305 2304 else { 2306 2305 if (mbox->cmd == MBOXCMD_EXTPTHRU) { ··· 2307 2308 memcpy(scp->sense_buffer, 2308 2309 epthru->reqsensearea, 14); 2309 2310 2310 - scp->result = DRIVER_SENSE << 24 | 2311 - DID_OK << 16 | 2312 - CHECK_CONDITION << 1; 2311 + scp->result = SAM_STAT_CHECK_CONDITION; 2313 2312 } else 2314 2313 scsi_build_sense(scp, 0, 2315 2314 ABORTED_COMMAND, 0, 0);
-2
drivers/scsi/megaraid/megaraid_sas_base.c
··· 3617 3617 SCSI_SENSE_BUFFERSIZE); 3618 3618 memcpy(cmd->scmd->sense_buffer, cmd->sense, 3619 3619 hdr->sense_len); 3620 - 3621 - cmd->scmd->result |= DRIVER_SENSE << 24; 3622 3620 } 3623 3621 3624 3622 break;
-1
drivers/scsi/megaraid/megaraid_sas_fusion.c
··· 2051 2051 SCSI_SENSE_BUFFERSIZE); 2052 2052 memcpy(scmd->sense_buffer, sense, 2053 2053 SCSI_SENSE_BUFFERSIZE); 2054 - scmd->result |= DRIVER_SENSE << 24; 2055 2054 } 2056 2055 2057 2056 /*
-1
drivers/scsi/mvumi.c
··· 1317 1317 if (ob_frame->rsp_flag & CL_RSP_FLAG_SENSEDATA) { 1318 1318 memcpy(cmd->scmd->sense_buffer, ob_frame->payload, 1319 1319 sizeof(struct mvumi_sense_data)); 1320 - scmd->result |= (DRIVER_SENSE << 24); 1321 1320 } 1322 1321 break; 1323 1322 default:
-7
drivers/scsi/scsi.c
··· 185 185 if (atomic_read(&sdev->device_blocked)) 186 186 atomic_set(&sdev->device_blocked, 0); 187 187 188 - /* 189 - * If we have valid sense information, then some kind of recovery 190 - * must have taken place. Make a note of this. 191 - */ 192 - if (SCSI_SENSE_VALID(cmd)) 193 - cmd->result |= (DRIVER_SENSE << 24); 194 - 195 188 SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, 196 189 "Notifying upper driver of completion " 197 190 "(result %x)\n", cmd->result));
+2 -2
drivers/scsi/scsi_debug.c
··· 851 851 }; 852 852 853 853 static const int check_condition_result = 854 - (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 854 + SAM_STAT_CHECK_CONDITION; 855 855 856 856 static const int illegal_condition_result = 857 - (DRIVER_SENSE << 24) | (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; 857 + (DID_ABORT << 16) | SAM_STAT_CHECK_CONDITION; 858 858 859 859 static const int device_qfull_result = 860 860 (DID_OK << 16) | SAM_STAT_TASK_SET_FULL;
+1 -2
drivers/scsi/scsi_ioctl.c
··· 103 103 104 104 if (result < 0) 105 105 goto out; 106 - if (driver_byte(result) == DRIVER_SENSE && 107 - scsi_sense_valid(&sshdr)) { 106 + if (scsi_sense_valid(&sshdr)) { 108 107 switch (sshdr.sense_key) { 109 108 case ILLEGAL_REQUEST: 110 109 if (cmd[0] == ALLOW_MEDIUM_REMOVAL)
+3 -7
drivers/scsi/scsi_lib.c
··· 593 593 case DID_OK: 594 594 /* 595 595 * Also check the other bytes than the status byte in result 596 - * to handle the case when a SCSI LLD sets result to 597 - * DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION. 598 596 */ 599 597 if (scsi_status_is_good(result) && (result & ~0xff) == 0) 600 598 return BLK_STS_OK; ··· 788 790 */ 789 791 if (!level && __ratelimit(&_rs)) { 790 792 scsi_print_result(cmd, NULL, FAILED); 791 - if (driver_byte(result) == DRIVER_SENSE) 793 + if (sense_valid) 792 794 scsi_print_sense(cmd); 793 795 scsi_print_command(cmd); 794 796 } ··· 2150 2152 * ILLEGAL REQUEST if the code page isn't supported */ 2151 2153 2152 2154 if (!scsi_status_is_good(result)) { 2153 - if (driver_byte(result) == DRIVER_SENSE && 2154 - scsi_sense_valid(sshdr)) { 2155 + if (scsi_sense_valid(sshdr)) { 2155 2156 if ((sshdr->sense_key == ILLEGAL_REQUEST) && 2156 2157 (sshdr->asc == 0x20) && (sshdr->ascq == 0)) { 2157 2158 /* ··· 3233 3236 void scsi_build_sense(struct scsi_cmnd *scmd, int desc, u8 key, u8 asc, u8 ascq) 3234 3237 { 3235 3238 scsi_build_sense_buffer(desc, scmd->sense_buffer, key, asc, ascq); 3236 - scmd->result = (DRIVER_SENSE << 24) | (DID_OK << 16) | 3237 - SAM_STAT_CHECK_CONDITION; 3239 + scmd->result = SAM_STAT_CHECK_CONDITION; 3238 3240 } 3239 3241 EXPORT_SYMBOL_GPL(scsi_build_sense);
+1 -1
drivers/scsi/scsi_scan.c
··· 623 623 * INQUIRY should not yield UNIT_ATTENTION 624 624 * but many buggy devices do so anyway. 625 625 */ 626 - if (driver_byte(result) == DRIVER_SENSE && 626 + if (scsi_status_is_check_condition(result) && 627 627 scsi_sense_valid(&sshdr)) { 628 628 if ((sshdr.sense_key == UNIT_ATTENTION) && 629 629 ((sshdr.asc == 0x28) ||
+1 -1
drivers/scsi/scsi_transport_spi.c
··· 127 127 REQ_FAILFAST_TRANSPORT | 128 128 REQ_FAILFAST_DRIVER, 129 129 RQF_PM, NULL); 130 - if (result < 0 || driver_byte(result) != DRIVER_SENSE || 130 + if (result < 0 || !scsi_sense_valid(sshdr) || 131 131 sshdr->sense_key != UNIT_ATTENTION) 132 132 break; 133 133 }
+17 -16
drivers/scsi/sd.c
··· 1722 1722 if (res < 0) 1723 1723 return res; 1724 1724 1725 - if (driver_byte(res) == DRIVER_SENSE) 1725 + if (scsi_status_is_check_condition(res) && 1726 + scsi_sense_valid(sshdr)) { 1726 1727 sd_print_sense_hdr(sdkp, sshdr); 1727 1728 1728 - /* we need to evaluate the error return */ 1729 - if (scsi_sense_valid(sshdr) && 1730 - (sshdr->asc == 0x3a || /* medium not present */ 1731 - sshdr->asc == 0x20 || /* invalid command */ 1732 - (sshdr->asc == 0x74 && sshdr->ascq == 0x71))) /* drive is password locked */ 1729 + /* we need to evaluate the error return */ 1730 + if (sshdr->asc == 0x3a || /* medium not present */ 1731 + sshdr->asc == 0x20 || /* invalid command */ 1732 + (sshdr->asc == 0x74 && sshdr->ascq == 0x71)) /* drive is password locked */ 1733 1733 /* this is no error here */ 1734 1734 return 0; 1735 + } 1735 1736 1736 1737 switch (host_byte(res)) { 1737 1738 /* ignore errors due to racing a disconnection */ ··· 1829 1828 result = scsi_execute_req(sdev, cmd, DMA_TO_DEVICE, &data, sizeof(data), 1830 1829 &sshdr, SD_TIMEOUT, sdkp->max_retries, NULL); 1831 1830 1832 - if (result > 0 && driver_byte(result) == DRIVER_SENSE && 1831 + if (scsi_status_is_check_condition(result) && 1833 1832 scsi_sense_valid(&sshdr)) { 1834 1833 sdev_printk(KERN_INFO, sdev, "PR command failed: %d\n", result); 1835 1834 scsi_print_sense_hdr(sdev, NULL, &sshdr); ··· 2073 2072 } 2074 2073 sdkp->medium_access_timed_out = 0; 2075 2074 2076 - if (driver_byte(result) != DRIVER_SENSE && 2075 + if (!scsi_status_is_check_condition(result) && 2077 2076 (!sense_valid || sense_deferred)) 2078 2077 goto out; 2079 2078 ··· 2176 2175 if (the_result) 2177 2176 sense_valid = scsi_sense_valid(&sshdr); 2178 2177 retries++; 2179 - } while (retries < 3 && 2178 + } while (retries < 3 && 2180 2179 (!scsi_status_is_good(the_result) || 2181 - ((driver_byte(the_result) == DRIVER_SENSE) && 2180 + (scsi_status_is_check_condition(the_result) && 2182 2181 sense_valid && sshdr.sense_key == UNIT_ATTENTION))); 2183 2182 2184 - if (the_result < 0 || driver_byte(the_result) != DRIVER_SENSE) { 2183 + if (!scsi_status_is_check_condition(the_result)) { 2185 2184 /* no sense, TUR either succeeded or failed 2186 2185 * with a status error */ 2187 2186 if(!spintime && !scsi_status_is_good(the_result)) { ··· 2309 2308 struct scsi_sense_hdr *sshdr, int sense_valid, 2310 2309 int the_result) 2311 2310 { 2312 - if (driver_byte(the_result) == DRIVER_SENSE) 2311 + if (sense_valid) 2313 2312 sd_print_sense_hdr(sdkp, sshdr); 2314 2313 else 2315 2314 sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n"); ··· 3595 3594 SD_TIMEOUT, sdkp->max_retries, 0, RQF_PM, NULL); 3596 3595 if (res) { 3597 3596 sd_print_result(sdkp, "Start/Stop Unit failed", res); 3598 - if (res > 0 && driver_byte(res) == DRIVER_SENSE) 3597 + if (res > 0 && scsi_sense_valid(&sshdr)) { 3599 3598 sd_print_sense_hdr(sdkp, &sshdr); 3600 - if (scsi_sense_valid(&sshdr) && 3601 3599 /* 0x3a is medium not present */ 3602 - sshdr.asc == 0x3a) 3603 - res = 0; 3600 + if (sshdr.asc == 0x3a) 3601 + res = 0; 3602 + } 3604 3603 } 3605 3604 3606 3605 /* SCSI error codes must not go to the generic layer */
+1 -2
drivers/scsi/sd_zbc.c
··· 116 116 sd_printk(KERN_ERR, sdkp, 117 117 "REPORT ZONES start lba %llu failed\n", lba); 118 118 sd_print_result(sdkp, "REPORT ZONES", result); 119 - if (result > 0 && driver_byte(result) == DRIVER_SENSE && 120 - scsi_sense_valid(&sshdr)) 119 + if (result > 0 && scsi_sense_valid(&sshdr)) 121 120 sd_print_sense_hdr(sdkp, &sshdr); 122 121 return -EIO; 123 122 }
+5 -2
drivers/scsi/sg.c
··· 498 498 old_hdr->host_status = hp->host_status; 499 499 old_hdr->driver_status = hp->driver_status; 500 500 if ((CHECK_CONDITION & hp->masked_status) || 501 - (DRIVER_SENSE & hp->driver_status)) 501 + (srp->sense_b[0] & 0x70) == 0x70) { 502 + old_hdr->driver_status = DRIVER_SENSE; 502 503 memcpy(old_hdr->sense_buffer, srp->sense_b, 503 504 sizeof (old_hdr->sense_buffer)); 505 + } 504 506 switch (hp->host_status) { 505 507 /* This setup of 'result' is for backward compatibility and is best 506 508 ignored by the user who should use target, host + driver status */ ··· 576 574 hp->sb_len_wr = 0; 577 575 if ((hp->mx_sb_len > 0) && hp->sbp) { 578 576 if ((CHECK_CONDITION & hp->masked_status) || 579 - (DRIVER_SENSE & hp->driver_status)) { 577 + (srp->sense_b[0] & 0x70) == 0x70) { 580 578 int sb_len = SCSI_SENSE_BUFFERSIZE; 581 579 sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; 582 580 len = 8 + (int) srp->sense_b[7]; /* Additional sense length field */ ··· 585 583 err = -EFAULT; 586 584 goto err_out; 587 585 } 586 + hp->driver_status = DRIVER_SENSE; 588 587 hp->sb_len_wr = len; 589 588 } 590 589 }
+2 -2
drivers/scsi/stex.c
··· 737 737 result |= DID_OK << 16; 738 738 break; 739 739 case SAM_STAT_CHECK_CONDITION: 740 - result |= DRIVER_SENSE << 24; 740 + result |= DID_OK << 16; 741 741 break; 742 742 case SAM_STAT_BUSY: 743 743 result |= DID_BUS_BUSY << 16; ··· 748 748 } 749 749 } 750 750 else if (ccb->srb_status & SRB_SEE_SENSE) 751 - result = DRIVER_SENSE << 24 | SAM_STAT_CHECK_CONDITION; 751 + result = SAM_STAT_CHECK_CONDITION; 752 752 else switch (ccb->srb_status) { 753 753 case SRB_STATUS_SELECTION_TIMEOUT: 754 754 result = DID_NO_CONNECT << 16;
+2 -4
drivers/scsi/sym53c8xx_2/sym_glue.c
··· 170 170 void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) 171 171 { 172 172 struct scsi_cmnd *cmd = cp->cmd; 173 - u_int cam_status, scsi_status, drv_status; 173 + u_int cam_status, scsi_status; 174 174 175 - drv_status = 0; 176 175 cam_status = DID_OK; 177 176 scsi_status = cp->ssss_status; 178 177 ··· 185 186 cp->xerr_status == 0) { 186 187 cam_status = sym_xerr_cam_status(DID_OK, 187 188 cp->sv_xerr_status); 188 - drv_status = DRIVER_SENSE; 189 189 /* 190 190 * Bounce back the sense data to user. 191 191 */ ··· 233 235 cam_status = sym_xerr_cam_status(DID_ERROR, cp->xerr_status); 234 236 } 235 237 scsi_set_resid(cmd, resid); 236 - cmd->result = (drv_status << 24) | (cam_status << 16) | scsi_status; 238 + cmd->result = (cam_status << 16) | scsi_status; 237 239 } 238 240 239 241 static int sym_scatter(struct sym_hcb *np, struct sym_ccb *cp, struct scsi_cmnd *cmd)
+1 -1
drivers/scsi/ufs/ufshcd.c
··· 8604 8604 sdev_printk(KERN_WARNING, sdp, 8605 8605 "START_STOP failed for power mode: %d, result %x\n", 8606 8606 pwr_mode, ret); 8607 - if (ret > 0 && driver_byte(ret) == DRIVER_SENSE) 8607 + if (ret > 0 && scsi_sense_valid(&sshdr)) 8608 8608 scsi_print_sense_hdr(sdp, NULL, &sshdr); 8609 8609 } 8610 8610
+1 -2
drivers/scsi/virtio_scsi.c
··· 161 161 min_t(u32, 162 162 virtio32_to_cpu(vscsi->vdev, resp->sense_len), 163 163 VIRTIO_SCSI_SENSE_SIZE)); 164 - if (resp->sense_len) 165 - set_driver_byte(sc, DRIVER_SENSE); 164 + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); 166 165 } 167 166 168 167 sc->scsi_done(sc);
-3
drivers/scsi/vmw_pvscsi.c
··· 576 576 cmd->result = (DID_RESET << 16); 577 577 } else { 578 578 cmd->result = (DID_OK << 16) | sdstat; 579 - if (sdstat == SAM_STAT_CHECK_CONDITION && 580 - cmd->sense_buffer) 581 - cmd->result |= (DRIVER_SENSE << 24); 582 579 } 583 580 } else 584 581 switch (btstat) {
-1
drivers/target/loopback/tcm_loop.c
··· 566 566 memcpy(sc->sense_buffer, se_cmd->sense_buffer, 567 567 SCSI_SENSE_BUFFERSIZE); 568 568 sc->result = SAM_STAT_CHECK_CONDITION; 569 - set_driver_byte(sc, DRIVER_SENSE); 570 569 } else 571 570 sc->result = scsi_status; 572 571
+2 -2
drivers/usb/storage/cypress_atacb.c
··· 221 221 desc[12] = regs[6]; /* device */ 222 222 desc[13] = regs[7]; /* command */ 223 223 224 - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 224 + srb->result = SAM_STAT_CHECK_CONDITION; 225 225 } 226 226 goto end; 227 227 invalid_fld: 228 - srb->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; 228 + srb->result = SAM_STAT_CHECK_CONDITION; 229 229 230 230 memcpy(srb->sense_buffer, 231 231 usb_stor_sense_invalidCDB,
+1 -2
drivers/xen/xen-scsiback.c
··· 1401 1401 if (se_cmd->sense_buffer && 1402 1402 ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || 1403 1403 (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) 1404 - pending_req->result = (DRIVER_SENSE << 24) | 1405 - SAM_STAT_CHECK_CONDITION; 1404 + pending_req->result = SAM_STAT_CHECK_CONDITION; 1406 1405 else 1407 1406 pending_req->result = se_cmd->scsi_status; 1408 1407
+11
include/scsi/sg.h
··· 131 131 #define SG_INFO_DIRECT_IO 0x2 /* direct IO requested and performed */ 132 132 #define SG_INFO_MIXED_IO 0x4 /* part direct, part indirect IO */ 133 133 134 + /* 135 + * Obsolete DRIVER_SENSE driver byte 136 + * 137 + * Originally the SCSI midlayer would set the DRIVER_SENSE driver byte when 138 + * a sense code was generated and a sense buffer was allocated. 139 + * However, as nowadays every scsi command has a sense code allocated this 140 + * distinction became moot as one could check the sense buffer directly. 141 + * Consequently this byte is not set anymore from the midlayer, but SG will 142 + * keep setting this byte to be compatible with previous releases. 143 + */ 144 + #define DRIVER_SENSE 0x08 134 145 135 146 typedef struct sg_scsi_id { /* used by SG_GET_SCSI_ID ioctl() */ 136 147 int host_no; /* as in "scsi<n>" where 'n' is one of 0, 1, 2 etc */