scsi: Revamp result values
Subsystems (39)
cover scsi: Revamp result values
Hi all,
the 'result' field in the SCSI command is defined as having 4 fields. The top byte is declared as a 'driver_byte', where the driver can signal some internal status back to the midlayer. However, there is quite a bit of overlap between the driver_byte and the host_byte, resulting in the driver_byte being used in very few places, and mostly in legacy drivers. Additionally, we have _two_ sets of definitions for the last byte (status byte), which can specified either in SAM terms or in the linux-specific terms, which are shifted right by one from the SAM ones.
Needless to say, the linux-specific ones are declared obsolete for years now.
And to make the confusion complete, both the status byte and the driver byte have a byte for a valid sense code, resulting in quite some confusion which of those bits to check.
This patchset does several things:
- remove the linux-specific status byte definitions, and use the SAM values throughout
- replace the driver-byte values with either SAM ones (for sense code checking) or host-byte definitions
- remove the driver-byte definitions
As usual, comments and reviews are welcome.
Please note, commit 66cf50e65b18 ("scsi: qla2xxx: fixup incorrect usage of host_byte") from 5.4/scsi-fixes is a prerequisite for this patch series.
Hannes Reinecke (24):
aic7xxx,aic79xxx: remove driver-defined SAM status definitions
bfa: drop driver-defined SCSI status codes
wd33c93: use SCSI status
acornscsi: use standard defines
scsi: use standard SAM status codes
scsi: change status_byte() to return the standard SCSI status
target_core: Fixup target_complete_cmd() usage
sg: use SAM status definitions and avoid using masked_status
scsi: Kill obsolete linux-specific status codes
scsi: introduce set_status_byte()
advansys: kill driver_defined status byte accessors
scsi: introduce scsi_build_sense()
scsi: Kill DRIVER_SENSE
scsi: Kill DRIVER_HARD
scsi_error: use DID_TIME_OUT instead of DRIVER_TIMEOUT
scsi: Kill DRIVER_TIMEOUT
scsi: do not use DRIVER_INVALID
st: return error code in st_scsi_execute()
scsi_ioctl: return error code when blk_map_user() fails
scsi_dh_alua: do not interpret DRIVER_ERROR
xen-scsiback: stop using DRIVER_ERROR
scsi: stop using DRIVER_ERROR
scsi: Kill DRIVER_MEDIA, DRIVER_SOFT, and DRIVER_BUSY
scsi: Drop now obsolete driver_byte definitions
Documentation/scsi/scsi_mid_low_api.txt | 3 +- block/bsg-lib.c | 2 +- block/bsg.c | 2 +- block/scsi_ioctl.c | 9 ++-- drivers/ata/libata-scsi.c | 22 +++----- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/message/fusion/mptscsih.c | 2 +- drivers/s390/scsi/zfcp_scsi.c | 5 +- drivers/scsi/3w-9xxx.c | 5 +- drivers/scsi/3w-sas.c | 3 +- drivers/scsi/3w-xxxx.c | 7 ++- drivers/scsi/53c700.c | 6 +-- drivers/scsi/NCR5380.c | 4 +- drivers/scsi/advansys.c | 78 ++++++++--------------------- drivers/scsi/aic7xxx/aic79xx_core.c | 8 +-- drivers/scsi/aic7xxx/aic79xx_osm.c | 35 ++++++------- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 +-- drivers/scsi/aic7xxx/aic7xxx_osm.c | 13 +++-- drivers/scsi/aic7xxx/aiclib.h | 15 ------ drivers/scsi/arcmsr/arcmsr_hba.c | 5 +- drivers/scsi/arm/acornscsi.c | 24 +++------ drivers/scsi/arm/fas216.c | 10 ++-- drivers/scsi/bfa/bfa_fc.h | 15 ------ drivers/scsi/bfa/bfa_fcpim.c | 2 +- drivers/scsi/bfa/bfad_im.c | 4 +- drivers/scsi/ch.c | 5 +- drivers/scsi/constants.c | 15 ------ drivers/scsi/cxlflash/superpipe.c | 45 ++++++++--------- drivers/scsi/dc395x.c | 26 +++------- drivers/scsi/device_handler/scsi_dh_alua.c | 4 -- drivers/scsi/dpt_i2o.c | 2 +- drivers/scsi/esp_scsi.c | 3 +- drivers/scsi/gdth.c | 12 ++--- drivers/scsi/hptiop.c | 2 +- drivers/scsi/libiscsi.c | 5 +- drivers/scsi/lpfc/lpfc_scsi.c | 30 +++-------- drivers/scsi/megaraid.c | 22 ++++---- drivers/scsi/megaraid/megaraid_mbox.c | 22 ++++---- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 - drivers/scsi/mpt3sas/mpt3sas_scsih.c | 8 +-- drivers/scsi/mvumi.c | 16 +++--- drivers/scsi/myrb.c | 61 ++++++---------------- drivers/scsi/myrs.c | 9 +--- drivers/scsi/ps3rom.c | 3 +- drivers/scsi/qla2xxx/qla_isr.c | 15 ++---- drivers/scsi/scsi.c | 8 +-- drivers/scsi/scsi_debug.c | 15 +++--- drivers/scsi/scsi_error.c | 52 +++++++++---------- drivers/scsi/scsi_ioctl.c | 2 +- drivers/scsi/scsi_lib.c | 44 +++++++++++----- drivers/scsi/scsi_logging.c | 10 +--- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 42 ++++++++-------- drivers/scsi/sd_zbc.c | 4 +- drivers/scsi/sg.c | 25 ++++----- drivers/scsi/smartpqi/smartpqi_init.c | 3 +- drivers/scsi/sr.c | 2 +- drivers/scsi/sr_ioctl.c | 2 +- drivers/scsi/st.c | 8 +-- drivers/scsi/stex.c | 9 ++-- drivers/scsi/sym53c8xx_2/sym_glue.c | 6 +-- drivers/scsi/ufs/ufshcd.c | 6 +-- drivers/scsi/virtio_scsi.c | 3 +- drivers/scsi/vmw_pvscsi.c | 21 ++++---- drivers/scsi/wd33c93.c | 21 +++----- drivers/target/loopback/tcm_loop.c | 1 - drivers/target/target_core_alua.c | 6 +-- drivers/target/target_core_iblock.c | 2 +- drivers/target/target_core_pr.c | 8 +-- drivers/target/target_core_sbc.c | 10 ++-- drivers/target/target_core_spc.c | 14 +++--- drivers/target/target_core_xcopy.c | 2 +- drivers/usb/storage/cypress_atacb.c | 4 +- drivers/xen/xen-scsiback.c | 12 ++--- include/scsi/scsi.h | 19 +------ include/scsi/scsi_cmnd.h | 12 +++-- include/scsi/scsi_proto.h | 19 ------- include/scsi/sg.h | 3 +- include/trace/events/scsi.h | 15 +----- 81 files changed, 371 insertions(+), 639 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/24 aic7xxx,aic79xxx: remove driver-defined SAM status definitions
Replace the driver-defined SAM status definitions with the standard mid-layer defined ones.
--- drivers/scsi/aic7xxx/aic79xx_core.c | 8 ++++---- drivers/scsi/aic7xxx/aic79xx_osm.c | 16 ++++++++-------- drivers/scsi/aic7xxx/aic7xxx_core.c | 6 +++--- drivers/scsi/aic7xxx/aic7xxx_osm.c | 12 ++++++------ drivers/scsi/aic7xxx/aiclib.h | 15 --------------- 5 files changed, 21 insertions(+), 36 deletions(-)
drivers/scsi/aic7xxx/aic79xx_core.c +4 -4
@@ -8955,7 +8955,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)break ; } } -if (siu->status ==SCSI_STATUS_OK ) +if (siu->status ==SAM_STAT_GOOD )ahd_set_transaction_status (scb,CAM_REQ_CMP_ERR ); }
@@ -8969,8 +8969,8 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)ahd_done (ahd, scb);break ; } -case SCSI_STATUS_CMD_TERMINATED : -case SCSI_STATUS_CHECK_COND : +case SAM_STAT_COMMAND_TERMINATED : +case SAM_STAT_CHECK_CONDITION : {struct ahd_devinfo devinfo;struct ahd_dma_seg *sg;
@@ -9060,7 +9060,7 @@ ahd_handle_scsi_status(struct ahd_softc *ahd, struct scb *scb)ahd_queue_scb (ahd, scb);break ; } -case SCSI_STATUS_OK : +case SAM_STAT_GOOD :printk ("%s: Interrupted for status of 0???\n" ,ahd_name (ahd));/* FALLTHROUGH */
drivers/scsi/aic7xxx/aic79xx_osm.c +8 -8
@@ -1846,7 +1846,7 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)if (dev->openings ==1 &&ahd_get_transaction_status (scb) ==CAM_REQ_CMP - &&ahd_get_scsi_status (scb) !=SCSI_STATUS_QUEUE_FULL ) + &&ahd_get_scsi_status (scb) !=SAM_STAT_TASK_SET_FULL ) dev->tag_success_count++;/* * Some devices deal with temporary internal resource
@@ -1903,8 +1903,8 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,switch (ahd_get_scsi_status (scb)) {default :break ; -case SCSI_STATUS_CHECK_COND : -case SCSI_STATUS_CMD_TERMINATED : +case SAM_STAT_CHECK_CONDITION : +case SAM_STAT_COMMAND_TERMINATED : {struct scsi_cmnd *cmd;
@@ -1959,7 +1959,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, }break ; } -case SCSI_STATUS_QUEUE_FULL : +case SAM_STAT_TASK_SET_FULL :/* * By the time the core driver has returned this * command, all other commands that were queued
@@ -2005,7 +2005,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd, dev->last_queuefull_same_count =0 ; }ahd_set_transaction_status (scb,CAM_REQUEUE_REQ ); -ahd_set_scsi_status (scb,SCSI_STATUS_OK ); +ahd_set_scsi_status (scb,SAM_STAT_GOOD );ahd_platform_set_tags (ahd, sdev, &devinfo, (dev->flags &AHD_DEV_Q_BASIC ) ?AHD_QUEUE_BASIC :AHD_QUEUE_TAGGED );
@@ -2019,7 +2019,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,ahd_platform_set_tags (ahd, sdev, &devinfo, (dev->flags &AHD_DEV_Q_BASIC ) ?AHD_QUEUE_BASIC :AHD_QUEUE_TAGGED ); -ahd_set_scsi_status (scb,SCSI_STATUS_BUSY ); +ahd_set_scsi_status (scb,SAM_STAT_BUSY ); } }
@@ -2051,8 +2051,8 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd) scsi_status =ahd_cmd_get_scsi_status (cmd);switch (scsi_status) { -case SCSI_STATUS_CMD_TERMINATED : -case SCSI_STATUS_CHECK_COND : +case SAM_STAT_COMMAND_TERMINATED : +case SAM_STAT_CHECK_CONDITION :if ((cmd->result >>24 ) !=DRIVER_SENSE ) { do_fallback =1 ; }else {
drivers/scsi/aic7xxx/aic7xxx_core.c +3 -3
@@ -1041,12 +1041,12 @@ ahc_handle_seqint(struct ahc_softc *ahc, u_int intstat)ahc_freeze_scb (scb);ahc_set_scsi_status (scb, hscb->shared_data.status.scsi_status);switch (hscb->shared_data.status.scsi_status) { -case SCSI_STATUS_OK : +case SAM_STAT_GOOD :printk ("%s: Interrupted for status of 0???\n" ,ahc_name (ahc));break ; -case SCSI_STATUS_CMD_TERMINATED : -case SCSI_STATUS_CHECK_COND : +case SAM_STAT_COMMAND_TERMINATED : +case SAM_STAT_CHECK_CONDITION : {struct ahc_dma_seg *sg;struct scsi_sense *sc;
drivers/scsi/aic7xxx/aic7xxx_osm.c +6 -6
@@ -1775,7 +1775,7 @@ ahc_done(struct ahc_softc *ahc, struct scb *scb)if (dev->openings ==1 &&ahc_get_transaction_status (scb) ==CAM_REQ_CMP - &&ahc_get_scsi_status (scb) !=SCSI_STATUS_QUEUE_FULL ) + &&ahc_get_scsi_status (scb) !=SAM_STAT_TASK_SET_FULL ) dev->tag_success_count++;/* * Some devices deal with temporary internal resource
@@ -1832,8 +1832,8 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,switch (ahc_get_scsi_status (scb)) {default :break ; -case SCSI_STATUS_CHECK_COND : -case SCSI_STATUS_CMD_TERMINATED : +case SAM_STAT_CHECK_CONDITION : +case SAM_STAT_COMMAND_TERMINATED : {struct scsi_cmnd *cmd;
@@ -1871,7 +1871,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc, }break ; } -case SCSI_STATUS_QUEUE_FULL : +case SAM_STAT_TASK_SET_FULL : {/* * By the time the core driver has returned this
@@ -1915,7 +1915,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc, dev->last_queuefull_same_count =0 ; }ahc_set_transaction_status (scb,CAM_REQUEUE_REQ ); -ahc_set_scsi_status (scb,SCSI_STATUS_OK ); +ahc_set_scsi_status (scb,SAM_STAT_GOOD );ahc_platform_set_tags (ahc, sdev, &devinfo, (dev->flags &AHC_DEV_Q_BASIC ) ?AHC_QUEUE_BASIC :AHC_QUEUE_TAGGED );
@@ -1926,7 +1926,7 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,* as if the target returned BUSY SCSI status. */ dev->openings =1 ; -ahc_set_scsi_status (scb,SCSI_STATUS_BUSY ); +ahc_set_scsi_status (scb,SAM_STAT_BUSY );ahc_platform_set_tags (ahc, sdev, &devinfo, (dev->flags &AHC_DEV_Q_BASIC ) ?AHC_QUEUE_BASIC :AHC_QUEUE_TAGGED );
drivers/scsi/aic7xxx/aiclib.h +0 -15
@@ -117,21 +117,6 @@ struct scsi_sense_data#define SSD_FULL_SIZE sizeof(struct scsi_sense_data) }; -/* -* Status Byte -*/ -#define SCSI_STATUS_OK 0x00 -#define SCSI_STATUS_CHECK_COND 0x02 -#define SCSI_STATUS_COND_MET 0x04 -#define SCSI_STATUS_BUSY 0x08 -#define SCSI_STATUS_INTERMED 0x10 -#define SCSI_STATUS_INTERMED_COND_MET 0x14 -#define SCSI_STATUS_RESERV_CONFLICT 0x18 -#define SCSI_STATUS_CMD_TERMINATED 0x22/* Obsolete in SAM-2 */ -#define SCSI_STATUS_QUEUE_FULL 0x28 -#define SCSI_STATUS_ACA_ACTIVE 0x30 -#define SCSI_STATUS_TASK_ABORTED 0x40 -/************************* Large Disk Handling ********************************/ static inline int aic_sector_div (sector_t capacity,int heads,int sectors)
Signature · 1 line
2.16.4
PATCH 2/24 bfa: drop driver-defined SCSI status codes
In reply to Hannes ReineckeDrop the driver-defined SCSI status code and use the generic ones instead.
--- drivers/scsi/bfa/bfa_fc.h | 15 --------------- drivers/scsi/bfa/bfa_fcpim.c | 2 +- drivers/scsi/bfa/bfad_im.c | 2 +- 3 files changed, 2 insertions(+), 17 deletions(-)
drivers/scsi/bfa/bfa_fc.h +0 -15
@@ -33,21 +33,6 @@ struct scsi_cdb_s {u8 scsi_cdb[SCSI_MAX_CDBLEN ]; }; -/* ------------------------------------------------------------ -* SCSI status byte values -* ------------------------------------------------------------ -*/ -#define SCSI_STATUS_GOOD 0x00 -#define SCSI_STATUS_CHECK_CONDITION 0x02 -#define SCSI_STATUS_CONDITION_MET 0x04 -#define SCSI_STATUS_BUSY 0x08 -#define SCSI_STATUS_INTERMEDIATE 0x10 -#define SCSI_STATUS_ICM 0x14/* intermediate condition met */ -#define SCSI_STATUS_RESERVATION_CONFLICT 0x18 -#define SCSI_STATUS_COMMAND_TERMINATED 0x22 -#define SCSI_STATUS_QUEUE_FULL 0x28 -#define SCSI_STATUS_ACA_ACTIVE 0x30 -#define SCSI_MAX_ALLOC_LEN 0xFF/* maximum allocarion length */ /*
drivers/scsi/bfa/bfa_fcpim.c +1 -1
@@ -2146,7 +2146,7 @@ __bfa_cb_ioim_comp(void *cbarg, bfa_boolean_t complete)/* * setup sense information, if present */ -if ((m->scsi_status ==SCSI_STATUS_CHECK_CONDITION ) && +if ((m->scsi_status ==SAM_STAT_CHECK_CONDITION ) && m->sns_len) { sns_len = m->sns_len; snsinfo = BFA_SNSINFO_FROM_TAG(ioim->fcpim->fcp,
drivers/scsi/bfa/bfad_im.c +1 -1
@@ -106,7 +106,7 @@ bfa_cb_ioim_good_comp(void *drv, struct bfad_ioim_s *dio)struct bfad_itnim_data_s *itnim_data;struct bfad_itnim_s *itnim; - cmnd->result =DID_OK <<16 |SCSI_STATUS_GOOD ; + cmnd->result =DID_OK <<16 |SAM_STAT_GOOD ;/* Unmap DMA, if host is NULL, it means a scsi passthru cmd */ if (cmnd->device->host !=NULL )
Signature · 1 line
2.16.4
PATCH 3/24 wd33c93: use SCSI status
In reply to Hannes ReineckeUse standard SCSI status and drop usage of the linux-specific ones.
--- drivers/scsi/wd33c93.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
drivers/scsi/wd33c93.c +8 -13
@@ -1176,10 +1176,8 @@ wd33c93_intr(struct Scsi_Host *instance)if (cmd->SCp.Status ==ILLEGAL_STATUS_BYTE ) cmd->SCp.Status = lun;if (cmd->cmnd[0 ] ==REQUEST_SENSE - && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); + && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd,DID_ERROR );else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );
@@ -1262,9 +1260,8 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ; -if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd->result &0x00ffff ) | (DID_ERROR <<16 ); +if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd,DID_ERROR );else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 ); cmd->scsi_done (cmd);
@@ -1294,12 +1291,10 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ; - DB(DB_INTR, printk(":%d", cmd->SCp.Status)) -if (cmd->cmnd[0 ] ==REQUEST_SENSE - && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); +DB (DB_INTR ,printk (":%d" , cmd->SCp.Status)); +if (cmd->cmnd[0 ] ==REQUEST_SENSE + && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd->result,DID_ERROR );else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );
Signature · 1 line
2.16.4
kbuild test robot
build botRe: [PATCH 03/24] wd33c93: use SCSI status
I love your patch! Perhaps something to improve:
Hi Hannes,
I love your patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Hannes-Reinecke/scsi-Revamp-result-values/20191022-004918 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: m68k-multi_defconfig (attached as .config) compiler: m68k-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=m68k
If you fix the issue, kindly add following tag
All warnings (new ones prefixed by >>):
drivers/scsi/wd33c93.c: In function 'wd33c93_intr':
>> drivers/scsi/wd33c93.c:1297:19: warning: passing argument 1 of 'set_host_byte' makes pointer from integer without a cast [-Wint-conversion]
set_host_byte(cmd->result, DID_ERROR);
^~~ In file included from drivers/scsi/wd33c93.c:79:0:
include/scsi/scsi_cmnd.h:315:20: note: expected 'struct scsi_cmnd *' but argument is of type 'int'
static inline void set_host_byte(struct scsi_cmnd *cmd, char status)
^~~~~~~~~~~~~
vim +/set_host_byte +1297 drivers/scsi/wd33c93.c
1200
1201 case CSR_SDP:
1202 DB(DB_INTR, printk("SDP"))
1203 hostdata->state = S_RUNNING_LEVEL2;
1204 write_wd33c93(regs, WD_COMMAND_PHASE, 0x41);
1205 write_wd33c93_cmd(regs, WD_CMD_SEL_ATN_XFER);
1206 spin_unlock_irqrestore(&hostdata->lock, flags);
1207 break;
1208
1209 case CSR_XFER_DONE | PHS_MESS_OUT:
1210 case CSR_UNEXP | PHS_MESS_OUT:
1211 case CSR_SRV_REQ | PHS_MESS_OUT:
1212 DB(DB_INTR, printk("MSG_OUT="))
1213
1214 /* To get here, we've probably requested MESSAGE_OUT and have
1215 * already put the correct bytes in outgoing_msg[] and filled
1216 * in outgoing_len. We simply send them out to the SCSI bus.
1217 * Sometimes we get MESSAGE_OUT phase when we're not expecting
1218 * it - like when our SDTR message is rejected by a target. Some
1219 * targets send the REJECT before receiving all of the extended
1220 * message, and then seem to go back to MESSAGE_OUT for a byte
1221 * or two. Not sure why, or if I'm doing something wrong to
1222 * cause this to happen. Regardless, it seems that sending
1223 * NOP messages in these situations results in no harm and
1224 * makes everyone happy.
1225 */
1226 if (hostdata->outgoing_len == 0) {
1227 hostdata->outgoing_len = 1;
1228 hostdata->outgoing_msg[0] = NOP;
1229 }
1230 transfer_pio(regs, hostdata->outgoing_msg,
1231 hostdata->outgoing_len, DATA_OUT_DIR, hostdata);
1232 DB(DB_INTR, printk("%02x", hostdata->outgoing_msg[0]))
1233 hostdata->outgoing_len = 0;
1234 hostdata->state = S_CONNECTED;
1235 spin_unlock_irqrestore(&hostdata->lock, flags);
1236 break;
1237
1238 case CSR_UNEXP_DISC:
1239
1240 /* I think I've seen this after a request-sense that was in response
1241 * to an error condition, but not sure. We certainly need to do
1242 * something when we get this interrupt - the question is 'what?'.
1243 * Let's think positively, and assume some command has finished
1244 * in a legal manner (like a command that provokes a request-sense),
1245 * so we treat it as a normal command-complete-disconnect.
1246 */
1247
1248 /* Make sure that reselection is enabled at this point - it may
1249 * have been turned off for the command that just completed.
1250 */
1251
1252 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
1253 if (cmd == NULL) {
1254 printk(" - Already disconnected! ");
1255 hostdata->state = S_UNCONNECTED;
1256 spin_unlock_irqrestore(&hostdata->lock, flags);
1257 return;
1258 }
1259 DB(DB_INTR, printk("UNEXP_DISC"))
1260 hostdata->connected = NULL;
1261 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1262 hostdata->state = S_UNCONNECTED;
1263 if (cmd->cmnd[0] == REQUEST_SENSE && cmd->SCp.Status != SAM_STAT_GOOD)
1264 set_host_byte(cmd, DID_ERROR);
1265 else
1266 cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
1267 cmd->scsi_done(cmd);
1268
1269 /* We are no longer connected to a target - check to see if
1270 * there are commands waiting to be executed.
1271 */
1272 /* look above for comments on scsi_done() */
1273 spin_unlock_irqrestore(&hostdata->lock, flags);
1274 wd33c93_execute(instance);
1275 break;
1276
1277 case CSR_DISC:
1278
1279 /* Make sure that reselection is enabled at this point - it may
1280 * have been turned off for the command that just completed.
1281 */
1282
1283 write_wd33c93(regs, WD_SOURCE_ID, SRCID_ER);
1284 DB(DB_INTR, printk("DISC"))
1285 if (cmd == NULL) {
1286 printk(" - Already disconnected! ");
1287 hostdata->state = S_UNCONNECTED;
1288 }
1289 switch (hostdata->state) {
1290 case S_PRE_CMP_DISC:
1291 hostdata->connected = NULL;
1292 hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun & 0xff));
1293 hostdata->state = S_UNCONNECTED;
1294 DB(DB_INTR, printk(":%d", cmd->SCp.Status));
1295 if (cmd->cmnd[0] == REQUEST_SENSE
1296 && cmd->SCp.Status != SAM_STAT_GOOD)
> 1297 set_host_byte(cmd->result, DID_ERROR);
1298 else
1299 cmd->result =
1300 cmd->SCp.Status | (cmd->SCp.Message << 8);
1301 cmd->scsi_done(cmd);
1302 break;
1303 case S_PRE_TMP_DISC:
1304 case S_RUNNING_LEVEL2:
1305 cmd->host_scribble = (uchar *) hostdata->disconnected_Q;
1306 hostdata->disconnected_Q = cmd;
1307 hostdata->connected = NULL;
1308 hostdata->state = S_UNCONNECTED;
1309
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH 03/24] wd33c93: use SCSI status
In reply to Hannes ReineckeQuoted 12 lines · Hannes Reinecke
Use standard SCSI status and drop usage of the linux-specific ones.
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/scsi/wd33c93.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)drivers/scsi/wd33c93.c +0
-0
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1180
Quoted 9 lines
drivers/scsi/wd33c93.c +2
-4@@ -1176,10 +1176,8 @@ wd33c93_intr(struct Scsi_Host *instance)if (cmd->SCp.Status ==ILLEGAL_STATUS_BYTE ) cmd->SCp.Status = lun;if (cmd->cmnd[0 ] ==REQUEST_SENSE - && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); + && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd,DID_ERROR );
This isn't obviously equivalent. Perhaps the set_host_byte() changes should be done in a separate patch to the SAM_STAT_FOO changes (?)
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1264
Quoted 12 lines
drivers/scsi/wd33c93.c +2
-3else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );@@ -1262,9 +1260,8 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ; -if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd->result &0x00ffff ) | (DID_ERROR <<16 ); +if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd,DID_ERROR );
Same.
Quoted 7 lines
drivers/scsi/wd33c93.c +0
-0else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 ); cmd->scsi_done (cmd);@@ -1294,12 +1291,10 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ;
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1297
Quoted 10 lines
drivers/scsi/wd33c93.c +4
-6- DB(DB_INTR, printk(":%d", cmd->SCp.Status)) -if (cmd->cmnd[0 ] ==REQUEST_SENSE - && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); +DB (DB_INTR ,printk (":%d" , cmd->SCp.Status)); +if (cmd->cmnd[0 ] ==REQUEST_SENSE + && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd->result,DID_ERROR );
Same.
Quoted 4 lines
drivers/scsi/wd33c93.c +0
-0else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );
Re: [PATCH 03/24] wd33c93: use SCSI status
Quoted 18 lines · Finn Thain
Quoted 16 lines · Hannes Reinecke
Use standard SCSI status and drop usage of the linux-specific ones.
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/scsi/wd33c93.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)drivers/scsi/wd33c93.c +0
-1@@ -1176,10 +1176,8 @@ wd33c93_intr(struct Scsi_Host *instance)if (cmd->SCp.Status ==ILLEGAL_STATUS_BYTE ) cmd->SCp.Status = lun; if (cmd->cmnd[0] == REQUEST_SENSE - && cmd->SCp.Status !=GOOD )
Quoted 9 lines
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1180
Quoted 5 lines
drivers/scsi/wd33c93.c +2
-3- cmd->result = - (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); + && cmd->SCp.Status != SAM_STAT_GOOD) +set_host_byte (cmd,DID_ERROR );This isn't obviously equivalent. Perhaps the
set_host_byte()changes should be done in a separate patch to theSAM_STAT_FOOchanges (?)
Yes, indeed.
Will be fixing it up in the next round.
Quoted 26 lines
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1264
Quoted 12 lines
drivers/scsi/wd33c93.c +2
-3else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 );@@ -1262,9 +1260,8 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ; -if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=GOOD ) - cmd->result = - (cmd->result &0x00ffff ) | (DID_ERROR <<16 ); +if (cmd->cmnd[0 ] ==REQUEST_SENSE && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd,DID_ERROR );Same.
Quoted 11 lines
drivers/scsi/wd33c93.c +0
-4else cmd->result = cmd->SCp.Status | (cmd->SCp.Message <<8 ); cmd->scsi_done (cmd);@@ -1294,12 +1291,10 @@ wd33c93_intr(struct Scsi_Host *instance) hostdata->connected =NULL ; hostdata->busy[cmd->device->id] &= ~(1 << (cmd->device->lun &0xff )); hostdata->state =S_UNCONNECTED ; - DB(DB_INTR, printk(":%d", cmd->SCp.Status)) -if (cmd->cmnd[0 ] ==REQUEST_SENSE - && cmd->SCp.Status !=GOOD ) - cmd->result =
Quoted 9 lines
drivers/scsi/wd33c93.c wd33c93_intr(struct Scsi_Host *instance) · line 1297
Quoted 6 lines
drivers/scsi/wd33c93.c +4
-2- (cmd-> - result &0x00ffff ) | (DID_ERROR <<16 ); +DB (DB_INTR ,printk (":%d" , cmd->SCp.Status)); +if (cmd->cmnd[0 ] ==REQUEST_SENSE + && cmd->SCp.Status !=SAM_STAT_GOOD ) +set_host_byte (cmd->result,DID_ERROR );Same.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
PATCH 4/24 acornscsi: use standard defines
In reply to Hannes ReineckeUse midlayer-defined values and drop the non-existing QUEUE_FULL case.
--- drivers/scsi/arm/acornscsi.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)
drivers/scsi/arm/acornscsi.c +2 -12
@@ -144,12 +144,6 @@#define VER_MINOR 0#define VER_PATCH 6 -#ifndef ABORT_TAG -#define ABORT_TAG 0xd -#else -#error "Yippee! ABORT TAG is now defined! Remove this error!" -#endif -#ifdef USE_DMAC /* * DMAC setup parameters
@@ -1490,8 +1484,8 @@ void acornscsi_message(AS_Host *host) }switch (message[0 ]) { -case ABORT : -case ABORT_TAG : +case ABORT_TASK_SET : +case ABORT_TASK :case COMMAND_COMPLETE :if (host->scsi.phase !=PHASE_STATUSIN ) { printk(KERN_ERR "scsi%d.%c: command complete following non-status in phase?\n",
@@ -1596,10 +1590,6 @@ void acornscsi_message(AS_Host *host) }break ; -case QUEUE_FULL : -/* TODO: target queue is full */ -break ; -case SIMPLE_QUEUE_TAG :/* tag queue reconnect... message[1] = queue tag. Print something to indicate something happened! */ printk("scsi%d.%c: reconnect queue tag %02X\n",
Signature · 1 line
2.16.4
PATCH 5/24 scsi: use standard SAM status codes
In reply to Hannes ReineckeUse standard SAM status codes and omit the explicit shift to convert to linus-specific ones.
--- drivers/ata/libata-scsi.c | 2 +- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/scsi/3w-9xxx.c | 5 +++-- drivers/scsi/3w-sas.c | 3 ++- drivers/scsi/3w-xxxx.c | 4 ++-- drivers/scsi/arcmsr/arcmsr_hba.c | 4 ++-- drivers/scsi/bfa/bfad_im.c | 2 +- drivers/scsi/dc395x.c | 18 +++++------------- drivers/scsi/dpt_i2o.c | 2 +- drivers/scsi/gdth.c | 12 ++++++------ drivers/scsi/megaraid.c | 10 +++++----- drivers/scsi/megaraid/megaraid_mbox.c | 12 ++++++------ 12 files changed, 35 insertions(+), 41 deletions(-)
drivers/ata/libata-scsi.c +1 -1
@@ -856,7 +856,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); }
drivers/infiniband/ulp/srp/ib_srp.c +1 -1
@@ -2404,7 +2404,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; }
drivers/scsi/3w-9xxx.c +3 -2
@@ -1018,7 +1018,8 @@ static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_if (copy_sense) {memcpy (tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data,TW_SENSE_DATA_LENGTH ); - tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status <<1 ); + tw_dev->srb[request_id]->result = + full_command_packet->command.newcommand.status; retval =TW_ISR_DONT_RESULT ; goto out; }
@@ -1342,7 +1343,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 */
drivers/scsi/3w-sas.c +2 -1
@@ -891,7 +891,8 @@ static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, inif (copy_sense) {memcpy (tw_dev->srb[request_id]->sense_buffer, header->sense_data,TW_SENSE_DATA_LENGTH ); - tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status <<1 ); + tw_dev->srb[request_id]->result = + full_command_packet->command.newcommand.status; goto out; } out:
drivers/scsi/3w-xxxx.c +2 -2
@@ -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 */ } }
@@ -2164,7 +2164,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 */
drivers/scsi/arcmsr/arcmsr_hba.c +2 -2
@@ -1271,7 +1271,7 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)struct scsi_cmnd *pcmd = ccb->pcmd;struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)pcmd->sense_buffer; - pcmd->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + pcmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (sensebuffer) {int sense_data_length =sizeof (struct SENSE_DATA ) <SCSI_SENSE_BUFFERSIZE
@@ -3110,7 +3110,7 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,if (!ccb)return SCSI_MLQUEUE_HOST_BUSY ;if (arcmsr_build_ccb ( acb, ccb, cmd ) ==FAILED ) { - cmd->result = (DID_ERROR <<16 ) | (RESERVATION_CONFLICT <<1 ); + cmd->result = (DID_ERROR <<16 ) |SAM_STAT_RESERVATION_CONFLICT ; cmd->scsi_done (cmd);return 0 ; }
drivers/scsi/bfa/bfad_im.c +1 -1
@@ -150,7 +150,7 @@ bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk;wait_queue_head_t *wq; - cmnd->SCp.Status |= tsk_status <<1 ; + cmnd->SCp.Status |= tsk_status;set_bit (IO_DONE_BIT , (unsigned long *)&cmnd->SCp.Status); wq = (wait_queue_head_t *) cmnd->SCp.ptr; cmnd->SCp.ptr =NULL ;
drivers/scsi/dc395x.c +5 -13
@@ -168,7 +168,6 @@#define RES_DRV 0xFF000000/* DRIVER_ codes */ #define MK_RES (drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)) -#define MK_RES_LNX (drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)#define SET_RES_TARGET (who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }#define SET_RES_TARGET_LNX (who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }
@@ -3228,7 +3227,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,*/ srb->flag &= ~AUTO_REQSENSE ; srb->adapter_status =0 ; - srb->target_status =CHECK_CONDITION <<1 ; + srb->target_status =SAM_STAT_CHECK_CONDITION ;if (debug_enabled (DBG_1 )) {switch (cmd->sense_buffer[2 ] &0x0f ) {case NOT_READY :
@@ -3275,22 +3274,15 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, *((unsigned int *)(cmd->sense_buffer + 3))); } -if (status == (CHECK_CONDITION <<1 )) { +if (status ==SAM_STAT_CHECK_CONDITION ) { cmd->result =DID_BAD_TARGET <<16 ; goto ckc_e; }dprintkdbg (DBG_0 ,"srb_done: AUTO_REQSENSE2\n" ); -if (srb->total_xfer_length - && srb->total_xfer_length >= cmd->underflow) - cmd->result = -MK_RES_LNX (DRIVER_SENSE ,DID_OK , - srb->end_message,CHECK_CONDITION ); -/*SET_RES_DID(cmd->result,DID_OK) */ -else - cmd->result = -MK_RES_LNX (DRIVER_SENSE ,DID_OK , - srb->end_message,CHECK_CONDITION ); + cmd->result = +MK_RES (DRIVER_SENSE ,DID_OK , + srb->end_message,SAM_STAT_CHECK_CONDITION ); goto ckc_e; }
drivers/scsi/dpt_i2o.c +1 -1
@@ -2656,7 +2656,7 @@ static void adpt_fail_posted_scbs(adpt_hba* pHba)unsigned long flags;spin_lock_irqsave (&d->list_lock, flags);list_for_each_entry (cmd, &d->cmd_list, list) { - cmd->result = (DID_OK <<16 ) | (QUEUE_FULL <<1 ); + cmd->result = (DID_OK <<16 ) |SAM_STAT_TASK_SET_FULL ; cmd->scsi_done (cmd); }spin_unlock_irqrestore (&d->list_lock, flags);
drivers/scsi/gdth.c +6 -6
@@ -1677,7 +1677,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =NOT_READY ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else
@@ -1722,7 +1722,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =UNIT_ATTENTION ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else
@@ -1774,7 +1774,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =UNIT_ATTENTION ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else
@@ -2802,7 +2802,7 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index,memset ((char *)scp->sense_buffer,0 ,16 ); scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =NOT_READY ; - scp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }else if (service ==CACHESERVICE ) { if (ha->status == S_CACHE_UNKNOWN && (ha->hdr[t].cluster_type &
@@ -2812,11 +2812,11 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, }memset ((char *)scp->sense_buffer,0 ,16 );if (ha->status == (u16 )S_CACHE_RESERV ) { - scp->result = (DID_OK <<16 ) | (RESERVATION_CONFLICT <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_RESERVATION_CONFLICT ; }else { scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =NOT_READY ; - scp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }if (!cmndinfo->internal_command) { ha->dvr.size =sizeof (ha->dvr.eu.sync);
drivers/scsi/megaraid.c +5 -5
@@ -1581,7 +1581,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | - (CHECK_CONDITION <<1 ); +SAM_STAT_CHECK_CONDITION ; }else {if (mbox->m_out.cmd ==MEGA_MBOXCMD_EXTPTHRU ) {
@@ -1591,11 +1591,11 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | - (CHECK_CONDITION <<1 ); +SAM_STAT_CHECK_CONDITION ; }else { cmd->sense_buffer[0 ] =0x70 ; cmd->sense_buffer[2 ] =ABORTED_COMMAND ; - cmd->result |= (CHECK_CONDITION <<1 ); + cmd->result |=SAM_STAT_CHECK_CONDITION ; } }break ;
@@ -1613,7 +1613,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)*/ if ( cmd->cmnd[0 ] ==TEST_UNIT_READY ) { cmd->result |= (DID_ERROR <<16 ) | - (RESERVATION_CONFLICT <<1 ); +SAM_STAT_RESERVATION_CONFLICT ; }else /*
@@ -1625,7 +1625,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->cmnd[0] == RELEASE) ) { cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + SAM_STAT_RESERVATION_CONFLICT; } else#endif
drivers/scsi/megaraid/megaraid_mbox.c +6 -6
@@ -1577,7 +1577,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =ILLEGAL_REQUEST ; scp->sense_buffer[12 ] =MEGA_INVALID_FIELD_IN_CDB ; - scp->result =CHECK_CONDITION <<1 ; + scp->result =SAM_STAT_CHECK_CONDITION ;return NULL ; }
@@ -2302,7 +2302,7 @@ megaraid_mbox_dpc(unsigned long devp) 14); scp->result =DRIVER_SENSE <<24 | -DID_OK <<16 |CHECK_CONDITION <<1 ; +DID_OK <<16 |SAM_STAT_CHECK_CONDITION ; }else {if (mbox->cmd ==MBOXCMD_EXTPTHRU ) {
@@ -2312,11 +2312,11 @@ megaraid_mbox_dpc(unsigned long devp) scp->result =DRIVER_SENSE <<24 |DID_OK <<16 | -CHECK_CONDITION <<1 ; +SAM_STAT_CHECK_CONDITION ; }else { scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =ABORTED_COMMAND ; - scp->result =CHECK_CONDITION <<1 ; + scp->result =SAM_STAT_CHECK_CONDITION ; } }break ;
@@ -2334,7 +2334,7 @@ megaraid_mbox_dpc(unsigned long devp)*/ if (scp->cmnd[0 ] ==TEST_UNIT_READY ) { scp->result =DID_ERROR <<16 | -RESERVATION_CONFLICT <<1 ; +SAM_STAT_RESERVATION_CONFLICT ; }else /*
@@ -2345,7 +2345,7 @@ megaraid_mbox_dpc(unsigned long devp) scp->cmnd[0] == RELEASE)) { scp->result = DID_ERROR << 16 | - RESERVATION_CONFLICT << 1; + SAM_STAT_RESERVATION_CONFLICT; } else { scp->result =DID_BAD_TARGET <<16 | status;
Signature · 1 line
2.16.4
Re: [PATCH 05/24] scsi: use standard SAM status codes
Quoted 2 lines · Hannes Reinecke
Use standard SAM status codes and omit the explicit shift to convert to linus-specific ones.
"Linux-specific".
Quoted 352 lines
Signed-off-by Hannes Reinecke <[email protected]>--- drivers/ata/libata-scsi.c | 2 +- drivers/infiniband/ulp/srp/ib_srp.c | 2 +- drivers/scsi/3w-9xxx.c | 5 +++-- drivers/scsi/3w-sas.c | 3 ++- drivers/scsi/3w-xxxx.c | 4 ++-- drivers/scsi/arcmsr/arcmsr_hba.c | 4 ++-- drivers/scsi/bfa/bfad_im.c | 2 +- drivers/scsi/dc395x.c | 18 +++++------------- drivers/scsi/dpt_i2o.c | 2 +- drivers/scsi/gdth.c | 12 ++++++------ drivers/scsi/megaraid.c | 10 +++++----- drivers/scsi/megaraid/megaraid_mbox.c | 12 ++++++------ 12 files changed, 35 insertions(+), 41 deletions(-)drivers/ata/libata-scsi.c +1
-1@@ -856,7 +856,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); }drivers/infiniband/ulp/srp/ib_srp.c +1
-1@@ -2404,7 +2404,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; }drivers/scsi/3w-9xxx.c +3
-2@@ -1018,7 +1018,8 @@ static int twa_fill_sense(TW_Device_Extension *tw_dev, int request_id, int copy_if (copy_sense) {memcpy (tw_dev->srb[request_id]->sense_buffer, full_command_packet->header.sense_data,TW_SENSE_DATA_LENGTH ); - tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status <<1 ); + tw_dev->srb[request_id]->result = + full_command_packet->command.newcommand.status; retval =TW_ISR_DONT_RESULT ; goto out; }@@ -1342,7 +1343,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 */ drivers/scsi/3w-sas.c +2
-1@@ -891,7 +891,8 @@ static int twl_fill_sense(TW_Device_Extension *tw_dev, int i, int request_id, inif (copy_sense) {memcpy (tw_dev->srb[request_id]->sense_buffer, header->sense_data,TW_SENSE_DATA_LENGTH ); - tw_dev->srb[request_id]->result = (full_command_packet->command.newcommand.status <<1 ); + tw_dev->srb[request_id]->result = + full_command_packet->command.newcommand.status; goto out; } out:drivers/scsi/3w-xxxx.c +2
-2@@ -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 */ } }@@ -2164,7 +2164,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 */ drivers/scsi/arcmsr/arcmsr_hba.c +2
-2@@ -1271,7 +1271,7 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)struct scsi_cmnd *pcmd = ccb->pcmd;struct SENSE_DATA *sensebuffer = (struct SENSE_DATA *)pcmd->sense_buffer; - pcmd->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + pcmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (sensebuffer) {int sense_data_length =sizeof (struct SENSE_DATA ) <SCSI_SENSE_BUFFERSIZE @@ -3110,7 +3110,7 @@ static int arcmsr_queue_command_lck(struct scsi_cmnd *cmd,if (!ccb)return SCSI_MLQUEUE_HOST_BUSY ;if (arcmsr_build_ccb ( acb, ccb, cmd ) ==FAILED ) { - cmd->result = (DID_ERROR <<16 ) | (RESERVATION_CONFLICT <<1 ); + cmd->result = (DID_ERROR <<16 ) |SAM_STAT_RESERVATION_CONFLICT ; cmd->scsi_done (cmd);return 0 ; }drivers/scsi/bfa/bfad_im.c +1
-1@@ -150,7 +150,7 @@ bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk;wait_queue_head_t *wq; - cmnd->SCp.Status |= tsk_status <<1 ; + cmnd->SCp.Status |= tsk_status;set_bit (IO_DONE_BIT , (unsigned long *)&cmnd->SCp.Status); wq = (wait_queue_head_t *) cmnd->SCp.ptr; cmnd->SCp.ptr =NULL ;drivers/scsi/dc395x.c +5
-13@@ -168,7 +168,6 @@#define RES_DRV 0xFF000000/* DRIVER_ codes */ #define MK_RES (drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)) -#define MK_RES_LNX (drv,did,msg,tgt) ((int)(drv)<<24 | (int)(did)<<16 | (int)(msg)<<8 | (int)(tgt)<<1)#define SET_RES_TARGET (who,tgt) { who &= ~RES_TARGET; who |= (int)(tgt); }#define SET_RES_TARGET_LNX (who,tgt) { who &= ~RES_TARGET_LNX; who |= (int)(tgt) << 1; }@@ -3228,7 +3227,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,*/ srb->flag &= ~AUTO_REQSENSE ; srb->adapter_status =0 ; - srb->target_status =CHECK_CONDITION <<1 ; + srb->target_status =SAM_STAT_CHECK_CONDITION ;if (debug_enabled (DBG_1 )) {switch (cmd->sense_buffer[2 ] &0x0f ) {case NOT_READY :@@ -3275,22 +3274,15 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, *((unsigned int *)(cmd->sense_buffer + 3))); } -if (status == (CHECK_CONDITION <<1 )) { +if (status ==SAM_STAT_CHECK_CONDITION ) { cmd->result =DID_BAD_TARGET <<16 ; goto ckc_e; }dprintkdbg (DBG_0 ,"srb_done: AUTO_REQSENSE2\n" ); -if (srb->total_xfer_length - && srb->total_xfer_length >= cmd->underflow) - cmd->result = -MK_RES_LNX (DRIVER_SENSE ,DID_OK , - srb->end_message,CHECK_CONDITION ); -/*SET_RES_DID(cmd->result,DID_OK) */ -else - cmd->result = -MK_RES_LNX (DRIVER_SENSE ,DID_OK , - srb->end_message,CHECK_CONDITION ); + cmd->result = +MK_RES (DRIVER_SENSE ,DID_OK , + srb->end_message,SAM_STAT_CHECK_CONDITION ); goto ckc_e; }drivers/scsi/dpt_i2o.c +1
-1@@ -2656,7 +2656,7 @@ static void adpt_fail_posted_scbs(adpt_hba* pHba)unsigned long flags;spin_lock_irqsave (&d->list_lock, flags);list_for_each_entry (cmd, &d->cmd_list, list) { - cmd->result = (DID_OK <<16 ) | (QUEUE_FULL <<1 ); + cmd->result = (DID_OK <<16 ) |SAM_STAT_TASK_SET_FULL ; cmd->scsi_done (cmd); }spin_unlock_irqrestore (&d->list_lock, flags);drivers/scsi/gdth.c +6
-6@@ -1677,7 +1677,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =NOT_READY ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else @@ -1722,7 +1722,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =UNIT_ATTENTION ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else @@ -1774,7 +1774,7 @@ static void gdth_next(gdth_ha_str *ha)memset ((char *)nscp->sense_buffer,0 ,16 ); nscp->sense_buffer[0 ] =0x70 ; nscp->sense_buffer[2 ] =UNIT_ATTENTION ; - nscp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + nscp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (!nscp_cmndinfo->wait_for_completion) nscp_cmndinfo->wait_for_completion++;else @@ -2802,7 +2802,7 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index,memset ((char *)scp->sense_buffer,0 ,16 ); scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =NOT_READY ; - scp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }else if (service ==CACHESERVICE ) { if (ha->status == S_CACHE_UNKNOWN && (ha->hdr[t].cluster_type &@@ -2812,11 +2812,11 @@ static int gdth_sync_event(gdth_ha_str *ha, int service, u8 index, }memset ((char *)scp->sense_buffer,0 ,16 );if (ha->status == (u16 )S_CACHE_RESERV ) { - scp->result = (DID_OK <<16 ) | (RESERVATION_CONFLICT <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_RESERVATION_CONFLICT ; }else { scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =NOT_READY ; - scp->result = (DID_OK <<16 ) | (CHECK_CONDITION <<1 ); + scp->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }if (!cmndinfo->internal_command) { ha->dvr.size =sizeof (ha->dvr.eu.sync);drivers/scsi/megaraid.c +5
-5@@ -1581,7 +1581,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | - (CHECK_CONDITION <<1 ); +SAM_STAT_CHECK_CONDITION ; }else {if (mbox->m_out.cmd ==MEGA_MBOXCMD_EXTPTHRU ) {@@ -1591,11 +1591,11 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | - (CHECK_CONDITION <<1 ); +SAM_STAT_CHECK_CONDITION ; }else { cmd->sense_buffer[0 ] =0x70 ; cmd->sense_buffer[2 ] =ABORTED_COMMAND ; - cmd->result |= (CHECK_CONDITION <<1 ); + cmd->result |=SAM_STAT_CHECK_CONDITION ; } }break ;@@ -1613,7 +1613,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)*/ if ( cmd->cmnd[0 ] ==TEST_UNIT_READY ) { cmd->result |= (DID_ERROR <<16 ) | - (RESERVATION_CONFLICT <<1 ); +SAM_STAT_RESERVATION_CONFLICT ; }else /* @@ -1625,7 +1625,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status) cmd->cmnd[0] == RELEASE) ) { cmd->result |= (DID_ERROR << 16) | - (RESERVATION_CONFLICT << 1); + SAM_STAT_RESERVATION_CONFLICT; } else#endif drivers/scsi/megaraid/megaraid_mbox.c +6
-6@@ -1577,7 +1577,7 @@ megaraid_mbox_build_cmd(adapter_t *adapter, struct scsi_cmnd *scp, int *busy) scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =ILLEGAL_REQUEST ; scp->sense_buffer[12 ] =MEGA_INVALID_FIELD_IN_CDB ; - scp->result =CHECK_CONDITION <<1 ; + scp->result =SAM_STAT_CHECK_CONDITION ;return NULL ; }@@ -2302,7 +2302,7 @@ megaraid_mbox_dpc(unsigned long devp) 14); scp->result =DRIVER_SENSE <<24 | -DID_OK <<16 |CHECK_CONDITION <<1 ; +DID_OK <<16 |SAM_STAT_CHECK_CONDITION ; }else {if (mbox->cmd ==MBOXCMD_EXTPTHRU ) {@@ -2312,11 +2312,11 @@ megaraid_mbox_dpc(unsigned long devp) scp->result =DRIVER_SENSE <<24 |DID_OK <<16 | -CHECK_CONDITION <<1 ; +SAM_STAT_CHECK_CONDITION ; }else { scp->sense_buffer[0 ] =0x70 ; scp->sense_buffer[2 ] =ABORTED_COMMAND ; - scp->result =CHECK_CONDITION <<1 ; + scp->result =SAM_STAT_CHECK_CONDITION ; } }break ;@@ -2334,7 +2334,7 @@ megaraid_mbox_dpc(unsigned long devp)*/ if (scp->cmnd[0 ] ==TEST_UNIT_READY ) { scp->result =DID_ERROR <<16 | -RESERVATION_CONFLICT <<1 ; +SAM_STAT_RESERVATION_CONFLICT ; }else /* @@ -2345,7 +2345,7 @@ megaraid_mbox_dpc(unsigned long devp) scp->cmnd[0] == RELEASE)) { scp->result = DID_ERROR << 16 | - RESERVATION_CONFLICT << 1; + SAM_STAT_RESERVATION_CONFLICT; } else { scp->result =DID_BAD_TARGET <<16 | status;
Re: [PATCH 05/24] scsi: use standard SAM status codes
Quoted 7 lines · Finn Thain
Quoted 2 lines · Hannes Reinecke
Use standard SAM status codes and omit the explicit shift to convert to linus-specific ones.
"Linux-specific".
Indeed, it was Linus who did that :-)
Will be fixing it up.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
PATCH 6/24 scsi: change status_byte() to return the standard SCSI status
In reply to Hannes ReineckeInstead of returning the linux-special status (which is shifted by 1 to the right) change the status_byte() macro to return the correct SCSI standard status.
And audit all callers to handle this change.
--- drivers/scsi/53c700.c | 6 +++--- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/arm/acornscsi.c | 10 ++++----- drivers/scsi/arm/fas216.c | 10 ++++----- drivers/scsi/dc395x.c | 8 +++----- drivers/scsi/scsi.c | 2 +- drivers/scsi/scsi_error.c | 48 ++++++++++++++++++++++---------------------- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/sg.c | 4 ++-- include/scsi/scsi.h | 2 +- 10 files changed, 46 insertions(+), 48 deletions(-)
drivers/scsi/53c700.c +3 -3
@@ -954,8 +954,8 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp, NCR_700_FINISHED_TAG_NEGOTIATION);/* check for contingent allegiance contitions */ -if (status_byte (hostdata->status[0 ]) ==CHECK_CONDITION || -status_byte (hostdata->status[0 ]) ==COMMAND_TERMINATED ) { +if (status_byte (hostdata->status[0 ]) ==SAM_STAT_CHECK_CONDITION || +status_byte (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 ) {
@@ -1021,7 +1021,7 @@ process_script_interrupt(__u32 dsps, __u32 dsp, struct scsi_cmnd *SCp,// Currently rely on the mid layer evaluation // of the tag queuing capability // -//if(status_byte(hostdata->status[0]) == GOOD && +//if(status_byte(hostdata->status[0]) == SAM_STAT_GOOD && // SCp->cmnd[0] == INQUIRY && SCp->use_sg == 0) { // /* Piggy back the tag queueing support // * on this command */
drivers/scsi/NCR5380.c +1 -1
@@ -522,7 +522,7 @@ static void complete_cmd(struct Scsi_Host *instance,if (hostdata->sensing == cmd) {/* Autosense processing ends here */ -if (status_byte (cmd->result) !=GOOD ) { +if (status_byte (cmd->result) !=SAM_STAT_GOOD ) {scsi_eh_restore_cmnd (cmd, &hostdata->ses); }else {scsi_eh_restore_cmnd (cmd, &hostdata->ses);
drivers/scsi/arm/acornscsi.c +5 -5
@@ -834,11 +834,11 @@ static void acornscsi_done(AS_Host *host, struct scsi_cmnd **SCpntp,if (xfer_warn) {switch (status_byte (SCpnt->result)) { -case CHECK_CONDITION : -case COMMAND_TERMINATED : -case BUSY : -case QUEUE_FULL : -case RESERVATION_CONFLICT : +case SAM_STAT_CHECK_CONDITION : +case SAM_STAT_COMMAND_TERMINATED : +case SAM_STAT_BUSY : +case SAM_STAT_TASK_SET_FULL : +case SAM_STAT_RESERVATION_CONFLICT :break ;default :
drivers/scsi/arm/fas216.c +5 -5
@@ -2056,18 +2056,18 @@ fas216_std_done(FAS216_Info *info, struct scsi_cmnd *SCpnt, unsigned int result) goto done;/* -* If the command returned CHECK_CONDITION or COMMAND_TERMINATED -* status, request the sense information. +* If the command returned SAM_STAT_CHECK_CONDITION or +* SAM_STAT_COMMAND_TERMINATED status, request the sense information. */ -if (status_byte (SCpnt->result) ==CHECK_CONDITION || -status_byte (SCpnt->result) ==COMMAND_TERMINATED ) +if (status_byte (SCpnt->result) ==SAM_STAT_CHECK_CONDITION || +status_byte (SCpnt->result) ==SAM_STAT_COMMAND_TERMINATED ) goto request_sense;/* * If the command did not complete with GOOD status, * we are all done here. */ -if (status_byte (SCpnt->result) !=GOOD ) +if (status_byte (SCpnt->result) !=SAM_STAT_GOOD ) goto done;/*
drivers/scsi/dc395x.c +3 -5
@@ -3292,10 +3292,10 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,/* * target status.......................... */ -if (status_byte (status) ==CHECK_CONDITION ) { +if (status_byte (status) ==SAM_STAT_CHECK_CONDITION ) {request_sense (acb, dcb, srb);return ; - }else if (status_byte (status) ==QUEUE_FULL ) { + }else if (status_byte (status) ==SAM_STAT_TASK_SET_FULL ) { tempcnt = (u8 )list_size (&dcb->srb_going_list);dprintkl (KERN_INFO ,"QUEUE_FULL for dev <%02i-%i> with %i cmnds\n" , dcb->target_id, dcb->target_lun, tempcnt);
@@ -3361,10 +3361,8 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb, && dir != PCI_DMA_NONE && ptr && (ptr->Vers & 0x07) >= 2) dcb->inquiry7 = ptr->Flags; -/*if( srb->cmd->cmnd[0] == INQUIRY && */ -/* (host_byte(cmd->result) == DID_OK || status_byte(cmd->result) & CHECK_CONDITION) ) */ if ((cmd->result == (DID_OK <<16 ) || -status_byte (cmd->result) ==CHECK_CONDITION )) { +status_byte (cmd->result) ==SAM_STAT_CHECK_CONDITION )) {if (!dcb->init_tcq_flag) {add_dev (acb, dcb, ptr); dcb->init_tcq_flag =1 ;
drivers/scsi/scsi.c +1 -1
@@ -158,7 +158,7 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition) (level > 1)) {scsi_print_result (cmd,"Done" , disposition);scsi_print_command (cmd); -if (status_byte (cmd->result) ==CHECK_CONDITION ) +if (status_byte (cmd->result) ==SAM_STAT_CHECK_CONDITION )scsi_print_sense (cmd);if (level >3 ) scmd_printk(KERN_INFO, cmd,
drivers/scsi/scsi_error.c +24 -24
129 lines not on this page · raw message
drivers/scsi/scsi_lib.c +1 -1
@@ -2180,7 +2180,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, data->block_descriptor_length = buffer[3 ]; } data->header_length = header_length; - }else if ((status_byte (result) ==CHECK_CONDITION ) && + }else if ((status_byte (result) ==SAM_STAT_CHECK_CONDITION ) &&scsi_sense_valid (sshdr) && sshdr->sense_key ==UNIT_ATTENTION && retry_count) { retry_count--;
drivers/scsi/sg.c +2 -2
@@ -1349,8 +1349,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status)if (0 != result) {struct scsi_sense_hdr sshdr; - srp->header.status =0xff & result; - srp->header.masked_status =status_byte (result); + srp->header.status =status_byte (result); + srp->header.masked_status =status_byte (result) >>1 ; srp->header.msg_status =msg_byte (result); srp->header.host_status =host_byte (result); srp->header.driver_status =driver_byte (result);
include/scsi/scsi.h +1 -1
@@ -207,7 +207,7 @@ static inline int scsi_is_wlun(u64 lun)* host_byte = set by low-level driver to indicate status. * driver_byte = set by mid-level. */ -#define status_byte (result) (((result) >> 1) & 0x7f) +#define status_byte (result) (((result)) & 0xff)#define msg_byte (result) (((result) >> 8) & 0xff)#define host_byte (result) (((result) >> 16) & 0xff)#define driver_byte (result) (((result) >> 24) & 0xff)
Signature · 1 line
2.16.4
Re: [PATCH 06/24] scsi: change status_byte() to return the standard SCSI status
Quoted 23 lines · Hannes Reinecke
Instead of returning the linux-special status (which is shifted by 1 to the right) change the
status_byte()macro to return the correct SCSI standard status.
And audit all callers to handle this change.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/scsi/53c700.c | 6 +++--- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/arm/acornscsi.c | 10 ++++----- drivers/scsi/arm/fas216.c | 10 ++++----- drivers/scsi/dc395x.c | 8 +++----- drivers/scsi/scsi.c | 2 +- drivers/scsi/scsi_error.c | 48 ++++++++++++++++++++++---------------------- drivers/scsi/scsi_lib.c | 2 +- drivers/scsi/sg.c | 4 ++-- include/scsi/scsi.h | 2 +- 10 files changed, 46 insertions(+), 48 deletions(-)include/scsi/scsi.h +0
-0
include/scsi/scsi.h static inline int scsi_is_wlun(u64 lun) · line 210
Quoted 5 lines
include/scsi/scsi.h +1
-1@@ -207,7 +207,7 @@ static inline int scsi_is_wlun(u64 lun)* host_byte = set by low-level driver to indicate status. * driver_byte = set by mid-level. */ -#define status_byte (result) (((result) >> 1) & 0x7f) +#define status_byte (result) (((result)) & 0xff)
drop the now unnecessary additional parentheses pair around (result)?:
+#define status_byte(result) ((result) & 0xff)
Quoted 4 lines
include/scsi/scsi.h +0
-0#define msg_byte (result) (((result) >> 8) & 0xff)#define host_byte (result) (((result) >> 16) & 0xff)#define driver_byte (result) (((result) >> 24) & 0xff)
Signature · 11 lines
Mit freundlichen Gruessen / Kind regards Steffen Maier Linux on IBM Z Development https://www.ibm.com/privacy/us/en/ IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Matthias Hartmann Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH 7/24 target_core: Fixup target_complete_cmd() usage
In reply to Hannes Reinecketarget_complete_cmd() occasionally still uses the linux-specific SCSI result values; fix it up to use SAM result values throughout.
--- drivers/target/target_core_alua.c | 6 +++--- drivers/target/target_core_iblock.c | 2 +- drivers/target/target_core_pr.c | 8 ++++---- drivers/target/target_core_sbc.c | 10 +++++----- drivers/target/target_core_spc.c | 14 +++++++------- drivers/target/target_core_xcopy.c | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-)
drivers/target/target_core_alua.c +3 -3
@@ -123,7 +123,7 @@ target_emulate_report_referrals(struct se_cmd *cmd)transport_kunmap_data_sg (cmd); -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
@@ -255,7 +255,7 @@ target_emulate_report_target_port_groups(struct se_cmd *cmd) }transport_kunmap_data_sg (cmd); -target_complete_cmd_with_length (cmd,GOOD , rd_len +4 ); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD , rd_len +4 );return 0 ; }
@@ -424,7 +424,7 @@ target_emulate_set_target_port_groups(struct se_cmd *cmd) out:transport_kunmap_data_sg (cmd);if (!rc) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return rc; }
drivers/target/target_core_iblock.c +1 -1
@@ -436,7 +436,7 @@ iblock_execute_zero_out(struct block_device *bdev, struct se_cmd *cmd)if (ret)return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ; -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
drivers/target/target_core_pr.c +4 -4
@@ -234,7 +234,7 @@ target_scsi2_reservation_release(struct se_cmd *cmd) out_unlock:spin_unlock (&dev->dev_reservation_lock); out: -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
@@ -297,7 +297,7 @@ target_scsi2_reservation_reserve(struct se_cmd *cmd)spin_unlock (&dev->dev_reservation_lock); out:if (!ret) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return ret; }
@@ -3680,7 +3680,7 @@ target_scsi3_emulate_pr_out(struct se_cmd *cmd) }if (!ret) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return ret; }
@@ -4070,7 +4070,7 @@ target_scsi3_emulate_pr_in(struct se_cmd *cmd) }if (!ret) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return ret; }
drivers/target/target_core_sbc.c +5 -5
@@ -67,7 +67,7 @@ sbc_emulate_readcapacity(struct se_cmd *cmd)transport_kunmap_data_sg (cmd); } -target_complete_cmd_with_length (cmd,GOOD ,8 ); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD ,8 );return 0 ; }
@@ -130,7 +130,7 @@ sbc_emulate_readcapacity_16(struct se_cmd *cmd)transport_kunmap_data_sg (cmd); } -target_complete_cmd_with_length (cmd,GOOD ,32 ); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD ,32 );return 0 ; }
@@ -202,14 +202,14 @@ sbc_execute_write_same_unmap(struct se_cmd *cmd)return ret; } -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }static sense_reason_t sbc_emulate_noop (struct se_cmd *cmd) { -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
@@ -1214,7 +1214,7 @@ sbc_execute_unmap(struct se_cmd *cmd) err:transport_kunmap_data_sg (cmd);if (!ret) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return ret; }
drivers/target/target_core_spc.c +7 -7
@@ -754,7 +754,7 @@ spc_emulate_inquiry(struct se_cmd *cmd)kfree (buf);if (!ret) -target_complete_cmd_with_length (cmd,GOOD , len); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD , len);return ret; }
@@ -1099,7 +1099,7 @@ static sense_reason_t spc_emulate_modesense(struct se_cmd *cmd)transport_kunmap_data_sg (cmd); } -target_complete_cmd_with_length (cmd,GOOD , length); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD , length);return 0 ; }
@@ -1117,7 +1117,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)int i;if (!cmd->data_length) { -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
@@ -1160,7 +1160,7 @@ static sense_reason_t spc_emulate_modeselect(struct se_cmd *cmd)transport_kunmap_data_sg (cmd);if (!ret) -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return ret; }
@@ -1193,7 +1193,7 @@ static sense_reason_t spc_emulate_request_sense(struct se_cmd *cmd)memcpy (rbuf, buf,min_t (u32,sizeof (buf), cmd->data_length));transport_kunmap_data_sg (cmd); -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
@@ -1260,7 +1260,7 @@ sense_reason_t spc_emulate_report_luns(struct se_cmd *cmd)transport_kunmap_data_sg (cmd); } -target_complete_cmd_with_length (cmd,GOOD ,8 + lun_count *8 ); +target_complete_cmd_with_length (cmd,SAM_STAT_GOOD ,8 + lun_count *8 );return 0 ; }EXPORT_SYMBOL (spc_emulate_report_luns);
@@ -1268,7 +1268,7 @@ EXPORT_SYMBOL(spc_emulate_report_luns);static sense_reason_t spc_emulate_testunitready (struct se_cmd *cmd) { -target_complete_cmd (cmd,GOOD ); +target_complete_cmd (cmd,SAM_STAT_GOOD );return 0 ; }
drivers/target/target_core_xcopy.c +1 -1
@@ -1043,7 +1043,7 @@ static sense_reason_t target_rcr_operating_parameters(struct se_cmd *se_cmd)put_unaligned_be32 (42 , &p[0 ]);transport_kunmap_data_sg (se_cmd); -target_complete_cmd (se_cmd,GOOD ); +target_complete_cmd (se_cmd,SAM_STAT_GOOD );return TCM_NO_SENSE ; }
Signature · 1 line
2.16.4
PATCH 8/24 sg: use SAM status definitions and avoid using masked_status
In reply to Hannes ReineckeUse standard SAM status definitions and avoid using masked status values.
--- drivers/scsi/sg.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/scsi/sg.c +7 -7
@@ -503,7 +503,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) old_hdr->target_status = hp->masked_status; old_hdr->host_status = hp->host_status; old_hdr->driver_status = hp->driver_status; -if ((CHECK_CONDITION & hp->masked_status) || +if ((SAM_STAT_CHECK_CONDITION & hp->status) || (DRIVER_SENSE & hp->driver_status))memcpy (old_hdr->sense_buffer, srp->sense_b,sizeof (old_hdr->sense_buffer));
@@ -529,7 +529,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)break ;case DID_ERROR : old_hdr->result = (srp->sense_b[0 ] ==0 && - hp->masked_status ==GOOD ) ?0 :EIO ; + hp->status ==SAM_STAT_GOOD ) ?0 :EIO ;break ;default : old_hdr->result =EIO ;
@@ -574,7 +574,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) } hp->sb_len_wr =0 ;if ((hp->mx_sb_len >0 ) && hp->sbp) { -if ((CHECK_CONDITION & hp->masked_status) || +if ((SAM_STAT_CHECK_CONDITION & hp->status) || (DRIVER_SENSE & hp->driver_status)) {int sb_len =SCSI_SENSE_BUFFERSIZE ; sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len;
@@ -587,7 +587,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) hp->sb_len_wr = len; } } -if (hp->masked_status || hp->host_status || hp->driver_status) +if (hp->status || hp->host_status || hp->driver_status) hp->info |=SG_INFO_CHECK ;if (copy_to_user (buf, hp,SZ_SG_IO_HDR )) { err = -EFAULT ;
@@ -873,7 +873,7 @@ sg_fill_request_table(Sg_fd *sfp, sg_req_info_t *rinfo)break ; rinfo[val].req_state = srp->done +1 ; rinfo[val].problem = - srp->header.masked_status & + srp->header.status & srp->header.host_status & srp->header.driver_status;if (srp->done)
@@ -1355,8 +1355,8 @@ sg_rq_end_io(struct request *rq, blk_status_t status) srp->header.host_status =host_byte (result); srp->header.driver_status =driver_byte (result);if ((sdp->sgdebug >0 ) && - ((CHECK_CONDITION == srp->header.masked_status) || - (COMMAND_TERMINATED == srp->header.masked_status))) + ((SAM_STAT_CHECK_CONDITION == srp->header.status) || + (SAM_STAT_COMMAND_TERMINATED == srp->header.status)))__scsi_print_sense (sdp->device, __func__, sense,SCSI_SENSE_BUFFERSIZE );
Signature · 1 line
2.16.4
PATCH 9/24 scsi: Kill obsolete linux-specific status codes
In reply to Hannes ReineckeAfter several years it's time to finally kill them.
--- include/scsi/scsi_proto.h | 19 ------------------- 1 file changed, 19 deletions(-)
include/scsi/scsi_proto.h +0 -19
@@ -202,25 +202,6 @@ struct scsi_varlen_cdb_hdr {#define SAM_STAT_ACA_ACTIVE 0x30#define SAM_STAT_TASK_ABORTED 0x40 -/* -* Status codes. These are deprecated as they are shifted 1 bit right -* from those found in the SCSI standards. This causes confusion for -* applications that are ported to several OSes. Prefer SAM Status codes -* above. -*/ - -#define GOOD 0x00 -#define CHECK_CONDITION 0x01 -#define CONDITION_GOOD 0x02 -#define BUSY 0x04 -#define INTERMEDIATE_GOOD 0x08 -#define INTERMEDIATE_C_GOOD 0x0a -#define RESERVATION_CONFLICT 0x0c -#define COMMAND_TERMINATED 0x11 -#define QUEUE_FULL 0x14 -#define ACA_ACTIVE 0x18 -#define TASK_ABORTED 0x20 -#define STATUS_MASK 0xfe/*
Signature · 1 line
2.16.4
kbuild test robot
build botRe: [PATCH 09/24] scsi: Kill obsolete linux-specific status codes
I love your patch! Yet something to improve:
Hi Hannes,
I love your patch! Yet something to improve:
[auto build test ERROR on mkp-scsi/for-next]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Hannes-Reinecke/scsi-Revamp-result-values/20191022-004918 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: sh-allmodconfig (attached as .config) compiler: sh4-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sh
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/scsi/pcmcia/nsp_cs.c: In function 'nsp_queuecommand_lck':
>> drivers/scsi/pcmcia/nsp_cs.c:226:22: error: 'CHECK_CONDITION' undeclared (first use in this function); did you mean 'SEC_CONVERSION'?
SCpnt->SCp.Status = CHECK_CONDITION;
^~~~~~~~~~~~~~~
SEC_CONVERSION drivers/scsi/pcmcia/nsp_cs.c:226:22: note: each undeclared identifier is reported only once for each function it appears in
vim +226 drivers/scsi/pcmcia/nsp_cs.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 221
^1da177e4c3f41 Linus Torvalds 2005-04-16 222 show_command(SCpnt);
^1da177e4c3f41 Linus Torvalds 2005-04-16 223
^1da177e4c3f41 Linus Torvalds 2005-04-16 224 data->CurrentSC = SCpnt;
^1da177e4c3f41 Linus Torvalds 2005-04-16 225
^1da177e4c3f41 Linus Torvalds 2005-04-16 @226 SCpnt->SCp.Status = CHECK_CONDITION;
^1da177e4c3f41 Linus Torvalds 2005-04-16 227 SCpnt->SCp.Message = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 228 SCpnt->SCp.have_data_in = IO_UNKNOWN;
^1da177e4c3f41 Linus Torvalds 2005-04-16 229 SCpnt->SCp.sent_command = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 230 SCpnt->SCp.phase = PH_UNDETERMINED;
040cd23242413a Boaz Harrosh 2007-08-16 231 scsi_set_resid(SCpnt, scsi_bufflen(SCpnt));
^1da177e4c3f41 Linus Torvalds 2005-04-16 232
^1da177e4c3f41 Linus Torvalds 2005-04-16 233 /* setup scratch area
^1da177e4c3f41 Linus Torvalds 2005-04-16 234 SCp.ptr : buffer pointer
^1da177e4c3f41 Linus Torvalds 2005-04-16 235 SCp.this_residual : buffer length
^1da177e4c3f41 Linus Torvalds 2005-04-16 236 SCp.buffer : next buffer
^1da177e4c3f41 Linus Torvalds 2005-04-16 237 SCp.buffers_residual : left buffers in list
^1da177e4c3f41 Linus Torvalds 2005-04-16 238 SCp.phase : current state of the command */
040cd23242413a Boaz Harrosh 2007-08-16 239 if (scsi_bufflen(SCpnt)) {
040cd23242413a Boaz Harrosh 2007-08-16 240 SCpnt->SCp.buffer = scsi_sglist(SCpnt);
^1da177e4c3f41 Linus Torvalds 2005-04-16 241 SCpnt->SCp.ptr = BUFFER_ADDR;
^1da177e4c3f41 Linus Torvalds 2005-04-16 242 SCpnt->SCp.this_residual = SCpnt->SCp.buffer->length;
040cd23242413a Boaz Harrosh 2007-08-16 243 SCpnt->SCp.buffers_residual = scsi_sg_count(SCpnt) - 1;
^1da177e4c3f41 Linus Torvalds 2005-04-16 244 } else {
040cd23242413a Boaz Harrosh 2007-08-16 245 SCpnt->SCp.ptr = NULL;
040cd23242413a Boaz Harrosh 2007-08-16 246 SCpnt->SCp.this_residual = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 247 SCpnt->SCp.buffer = NULL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 248 SCpnt->SCp.buffers_residual = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 249 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 250
^1da177e4c3f41 Linus Torvalds 2005-04-16 251 if (nsphw_start_selection(SCpnt) == FALSE) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 252 nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "selection fail");
^1da177e4c3f41 Linus Torvalds 2005-04-16 253 SCpnt->result = DID_BUS_BUSY << 16;
^1da177e4c3f41 Linus Torvalds 2005-04-16 254 nsp_scsi_done(SCpnt);
^1da177e4c3f41 Linus Torvalds 2005-04-16 255 return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 256 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 257
^1da177e4c3f41 Linus Torvalds 2005-04-16 258
^1da177e4c3f41 Linus Torvalds 2005-04-16 259 //nsp_dbg(NSP_DEBUG_QUEUECOMMAND, "out");
^1da177e4c3f41 Linus Torvalds 2005-04-16 260 #ifdef NSP_DEBUG
^1da177e4c3f41 Linus Torvalds 2005-04-16 261 data->CmdId++;
^1da177e4c3f41 Linus Torvalds 2005-04-16 262 #endif
^1da177e4c3f41 Linus Torvalds 2005-04-16 263 return 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16 264 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 265 :::::: The code at line 226 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH 09/24] scsi: Kill obsolete linux-specific status codes
In reply to Hannes ReineckeI love your patch! Yet something to improve:
Hi Hannes,
I love your patch! Yet something to improve:
[auto build test ERROR on mkp-scsi/for-next]
[cannot apply to v5.4-rc4 next-20191021]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Hannes-Reinecke/scsi-Revamp-result-values/20191022-004918 base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next config: powerpc-defconfig (attached as .config) compiler: powerpc64-linux-gcc (GCC) 7.4.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=powerpc
If you fix the issue, kindly add following tag
All errors (new ones prefixed by >>):
drivers/scsi/ibmvscsi/ibmvscsi.c: In function 'handle_cmd_rsp':
>> drivers/scsi/ibmvscsi/ibmvscsi.c:989:39: error: 'CHECK_CONDITION' undeclared (first use in this function); did you mean 'H_MR_CONDITION'?
if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION)
^~~~~~~~~~~~~~~
H_MR_CONDITION drivers/scsi/ibmvscsi/ibmvscsi.c:989:39: note: each undeclared identifier is reported only once for each function it appears in
vim +989 drivers/scsi/ibmvscsi/ibmvscsi.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 968
^1da177e4c3f41 Linus Torvalds 2005-04-16 969 /**
^1da177e4c3f41 Linus Torvalds 2005-04-16 970 * handle_cmd_rsp: - Handle responses from commands
^1da177e4c3f41 Linus Torvalds 2005-04-16 971 * @evt_struct: srp_event_struct to be handled
^1da177e4c3f41 Linus Torvalds 2005-04-16 972 *
^1da177e4c3f41 Linus Torvalds 2005-04-16 973 * Used as a callback by when sending scsi cmds.
^1da177e4c3f41 Linus Torvalds 2005-04-16 974 * Gets called by ibmvscsi_handle_crq()
^1da177e4c3f41 Linus Torvalds 2005-04-16 975 */
^1da177e4c3f41 Linus Torvalds 2005-04-16 976 static void handle_cmd_rsp(struct srp_event_struct *evt_struct)
^1da177e4c3f41 Linus Torvalds 2005-04-16 977 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 978 struct srp_rsp *rsp = &evt_struct->xfer_iu->srp.rsp;
^1da177e4c3f41 Linus Torvalds 2005-04-16 979 struct scsi_cmnd *cmnd = evt_struct->cmnd;
^1da177e4c3f41 Linus Torvalds 2005-04-16 980
ef265673434680 FUJITA Tomonori 2006-03-26 981 if (unlikely(rsp->opcode != SRP_RSP)) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 982 if (printk_ratelimit())
6c0a60ec52042e Brian King 2007-06-13 983 dev_warn(evt_struct->hostdata->dev,
15c9274699e8b6 Tyrel Datwyler 2016-12-07 984 "bad SRP RSP type %#02x\n", rsp->opcode);
^1da177e4c3f41 Linus Torvalds 2005-04-16 985 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 986
^1da177e4c3f41 Linus Torvalds 2005-04-16 987 if (cmnd) {
c3a3b55ae80a0d Brian King 2008-04-25 988 cmnd->result |= rsp->status;
^1da177e4c3f41 Linus Torvalds 2005-04-16 @989 if (((cmnd->result >> 1) & 0x1f) == CHECK_CONDITION)
^1da177e4c3f41 Linus Torvalds 2005-04-16 990 memcpy(cmnd->sense_buffer,
ef265673434680 FUJITA Tomonori 2006-03-26 991 rsp->data,
72264eb6dbb909 Anton Blanchard 2013-09-03 992 be32_to_cpu(rsp->sense_data_len));
^1da177e4c3f41 Linus Torvalds 2005-04-16 993 unmap_cmd_data(&evt_struct->iu.srp.cmd,
4dddbc26c3895e James Bottomley 2005-09-06 994 evt_struct,
^1da177e4c3f41 Linus Torvalds 2005-04-16 995 evt_struct->hostdata->dev);
^1da177e4c3f41 Linus Torvalds 2005-04-16 996
ef265673434680 FUJITA Tomonori 2006-03-26 997 if (rsp->flags & SRP_RSP_FLAG_DOOVER)
72264eb6dbb909 Anton Blanchard 2013-09-03 998 scsi_set_resid(cmnd,
72264eb6dbb909 Anton Blanchard 2013-09-03 999 be32_to_cpu(rsp->data_out_res_cnt));
ef265673434680 FUJITA Tomonori 2006-03-26 1000 else if (rsp->flags & SRP_RSP_FLAG_DIOVER)
72264eb6dbb909 Anton Blanchard 2013-09-03 1001 scsi_set_resid(cmnd, be32_to_cpu(rsp->data_in_res_cnt));
^1da177e4c3f41 Linus Torvalds 2005-04-16 1002 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1003
^1da177e4c3f41 Linus Torvalds 2005-04-16 1004 if (evt_struct->cmnd_done)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1005 evt_struct->cmnd_done(cmnd);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1006 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1007 :::::: The code at line 989 was first introduced by commit :::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2
:::::: TO: Linus Torvalds <[email protected]> :::::: CC: Linus Torvalds <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH 10/24 scsi: introduce set_status_byte()
In reply to Hannes ReineckeTo be in-line with the other set_XX_byte() functions.
--- include/scsi/scsi_cmnd.h | 5 +++++ 1 file changed, 5 insertions(+)
include/scsi/scsi_cmnd.h +5 -0
@@ -307,6 +307,11 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)#define scsi_for_each_prot_sg (cmd, sg, nseg, __i) \ for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i) +static inline void set_status_byte (struct scsi_cmnd *cmd,char status) +{ + cmd->result = (cmd->result &0xffffff00 ) | status; +} +static inline void set_msg_byte (struct scsi_cmnd *cmd,char status) { cmd->result = (cmd->result &0xffff00ff ) | (status <<8 );
Signature · 1 line
2.16.4
Re: [PATCH 10/24] scsi: introduce set_status_byte()
Quoted 12 lines · Hannes Reinecke
To be in-line with the other
set_XX_byte()functions.Signed-off-by Hannes Reinecke <[email protected]>--- include/scsi/scsi_cmnd.h | 5 +++++ 1 file changed, 5 insertions(+)include/scsi/scsi_cmnd.h +0
-0
include/scsi/scsi_cmnd.h static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd) · line 312
Quoted 6 lines
include/scsi/scsi_cmnd.h +3
-0@@ -307,6 +307,11 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)#define scsi_for_each_prot_sg (cmd, sg, nseg, __i) \ for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i) +static inline void set_status_byte (struct scsi_cmnd *cmd,char status) +{ + cmd->result = (cmd->result &0xffffff00 ) | status;
Is sign-extension desirable here? Do callers need it?
Quoted 6 lines
include/scsi/scsi_cmnd.h +2
-0+} +static inline void set_msg_byte (struct scsi_cmnd *cmd,char status) { cmd->result = (cmd->result &0xffff00ff ) | (status <<8 );
Re: [PATCH 10/24] scsi: introduce set_status_byte()
Quoted 17 lines · Finn Thain
Quoted 15 lines · Hannes Reinecke
To be in-line with the other
set_XX_byte()functions.Signed-off-by Hannes Reinecke <[email protected]>--- include/scsi/scsi_cmnd.h | 5 +++++ 1 file changed, 5 insertions(+)include/scsi/scsi_cmnd.h +0
-0@@ -307,6 +307,11 @@ static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd)#define scsi_for_each_prot_sg (cmd, sg, nseg, __i) \ for_each_sg(scsi_prot_sglist(cmd), sg, nseg, __i)
Quoted 6 lines
include/scsi/scsi_cmnd.h static inline struct scsi_data_buffer *scsi_prot(struct scsi_cmnd *cmd) · line 312
Quoted 3 lines
include/scsi/scsi_cmnd.h +3
-0+static inline void set_status_byte (struct scsi_cmnd *cmd,char status) +{ + cmd->result = (cmd->result &0xffffff00 ) | status;Is sign-extension desirable here? Do callers need it?
It'll be a theoretical issue, as a status value with the top bit set would be invalid anyway.
But for consistencies sake I'll make it an unsigned char in the next iteration.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
PATCH 11/24 advansys: kill driver_defined status byte accessors
In reply to Hannes ReineckeReplace the driver-defined status byte accessors by the mid-layer defined ones.
--- drivers/scsi/advansys.c | 78 +++++++++++++------------------------------------ 1 file changed, 20 insertions(+), 58 deletions(-)
drivers/scsi/advansys.c +20 -58
@@ -2085,12 +2085,6 @@ do { \#define ASC_BUSY 0#define ASC_ERROR (-1) -/* struct scsi_cmnd function return codes */ -#define STATUS_BYTE (byte) (byte) -#define MSG_BYTE (byte) ((byte) << 8) -#define HOST_BYTE (byte) ((byte) << 16) -#define DRIVER_BYTE (byte) ((byte) << 24) -#define ASC_STATS (shost, counter) ASC_STATS_ADD(shost, counter, 1)#ifndef ADVANSYS_STATS #define ASC_STATS_ADD (shost, counter, count)
@@ -6021,43 +6015,28 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)ASC_DBG (2 ,"SAM_STAT_CHECK_CONDITION\n" );ASC_DBG_PRT_SENSE (2 , scp->sense_buffer,SCSI_SENSE_BUFFERSIZE ); -/* -* Note: The 'status_byte()' macro used by -* target drivers defined in scsi.h shifts the -* status byte returned by host drivers right -* by 1 bit. This is why target drivers also -* use right shifted status byte definitions. -* For instance target drivers use -* CHECK_CONDITION, defined to 0x1, instead of -* the SCSI defined check condition value of -* 0x2. Host drivers are supposed to return -* the status byte as it is defined by SCSI. -*/ - scp->result =DRIVER_BYTE (DRIVER_SENSE ) | -STATUS_BYTE (scsiqp->scsi_status); - }else { - scp->result =STATUS_BYTE (scsiqp->scsi_status); } + scp->result =status_byte (scsiqp->scsi_status);break ;default :/* Some other QHSTA error occurred. */ ASC_DBG (1 ,"host_status 0x%x\n" , scsiqp->host_status); - scp->result =HOST_BYTE (DID_BAD_TARGET ); + scp->result =host_byte (DID_BAD_TARGET );break ; }break ;case QD_ABORTED_BY_HOST :ASC_DBG (1 ,"QD_ABORTED_BY_HOST\n" ); - scp->result = -HOST_BYTE (DID_ABORT ) |STATUS_BYTE (scsiqp->scsi_status); + scp->result =host_byte (DID_ABORT ); +set_status_byte (scp, scsiqp->scsi_status);break ;default :ASC_DBG (1 ,"done_status 0x%x\n" , scsiqp->done_status); - scp->result = -HOST_BYTE (DID_ERROR ) |STATUS_BYTE (scsiqp->scsi_status); + scp->result =host_byte (DID_ERROR ); +set_status_byte (scp, scsiqp->scsi_status);break ; }
@@ -6789,47 +6768,30 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)ASC_DBG (2 ,"SAM_STAT_CHECK_CONDITION\n" );ASC_DBG_PRT_SENSE (2 , scp->sense_buffer,SCSI_SENSE_BUFFERSIZE ); -/* -* Note: The 'status_byte()' macro used by -* target drivers defined in scsi.h shifts the -* status byte returned by host drivers right -* by 1 bit. This is why target drivers also -* use right shifted status byte definitions. -* For instance target drivers use -* CHECK_CONDITION, defined to 0x1, instead of -* the SCSI defined check condition value of -* 0x2. Host drivers are supposed to return -* the status byte as it is defined by SCSI. -*/ - scp->result =DRIVER_BYTE (DRIVER_SENSE ) | -STATUS_BYTE (qdonep->d3.scsi_stat); - }else { - scp->result =STATUS_BYTE (qdonep->d3.scsi_stat); } + scp->result =status_byte (qdonep->d3.scsi_stat);break ;default :/* QHSTA error occurred */ ASC_DBG (1 ,"host_stat 0x%x\n" , qdonep->d3.host_stat); - scp->result =HOST_BYTE (DID_BAD_TARGET ); + scp->result =host_byte (DID_BAD_TARGET );break ; }break ;case QD_ABORTED_BY_HOST :ASC_DBG (1 ,"QD_ABORTED_BY_HOST\n" ); - scp->result = -HOST_BYTE (DID_ABORT ) |MSG_BYTE (qdonep->d3. - scsi_msg) | -STATUS_BYTE (qdonep->d3.scsi_stat); + scp->result =host_byte (DID_ABORT ); +set_msg_byte (scp, qdonep->d3.scsi_msg); +set_status_byte (scp, qdonep->d3.scsi_stat);break ;default :ASC_DBG (1 ,"done_stat 0x%x\n" , qdonep->d3.done_stat); - scp->result = -HOST_BYTE (DID_ERROR ) |MSG_BYTE (qdonep->d3. - scsi_msg) | -STATUS_BYTE (qdonep->d3.scsi_stat); + scp->result =host_byte (DID_ERROR ); +set_msg_byte (scp, qdonep->d3.scsi_msg); +set_status_byte (scp, qdonep->d3.scsi_stat);break ; }
@@ -7568,7 +7530,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,"sg_tablesize %d\n" , use_sg, scp->device->host->sg_tablesize);scsi_dma_unmap (scp); - scp->result =HOST_BYTE (DID_ERROR ); + scp->result =host_byte (DID_ERROR );return ASC_ERROR ; }
@@ -7576,7 +7538,7 @@ static int asc_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, use_sg * sizeof(struct asc_sg_list), GFP_ATOMIC);if (!asc_sg_head) {scsi_dma_unmap (scp); - scp->result =HOST_BYTE (DID_SOFT_ERROR ); + scp->result =host_byte (DID_SOFT_ERROR );return ASC_ERROR ; }
@@ -7819,7 +7781,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp,"ADV_MAX_SG_LIST %d\n" , use_sg, scp->device->host->sg_tablesize);scsi_dma_unmap (scp); - scp->result =HOST_BYTE (DID_ERROR ); + scp->result =host_byte (DID_ERROR ); reqp->cmndp =NULL ; scp->host_scribble =NULL ;
@@ -7831,7 +7793,7 @@ adv_build_req(struct asc_board *boardp, struct scsi_cmnd *scp, ret =adv_get_sglist (boardp, reqp, scsiqp, scp, use_sg);if (ret !=ADV_SUCCESS ) {scsi_dma_unmap (scp); - scp->result =HOST_BYTE (DID_ERROR ); + scp->result =host_byte (DID_ERROR ); reqp->cmndp =NULL ; scp->host_scribble =NULL ;
@@ -8528,13 +8490,13 @@ static int asc_execute_scsi_cmnd(struct scsi_cmnd *scp)scmd_printk (KERN_ERR , scp,"ExeScsiQueue() ASC_ERROR, " "err_code 0x%x\n" , err_code);ASC_STATS (scp->device->host, exe_error); - scp->result =HOST_BYTE (DID_ERROR ); + scp->result =host_byte (DID_ERROR );break ;default :scmd_printk (KERN_ERR , scp,"ExeScsiQueue() unknown, " "err_code 0x%x\n" , err_code);ASC_STATS (scp->device->host, exe_unknown); - scp->result =HOST_BYTE (DID_ERROR ); + scp->result =host_byte (DID_ERROR );break ; }
Signature · 1 line
2.16.4
Bart Van Assche
maintainerRe: [PATCH 11/24] advansys: kill driver_defined status byte accessors
Quoted 13 lines · Hannes Reinecke
drivers/scsi/advansys.c +0
-9@@ -6021,43 +6015,28 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp)ASC_DBG (2 ,"SAM_STAT_CHECK_CONDITION\n" );ASC_DBG_PRT_SENSE (2 , scp->sense_buffer,SCSI_SENSE_BUFFERSIZE ); -/* -* Note: The 'status_byte()' macro used by -* target drivers defined in scsi.h shifts the -* status byte returned by host drivers right -* by 1 bit. This is why target drivers also -* use right shifted status byte definitions. -* For instance target drivers use -* CHECK_CONDITION, defined to 0x1, instead of -* the SCSI defined check condition value of
drivers/scsi/advansys.c static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) · line 6020
Quoted 10 lines
drivers/scsi/advansys.c +1
-7-* 0x2. Host drivers are supposed to return -* the status byte as it is defined by SCSI. -*/ - scp->result =DRIVER_BYTE (DRIVER_SENSE ) | -STATUS_BYTE (scsiqp->scsi_status); - }else { - scp->result =STATUS_BYTE (scsiqp->scsi_status); } + scp->result =status_byte (scsiqp->scsi_status);break ;
Did you really want to delete the code that sets DRIVER_SENSE?
Quoted 13 lines
drivers/scsi/advansys.c +0
-9@@ -6789,47 +6768,30 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep)ASC_DBG (2 ,"SAM_STAT_CHECK_CONDITION\n" );ASC_DBG_PRT_SENSE (2 , scp->sense_buffer,SCSI_SENSE_BUFFERSIZE ); -/* -* Note: The 'status_byte()' macro used by -* target drivers defined in scsi.h shifts the -* status byte returned by host drivers right -* by 1 bit. This is why target drivers also -* use right shifted status byte definitions. -* For instance target drivers use -* CHECK_CONDITION, defined to 0x1, instead of -* the SCSI defined check condition value of
drivers/scsi/advansys.c static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · line 6773
Quoted 10 lines
drivers/scsi/advansys.c +1
-7-* 0x2. Host drivers are supposed to return -* the status byte as it is defined by SCSI. -*/ - scp->result =DRIVER_BYTE (DRIVER_SENSE ) | -STATUS_BYTE (qdonep->d3.scsi_stat); - }else { - scp->result =STATUS_BYTE (qdonep->d3.scsi_stat); } + scp->result =status_byte (qdonep->d3.scsi_stat);break ;
Same comment here: did you really want to delete the code that sets DRIVER_SENSE?
Thanks,
Bart.
Re: [PATCH 11/24] advansys: kill driver_defined status byte accessors
Quoted 19 lines · Bart Van Assche
Quoted 18 lines · Hannes Reinecke
drivers/scsi/advansys.c +0
-13@@ -6021,43 +6015,28 @@ static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG_PRT_SENSE(2, scp->sense_buffer, SCSI_SENSE_BUFFERSIZE); - /* - * Note: The 'status_byte()' macro used by - * target drivers defined in scsi.h shifts the - * status byte returned by host drivers right - * by 1 bit. This is why target drivers also - * use right shifted status byte definitions. - * For instance target drivers use - * CHECK_CONDITION, defined to 0x1, instead of - * the SCSI defined check condition value of - * 0x2. Host drivers are supposed to return - * the status byte as it is defined by SCSI. - */ - scp->result = DRIVER_BYTE(DRIVER_SENSE) |
Quoted 9 lines
drivers/scsi/advansys.c static void adv_isr_callback(ADV_DVC_VAR *adv_dvc_varp, ADV_SCSI_REQ_Q *scsiqp) · line 6020
Quoted 6 lines
drivers/scsi/advansys.c +1
-3- STATUS_BYTE(scsiqp->scsi_status); - } else { - scp->result = STATUS_BYTE(scsiqp->scsi_status); } + scp->result = status_byte(scsiqp->scsi_status); break;Did you really want to delete the code that sets
DRIVER_SENSE?
Yes. SAM_STAT_CHECK_CONDITION is already set, and the whole point of this patchset was to drop the DRIVER_SENSE usage.
Quoted 19 lines
Quoted 19 lines
drivers/scsi/advansys.c +0
-14@@ -6789,47 +6768,30 @@ static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) ASC_DBG(2, "SAM_STAT_CHECK_CONDITION\n"); ASC_DBG_PRT_SENSE(2, scp->sense_buffer, SCSI_SENSE_BUFFERSIZE); - /* - * Note: The 'status_byte()' macro used by - * target drivers defined in scsi.h shifts the - * status byte returned by host drivers right - * by 1 bit. This is why target drivers also - * use right shifted status byte definitions. - * For instance target drivers use - * CHECK_CONDITION, defined to 0x1, instead of - * the SCSI defined check condition value of - * 0x2. Host drivers are supposed to return - * the status byte as it is defined by SCSI. - */ - scp->result = DRIVER_BYTE(DRIVER_SENSE) | - STATUS_BYTE(qdonep->d3.scsi_stat);
Quoted 9 lines
drivers/scsi/advansys.c static void asc_isr_callback(ASC_DVC_VAR *asc_dvc_varp, ASC_QDONE_INFO *qdonep) · line 6773
Quoted 5 lines
drivers/scsi/advansys.c +1
-2- } else { - scp->result = STATUS_BYTE(qdonep->d3.scsi_stat); } + scp->result = status_byte(qdonep->d3.scsi_stat); break;Same comment here: did you really want to delete the code that sets
DRIVER_SENSE?
See above: yes.
That was kinda the point of this patchset.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
PATCH 12/24 scsi: introduce scsi_build_sense()
In reply to Hannes ReineckeIntroduce scsi_build_sense() as a wrapper around scsi_build_sense_buffer() to format the buffer and set the correct SCSI status.
--- drivers/ata/libata-scsi.c | 7 ++-- drivers/s390/scsi/zfcp_scsi.c | 5 +-- drivers/scsi/3w-xxxx.c | 3 +- drivers/scsi/libiscsi.c | 5 +-- drivers/scsi/lpfc/lpfc_scsi.c | 30 ++++------------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 +-- drivers/scsi/mvumi.c | 5 +-- drivers/scsi/myrb.c | 61 ++++++++--------------------------- drivers/scsi/myrs.c | 9 ++---- drivers/scsi/ps3rom.c | 3 +- drivers/scsi/qla2xxx/qla_isr.c | 15 ++------- drivers/scsi/scsi_debug.c | 11 +++---- drivers/scsi/scsi_lib.c | 18 +++++++++++ drivers/scsi/smartpqi/smartpqi_init.c | 3 +- drivers/scsi/stex.c | 5 +-- include/scsi/scsi_cmnd.h | 3 ++ 16 files changed, 60 insertions(+), 128 deletions(-)
drivers/ata/libata-scsi.c +2 -5
@@ -342,9 +342,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,
@@ -1092,8 +1090,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 ) {
drivers/s390/scsi/zfcp_scsi.c +1 -4
@@ -834,10 +834,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 ); }
drivers/scsi/3w-xxxx.c +1 -2
@@ -1981,8 +1981,7 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cprintk (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); - SCpnt->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; -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 ; }
drivers/scsi/libiscsi.c +1 -4
@@ -813,10 +813,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ascq = session->tt->check_protection (task, §or);if (ascq) { - sc->result =DRIVER_SENSE <<24 | -SAM_STAT_CHECK_CONDITION ; -scsi_build_sense_buffer (1 , sc->sense_buffer, -ILLEGAL_REQUEST ,0x10 , ascq); +scsi_build_sense (sc,1 ,ILLEGAL_REQUEST ,0x10 , ascq);scsi_set_sense_information (sc->sense_buffer,SCSI_SENSE_BUFFERSIZE , sector);
drivers/scsi/lpfc/lpfc_scsi.c +6 -24
@@ -2843,10 +2843,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) } out:if (err_type ==BGS_GUARD_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 ); phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, "9069 BLKGRD: LBA %lx grd_tag error %x != %x\n",
@@ -2854,10 +2851,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) sum, guard_tag); }else if (err_type ==BGS_REFTAG_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x3 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 ); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2866,10 +2860,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) ref_tag, start_ref_tag); }else if (err_type ==BGS_APPTAG_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x2 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 ); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2930,10 +2921,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_guard_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 ); phba->bg_guard_err_cnt++;lpfc_printf_log (phba,KERN_WARNING ,LOG_FCP |LOG_BG , "9055 BLKGRD: Guard Tag error in cmd"
@@ -2946,10 +2934,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_reftag_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x3 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 ); phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
@@ -2963,10 +2948,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_apptag_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x2 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 ); phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -4
@@ -4619,10 +4619,7 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) ascq =0x00 ;break ; } -scsi_build_sense_buffer (0 , scmd->sense_buffer,ILLEGAL_REQUEST ,0x10 , - ascq); - scmd->result =DRIVER_SENSE <<24 | (DID_ABORT <<16 ) | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x10 , ascq); }/**
drivers/scsi/mvumi.c +1 -4
@@ -2067,10 +2067,7 @@ static unsigned char mvumi_build_frame(struct mvumi_hba *mhba,return 0 ; error: - scmd->result = (DID_OK <<16 ) | (DRIVER_SENSE <<24 ) | -SAM_STAT_CHECK_CONDITION ; -scsi_build_sense_buffer (0 , scmd->sense_buffer,ILLEGAL_REQUEST ,0x24 , -0 ); +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 );return -1 ; }
drivers/scsi/myrb.c +14 -47
136 lines not on this page · raw message
drivers/scsi/myrs.c +2 -7
@@ -1602,9 +1602,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost,switch (scmd->cmnd[0 ]) {case REPORT_LUNS : -scsi_build_sense_buffer (0 , scmd->sense_buffer,ILLEGAL_REQUEST , -0x20 ,0x0 ); - scmd->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x20 ,0x0 ); scmd->scsi_done (scmd);return 0 ;case MODE_SENSE :
@@ -1614,10 +1612,7 @@ static int myrs_queuecommand(struct Scsi_Host *shost,if ((scmd->cmnd[2 ] &0x3F ) !=0x3F && (scmd->cmnd[2 ] &0x3F ) !=0x08 ) {/* Illegal request, invalid field in CDB */ -scsi_build_sense_buffer (0 , scmd->sense_buffer, -ILLEGAL_REQUEST ,0x24 ,0 ); - scmd->result = (DRIVER_SENSE <<24 ) | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x24 ,0 ); }else {myrs_mode_sense (cs, scmd, ldev_info); scmd->result = (DID_OK <<16 );
drivers/scsi/ps3rom.c +1 -2
@@ -319,8 +319,7 @@ static irqreturn_t ps3rom_interrupt(int irq, void *data) goto done; } -scsi_build_sense_buffer (0 , cmd->sense_buffer, sense_key, asc, ascq); - cmd->result =SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,0 , sense_key, asc, ascq); done: priv->curr_cmd =NULL ;
drivers/scsi/qla2xxx/qla_isr.c +3 -12
@@ -2232,31 +2232,22 @@ qla2x00_handle_dif_error(srb_t *sp, struct sts_entry_24xx *sts24)/* check guard */ if (e_guard != a_guard) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); -set_driver_byte (cmd,DRIVER_SENSE ); +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 );set_host_byte (cmd,DID_ABORT ); - cmd->result |=SAM_STAT_CHECK_CONDITION ;return 1 ; }/* check ref tag */ if (e_ref_tag != a_ref_tag) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x3 ); -set_driver_byte (cmd,DRIVER_SENSE ); +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 );set_host_byte (cmd,DID_ABORT ); - cmd->result |=SAM_STAT_CHECK_CONDITION ;return 1 ; }/* check appl tag */ if (e_app_tag != a_app_tag) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x2 ); -set_driver_byte (cmd,DRIVER_SENSE ); +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 );set_host_byte (cmd,DID_ABORT ); - cmd->result |=SAM_STAT_CHECK_CONDITION ;return 1 ; }
drivers/scsi/scsi_debug.c +4 -7
@@ -779,7 +779,7 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp, } asc = c_d ?INVALID_FIELD_IN_CDB :INVALID_FIELD_IN_PARAM_LIST ;memset (sbuff,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense_buffer (sdebug_dsense, sbuff,ILLEGAL_REQUEST , asc,0 ); +scsi_build_sense (scp, sdebug_dsense,ILLEGAL_REQUEST , asc,0 );memset (sks,0 ,sizeof (sks)); sks[0 ] =0x80 ;if (c_d)
@@ -805,17 +805,14 @@ static void mk_sense_invalid_fld(struct scsi_cmnd *scp,static void mk_sense_buffer (struct scsi_cmnd *scp,int key,int asc,int asq) { -unsigned char *sbuff; - - sbuff = scp->sense_buffer; -if (!sbuff) { +if (!scp->sense_buffer) {sdev_printk (KERN_ERR , scp->device,"%s: sense_buffer is NULL\n" , __func__);return ; } -memset (sbuff,0 ,SCSI_SENSE_BUFFERSIZE ); +memset (scp->sense_buffer,0 ,SCSI_SENSE_BUFFERSIZE ); -scsi_build_sense_buffer (sdebug_dsense, sbuff, key, asc, asq); +scsi_build_sense (scp, sdebug_dsense, key, asc, asq);if (sdebug_verbose) sdev_printk(KERN_INFO, scp->device,
drivers/scsi/scsi_lib.c +18 -0
@@ -3117,3 +3117,21 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id)return group_id; }EXPORT_SYMBOL (scsi_vpd_tpg_id); + +/** +* scsi_build_sense - build sense data for a command +* @scmd: scsi command for which the sense should be formatted +* @desc: Sense format (non-zero == descriptor format, +* 0 == fixed format) +* @key: Sense key +* @asc: Additional sense code +* @ascq: Additional sense code qualifier +* +**/ +void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq) +{ +scsi_build_sense_buffer (desc, scmd->sense_buffer, key, asc, ascq); + scmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | +SAM_STAT_CHECK_CONDITION ; +} +EXPORT_SYMBOL_GPL (scsi_build_sense);
drivers/scsi/smartpqi/smartpqi_init.c +1 -2
@@ -2874,8 +2874,7 @@ static void pqi_process_aio_io_error(struct pqi_io_request *io_request) }if (device_offline && sense_data_length ==0 ) -scsi_build_sense_buffer (0 , scmd->sense_buffer,HARDWARE_ERROR , -0x3e ,0x1 ); +scsi_build_sense (scmd,0 ,HARDWARE_ERROR ,0x3e ,0x1 ); scmd->result = scsi_status;set_host_byte (scmd, host_byte);
drivers/scsi/stex.c +1 -4
@@ -398,11 +398,8 @@ static struct status_msg *stex_get_status(struct st_hba *hba)static void stex_invalid_field (struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *)) { - cmd->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; -/* "Invalid field in cdb" */ -scsi_build_sense_buffer (0 , cmd->sense_buffer,ILLEGAL_REQUEST ,0x24 , -0x0 ); +scsi_build_sense (cmd,0 ,ILLEGAL_REQUEST ,0x24 ,0x0 );done (cmd); }
include/scsi/scsi_cmnd.h +3 -0
@@ -338,4 +338,7 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) return xfer_len; } +extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u8 asc,u8 ascq); +#endif /* _SCSI_SCSI_CMND_H */
Signature · 1 line
2.16.4
Re: [PATCH 12/24] scsi: introduce scsi_build_sense()
Quoted 100 lines · Hannes Reinecke
Introduce
scsi_build_sense()as a wrapper aroundscsi_build_sense_buffer()to format the buffer and set the correct SCSI status.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/ata/libata-scsi.c | 7 ++-- drivers/s390/scsi/zfcp_scsi.c | 5 +-- drivers/scsi/3w-xxxx.c | 3 +- drivers/scsi/libiscsi.c | 5 +-- drivers/scsi/lpfc/lpfc_scsi.c | 30 ++++------------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 +-- drivers/scsi/mvumi.c | 5 +-- drivers/scsi/myrb.c | 61 ++++++++--------------------------- drivers/scsi/myrs.c | 9 ++---- drivers/scsi/ps3rom.c | 3 +- drivers/scsi/qla2xxx/qla_isr.c | 15 ++------- drivers/scsi/scsi_debug.c | 11 +++---- drivers/scsi/scsi_lib.c | 18 +++++++++++ drivers/scsi/smartpqi/smartpqi_init.c | 3 +- drivers/scsi/stex.c | 5 +-- include/scsi/scsi_cmnd.h | 3 ++ 16 files changed, 60 insertions(+), 128 deletions(-)drivers/ata/libata-scsi.c +2
-5@@ -342,9 +342,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,@@ -1092,8 +1090,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 ) {drivers/s390/scsi/zfcp_scsi.c +1
-4@@ -834,10 +834,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 ); }drivers/scsi/3w-xxxx.c +1
-2@@ -1981,8 +1981,7 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cprintk (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); - SCpnt->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; -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 ; }drivers/scsi/libiscsi.c +1
-4@@ -813,10 +813,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ascq = session->tt->check_protection (task, §or);if (ascq) { - sc->result =DRIVER_SENSE <<24 | -SAM_STAT_CHECK_CONDITION ; -scsi_build_sense_buffer (1 , sc->sense_buffer, -ILLEGAL_REQUEST ,0x10 , ascq); +scsi_build_sense (sc,1 ,ILLEGAL_REQUEST ,0x10 , ascq);scsi_set_sense_information (sc->sense_buffer,SCSI_SENSE_BUFFERSIZE , sector);drivers/scsi/lpfc/lpfc_scsi.c +0
-0
drivers/scsi/lpfc/lpfc_scsi.c lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · line 2846
Quoted 8 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4@@ -2843,10 +2843,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) } out:if (err_type ==BGS_GUARD_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 );
set_host_byte(cmd, DID_ABORT);
drivers/scsi/lpfc/lpfc_scsi.c lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · line 2855
Quoted 13 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4phba->bg_guard_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG, "9069 BLKGRD: LBA %lx grd_tag error %x != %x\n",@@ -2854,10 +2851,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) sum, guard_tag); }else if (err_type ==BGS_REFTAG_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x3 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 );
Same.
drivers/scsi/lpfc/lpfc_scsi.c lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · line 2864
Quoted 12 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,@@ -2866,10 +2860,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) ref_tag, start_ref_tag); }else if (err_type ==BGS_APPTAG_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x2 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 );
Same.
drivers/scsi/lpfc/lpfc_scsi.c lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, · line 2924
Quoted 11 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,@@ -2930,10 +2921,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_guard_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 );
Same.
drivers/scsi/lpfc/lpfc_scsi.c lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, · line 2938
Quoted 13 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4phba->bg_guard_err_cnt++;lpfc_printf_log (phba,KERN_WARNING ,LOG_FCP |LOG_BG , "9055 BLKGRD: Guard Tag error in cmd"@@ -2946,10 +2934,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_reftag_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x3 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x3 );
Same.
drivers/scsi/lpfc/lpfc_scsi.c lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd, · line 2952
Quoted 12 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4phba->bg_reftag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,@@ -2963,10 +2948,7 @@ lpfc_parse_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd,if (lpfc_bgs_get_apptag_err (bgstat)) { ret =1 ; -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x2 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x2 );
Same.
Quoted 7 lines
drivers/scsi/lpfc/lpfc_scsi.c +0
-0phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,drivers/scsi/mpt3sas/mpt3sas_scsih.c +0
-0
drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) · line 4622
Quoted 8 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1
-4@@ -4619,10 +4619,7 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) ascq =0x00 ;break ; } -scsi_build_sense_buffer (0 , scmd->sense_buffer,ILLEGAL_REQUEST ,0x10 , - ascq); - scmd->result =DRIVER_SENSE <<24 | (DID_ABORT <<16 ) | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x10 , ascq);
Same.
Re: [PATCH 12/24] scsi: introduce scsi_build_sense()
Quoted 114 lines · Finn Thain
Quoted 100 lines · Hannes Reinecke
Introduce
scsi_build_sense()as a wrapper aroundscsi_build_sense_buffer()to format the buffer and set the correct SCSI status.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/ata/libata-scsi.c | 7 ++-- drivers/s390/scsi/zfcp_scsi.c | 5 +-- drivers/scsi/3w-xxxx.c | 3 +- drivers/scsi/libiscsi.c | 5 +-- drivers/scsi/lpfc/lpfc_scsi.c | 30 ++++------------- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 5 +-- drivers/scsi/mvumi.c | 5 +-- drivers/scsi/myrb.c | 61 ++++++++--------------------------- drivers/scsi/myrs.c | 9 ++---- drivers/scsi/ps3rom.c | 3 +- drivers/scsi/qla2xxx/qla_isr.c | 15 ++------- drivers/scsi/scsi_debug.c | 11 +++---- drivers/scsi/scsi_lib.c | 18 +++++++++++ drivers/scsi/smartpqi/smartpqi_init.c | 3 +- drivers/scsi/stex.c | 5 +-- include/scsi/scsi_cmnd.h | 3 ++ 16 files changed, 60 insertions(+), 128 deletions(-)drivers/ata/libata-scsi.c +2
-5@@ -342,9 +342,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,@@ -1092,8 +1090,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 ) {drivers/s390/scsi/zfcp_scsi.c +1
-4@@ -834,10 +834,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 ); }drivers/scsi/3w-xxxx.c +1
-2@@ -1981,8 +1981,7 @@ static int tw_scsi_queue_lck(struct scsi_cmnd *SCpnt, void (*done)(struct scsi_cprintk (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); - SCpnt->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; -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 ; }drivers/scsi/libiscsi.c +1
-4@@ -813,10 +813,7 @@ static void iscsi_scsi_cmd_rsp(struct iscsi_conn *conn, struct iscsi_hdr *hdr, ascq = session->tt->check_protection (task, §or);if (ascq) { - sc->result =DRIVER_SENSE <<24 | -SAM_STAT_CHECK_CONDITION ; -scsi_build_sense_buffer (1 , sc->sense_buffer, -ILLEGAL_REQUEST ,0x10 , ascq); +scsi_build_sense (sc,1 ,ILLEGAL_REQUEST ,0x10 , ascq);scsi_set_sense_information (sc->sense_buffer,SCSI_SENSE_BUFFERSIZE , sector);drivers/scsi/lpfc/lpfc_scsi.c +0
-0drivers/scsi/lpfc/lpfc_scsi.c lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) · line 2846
Quoted 8 lines
drivers/scsi/lpfc/lpfc_scsi.c +1
-4@@ -2843,10 +2843,7 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd) } out:if (err_type ==BGS_GUARD_ERR_MASK ) { -scsi_build_sense_buffer (1 , cmd->sense_buffer,ILLEGAL_REQUEST , -0x10 ,0x1 ); - cmd->result =DRIVER_SENSE <<24 |DID_ABORT <<16 | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (cmd,1 ,ILLEGAL_REQUEST ,0x10 ,0x1 );
set_host_byte(cmd, DID_ABORT);
[ .. ]
Quoted 9 lines
Quoted 9 lines
drivers/scsi/lpfc/lpfc_scsi.c +0
-0phba->bg_apptag_err_cnt++; lpfc_printf_log(phba, KERN_WARNING, LOG_FCP | LOG_BG,drivers/scsi/mpt3sas/mpt3sas_scsih.c +0
-0@@ -4619,10 +4619,7 @@ _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) ascq =0x00 ;break ;
Quoted 9 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c _scsih_eedp_error_handling(struct scsi_cmnd *scmd, u16 ioc_status) · line 4622
Quoted 6 lines
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1
-4} -scsi_build_sense_buffer (0 , scmd->sense_buffer,ILLEGAL_REQUEST ,0x10 , - ascq); - scmd->result =DRIVER_SENSE <<24 | (DID_ABORT <<16 ) | -SAM_STAT_CHECK_CONDITION ; +scsi_build_sense (scmd,0 ,ILLEGAL_REQUEST ,0x10 , ascq);Same.
And while you are correct that it should introduce set_host_byte() here, too, the larger issue here is that setting DID_ABORT will obliterate any sense code we set; in scsi_decide_dispostion() the sense code is never evaluated if DID_ABORT is set.
But indeed, that should be a separate patch, and possibly even a separate discussion.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
Re: [PATCH 12/24] scsi: introduce scsi_build_sense()
In reply to Hannes ReineckeQuoted 17 lines · Hannes Reinecke
Introduce
scsi_build_sense()as a wrapper aroundscsi_build_sense_buffer()to format the buffer and set the correct SCSI status.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/s390/scsi/zfcp_scsi.c | 5 +--16 files changed, 60 insertions(+), 128 deletions(-)drivers/s390/scsi/zfcp_scsi.c +0
-0@@ -834,10 +834,7 @@ void zfcp_scsi_set_prot(struct zfcp_adapter *adapter)*/
drivers/s390/scsi/zfcp_scsi.c void zfcp_scsi_set_prot(struct zfcp_adapter *adapter) · line 840
Quoted 10 lines
drivers/s390/scsi/zfcp_scsi.c +1
-4void 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 ); }
looks like a non-functional change for zfcp, so for this part:
drivers/scsi/scsi_lib.c int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) · line 3122
Quoted 11 lines
drivers/scsi/scsi_lib.c +3
-0@@ -3117,3 +3117,21 @@ int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id)return group_id; }EXPORT_SYMBOL (scsi_vpd_tpg_id); + +/** +* scsi_build_sense - build sense data for a command
minor: I suppose kdoc&sphnix parse and render it correctly? Because Documentation/doc-guide/kernel-doc.rst says the format for function kdoc has "()" as function name suffix:
+ * scsi_build_sense() - build sense data for a command
drivers/scsi/scsi_lib.c int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) · line 3125
Quoted 3 lines
drivers/scsi/scsi_lib.c +3
-0+* @scmd: scsi command for which the sense should be formatted +* @desc: Sense format (non-zero == descriptor format, +* 0 == fixed format)
Looks like this has already been like that. Not sure if this patch set touches every user of scsi_build_sense{_buffer}(). It would be nice to have meaningful identifiers for values passed to @desc, e.g. something like the following instead of "magic" zero and non-zero:
enum scsi_sense_format {
SCSI_SENSE_FIXED = 0,
SCSI_SENSE_DESCRIPTOR
};
drivers/scsi/scsi_lib.c int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) · line 3130
Quoted 5 lines
drivers/scsi/scsi_lib.c +5
-0+* @key: Sense key +* @asc: Additional sense code +* @ascq: Additional sense code qualifier +* +**/
minor:
+ */
[no double star at kdoc end?]
drivers/scsi/scsi_lib.c int scsi_vpd_tpg_id(struct scsi_device *sdev, int *rel_id) · line 3135
Quoted 5 lines
drivers/scsi/scsi_lib.c +5
-0+void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq) +{ +scsi_build_sense_buffer (desc, scmd->sense_buffer, key, asc, ascq); + scmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | +SAM_STAT_CHECK_CONDITION ;
While this is scsi_lib and thus "internal" helper code, I wonder if this should nonetheless use the helper functions to access and build scmd->result in order to have the error-prone bit shifts in only one central place?:
scmd->result = SAM_STAT_CHECK_CONDITION; set_driver_byte(scmd, DRIVER_SENSE); set_host_byte(scmd, DID_OK);
Quoted 16 lines
drivers/scsi/scsi_lib.c +2
-0+} +EXPORT_SYMBOL_GPL (scsi_build_sense);include/scsi/scsi_cmnd.h +3
-0@@ -338,4 +338,7 @@ static inline unsigned scsi_transfer_length(struct scsi_cmnd *scmd) return xfer_len; } +extern void scsi_build_sense (struct scsi_cmnd *scmd,int desc, +u8 key,u8 asc,u8 ascq); +#endif /* _SCSI_SCSI_CMND_H */
Signature · 11 lines
Mit freundlichen Gruessen / Kind regards Steffen Maier Linux on IBM Z Development https://www.ibm.com/privacy/us/en/ IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Matthias Hartmann Geschaeftsfuehrung: Dirk Wittkopp Sitz der Gesellschaft: Boeblingen Registergericht: Amtsgericht Stuttgart, HRB 243294
PATCH 13/24 scsi: Kill DRIVER_SENSE
In reply to Hannes ReineckeReplace the check for DRIVER_SENSE with a check for SAM_STAT_CHECK_CONDITION and audit all callsites to ensure the SAM status is set correctly.
--- drivers/ata/libata-scsi.c | 13 ++++----- drivers/scsi/NCR5380.c | 2 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 19 +++++------- drivers/scsi/aic7xxx/aic7xxx_osm.c | 1 - drivers/scsi/arcmsr/arcmsr_hba.c | 1 - drivers/scsi/ch.c | 3 +- drivers/scsi/constants.c | 2 +- drivers/scsi/cxlflash/superpipe.c | 45 ++++++++++++++--------------- drivers/scsi/dc395x.c | 2 +- drivers/scsi/esp_scsi.c | 3 +- drivers/scsi/megaraid.c | 14 ++++----- drivers/scsi/megaraid/megaraid_mbox.c | 14 ++++----- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +- drivers/scsi/megaraid/megaraid_sas_fusion.c | 1 - drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +- drivers/scsi/mvumi.c | 1 - drivers/scsi/scsi.c | 4 +-- drivers/scsi/scsi_debug.c | 4 +-- drivers/scsi/scsi_ioctl.c | 2 +- drivers/scsi/scsi_lib.c | 13 ++++----- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/sd.c | 33 +++++++++++---------- drivers/scsi/sg.c | 6 ++-- drivers/scsi/stex.c | 4 +-- drivers/scsi/sym53c8xx_2/sym_glue.c | 6 ++-- drivers/scsi/ufs/ufshcd.c | 2 +- drivers/scsi/virtio_scsi.c | 3 +- drivers/scsi/vmw_pvscsi.c | 3 -- drivers/target/loopback/tcm_loop.c | 1 - drivers/usb/storage/cypress_atacb.c | 4 +-- drivers/xen/xen-scsiback.c | 2 +- include/scsi/scsi.h | 1 - include/scsi/sg.h | 3 +- include/trace/events/scsi.h | 3 +- 35 files changed, 92 insertions(+), 133 deletions(-)
drivers/ata/libata-scsi.c +5 -8
@@ -633,13 +633,12 @@ 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 (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 (status_byte (cmd_result) ==SAM_STAT_CHECK_CONDITION ) {if (sshdr.sense_key ==RECOVERED_ERROR && sshdr.asc ==0 && sshdr.ascq ==0x1d ) cmd_result &= ~SAM_STAT_CHECK_CONDITION ;
@@ -714,9 +713,8 @@ 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 (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. */
@@ -1074,7 +1072,7 @@ 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 ; + cmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;/* * Use ata_to_sense_error() to map status register bits
@@ -1172,7 +1170,7 @@ 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 ; + cmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;if (ata_dev_disabled (dev)) {/* Device disabled after error recovery */
@@ -4480,7 +4478,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,
drivers/scsi/NCR5380.c +1 -1
@@ -526,7 +526,7 @@ static void complete_cmd(struct Scsi_Host *instance,scsi_eh_restore_cmnd (cmd, &hostdata->ses); }else {scsi_eh_restore_cmnd (cmd, &hostdata->ses); -set_driver_byte (cmd,DRIVER_SENSE ); +set_status_byte (cmd,SAM_STAT_CHECK_CONDITION ); } hostdata->sensing =NULL ; }
drivers/scsi/aic7xxx/aic79xx_osm.c +7 -12
@@ -1940,7 +1940,7 @@ ahd_linux_handle_scsi_status(struct ahd_softc *ahd,memcpy (cmd->sense_buffer,ahd_get_sense_buf (ahd, scb) + sense_offset, sense_size); - cmd->result |= (DRIVER_SENSE <<24 ); + cmd->result |=SAM_STAT_CHECK_CONDITION ;#ifdef AHD_DEBUG if (ahd_debug &AHD_SHOW_SENSE ) {
@@ -2030,6 +2030,7 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)int new_status =DID_OK ;int do_fallback =0 ;int scsi_status; +struct scsi_sense_data *sense;/* * Map CAM error codes into Linux Error codes. We
@@ -2053,18 +2054,12 @@ ahd_linux_queue_cmd_complete(struct ahd_softc *ahd, struct scsi_cmnd *cmd)switch (scsi_status) {case SAM_STAT_COMMAND_TERMINATED :case SAM_STAT_CHECK_CONDITION : -if ((cmd->result >>24 ) !=DRIVER_SENSE ) { + sense = (struct scsi_sense_data *) + cmd->sense_buffer; +if (sense->extra_len >=5 && + (sense->add_sense_code ==0x47 + || sense->add_sense_code ==0x48 )) do_fallback =1 ; - }else { -struct scsi_sense_data *sense; - - sense = (struct scsi_sense_data *) - cmd->sense_buffer; -if (sense->extra_len >=5 && - (sense->add_sense_code ==0x47 - || sense->add_sense_code ==0x48 )) - do_fallback =1 ; - }break ;default :break ;
drivers/scsi/aic7xxx/aic7xxx_osm.c +0 -1
@@ -1853,7 +1853,6 @@ ahc_linux_handle_scsi_status(struct ahc_softc *ahc,if (sense_size <SCSI_SENSE_BUFFERSIZE )memset (&cmd->sense_buffer[sense_size],0 ,SCSI_SENSE_BUFFERSIZE - sense_size); - cmd->result |= (DRIVER_SENSE <<24 );#ifdef AHC_DEBUG if (ahc_debug &AHC_SHOW_SENSE ) {int i;
drivers/scsi/arcmsr/arcmsr_hba.c +0 -1
@@ -1280,7 +1280,6 @@ static void arcmsr_report_sense_info(struct CommandControlBlock *ccb)memcpy (sensebuffer, ccb->arcmsr_cdb.SenseData, sense_data_length); sensebuffer->ErrorCode =SCSI_SENSE_CURRENT_ERRORS ; sensebuffer->Valid =1 ; - pcmd->result |= (DRIVER_SENSE <<24 ); } }
drivers/scsi/ch.c +1 -2
@@ -199,8 +199,7 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, result =scsi_execute_req (ch->device, cmd, direction, buffer, buflength, &sshdr, timeout *HZ ,MAX_RETRIES ,NULL ); - -if (driver_byte (result) ==DRIVER_SENSE ) { +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION ) {if (debug)scsi_print_sense_hdr (ch->device, ch->name, &sshdr); errno =ch_find_errno (&sshdr);
drivers/scsi/constants.c +1 -1
@@ -408,7 +408,7 @@ static const char * const hostbyte_table[]={static const char *const driverbyte_table[]={"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" , -"DRIVER_INVALID" ,"DRIVER_TIMEOUT" ,"DRIVER_HARD" ,"DRIVER_SENSE" }; +"DRIVER_INVALID" ,"DRIVER_TIMEOUT" ,"DRIVER_HARD" };const char *scsi_hostbyte_string (int result) {
drivers/scsi/cxlflash/superpipe.c +21 -24
54 lines not on this page · raw message
drivers/scsi/dc395x.c +1 -1
@@ -3281,7 +3281,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,dprintkdbg (DBG_0 ,"srb_done: AUTO_REQSENSE2\n" ); cmd->result = -MK_RES (DRIVER_SENSE ,DID_OK , +MK_RES (0 ,DID_OK , srb->end_message,SAM_STAT_CHECK_CONDITION ); goto ckc_e;
drivers/scsi/esp_scsi.c +1 -2
@@ -916,8 +916,7 @@ static void esp_cmd_is_done(struct esp *esp, struct esp_cmd_entry *ent,* saw originally. Also, report that we are providing * the sense data. */ - cmd->result = ((DRIVER_SENSE <<24 ) | - (DID_OK <<16 ) | + cmd->result = ((DID_OK <<16 ) | (COMMAND_COMPLETE <<8 ) | (SAM_STAT_CHECK_CONDITION <<0 ));
drivers/scsi/megaraid.c +5 -9
@@ -1579,8 +1579,7 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)memcpy (cmd->sense_buffer, pthru->reqsensearea,14 ); - cmd->result = (DRIVER_SENSE <<24 ) | - (DID_OK <<16 ) | + cmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }else {
@@ -1589,14 +1588,11 @@ mega_cmd_done(adapter_t *adapter, u8 completed[], int nstatus, int status)memcpy (cmd->sense_buffer, epthru->reqsensearea,14 ); - cmd->result = (DRIVER_SENSE <<24 ) | - (DID_OK <<16 ) | + cmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; - }else { - cmd->sense_buffer[0 ] =0x70 ; - cmd->sense_buffer[2 ] =ABORTED_COMMAND ; - cmd->result |=SAM_STAT_CHECK_CONDITION ; - } + }else +scsi_build_sense (cmd,0 , +ABORTED_COMMAND ,0 ,0 ); }break ;
drivers/scsi/megaraid/megaraid_mbox.c +5 -9
@@ -2301,8 +2301,7 @@ megaraid_mbox_dpc(unsigned long devp)memcpy (scp->sense_buffer, pthru->reqsensearea,14 ); - scp->result =DRIVER_SENSE <<24 | -DID_OK <<16 |SAM_STAT_CHECK_CONDITION ; + scp->result =DID_OK <<16 |SAM_STAT_CHECK_CONDITION ; }else {if (mbox->cmd ==MBOXCMD_EXTPTHRU ) {
@@ -2310,14 +2309,11 @@ megaraid_mbox_dpc(unsigned long devp)memcpy (scp->sense_buffer, epthru->reqsensearea,14 ); - scp->result =DRIVER_SENSE <<24 | -DID_OK <<16 | + scp->result =DID_OK <<16 |SAM_STAT_CHECK_CONDITION ; - }else { - scp->sense_buffer[0 ] =0x70 ; - scp->sense_buffer[2 ] =ABORTED_COMMAND ; - scp->result =SAM_STAT_CHECK_CONDITION ; - } + }else +scsi_build_sense (scp,0 , +ABORTED_COMMAND ,0 ,0 ); }break ;
drivers/scsi/megaraid/megaraid_sas_base.c +1 -2
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Linux MegaRAID driver for SAS based RAID controllers
@@ -3548,8 +3549,6 @@ megasas_complete_cmd(struct megasas_instance *instance, struct megasas_cmd *cmd, SCSI_SENSE_BUFFERSIZE);memcpy (cmd->scmd->sense_buffer, cmd->sense, hdr->sense_len); - - cmd->scmd->result |=DRIVER_SENSE <<24 ; }break ;
drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -1
@@ -1988,7 +1988,6 @@ map_cmd_status(struct fusion_context *fusion, SCSI_SENSE_BUFFERSIZE);memcpy (scmd->sense_buffer, sense,SCSI_SENSE_BUFFERSIZE ); - scmd->result |=DRIVER_SENSE <<24 ; }/*
drivers/scsi/mpt3sas/mpt3sas_scsih.c +1 -2
@@ -5376,8 +5376,7 @@ _scsih_io_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u32 reply)else if (!xfer_cnt && scmd->cmnd[0 ] ==REPORT_LUNS ) { mpi_reply->SCSIState =MPI2_SCSI_STATE_AUTOSENSE_VALID ; mpi_reply->SCSIStatus =SAM_STAT_CHECK_CONDITION ; - scmd->result = (DRIVER_SENSE <<24 ) | -SAM_STAT_CHECK_CONDITION ; + scmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; scmd->sense_buffer[0 ] =0x70 ; scmd->sense_buffer[2 ] =ILLEGAL_REQUEST ; scmd->sense_buffer[12 ] =0x20 ;
drivers/scsi/mvumi.c +0 -1
@@ -1316,7 +1316,6 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd,if (ob_frame->rsp_flag &CL_RSP_FLAG_SENSEDATA ) {memcpy (cmd->scmd->sense_buffer, ob_frame->payload,sizeof (struct mvumi_sense_data )); - scmd->result |= (DRIVER_SENSE <<24 ); }break ;default :
drivers/scsi/scsi.c +2 -2
@@ -203,8 +203,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)* If we have valid sense information, then some kind of recovery * must have taken place. Make a note of this. */ -if (SCSI_SENSE_VALID (cmd)) - cmd->result |= (DRIVER_SENSE <<24 ); +if (SCSI_SENSE_VALID (cmd) &&status_byte (cmd->result) ==SAM_STAT_GOOD ) +set_status_byte (cmd,SAM_STAT_CHECK_CONDITION ); SCSI_LOG_MLCOMPLETE(4, sdev_printk(KERN_INFO, sdev, "Notifying upper driver of completion "
drivers/scsi/scsi_debug.c +2 -2
@@ -708,10 +708,10 @@ static struct device_driver sdebug_driverfs_driver = { };static const int check_condition_result = - (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; + (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;static const int illegal_condition_result = - (DRIVER_SENSE <<24 ) | (DID_ABORT <<16 ) |SAM_STAT_CHECK_CONDITION ; + (DID_ABORT <<16 ) |SAM_STAT_CHECK_CONDITION ;static const int device_qfull_result = (DID_OK <<16 ) | (COMMAND_COMPLETE <<8 ) |SAM_STAT_TASK_SET_FULL ;
drivers/scsi/scsi_ioctl.c +1 -1
@@ -101,7 +101,7 @@ static int ioctl_internal_command(struct scsi_device *sdev, char *cmd,SCSI_LOG_IOCTL (2 ,sdev_printk (KERN_INFO , sdev,"Ioctl returned 0x%x\n" , result)); -if (driver_byte (result) ==DRIVER_SENSE && +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION &&scsi_sense_valid (&sshdr)) {switch (sshdr.sense_key) {case ILLEGAL_REQUEST :
drivers/scsi/scsi_lib.c +5 -8
@@ -636,8 +636,6 @@ static blk_status_t scsi_result_to_blk_status(struct scsi_cmnd *cmd, int result)case DID_OK :/* * Also check the other bytes than the status byte in result -* to handle the case when a SCSI LLD sets result to -* DRIVER_SENSE << 24 without setting SAM_STAT_CHECK_CONDITION. */ if (scsi_status_is_good (result) && (result & ~0xff ) ==0 )return BLK_STS_OK ;
@@ -805,7 +803,7 @@ static void scsi_io_completion_action(struct scsi_cmnd *cmd, int result)*/ if (!level &&__ratelimit (&_rs)) {scsi_print_result (cmd,NULL ,FAILED ); -if (driver_byte (result) ==DRIVER_SENSE ) +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION )scsi_print_sense (cmd);scsi_print_command (cmd); }
@@ -2143,11 +2141,11 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage,* ILLEGAL REQUEST if the code page isn't supported */ if (use_10_for_ms && !scsi_status_is_good (result) && -driver_byte (result) ==DRIVER_SENSE ) { +status_byte (result) ==SAM_STAT_CHECK_CONDITION ) {if (scsi_sense_valid (sshdr)) {if ((sshdr->sense_key ==ILLEGAL_REQUEST ) && (sshdr->asc ==0x20 ) && (sshdr->ascq ==0 )) { -/* +/* * Invalid command operation code */ sdev->use_10_for_ms =0 ;
@@ -2156,7 +2154,7 @@ scsi_mode_sense(struct scsi_device *sdev, int dbd, int modepage, } } -if (scsi_status_is_good (result)) { +if (scsi_status_is_good (result)) {if (unlikely (buffer[0 ] ==0x86 && buffer[1 ] ==0x0b && (modepage ==6 || modepage ==8 ))) {/* Initio breakage? */
@@ -3131,7 +3129,6 @@ EXPORT_SYMBOL(scsi_vpd_tpg_id);void scsi_build_sense (struct scsi_cmnd *scmd,int desc,u8 key,u8 asc,u8 ascq) {scsi_build_sense_buffer (desc, scmd->sense_buffer, key, asc, ascq); - scmd->result = (DRIVER_SENSE <<24 ) | (DID_OK <<16 ) | -SAM_STAT_CHECK_CONDITION ; + scmd->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; }EXPORT_SYMBOL_GPL (scsi_build_sense);
drivers/scsi/scsi_scan.c +1 -1
@@ -606,7 +606,7 @@ static int scsi_probe_lun(struct scsi_device *sdev, unsigned char *inq_result,* INQUIRY should not yield UNIT_ATTENTION * but many buggy devices do so anyway. */ -if (driver_byte (result) ==DRIVER_SENSE && +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION &&scsi_sense_valid (&sshdr)) { if ((sshdr.sense_key == UNIT_ATTENTION) && ((sshdr.asc == 0x28) ||
drivers/scsi/scsi_transport_spi.c +1 -1
@@ -123,7 +123,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd,REQ_FAILFAST_TRANSPORT |REQ_FAILFAST_DRIVER , 0, NULL); -if (driver_byte (result) !=DRIVER_SENSE || +if (status_byte (result) !=SAM_STAT_CHECK_CONDITION || sshdr->sense_key !=UNIT_ATTENTION )break ; }
drivers/scsi/sd.c +17 -16
@@ -1648,16 +1648,17 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)if (res) {sd_print_result (sdkp,"Synchronize Cache(10) failed" , res); -if (driver_byte (res) ==DRIVER_SENSE ) +if (status_byte (res) ==SAM_STAT_CHECK_CONDITION && +scsi_sense_valid (sshdr)) {sd_print_sense_hdr (sdkp, sshdr); -/* we need to evaluate the error return */ -if (scsi_sense_valid (sshdr) && - (sshdr->asc ==0x3a ||/* medium not present */ - sshdr->asc ==0x20 ||/* invalid command */ - (sshdr->asc ==0x74 && sshdr->ascq ==0x71 )))/* drive is password locked */ +/* we need to evaluate the error return */ +if (sshdr->asc ==0x3a ||/* medium not present */ + sshdr->asc ==0x20 ||/* invalid command */ + (sshdr->asc ==0x74 && sshdr->ascq ==0x71 ))/* drive is password locked */ /* this is no error here */ return 0 ; + }switch (host_byte (res)) {/* ignore errors due to racing a disconnection */
@@ -1751,7 +1752,7 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, result =scsi_execute_req (sdev, cmd,DMA_TO_DEVICE , &data,sizeof (data), &sshdr,SD_TIMEOUT ,SD_MAX_RETRIES ,NULL ); -if (driver_byte (result) ==DRIVER_SENSE && +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION &&scsi_sense_valid (&sshdr)) {sdev_printk (KERN_INFO , sdev,"PR command failed: %d\n" , result);scsi_print_sense_hdr (sdev,NULL , &sshdr);
@@ -1993,7 +1994,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out =0 ; -if (driver_byte (result) !=DRIVER_SENSE && +if (status_byte (result) !=SAM_STAT_CHECK_CONDITION && (!sense_valid || sense_deferred)) goto out;
@@ -2096,12 +2097,12 @@ sd_spinup_disk(struct scsi_disk *sdkp)if (the_result) sense_valid =scsi_sense_valid (&sshdr); retries++; - }while (retries <3 && + }while (retries <3 && (!scsi_status_is_good (the_result) || - ((driver_byte (the_result) ==DRIVER_SENSE ) && + ((status_byte (the_result) ==SAM_STAT_CHECK_CONDITION ) && sense_valid && sshdr.sense_key ==UNIT_ATTENTION ))); -if (driver_byte (the_result) !=DRIVER_SENSE ) { +if (status_byte (the_result) !=SAM_STAT_CHECK_CONDITION ) {/* no sense, TUR either succeeded or failed * with a status error */ if (!spintime && !scsi_status_is_good (the_result)) {
@@ -2227,7 +2228,7 @@ static void read_capacity_error(struct scsi_disk *sdkp, struct scsi_device *sdp, struct scsi_sense_hdr *sshdr, int sense_valid, int the_result) { - if (driver_byte(the_result) == DRIVER_SENSE) + if (status_byte(the_result) == SAM_STAT_CHECK_CONDITION) sd_print_sense_hdr(sdkp, sshdr); else sd_printk(KERN_NOTICE, sdkp, "Sense not available.\n");
@@ -3494,12 +3495,12 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start) SD_TIMEOUT, SD_MAX_RETRIES, 0, RQF_PM, NULL);if (res) {sd_print_result (sdkp,"Start/Stop Unit failed" , res); -if (driver_byte (res) ==DRIVER_SENSE ) +if (status_byte (res) ==SAM_STAT_CHECK_CONDITION ) {sd_print_sense_hdr (sdkp, &sshdr); -if (scsi_sense_valid (&sshdr) &&/* 0x3a is medium not present */ - sshdr.asc ==0x3a ) - res =0 ; +if (sshdr.asc ==0x3a ) + res =0 ; + } }/* SCSI error codes must not go to the generic layer */
drivers/scsi/sg.c +2 -4
@@ -503,8 +503,7 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos) old_hdr->target_status = hp->masked_status; old_hdr->host_status = hp->host_status; old_hdr->driver_status = hp->driver_status; -if ((SAM_STAT_CHECK_CONDITION & hp->status) || - (DRIVER_SENSE & hp->driver_status)) +if (SAM_STAT_CHECK_CONDITION & hp->status)memcpy (old_hdr->sense_buffer, srp->sense_b,sizeof (old_hdr->sense_buffer));switch (hp->host_status) {
@@ -574,8 +573,7 @@ sg_new_read(Sg_fd * sfp, char __user *buf, size_t count, Sg_request * srp) } hp->sb_len_wr =0 ;if ((hp->mx_sb_len >0 ) && hp->sbp) { -if ((SAM_STAT_CHECK_CONDITION & hp->status) || - (DRIVER_SENSE & hp->driver_status)) { +if (SAM_STAT_CHECK_CONDITION & hp->status) {int sb_len =SCSI_SENSE_BUFFERSIZE ; sb_len = (hp->mx_sb_len > sb_len) ? sb_len : hp->mx_sb_len; len =8 + (int ) srp->sense_b[7 ];/* Additional sense length field */
drivers/scsi/stex.c +2 -2
@@ -735,7 +735,7 @@ static void stex_scsi_done(struct st_ccb *ccb) result |=DID_OK <<16 |COMMAND_COMPLETE <<8 ;break ;case SAM_STAT_CHECK_CONDITION : - result |=DRIVER_SENSE <<24 ; + result |=DID_OK <<16 ;break ;case SAM_STAT_BUSY : result |=DID_BUS_BUSY <<16 |COMMAND_COMPLETE <<8 ;
@@ -746,7 +746,7 @@ static void stex_scsi_done(struct st_ccb *ccb) } }else if (ccb->srb_status &SRB_SEE_SENSE ) - result =DRIVER_SENSE <<24 |SAM_STAT_CHECK_CONDITION ; + result =DID_OK <<16 |SAM_STAT_CHECK_CONDITION ;else switch (ccb->srb_status) {case SRB_STATUS_SELECTION_TIMEOUT : result =DID_NO_CONNECT <<16 |COMMAND_COMPLETE <<8 ;
drivers/scsi/sym53c8xx_2/sym_glue.c +2 -4
@@ -174,9 +174,8 @@ static int sym_xerr_cam_status(int cam_status, int x_status)void sym_set_cam_result_error (struct sym_hcb *np,struct sym_ccb *cp,int resid) {struct scsi_cmnd *cmd = cp->cmd; -u_int cam_status, scsi_status, drv_status; +u_int cam_status, scsi_status; - drv_status =0 ; cam_status =DID_OK ; scsi_status = cp->ssss_status;
@@ -190,7 +189,6 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) cp->xerr_status == 0) { cam_status =sym_xerr_cam_status (DID_OK , cp->sv_xerr_status); - drv_status =DRIVER_SENSE ;/* * Bounce back the sense data to user. */
@@ -239,7 +237,7 @@ void sym_set_cam_result_error(struct sym_hcb *np, struct sym_ccb *cp, int resid) cam_status =sym_xerr_cam_status (DID_ERROR , cp->xerr_status); }scsi_set_resid (cmd, resid); - cmd->result = (drv_status <<24 ) | (cam_status <<16 ) | scsi_status; + cmd->result = (cam_status <<16 ) | scsi_status; }static int sym_scatter (struct sym_hcb *np,struct sym_ccb *cp,struct scsi_cmnd *cmd)
drivers/scsi/ufs/ufshcd.c +1 -1
@@ -7600,7 +7600,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba,sdev_printk (KERN_WARNING , sdp,"START_STOP failed for power mode: %d, result %x\n" , pwr_mode, ret); -if (driver_byte (ret) ==DRIVER_SENSE ) +if (scsi_sense_valid (&sshdr))scsi_print_sense_hdr (sdp,NULL , &sshdr); }
drivers/scsi/virtio_scsi.c +1 -2
@@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)min_t (u32,virtio32_to_cpu (vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); -if (resp->sense_len) -set_driver_byte (sc,DRIVER_SENSE ); +set_status_byte (sc,SAM_STAT_CHECK_CONDITION ); } sc->scsi_done (sc);
drivers/scsi/vmw_pvscsi.c +0 -3
@@ -565,9 +565,6 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, cmd->result = (DID_RESET <<16 ); }else { cmd->result = (DID_OK <<16 ) | sdstat; -if (sdstat ==SAM_STAT_CHECK_CONDITION && - cmd->sense_buffer) - cmd->result |= (DRIVER_SENSE <<24 ); } }else switch (btstat) {
drivers/target/loopback/tcm_loop.c +0 -1
@@ -579,7 +579,6 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd)memcpy (sc->sense_buffer, se_cmd->sense_buffer,SCSI_SENSE_BUFFERSIZE ); sc->result =SAM_STAT_CHECK_CONDITION ; -set_driver_byte (sc,DRIVER_SENSE ); }else sc->result = se_cmd->scsi_status;
drivers/usb/storage/cypress_atacb.c +2 -2
@@ -221,11 +221,11 @@ static void cypress_atacb_passthrough(struct scsi_cmnd *srb, struct us_data *us) desc[12 ] = regs[6 ];/* device */ desc[13 ] = regs[7 ];/* command */ - srb->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; + srb->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; } goto end; invalid_fld: - srb->result = (DRIVER_SENSE <<24 ) |SAM_STAT_CHECK_CONDITION ; + srb->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ; memcpy(srb->sense_buffer, usb_stor_sense_invalidCDB,
drivers/xen/xen-scsiback.c +1 -1
@@ -1431,7 +1431,7 @@ static int scsiback_queue_status(struct se_cmd *se_cmd)if (se_cmd->sense_buffer && ((se_cmd->se_cmd_flags &SCF_TRANSPORT_TASK_SENSE ) || (se_cmd->se_cmd_flags &SCF_EMULATED_TASK_SENSE ))) - pending_req->result = (DRIVER_SENSE <<24 ) | + pending_req->result = (DID_OK <<16 ) |SAM_STAT_CHECK_CONDITION ;else pending_req->result = se_cmd->scsi_status;
include/scsi/scsi.h +0 -1
@@ -173,7 +173,6 @@ static inline int scsi_is_wlun(u64 lun)#define DRIVER_INVALID 0x05#define DRIVER_TIMEOUT 0x06#define DRIVER_HARD 0x07 -#define DRIVER_SENSE 0x08/* * Internal return values.
include/scsi/sg.h +1 -2
@@ -234,8 +234,7 @@ struct sg_header unsigned int other_flags:10; /* unused */unsigned char sense_buffer[SG_MAX_SENSE ];/* [o] Output in 3 cases: when target_status is CHECK_CONDITION or -when target_status is COMMAND_TERMINATED or -when (driver_status & DRIVER_SENSE) is true. */ +when target_status is COMMAND_TERMINATED */ };/* This structure is 36 bytes long on i386 */
include/trace/events/scsi.h +1 -2
@@ -134,8 +134,7 @@ scsi_driverbyte_name(DRIVER_ERROR), \ scsi_driverbyte_name(DRIVER_INVALID), \ scsi_driverbyte_name(DRIVER_TIMEOUT), \ -scsi_driverbyte_name (DRIVER_HARD ), \ - scsi_driverbyte_name(DRIVER_SENSE)) + scsi_driverbyte_name(DRIVER_HARD))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
drivers/scsi/megaraid/megaraid_sas_base.c line 4
Quoted 10 lines
drivers/scsi/megaraid/megaraid_sas_base.c +1
-0@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Linux MegaRAID driver for SAS based RAID controllers
Typo?
drivers/scsi/scsi.c void scsi_finish_command(struct scsi_cmnd *cmd) · line 207
Quoted 11 lines
index
59443e0184fd..d6ecb773c512100644drivers/scsi/scsi.c +2
-2@@ -203,8 +203,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)* If we have valid sense information, then some kind of recovery * must have taken place. Make a note of this. */ -if (SCSI_SENSE_VALID (cmd)) - cmd->result |= (DRIVER_SENSE <<24 ); +if (SCSI_SENSE_VALID (cmd) &&status_byte (cmd->result) ==SAM_STAT_GOOD ) +set_status_byte (cmd,SAM_STAT_CHECK_CONDITION );
This means that a REQUEST SENSE command can never result in SAM_STAT_GOOD, right? Are there implications for higher layers?
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 13 lines · Finn Thain
drivers/scsi/megaraid/megaraid_sas_base.c line 4
Quoted 10 lines
drivers/scsi/megaraid/megaraid_sas_base.c +1
-0@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * Linux MegaRAID driver for SAS based RAID controllers Typo?
Indeed. Will fix it up.
Quoted 6 lines
Quoted 6 lines
index
59443e0184fd..d6ecb773c512100644drivers/scsi/scsi.c +0
-0@@ -203,8 +203,8 @@ void scsi_finish_command(struct scsi_cmnd *cmd)* If we have valid sense information, then some kind of recovery * must have taken place. Make a note of this.
Quoted 9 lines
drivers/scsi/scsi.c void scsi_finish_command(struct scsi_cmnd *cmd) · line 207
Quoted 5 lines
drivers/scsi/scsi.c +2
-2*/ -if (SCSI_SENSE_VALID (cmd)) - cmd->result |= (DRIVER_SENSE <<24 ); +if (SCSI_SENSE_VALID (cmd) &&status_byte (cmd->result) ==SAM_STAT_GOOD ) +set_status_byte (cmd,SAM_STAT_CHECK_CONDITION );This means that a REQUEST SENSE command can never result in
SAM_STAT_GOOD, right? Are there implications for higher layers?
Hmm. Blasted REQUEST SENSE.
Indeed a REQUEST SENSE command should never return with CHECK_CONDITION. But then a REQUEST SENSE command returns with the sense code in the payload, which equally is not something which is expected.
I'll be having a look here.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
In reply to Hannes ReineckeHi,
Quoted 6 lines · Hannes Reinecke
Replace the check for
DRIVER_SENSEwith a check forSAM_STAT_CHECK_CONDITIONand audit all callsites to ensure the SAM status is set correctly.Signed-off-by Hannes Reinecke <[email protected]>---
...
Quoted 1 line
drivers/scsi/virtio_scsi.c | 3 +-
A bisection says that this patch breaks virto_scsi for me. The (virtual) disk is not found by the kernel.
GOOD:
scsi 0:0:0:0: Direct-Access QEMU QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5
BAD:
scsi 0:0:0:0: Power-on or device reset occurred
I cannot revert the patch on the top of -next as there are conflicts...
Any ideas?
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 19 lines · Jiri Slaby
Hi,
Quoted 6 lines · Hannes Reinecke
Replace the check for
DRIVER_SENSEwith a check forSAM_STAT_CHECK_CONDITIONand audit all callsites to ensure the SAM status is set correctly.Signed-off-by Hannes Reinecke <[email protected]>---
...
Quoted 1 line
drivers/scsi/virtio_scsi.c | 3 +-
A bisection says that this patch breaks
virto_scsifor me. The (virtual) disk is not found by the kernel.GOOD:
scsi 0:0:0:0: Direct-Access QEMU QEMU HARDDISK 2.5+ PQ: 0
ANSI: 5
Quoted 7 lines
BAD:
scsi 0:0:0:0: Power-on or device reset occurredI cannot revert the patch on the top of -next as there are conflicts...
Any ideas?
Can you enable SCSI logging via
scsi.scsi_logging_level=216
on the kernel commandline and send me the output?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, 90409 Nürnberg GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Hannes,
Quoted 7 lines
Quoted 3 lines
Any ideas?
Can you enable SCSI logging via
scsi.scsi_logging_level=216
on the kernel commandline and send me the output?
You now effectively set SAM_STAT_CHECK_CONDITION if the scsi_cmnd has a sense buffer.
The original code only set DRIVER_SENSE if the adapter response actually contained sense information:
@@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)
min_t(u32,
virtio32_to_cpu(vscsi->vdev, resp->sense_len),
VIRTIO_SCSI_SENSE_SIZE));
- if (resp->sense_len)
- set_driver_byte(sc, DRIVER_SENSE);
+ set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
}Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 18 lines · Martin K. Petersen
Hannes,
Quoted 7 lines
Quoted 3 lines
Any ideas?
Can you enable SCSI logging via
scsi.scsi_logging_level=216
on the kernel commandline and send me the output?
You now effectively set
SAM_STAT_CHECK_CONDITIONif thescsi_cmndhas a sense buffer.The original code only set
DRIVER_SENSEif the adapter response actually contained sense information:
Review static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) · line 166
Quoted 8 lines
(quoted diff) +1
-2@@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) min_t(u32, virtio32_to_cpu(vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); - if (resp->sense_len) - set_driver_byte(sc, DRIVER_SENSE); + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); }
Oh, I know. But we're checking for a valid sense code during scanning:
if (scsi_status_is_check_condition(result) &&
scsi_sense_valid(&sshdr)) {so if that makes a difference it would mean that the virtio driver has some stale sense data which then gets copied over.
Anyway.
Can you test with this patch?
drivers/scsi/virtio_scsi.c +0 -0
@@ -161,7 +161,8 @@ static void virtscsi_complete_cmd(struct virtio_scsi
*vscsi, void *buf)
min_t(u32,
virtio32_to_cpu(vscsi->vdev, resp->sense_len),
VIRTIO_SCSI_SENSE_SIZE));
- set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
+ if (resp->sense_len)
+ set_status_byte(sc, SAM_STAT_CHECK_CONDITION);
}
sc->scsi_done(sc);Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, 90409 Nürnberg GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 29 lines · Hannes Reinecke
Quoted 18 lines · Martin K. Petersen
Hannes,
Quoted 7 lines
Quoted 3 lines
Any ideas?
Can you enable SCSI logging via
scsi.scsi_logging_level=216
on the kernel commandline and send me the output?
You now effectively set
SAM_STAT_CHECK_CONDITIONif thescsi_cmndhas a sense buffer.The original code only set
DRIVER_SENSEif the adapter response actually contained sense information:Review static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) · line 166
Quoted 8 lines
(quoted diff) +1
-2@@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) min_t(u32, virtio32_to_cpu(vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); - if (resp->sense_len) - set_driver_byte(sc, DRIVER_SENSE); + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); }Oh, I know. But we're checking for a valid sense code during scanning:
Quoted 7 lines
if (scsi_status_is_check_condition(result) && scsi_sense_valid(&sshdr)) {so if that makes a difference it would mean that the virtio driver has some stale sense data which then gets copied over.
Anyway.
Can you test with this patch?
Yes, that boots, but is somehow sloooow (hard to tell what is causing this).
Anyway, the new print is still there with the patch:
[ 11.549986] sd 0:0:0:0: Power-on or device reset occurred
Quoted 14 lines
drivers/scsi/virtio_scsi.c +2
-1@@ -161,7 +161,8 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf)min_t (u32,virtio32_to_cpu (vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); -set_status_byte (sc,SAM_STAT_CHECK_CONDITION ); +if (resp->sense_len) +set_status_byte (sc,SAM_STAT_CHECK_CONDITION ); }
Quoted 2 lines
sc->scsi_done(sc);
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 40 lines · Jiri Slaby
Quoted 31 lines · Hannes Reinecke
Quoted 19 lines · Martin K. Petersen
Hannes,
Quoted 7 lines
Quoted 3 lines
Any ideas?
Can you enable SCSI logging via
scsi.scsi_logging_level=216
on the kernel commandline and send me the output?
You now effectively set
SAM_STAT_CHECK_CONDITIONif thescsi_cmndhas a sense buffer.The original code only set
DRIVER_SENSEif the adapter response actually contained sense information:Review static void virtscsi_complete_cmd(struct · line 167
Quoted 9 lines
(quoted diff) +1
-2@@ -161,8 +161,7 @@ static void virtscsi_complete_cmd(struct virtio_scsi *vscsi, void *buf) min_t(u32, virtio32_to_cpu(vscsi->vdev, resp->sense_len), VIRTIO_SCSI_SENSE_SIZE)); - if (resp->sense_len) - set_driver_byte(sc, DRIVER_SENSE); + set_status_byte(sc, SAM_STAT_CHECK_CONDITION); }Oh, I know. But we're checking for a valid sense code during scanning:
Quoted 7 lines
if (
scsi_status_is_check_condition(result)&&scsi_sense_valid(&sshdr)) {so if that makes a difference it would mean that the virtio driver has some stale sense data which then gets copied over.
Anyway.
Can you test with this patch?
Quoted 7 lines
Yes, that boots, but is somehow sloooow (hard to tell what is causing this).
Anyway, the new print is still there with the patch:
[ 11.549986] sd 0:0:0:0: Power-on or device reset occurredCool; one step further.
Can you check if the attached patch helps, too?
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, 90409 Nürnberg GF: F. Imendörffer, HRB 36809 (AG Nürnberg)
From f60b3ab985a555cd623b77f6da95cb094da08d2a Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <[email protected]>
Date: Thu, 10 Jun 2021 15:46:56 +0200
Subject: [PATCH 2/2] scsi: do not assume CHECK_CONDITION is set for valid
sense code
While the standard implies that a sense code should be returned in response to CHECK CONDITION status, it _might_ be returned on other status codes, too.
At least, that's what the original code assumed. So it's arguably wrong to assume we only will have a valid sense code when CHECK CONDITION is set.
--- drivers/scsi/sd.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)
drivers/scsi/sd.c +7 -9
@@ -1722,8 +1722,7 @@ static int sd_sync_cache(struct scsi_disk *sdkp, struct scsi_sense_hdr *sshdr)if (res <0 )return res; -if (scsi_status_is_check_condition (res) && -scsi_sense_valid (sshdr)) { +if (scsi_sense_valid (sshdr)) {sd_print_sense_hdr (sdkp, sshdr);/* we need to evaluate the error return */
@@ -1829,10 +1828,10 @@ static int sd_pr_command(struct block_device *bdev, u8 sa, result =scsi_execute_req (sdev, cmd,DMA_TO_DEVICE , &data,sizeof (data), &sshdr,SD_TIMEOUT , sdkp->max_retries,NULL ); -if (scsi_status_is_check_condition (result) && -scsi_sense_valid (&sshdr)) { +if (result) {sdev_printk (KERN_INFO , sdev,"PR command failed: %d\n" , result); -scsi_print_sense_hdr (sdev,NULL , &sshdr); +if (scsi_sense_valid (&sshdr)) +scsi_print_sense_hdr (sdev,NULL , &sshdr); }return result;
@@ -2073,7 +2072,7 @@ static int sd_done(struct scsi_cmnd *SCpnt) } sdkp->medium_access_timed_out =0 ; -if (!scsi_status_is_check_condition (result) && +if (result && (!sense_valid || sense_deferred)) goto out;
@@ -2178,10 +2177,9 @@ sd_spinup_disk(struct scsi_disk *sdkp) retries++; }while (retries <3 && (!scsi_status_is_good (the_result) || - (scsi_status_is_check_condition (the_result) && - sense_valid && sshdr.sense_key ==UNIT_ATTENTION ))); + (sense_valid && sshdr.sense_key ==UNIT_ATTENTION ))); -if (!scsi_status_is_check_condition (the_result)) { +if (the_result <0 || !sense_valid) {/* no sense, TUR either succeeded or failed * with a status error */ if (!spintime && !scsi_status_is_good (the_result)) {
Signature · 1 line
2.26.2
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 10 lines · Hannes Reinecke
Quoted 9 lines
Quoted 1 line
Can you test with this patch?
Yes, that boots, but is somehow sloooow (hard to tell what is causing this).
Anyway, the new print is still there with the patch:
[ 11.549986] sd 0:0:0:0: Power-on or device reset occurredCool; one step further.
Can you check if the attached patch helps, too?
No, this doesn't boot:
[ 20.293526] scsi host0: Virtio SCSI HBA [ 22.236517] scsi 0:0:0:0: Power-on or device reset occurred [ 22.237986] scsi 0:0:0:0: Power-on or device reset occurred
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 9 lines · Jiri Slaby
Quoted 8 lines · Hannes Reinecke
Quoted 8 lines
Quoted 1 line
Can you test with this patch?
Yes, that boots, but is somehow sloooow (hard to tell what is causing this).
Anyway, the new print is still there with the patch:
[ 11.549986] sd 0:0:0:0: Power-on or device reset occurred
Quoted 8 lines
Quoted 2 lines
Quoted 1 line
Cool; one step further.
Can you check if the attached patch helps, too?
No, this doesn't boot:
[ 20.293526] scsi host0: Virtio SCSI HBA
[ 22.236517] scsi 0:0:0:0: Power-on or device reset occurred [ 22.237986] scsi 0:0:0:0: Power-on or device reset occurred
Ok, thought so.
So it's really looks like the virtio driver is copying stale sense data.
Next try:
Can you take the patch from the mailing list (virtio_scsi: do not overwrite SCSI status), and enable SCSI logging level eg via
scsi.scsi_logging_level=216
on the kernel command line.
That should give us some hint why it's so slow.
Alternatively: which configuration do you use?
Maybe I can reproduce it here locally ...
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Kernel Storage Architect [email protected] +49 911 74053 688 SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
Quoted 2 lines · Hannes Reinecke
Alternatively: which configuration do you use?
Maybe I can reproduce it here locally ...
It's quite easy:
qemu-img create /tmp/dr.img 1G
qemu-kvm -smp 4 -m 2G -drive file=/tmp/dr.img,if=none,id=hd,format=raw -device virtio-scsi-pci,id=scsi -device scsi-hd,drive=hd -serial stdio -kernel /path/to/bzImage -append 'console=ttyS0' -nographic -monitor none
Either sda appears or not... Assuming virtio_scsi and sd are built in.
thanks,
Signature · 2 lines
js suse labs
Re: [PATCH 13/24] scsi: Kill DRIVER_SENSE
In reply to Hannes ReineckeQuoted 2 lines · Hannes Reinecke
Next try:
Can you take the patch from the mailing list (virtio_scsi: do not overwrite SCSI status),
That ([email protected] for reference) works fine for me:
[ 3.173255] scsi host0: Virtio SCSI HBA [ 3.183529] scsi 0:0:0:0: Direct-Access QEMU QEMU HARDDISK 2.5+ PQ: 0 ANSI: 5 [ 3.220967] sd 0:0:0:0: Power-on or device reset occurred [ 3.226150] sd 0:0:0:0: [sda] 20971520 512-byte logical blocks: (10.7 GB/10.0 GiB) [ 3.230889] sd 0:0:0:0: [sda] Write Protect is off [ 3.232772] sd 0:0:0:0: [sda] Mode Sense: 63 00 00 08 [ 3.233633] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA [ 3.239478] sda: sda1 sda2 [ 3.243752] sd 0:0:0:0: [sda] Attached SCSI disk
thanks,
Signature · 2 lines
js suse labs
PATCH 14/24 scsi: Kill DRIVER_HARD
In reply to Hannes ReineckeUnused.
--- drivers/scsi/constants.c | 2 +- include/scsi/scsi.h | 1 - include/trace/events/scsi.h | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/constants.c +1 -1
@@ -408,7 +408,7 @@ static const char * const hostbyte_table[]={static const char *const driverbyte_table[]={"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" , -"DRIVER_INVALID" ,"DRIVER_TIMEOUT" ,"DRIVER_HARD" }; +"DRIVER_INVALID" ,"DRIVER_TIMEOUT" };const char *scsi_hostbyte_string (int result) {
include/scsi/scsi.h +0 -1
@@ -172,7 +172,6 @@ static inline int scsi_is_wlun(u64 lun)#define DRIVER_INVALID 0x05#define DRIVER_TIMEOUT 0x06 -#define DRIVER_HARD 0x07/* * Internal return values.
include/trace/events/scsi.h +1 -2
@@ -133,8 +133,7 @@ scsi_driverbyte_name(DRIVER_MEDIA), \ scsi_driverbyte_name(DRIVER_ERROR), \ scsi_driverbyte_name(DRIVER_INVALID), \ -scsi_driverbyte_name (DRIVER_TIMEOUT ), \ - scsi_driverbyte_name(DRIVER_HARD)) + scsi_driverbyte_name(DRIVER_TIMEOUT))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
PATCH 15/24 scsi_error: use DID_TIME_OUT instead of DRIVER_TIMEOUT
In reply to Hannes ReineckeSet DID_TIME_OUT instead of DRIVER_TIMEOUT when a command is finally marked as failed after error recovery.
--- drivers/scsi/scsi_error.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/scsi_error.c +2 -2
@@ -2100,10 +2100,10 @@ void scsi_eh_flush_done_q(struct list_head *done_q)/* * If just we got sense for the device (called * scsi_eh_get_sense), scmd->result is already -* set, do not set DRIVER_TIMEOUT. +* set, do not set DID_TIME_OUT. */ if (!scmd->result) - scmd->result |= (DRIVER_TIMEOUT <<24 ); + scmd->result |= (DID_TIME_OUT <<16 ); SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd, "%s: flush finish cmd\n",
Signature · 1 line
2.16.4
PATCH 16/24 scsi: Kill DRIVER_TIMEOUT
In reply to Hannes ReineckeUnused now.
--- drivers/scsi/constants.c | 2 +- include/scsi/scsi.h | 1 - include/trace/events/scsi.h | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/scsi/constants.c +1 -1
@@ -408,7 +408,7 @@ static const char * const hostbyte_table[]={static const char *const driverbyte_table[]={"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" , -"DRIVER_INVALID" ,"DRIVER_TIMEOUT" }; +"DRIVER_INVALID" };const char *scsi_hostbyte_string (int result) {
include/scsi/scsi.h +0 -1
@@ -171,7 +171,6 @@ static inline int scsi_is_wlun(u64 lun)#define DRIVER_ERROR 0x04#define DRIVER_INVALID 0x05 -#define DRIVER_TIMEOUT 0x06/* * Internal return values.
include/trace/events/scsi.h +1 -2
@@ -132,8 +132,7 @@ scsi_driverbyte_name(DRIVER_SOFT), \ scsi_driverbyte_name(DRIVER_MEDIA), \ scsi_driverbyte_name(DRIVER_ERROR), \ -scsi_driverbyte_name (DRIVER_INVALID ), \ - scsi_driverbyte_name(DRIVER_TIMEOUT)) + scsi_driverbyte_name(DRIVER_INVALID))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
PATCH 17/24 scsi: do not use DRIVER_INVALID
In reply to Hannes ReineckeUse DID_ERROR instead of DRIVER_INVALID, as it really doesn't matter if the driver or the device didn't understand the command.
--- drivers/scsi/constants.c | 3 +-- drivers/scsi/hptiop.c | 2 +- drivers/scsi/mvumi.c | 10 +++++----- drivers/scsi/vmw_pvscsi.c | 18 +++++++++--------- include/scsi/scsi.h | 2 -- include/trace/events/scsi.h | 3 +-- 6 files changed, 17 insertions(+), 21 deletions(-)
drivers/scsi/constants.c +1 -2
@@ -407,8 +407,7 @@ static const char * const hostbyte_table[]={ "DID_NEXUS_FAILURE" };static const char *const driverbyte_table[]={ -"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" , -"DRIVER_INVALID" }; +"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" };const char *scsi_hostbyte_string (int result) {
drivers/scsi/hptiop.c +1 -1
@@ -761,7 +761,7 @@ static void hptiop_finish_scsi_req(struct hptiop_hba *hba, u32 tag,break ;default : - scp->result =DRIVER_INVALID <<24 |DID_ABORT <<16 ; + scp->result = (DID_ERROR <<16 );break ; }
drivers/scsi/mvumi.c +5 -5
@@ -1306,20 +1306,20 @@ static void mvumi_complete_cmd(struct mvumi_hba *mhba, struct mvumi_cmd *cmd,switch (ob_frame->req_status) {case SAM_STAT_GOOD : - scmd->result |=DID_OK <<16 ; +set_host_byte (scmd,DID_OK );break ;case SAM_STAT_BUSY : - scmd->result |=DID_BUS_BUSY <<16 ; +set_host_byte (scmd,DID_BUS_BUSY );break ;case SAM_STAT_CHECK_CONDITION : - scmd->result |= (DID_OK <<16 ); +set_host_byte (scmd,DID_OK );if (ob_frame->rsp_flag &CL_RSP_FLAG_SENSEDATA ) {memcpy (cmd->scmd->sense_buffer, ob_frame->payload,sizeof (struct mvumi_sense_data )); }break ;default : - scmd->result |= (DRIVER_INVALID <<24 ) | (DID_ABORT <<16 ); +set_host_byte (scmd,DID_ABORT );break ; }
@@ -2126,7 +2126,7 @@ static enum blk_eh_timer_return mvumi_timed_out(struct scsi_cmnd *scmd)else atomic_dec (&mhba->fw_outstanding); - scmd->result = (DRIVER_INVALID <<24 ) | (DID_ABORT <<16 ); + scmd->result = (DID_ABORT <<16 ); scmd->SCp.ptr =NULL ;if (scsi_bufflen (scmd)) { dma_unmap_sg(&mhba->pdev->dev, scsi_sglist(scmd),
drivers/scsi/vmw_pvscsi.c +9 -9
@@ -572,25 +572,25 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,case BTSTAT_LINKED_COMMAND_COMPLETED :case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG :/* If everything went fine, let's move on.. */ - cmd->result = (DID_OK <<16 ); +set_host_byte (cmd,DID_OK );break ;case BTSTAT_DATARUN :case BTSTAT_DATA_UNDERRUN :/* Report residual data in underruns */ scsi_set_resid (cmd,scsi_bufflen (cmd) - e->dataLen); - cmd->result = (DID_ERROR <<16 ); +set_host_byte (cmd,DID_ERROR );break ;case BTSTAT_SELTIMEO :/* Our emulation returns this for non-connected devs */ - cmd->result = (DID_BAD_TARGET <<16 ); +set_host_byte (cmd,DID_BAD_TARGET );break ;case BTSTAT_LUNMISMATCH :case BTSTAT_TAGREJECT :case BTSTAT_BADMSG : - cmd->result = (DRIVER_INVALID <<24 ); + cmd->result =0 ;/* fall through */ case BTSTAT_HAHARDWARE :
@@ -601,25 +601,25 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,case BTSTAT_HASOFTWARE :case BTSTAT_BUSFREE :case BTSTAT_SENSFAILED : - cmd->result |= (DID_ERROR <<16 ); +set_host_byte (cmd,DID_ERROR );break ;case BTSTAT_SENTRST :case BTSTAT_RECVRST :case BTSTAT_BUSRESET : - cmd->result = (DID_RESET <<16 ); +set_host_byte (cmd,DID_RESET );break ;case BTSTAT_ABORTQUEUE : - cmd->result = (DID_BUS_BUSY <<16 ); +set_host_byte (cmd,DID_BUS_BUSY );break ;case BTSTAT_SCSIPARITY : - cmd->result = (DID_PARITY <<16 ); +set_host_byte (cmd,DID_PARITY );break ;default : - cmd->result = (DID_ERROR <<16 ); +set_host_byte (cmd,DID_ERROR );scmd_printk (KERN_DEBUG , cmd,"Unknown completion status: 0x%x\n" , btstat);
include/scsi/scsi.h +0 -2
@@ -170,8 +170,6 @@ static inline int scsi_is_wlun(u64 lun)#define DRIVER_MEDIA 0x03#define DRIVER_ERROR 0x04 -#define DRIVER_INVALID 0x05 -/* * Internal return values. */
include/trace/events/scsi.h +1 -2
@@ -131,8 +131,7 @@ scsi_driverbyte_name(DRIVER_BUSY), \ scsi_driverbyte_name(DRIVER_SOFT), \ scsi_driverbyte_name(DRIVER_MEDIA), \ -scsi_driverbyte_name (DRIVER_ERROR ), \ - scsi_driverbyte_name(DRIVER_INVALID)) + scsi_driverbyte_name(DRIVER_ERROR))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
PATCH 18/24 st: return error code in st_scsi_execute()
In reply to Hannes ReineckeWe should return the actual error code in st_scsi_execute(), avoiding the need to use DRIVER_ERROR.
--- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/st.c +2 -2
@@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, data_direction ==DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0);if (IS_ERR (req)) -return DRIVER_ERROR <<24 ; +return PTR_ERR (req); rq =scsi_req (req); req->rq_flags |=RQF_QUIET ;
@@ -560,7 +560,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, GFP_KERNEL);if (err) {blk_put_request (req); -return DRIVER_ERROR <<24 ; +return err; } }
Signature · 1 line
2.16.4
Bart Van Assche
maintainerRe: [PATCH 18/24] st: return error code in st_scsi_execute()
Quoted 22 lines · Hannes Reinecke
We should return the actual error code in
st_scsi_execute(), avoiding the need to useDRIVER_ERROR.Signed-off-by Hannes Reinecke <[email protected]>--- drivers/scsi/st.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/st.c +1
-1@@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, data_direction ==DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, 0);if (IS_ERR (req)) -return DRIVER_ERROR <<24 ; +return PTR_ERR (req); rq =scsi_req (req); req->rq_flags |=RQF_QUIET ;
drivers/scsi/st.c static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, · line 565
Quoted 7 lines
drivers/scsi/st.c +1
-1@@ -560,7 +560,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd, GFP_KERNEL);if (err) {blk_put_request (req); -return DRIVER_ERROR <<24 ; +return err; } }
The patch description looks confusing to me. Is it perhaps because the caller compares the st_scsi_execute() return value with zero and doesn't use the return value in any other way that it is fine to return an integer error code instead of a SCSI status?
Thanks,
Bart.
Re: [PATCH 18/24] st: return error code in st_scsi_execute()
Quoted 28 lines · Bart Van Assche
Quoted 27 lines · Hannes Reinecke
We should return the actual error code in
st_scsi_execute(), avoiding the need to useDRIVER_ERROR.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/scsi/st.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/st.c +0
-0@@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
data_direction==DMA_TO_DEVICE?REQ_OP_SCSI_OUT:REQ_OP_SCSI_IN, 0);
if (IS_ERR(req))
- returnDRIVER_ERROR<< 24;
+ returnPTR_ERR(req);
rq =scsi_req(req);
req->rq_flags|=RQF_QUIET;
@@ -560,7 +560,7 @@ static int st_scsi_execute(structst_request*SRpnt, const unsigned char *cmd,
GFP_KERNEL);
if (err) {
blk_put_request(req);
- returnDRIVER_ERROR<< 24;
Quoted 9 lines
Quoted 3 lines
+ return err;
}
}The patch description looks confusing to me. Is it perhaps because the caller compares the
st_scsi_execute()return value with zero and doesn't use the return value in any other way that it is fine to return an integer error code instead of a SCSI status?
Yes. The caller does:
ret = st_scsi_execute(SRpnt, cmd, direction, NULL, bytes, timeout,
retries);
if (ret) {
/* could not allocate the buffer or request was too large */
(STp->buffer)->syscall_result = (-EBUSY);
(STp->buffer)->last_SRpnt = NULL;So it's immaterial _what_ we return here as long as it's non-zero.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
Bart Van Assche
maintainerRe: [PATCH 18/24] st: return error code in st_scsi_execute()
Quoted 40 lines · Hannes Reinecke
Quoted 28 lines · Bart Van Assche
Quoted 27 lines · Hannes Reinecke
We should return the actual error code in
st_scsi_execute(), avoiding the need to useDRIVER_ERROR.Signed-off-by Hannes Reinecke <[email protected]>---
drivers/scsi/st.c| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)drivers/scsi/st.c +0
-0@@ -549,7 +549,7 @@ static int st_scsi_execute(struct st_request *SRpnt, const unsigned char *cmd,
data_direction==DMA_TO_DEVICE?REQ_OP_SCSI_OUT:REQ_OP_SCSI_IN, 0);
if (IS_ERR(req))
- returnDRIVER_ERROR<< 24;
+ returnPTR_ERR(req);
rq =scsi_req(req);
req->rq_flags|=RQF_QUIET;
@@ -560,7 +560,7 @@ static int st_scsi_execute(structst_request*SRpnt, const unsigned char *cmd,
GFP_KERNEL);
if (err) {
blk_put_request(req);
- returnDRIVER_ERROR<< 24;Quoted 9 lines
Quoted 3 lines
+ return err;
}
}The patch description looks confusing to me. Is it perhaps because the caller compares the
st_scsi_execute()return value with zero and doesn't use the return value in any other way that it is fine to return an integer error code instead of a SCSI status?Yes. The caller does:
Quoted 8 lines
ret = st_scsi_execute(SRpnt, cmd, direction, NULL, bytes, timeout, retries); if (ret) { /* could not allocate the buffer or request was too large */ (STp->buffer)->syscall_result = (-EBUSY); (STp->buffer)->last_SRpnt = NULL;So it's immaterial _what_ we return here as long as it's non-zero.
Please make this clear in the patch description. I think that will make this patch easier to review.
Thanks,
Bart.
PATCH 19/24 scsi_ioctl: return error code when blk_map_user() fails
In reply to Hannes ReineckeWhen failing to map the user buffer we should return the actual error code, avoiding the usage of DRIVER_ERROR.
--- block/scsi_ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
block/scsi_ioctl.c +4 -3
@@ -485,9 +485,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,break ; } -if (bytes &&blk_rq_map_kern (q, rq, buffer, bytes,GFP_NOIO )) { - err =DRIVER_ERROR <<24 ; - goto error; +if (bytes) { + err =blk_rq_map_kern (q, rq, buffer, bytes,GFP_NOIO ); +if (err) + goto error; }blk_execute_rq (q, disk, rq,0 );
Signature · 1 line
2.16.4
Bart Van Assche
maintainerRe: [PATCH 19/24] scsi_ioctl: return error code when blk_map_user() fails
Quoted 16 lines · Hannes Reinecke
When failing to map the user buffer we should return the actual error code, avoiding the usage of
DRIVER_ERROR.Signed-off-by Hannes Reinecke <[email protected]>--- block/scsi_ioctl.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)block/scsi_ioctl.c +0
-0@@ -485,9 +485,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,break ; }
block/scsi_ioctl.c int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, · line 494
Quoted 10 lines
block/scsi_ioctl.c +4
-3-if (bytes &&blk_rq_map_kern (q, rq, buffer, bytes,GFP_NOIO )) { - err =DRIVER_ERROR <<24 ; - goto error; +if (bytes) { + err =blk_rq_map_kern (q, rq, buffer, bytes,GFP_NOIO ); +if (err) + goto error; }blk_execute_rq (q, disk, rq,0 );
Since sg_scsi_ioctl() is used to implement SCSI_IOCTL_SEND_COMMAND, does this patch change the ABI between user space and kernel in a backwards-incompatible way?
Thanks,
Bart.
Re: [PATCH 19/24] scsi_ioctl: return error code when blk_map_user() fails
Quoted 22 lines · Bart Van Assche
Quoted 21 lines · Hannes Reinecke
When failing to map the user buffer we should return the actual error code, avoiding the usage of
DRIVER_ERROR.Signed-off-by Hannes Reinecke <[email protected]>---
block/scsi_ioctl.c| 7 ++++---1 file changed, 4 insertions(+), 3 deletions(-)block/scsi_ioctl.c +2
-2@@ -485,9 +485,10 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, break; } - if (bytes && blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO)) { - err = DRIVER_ERROR << 24; - goto error; + if (bytes) { + err = blk_rq_map_kern(q, rq, buffer, bytes, GFP_NOIO);
Quoted 9 lines
block/scsi_ioctl.c int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode, · line 494
Quoted 4 lines
block/scsi_ioctl.c +2
-0+ if (err) + goto error; } blk_execute_rq(q, disk, rq, 0);Since
sg_scsi_ioctl()is used to implementSCSI_IOCTL_SEND_COMMAND, does this patch change the ABI between user space and kernel in a backwards-incompatible way?
Not really. We do change the return code, but sg_scsi_ioctl() already returns negative POSIX error numbers on failure. And, in fact, this position is the _only_ possible case where we return something else than either an errno or a SCSI status. Which arguably is an error even in the current code.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer
PATCH 20/24 scsi_dh_alua: do not interpret DRIVER_ERROR
In reply to Hannes ReineckeRemove the special handling for DRIVER_ERROR; if there is an error we should just fail the command and don't try anything clever.
--- drivers/scsi/device_handler/scsi_dh_alua.c | 4 ---- 1 file changed, 4 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +0 -4
@@ -552,8 +552,6 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)"%s: rtpg failed, result %d\n" , ALUA_DH_NAME, retval);kfree (buff); -if (driver_byte (retval) ==DRIVER_ERROR ) -return SCSI_DH_DEV_TEMP_BUSY ;return SCSI_DH_IO ; }
@@ -766,8 +764,6 @@ static unsigned alua_stpg(struct scsi_device *sdev, struct alua_port_group *pg)sdev_printk (KERN_INFO , sdev,"%s: stpg failed, result %d" ,ALUA_DH_NAME , retval); -if (driver_byte (retval) ==DRIVER_ERROR ) -return SCSI_DH_DEV_TEMP_BUSY ; }else {sdev_printk (KERN_INFO , sdev,"%s: stpg failed\n" ,ALUA_DH_NAME );
Signature · 1 line
2.16.4
PATCH 21/24 xen-scsiback: stop using DRIVER_ERROR
In reply to Hannes ReineckeReturn DID_ERROR instead of DRIVER_ERROR for internal failures.
--- drivers/xen/xen-scsiback.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/xen/xen-scsiback.c +5 -5
@@ -260,10 +260,10 @@ static void scsiback_print_status(char *sense_buffer, int errors, {struct scsiback_tpg *tpg = pending_req->v2p->tpg; -pr_err ("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=%02x\n" , +pr_err ("[%s:%d] cmnd[0]=%02x -> st=%02x msg=%02x host=%02x drv=0\n" , tpg->tport->tport_name, pending_req->v2p->lun, pending_req->cmnd[0 ],status_byte (errors),msg_byte (errors), -host_byte (errors),driver_byte (errors)); +host_byte (errors)); }static void scsiback_fast_flush_area (struct vscsibk_pend *req)
@@ -757,7 +757,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info) result =DID_NO_CONNECT ;break ;default : - result =DRIVER_ERROR ; + result =DID_ERROR ;break ; } scsiback_send_response(info, NULL, result << 24, 0,
@@ -770,7 +770,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)if (scsiback_gnttab_data_map (&ring_req, pending_req)) {scsiback_fast_flush_area (pending_req);scsiback_do_resp_with_sense (NULL , -DRIVER_ERROR <<24 ,0 , pending_req); +DID_ERROR <<16 ,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,0 ); }else {scsiback_cmd_exec (pending_req);
@@ -785,7 +785,7 @@ static int scsiback_do_cmd_fn(struct vscsibk_info *info)break ;default :pr_err_ratelimited ("invalid request\n" ); -scsiback_do_resp_with_sense (NULL ,DRIVER_ERROR <<24 ,0 , +scsiback_do_resp_with_sense (NULL ,DID_ERROR <<16 ,0 , pending_req);transport_generic_free_cmd (&pending_req->se_cmd,0 );break ;
Signature · 1 line
2.16.4
PATCH 22/24 scsi: stop using DRIVER_ERROR
In reply to Hannes ReineckeReturn the actual error code in __scsi_execute() (which, according to the documentation, should have happened anyway).
And audit all callers to cope with negative return values from __scsi_execute() and friends.
--- drivers/scsi/ch.c | 2 ++ drivers/scsi/constants.c | 2 +- drivers/scsi/scsi.c | 2 ++ drivers/scsi/scsi_lib.c | 15 +++++++++------ drivers/scsi/ufs/ufshcd.c | 4 +--- include/scsi/scsi.h | 1 - include/trace/events/scsi.h | 3 +-- 7 files changed, 16 insertions(+), 13 deletions(-)
drivers/scsi/ch.c +2 -0
@@ -199,6 +199,8 @@ ch_do_scsi(scsi_changer *ch, unsigned char *cmd, int cmd_len, result =scsi_execute_req (ch->device, cmd, direction, buffer, buflength, &sshdr, timeout *HZ ,MAX_RETRIES ,NULL ); +if (result <0 ) +return result;if (status_byte (result) ==SAM_STAT_CHECK_CONDITION ) {if (debug)scsi_print_sense_hdr (ch->device, ch->name, &sshdr);
drivers/scsi/constants.c +1 -1
@@ -407,7 +407,7 @@ static const char * const hostbyte_table[]={ "DID_NEXUS_FAILURE" };static const char *const driverbyte_table[]={ -"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" ,"DRIVER_ERROR" }; +"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" };const char *scsi_hostbyte_string (int result) {
drivers/scsi/scsi.c +2 -0
@@ -509,6 +509,8 @@ int scsi_report_opcode(struct scsi_device *sdev, unsigned char *buffer, result =scsi_execute_req (sdev, cmd,DMA_FROM_DEVICE , buffer, len, &sshdr,30 *HZ ,3 ,NULL ); +if (result <0 ) +return result;if (result &&scsi_sense_valid (&sshdr) && sshdr.sense_key ==ILLEGAL_REQUEST && (sshdr.asc ==0x20 || sshdr.asc ==0x24 ) && sshdr.ascq ==0x00 )
drivers/scsi/scsi_lib.c +9 -6
@@ -253,19 +253,22 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, {struct request *req;struct scsi_request *rq; -int ret =DRIVER_ERROR <<24 ; +int ret; req =blk_get_request (sdev->request_queue, data_direction ==DMA_TO_DEVICE ?REQ_OP_SCSI_OUT :REQ_OP_SCSI_IN ,BLK_MQ_REQ_PREEMPT );if (IS_ERR (req)) -return ret; - rq =scsi_req (req); +return PTR_ERR (req); -if (bufflen &&blk_rq_map_kern (sdev->request_queue, req, - buffer, bufflen,GFP_NOIO )) - goto out; + rq =scsi_req (req); +if (bufflen) { + ret =blk_rq_map_kern (sdev->request_queue, req, + buffer, bufflen,GFP_NOIO ); +if (ret) + goto out; + } rq->cmd_len =COMMAND_SIZE (cmd[0 ]);memcpy (rq->cmd, cmd, rq->cmd_len); rq->retries = retries;
drivers/scsi/ufs/ufshcd.c +1 -3
@@ -7602,9 +7602,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, pwr_mode, ret);if (scsi_sense_valid (&sshdr))scsi_print_sense_hdr (sdp,NULL , &sshdr); - } - -if (!ret) + }else hba->curr_dev_pwr_mode = pwr_mode; out:scsi_device_put (sdp);
include/scsi/scsi.h +0 -1
@@ -168,7 +168,6 @@ static inline int scsi_is_wlun(u64 lun)#define DRIVER_BUSY 0x01#define DRIVER_SOFT 0x02#define DRIVER_MEDIA 0x03 -#define DRIVER_ERROR 0x04/* * Internal return values.
include/trace/events/scsi.h +1 -2
@@ -130,8 +130,7 @@ scsi_driverbyte_name(DRIVER_OK), \ scsi_driverbyte_name(DRIVER_BUSY), \ scsi_driverbyte_name(DRIVER_SOFT), \ -scsi_driverbyte_name (DRIVER_MEDIA ), \ - scsi_driverbyte_name(DRIVER_ERROR)) + scsi_driverbyte_name(DRIVER_MEDIA))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
PATCH 23/24 scsi: Kill DRIVER_MEDIA, DRIVER_SOFT, and DRIVER_BUSY
In reply to Hannes ReineckeUnused.
--- drivers/message/fusion/mptscsih.c | 2 +- drivers/scsi/constants.c | 2 +- include/scsi/scsi.h | 8 -------- include/trace/events/scsi.h | 5 +---- 4 files changed, 3 insertions(+), 14 deletions(-)
drivers/message/fusion/mptscsih.c +1 -1
@@ -703,7 +703,7 @@ mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *mr)case MPI_IOCSTATUS_BUSY :/* 0x0002 */ case MPI_IOCSTATUS_INSUFFICIENT_RESOURCES :/* 0x0006 */ /* CHECKME! -* Maybe: DRIVER_BUSY | SUGGEST_RETRY | DID_SOFT_ERROR (retry) +* Maybe: SUGGEST_RETRY | DID_SOFT_ERROR (retry) * But not: DID_BUS_BUSY lest one risk * killing interrupt handler:-( */
drivers/scsi/constants.c +1 -1
@@ -407,7 +407,7 @@ static const char * const hostbyte_table[]={ "DID_NEXUS_FAILURE" };static const char *const driverbyte_table[]={ -"DRIVER_OK" ,"DRIVER_BUSY" ,"DRIVER_SOFT" ,"DRIVER_MEDIA" }; +"DRIVER_OK" };const char *scsi_hostbyte_string (int result) {
include/scsi/scsi.h +0 -8
@@ -161,14 +161,6 @@ static inline int scsi_is_wlun(u64 lun)#define DID_MEDIUM_ERROR 0x13/* Medium error */ #define DRIVER_OK 0x00/* Driver status */ -/* -* These indicate the error that occurred, and what is available. -*/ - -#define DRIVER_BUSY 0x01 -#define DRIVER_SOFT 0x02 -#define DRIVER_MEDIA 0x03 -/* * Internal return values. */
include/trace/events/scsi.h +1 -4
@@ -127,10 +127,7 @@#define scsi_driverbyte_name (result) { result, #result }#define show_driverbyte_name (val) \ __print_symbolic(val, \ - scsi_driverbyte_name(DRIVER_OK), \ - scsi_driverbyte_name(DRIVER_BUSY), \ - scsi_driverbyte_name(DRIVER_SOFT), \ - scsi_driverbyte_name(DRIVER_MEDIA)) + scsi_driverbyte_name(DRIVER_OK))#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \
Signature · 1 line
2.16.4
PATCH 24/24 scsi: Drop now obsolete driver_byte definitions
In reply to Hannes ReineckeThe driver_byte field in the result is now unused, so we can drop the definitions.
--- Documentation/scsi/scsi_mid_low_api.txt | 3 +-- block/bsg-lib.c | 2 +- block/bsg.c | 2 +- block/scsi_ioctl.c | 2 +- drivers/scsi/constants.c | 14 -------------- drivers/scsi/scsi_logging.c | 10 ++-------- drivers/scsi/sd.c | 9 ++++----- drivers/scsi/sd_zbc.c | 4 ++-- drivers/scsi/sg.c | 5 ++--- drivers/scsi/sr.c | 2 +- drivers/scsi/sr_ioctl.c | 2 +- drivers/scsi/st.c | 4 ++-- include/scsi/scsi.h | 3 --- include/scsi/scsi_cmnd.h | 4 ---- include/trace/events/scsi.h | 7 +------ 15 files changed, 19 insertions(+), 54 deletions(-)
Documentation/scsi/scsi_mid_low_api.txt +1 -2
@@ -1160,8 +1160,7 @@ Members of interest: target device). 'result' is a 32 bit unsigned integer that can be viewed as 4 related bytes. The SCSI status value is in the LSB. See include/scsi/scsi.h status_byte(), - msg_byte(), host_byte() and driver_byte() macros and - related constants. + msg_byte() and host_byte() macros and related constants. sense_buffer - an array (maximum size: SCSI_SENSE_BUFFERSIZE bytes) that should be written when the SCSI status (LSB of 'result') is set to CHECK_CONDITION (2). When CHECK_CONDITION is
block/bsg-lib.c +1 -1
@@ -84,7 +84,7 @@ static int bsg_transport_complete_rq(struct request *rq, struct sg_io_v4 *hdr)*/ hdr->device_status = job->result &0xff ; hdr->transport_status =host_byte (job->result); - hdr->driver_status =driver_byte (job->result); + hdr->driver_status =0 ; hdr->info =0 ;if (hdr->device_status || hdr->transport_status || hdr->driver_status) hdr->info |=SG_INFO_CHECK ;
block/bsg.c +1 -1
@@ -96,7 +96,7 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr)*/ hdr->device_status = sreq->result &0xff ; hdr->transport_status =host_byte (sreq->result); - hdr->driver_status =driver_byte (sreq->result); + hdr->driver_status =0 ; hdr->info =0 ;if (hdr->device_status || hdr->transport_status || hdr->driver_status) hdr->info |=SG_INFO_CHECK ;
block/scsi_ioctl.c +1 -1
@@ -252,7 +252,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr, hdr->masked_status =status_byte (req->result); hdr->msg_status =msg_byte (req->result); hdr->host_status =host_byte (req->result); - hdr->driver_status =driver_byte (req->result); + hdr->driver_status =0 ; hdr->info =0 ;if (hdr->masked_status || hdr->host_status || hdr->driver_status) hdr->info |=SG_INFO_CHECK ;
drivers/scsi/constants.c +0 -14
@@ -406,9 +406,6 @@ static const char * const hostbyte_table[]={"DID_TRANSPORT_DISRUPTED" ,"DID_TRANSPORT_FAILFAST" ,"DID_TARGET_FAILURE" , "DID_NEXUS_FAILURE" }; -static const char *const driverbyte_table[]={ -"DRIVER_OK" }; -const char *scsi_hostbyte_string (int result) {const char *hb_string =NULL ;
@@ -420,17 +417,6 @@ const char *scsi_hostbyte_string(int result) }EXPORT_SYMBOL (scsi_hostbyte_string); -const char *scsi_driverbyte_string (int result) -{ -const char *db_string =NULL ; -int db =driver_byte (result); - -if (db <ARRAY_SIZE (driverbyte_table)) - db_string = driverbyte_table[db]; -return db_string; -} -EXPORT_SYMBOL (scsi_driverbyte_string); -#define scsi_mlreturn_name (result) { result, #result }static const struct value_name_pair scsi_mlreturn_arr[] = {scsi_mlreturn_name (NEEDS_RETRY ),
drivers/scsi/scsi_logging.c +2 -8
@@ -389,7 +389,6 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,size_t off, logbuf_len;const char *mlret_string =scsi_mlreturn_string (disposition);const char *hb_string =scsi_hostbyte_string (cmd->result); -const char *db_string =scsi_driverbyte_string (cmd->result);unsigned long cmd_age = (jiffies - cmd->jiffies_at_alloc) /HZ ; logbuf =scsi_log_reserve_buffer (&logbuf_len);
@@ -430,13 +429,8 @@ void scsi_print_result(const struct scsi_cmnd *cmd, const char *msg,if (WARN_ON (off >= logbuf_len)) goto out_printk; -if (db_string) - off +=scnprintf (logbuf + off, logbuf_len - off, -"driverbyte=%s " , db_string); -else - off +=scnprintf (logbuf + off, logbuf_len - off, -"driverbyte=0x%02x " , -driver_byte (cmd->result)); + off +=scnprintf (logbuf + off, logbuf_len - off, +"driverbyte=DRIVER_OK " ); off +=scnprintf (logbuf + off, logbuf_len - off,"cmd_age=%lus" , cmd_age);
drivers/scsi/sd.c +4 -5
@@ -3716,16 +3716,15 @@ static void sd_print_result(const struct scsi_disk *sdkp, const char *msg, int result) {const char *hb_string =scsi_hostbyte_string (result); -const char *db_string =scsi_driverbyte_string (result); -if (hb_string || db_string) +if (hb_string)sd_printk (KERN_INFO , sdkp,"%s: Result: hostbyte=%s driverbyte=%s\n" , msg, hb_string ? hb_string :"invalid" , - db_string ? db_string :"invalid" ); +"DRIVER_OK" );else sd_printk (KERN_INFO , sdkp, -"%s: Result: hostbyte=0x%02x driverbyte=0x%02x\n" , - msg,host_byte (result),driver_byte (result)); +"%s: Result: hostbyte=0x%02x driverbyte=%s\n" , + msg,host_byte (result),"DRIVER_OK" ); }
drivers/scsi/sd_zbc.c +2 -2
@@ -87,9 +87,9 @@ static int sd_zbc_do_report_zones(struct scsi_disk *sdkp, unsigned char *buf, timeout, SD_MAX_RETRIES, NULL);if (result) {sd_printk (KERN_ERR , sdkp, -"REPORT ZONES lba %llu failed with %d/%d\n" , +"REPORT ZONES lba %llu failed with %d/0\n" , (unsigned long long )lba, -host_byte (result),driver_byte (result)); +host_byte (result));return -EIO ; }
drivers/scsi/sg.c +2 -3
@@ -1351,7 +1351,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status) srp->header.masked_status =status_byte (result) >>1 ; srp->header.msg_status =msg_byte (result); srp->header.host_status =host_byte (result); - srp->header.driver_status =driver_byte (result); + srp->header.driver_status =0 ;if ((sdp->sgdebug >0 ) && ((SAM_STAT_CHECK_CONDITION == srp->header.status) || (SAM_STAT_COMMAND_TERMINATED == srp->header.status)))
@@ -1359,8 +1359,7 @@ sg_rq_end_io(struct request *rq, blk_status_t status) SCSI_SENSE_BUFFERSIZE);/* Following if statement is a patch supplied by Eric Youngdale */ -if (driver_byte (result) !=0 - &&scsi_normalize_sense (sense,SCSI_SENSE_BUFFERSIZE , &sshdr) +if (scsi_normalize_sense (sense,SCSI_SENSE_BUFFERSIZE , &sshdr) && !scsi_sense_is_deferred (&sshdr) && sshdr.sense_key ==UNIT_ATTENTION && sdp->device->removable) {
drivers/scsi/sr.c +1 -1
@@ -336,7 +336,7 @@ static int sr_done(struct scsi_cmnd *SCpnt)* care is taken to avoid unnecessary additional work such as * memcpy's that could be avoided. */ -if (driver_byte (result) !=0 &&/* An error occurred */ +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION && (SCpnt->sense_buffer[0 ] &0x7f ) ==0x70 ) {/* Sense current */ switch (SCpnt->sense_buffer[2 ]) {case MEDIUM_ERROR :
drivers/scsi/sr_ioctl.c +1 -1
@@ -205,7 +205,7 @@ int sr_do_ioctl(Scsi_CD *cd, struct packet_command *cgc) cgc->timeout, IOCTL_RETRIES, 0, 0, NULL);/* Minimal error checking. Ignore cases we know about, and report the rest. */ -if (driver_byte (result) !=0 ) { +if (status_byte (result) ==SAM_STAT_CHECK_CONDITION ) {switch (sshdr->sense_key) {case UNIT_ATTENTION : SDev->changed =1 ;
drivers/scsi/st.c +2 -2
@@ -388,8 +388,8 @@ static int st_chk_result(struct scsi_tape *STp, struct st_request * SRpnt)if (!debugging) {/* Abnormal conditions for tape */ if (!cmdstatp->have_sense)st_printk (KERN_WARNING , STp, -"Error %x (driver bt 0x%x, host bt 0x%x).\n" , - result,driver_byte (result),host_byte (result)); +"Error %x (driver bt 0, host bt 0x%x).\n" , + result,host_byte (result)); else if (cmdstatp->have_sense && scode != NO_SENSE && scode != RECOVERED_ERROR &&
include/scsi/scsi.h +0 -3
@@ -159,7 +159,6 @@ static inline int scsi_is_wlun(u64 lun)* paths might yield different results */ #define DID_ALLOC_FAILURE 0x12/* Space allocation on the device failed */ #define DID_MEDIUM_ERROR 0x13/* Medium error */ -#define DRIVER_OK 0x00/* Driver status */ /* * Internal return values.
@@ -191,12 +190,10 @@ static inline int scsi_is_wlun(u64 lun)* status byte = set from target device * msg_byte = return status from host adapter itself. * host_byte = set by low-level driver to indicate status. -* driver_byte = set by mid-level. */ #define status_byte (result) (((result)) & 0xff)#define msg_byte (result) (((result) >> 8) & 0xff)#define host_byte (result) (((result) >> 16) & 0xff) -#define driver_byte (result) (((result) >> 24) & 0xff)#define sense_class (sense) (((sense) >> 4) & 0x7)#define sense_error (sense) ((sense) & 0xf)
include/scsi/scsi_cmnd.h +0 -4
@@ -322,10 +322,6 @@ static inline void set_host_byte(struct scsi_cmnd *cmd, char status) cmd->result = (cmd->result &0xff00ffff ) | (status <<16 ); } -static inline void set_driver_byte (struct scsi_cmnd *cmd,char status) -{ - cmd->result = (cmd->result &0x00ffffff ) | (status <<24 ); -}static inline unsigned scsi_transfer_length (struct scsi_cmnd *scmd) {
include/trace/events/scsi.h +1 -6
@@ -124,11 +124,6 @@ scsi_hostbyte_name(DID_TRANSPORT_DISRUPTED), \ scsi_hostbyte_name(DID_TRANSPORT_FAILFAST)) -#define scsi_driverbyte_name (result) { result, #result } -#define show_driverbyte_name (val) \ - __print_symbolic(val, \ - scsi_driverbyte_name(DRIVER_OK)) -#define scsi_msgbyte_name (result) { result, #result }#define show_msgbyte_name (val) \ __print_symbolic(val, \
@@ -319,7 +314,7 @@ DECLARE_EVENT_CLASS(scsi_cmd_done_timeout_template,show_opcode_name (__entry->opcode),__parse_cdb (__get_dynamic_array (cmnd), __entry->cmd_len),__print_hex (__get_dynamic_array (cmnd), __entry->cmd_len), -show_driverbyte_name (((__entry->result) >>24 ) &0xff ), +"DRIVER_OK" ,show_hostbyte_name (((__entry->result) >>16 ) &0xff ),show_msgbyte_name (((__entry->result) >>8 ) &0xff ), show_statusbyte_name(__entry->result & 0xff))
Signature · 1 line
2.16.4
Douglas Gilbert
maintainerQuoted 18 lines · Hannes Reinecke
Hi all,
the 'result' field in the SCSI command is defined as having 4 fields. The top byte is declared as a '
driver_byte', where the driver can signal some internal status back to the midlayer. However, there is quite a bit of overlap between thedriver_byteand thehost_byte, resulting in thedriver_bytebeing used in very few places, and mostly in legacy drivers. Additionally, we have _two_ sets of definitions for the last byte (status byte), which can specified either in SAM terms or in the linux-specific terms, which are shifted right by one from the SAM ones.
Needless to say, the linux-specific ones are declared obsolete for years now.
And to make the confusion complete, both the status byte and the driver byte have a byte for a valid sense code, resulting in quite some confusion which of those bits to check.
Quoted 6 lines
This patchset does several things:
- remove the linux-specific status byte definitions, and use the SAM values throughout
- replace the driver-byte values with either SAM ones (for sense code checking) or host-byte definitions
- remove the driver-byte definitions
This is a brave change proposal. The masked_status has been tricked up so it won't break user code. However the driver byte is exposed by the sg v2, v3 and v4 interfaces which means via bsg device nodes, sg devices nodes and many other block storage device nodes (e.g. /dev/sdc and /dev/st1) via:
ioctl(<storage_dev>, SG_IO, ptr_to_v3_interface) .
So if there is any user space code out there that checks the driver byte (e.g. 'sg_io_hdr::driver_status & DRIVER_SENSE') do we have a problem?
If so, we could hack the DRIVER_SENSE case *** by putting it back for the user space to see when the driver (e.g. sg) knows there is sense data. What about the other values?
Quoted 1 line
As usual, comments and reviews are welcome.
It is hard to make an omelette without breaking some eggs.
Doug Gilbert
Quoted 3 lines
Please note, commit
66cf50e65b18("scsi: qla2xxx: fixup incorrect usage ofhost_byte") from 5.4/scsi-fixes is a prerequisite for this patch series.
<snip>
*** Here is a snippet from sg3_utils library code:
if ((SAM_STAT_CHECK_CONDITION == scsi_status) ||
(SAM_STAT_COMMAND_TERMINATED == scsi_status) ||
(SG_LIB_DRIVER_SENSE == masked_driver_status))
return sg_err_category_sense(sense_buffer, sb_len);Due to the logical OR, as long as SAM_STAT_CHECK_CONDITION is set whenever there is sense, then we don't care about DRIVER_SENSE.
I believe this code comes from the days before auto-sense when say a READ(6) would fail, send back a CHECK_CONDITION and the host would then need to issue a REQUEST SENSE command to get the sense data. However REQUEST SENSE could itself yield a CHECK_CONDITION. Hence DRIVER_SENSE set, SAM_STAT_CHECK_CONDITION clear could be interpreted as the initial command failing and the follow-up REQUEST SENSE succeeded; if they are both set, then both commands failed (e.g. the disk has gone away).
Quoted 5 lines · Douglas Gilbert
Quoted 2 lines
As usual, comments and reviews are welcome.
It is hard to make an omelette without breaking some eggs.
Coccinelle can minimize the breakage; particularly the straight-forward conversion of (FOO << 1) to SAM_STAT_BAR.
Quoted 2 lines
Doug Gilbert
Quoted 63 lines · Douglas Gilbert
Quoted 18 lines · Hannes Reinecke
Hi all,
the 'result' field in the SCSI command is defined as having 4 fields. The top byte is declared as a '
driver_byte', where the driver can signal some internal status back to the midlayer. However, there is quite a bit of overlap between thedriver_byteand thehost_byte, resulting in thedriver_bytebeing used in very few places, and mostly in legacy drivers. Additionally, we have _two_ sets of definitions for the last byte (status byte), which can specified either in SAM terms or in the linux-specific terms, which are shifted right by one from the SAM ones.
Needless to say, the linux-specific ones are declared obsolete for years now.
And to make the confusion complete, both the status byte and the driver byte have a byte for a valid sense code, resulting in quite some confusion which of those bits to check.Quoted 6 lines
This patchset does several things:
- remove the linux-specific status byte definitions, and use the SAM values throughout
- replace the driver-byte values with either SAM ones (for sense code checking) or host-byte definitions
- remove the driver-byte definitionsThis is a brave change proposal. The
masked_statushas been tricked up so it won't break user code. However the driver byte is exposed by the sg v2, v3 and v4 interfaces which means via bsg device nodes, sg devices nodes and many other block storage device nodes (e.g./dev/sdcand/dev/st1) via:
ioctl(<storage_dev>, SG_IO, ptr_to_v3_interface).So if there is any user space code out there that checks the driver byte (e.g. '
sg_io_hdr::driver_status&DRIVER_SENSE') do we have a problem?If so, we could hack the
DRIVER_SENSEcase *** by putting it back for the user space to see when the driver (e.g. sg) knows there is sense data. What about the other values?Quoted 1 line
As usual, comments and reviews are welcome.
It is hard to make an omelette without breaking some eggs.
Doug Gilbert
Quoted 3 lines
Please note, commit
66cf50e65b18("scsi: qla2xxx: fixup incorrect usage ofhost_byte") from 5.4/scsi-fixes is a prerequisite for this patch series.<snip>
*** Here is a snippet from
sg3_utilslibrary code:if ((
SAM_STAT_CHECK_CONDITION==scsi_status) || (SAM_STAT_COMMAND_TERMINATED==scsi_status) || (SG_LIB_DRIVER_SENSE==masked_driver_status)) returnsg_err_category_sense(sense_buffer, sb_len);Due to the logical OR, as long as
SAM_STAT_CHECK_CONDITIONis set whenever there is sense, then we don't care aboutDRIVER_SENSE.
Quoted 8 lines
I believe this code comes from the days before auto-sense when say a READ(6) would fail, send back a
CHECK_CONDITIONand the host would then need to issue a REQUEST SENSE command to get the sense data. However REQUEST SENSE could itself yield aCHECK_CONDITION. HenceDRIVER_SENSEset,SAM_STAT_CHECK_CONDITIONclear could be interpreted as the initial command failing and the follow-up REQUEST SENSE succeeded; if they are both set, then both commands failed (e.g. the disk has gone away).
Well, the easier explanation is that not every driver sets DRIVER_SENSE; some do, some don't, relying on CHECK_CONDITION here.
Which also means that any code relying on DRIVER_SENSE alone would break even today.
So really I don't think this should break anything; but if the consensus is that we need to fake DRIVER_SENSE for userland ABI stability so be it.
Cheers,
Hannes
Signature · 4 lines
Dr. Hannes Reinecke Teamlead Storage & Networking [email protected] +49 911 74053 688 SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg HRB 247165 (AG München), GF: Felix Imendörffer