On 2018-04-18 11:01 AM, Johannes Thumshirn wrote:
Hey all, here's a early preview of my SCSI results rework so we can eventually discuss things next week at LSF/MM (it still has compiler errors on aic7xxx and scsi_debug). The motivation behing this is that some drivers have failed to set the scsi_cmnd::result bytes correctly in the past and this is resulting in hard to case down errors. The open points: 1) 148 files changed, treewide. That's huge. Is it worth it? 2) remove the old status byte definitions 3) add a scsi_cmnd::result == 0 wrapper 3) convert aic7xx's CAM stuff so this series compiles cleanly 4) What the heck is the SDEG_RES_IMMED_MASK stuff in scsi_debug doing
It's a hack. The cdb tables have only one delay value per command and for Start Stop Unit and Synchronize Cache those are relatively long delays. However as you may be aware both those commands have an IMMED bit which makes those commands return more or less immediately. In the work flow of the scsi_debug driver the work done by a specific command is done more or less immediately and any delay associated with that command is done by generic code just prior to calling scsi_cmnd::done(). So for those two commands I needed an additional return value from the resp_start_stop() and resp_sync_cache() to indicate that their normal delay should be short circuited. And the signatures of those functions are function pointers in many of the scsi_debug tables, so expanding the number of arguments for these two cases would have been messy. So the (hacky) solution was to overload the return int with an extra flag. And that return int is none other than the infamous SCSI result. With the benefit of hindsight a better solution is to add a new bool to struct sdebug_dev_info: bool immed_shortens_delay; that is set by those two commands when their IMMED bit is set (in their cdbs). Then the code in schedule_resp() can act on that bool (when set) to short circuit the delay. That will be a worthwhile improvement so other commands (if and when implemented) can react properly when their IMMED bit is set (e.g. FORMAT UNIT, PRE-FETCH and SANITIZE). Does that clear up this matter? Doug Gilbert
5) change scsi_execute() so we get a newish 'struct scsi_results' instead of an int 6) {to,from}_scsi_result() are odd 7) find suitable commit messages In case someone want's it in a more viewable form I've pushed the series to my kernel.org git: https://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git/log/?h=scsi-results Johannes Thumshirn (13): scsi: use host_byte() accessor scsi: remove Scsi_Cmnd typedef scsi: add enum for host byte codes scsi: add enum for driver byte codes scsi: add enum for message byte codes scsi: introduce set_scsi_result scsi: use set_driver_byte treewide: use set_host_byte scsi: use set_msg_byte scsi: introduce set_status_byte and convert LLDDs to use it scsi: Change status bytes to use SAM-3 version reewide: introduce clear_scsi_result() and convert drivers scsi: introduce struct scsi_result arch/ia64/hp/sim/simscsi.c | 6 +- block/bsg-lib.c | 8 +- block/bsg.c | 8 +- block/scsi_ioctl.c | 12 +- drivers/ata/libata-scsi.c | 54 +++--- drivers/firewire/sbp2.c | 2 +- drivers/infiniband/ulp/srp/ib_srp.c | 23 ++- drivers/message/fusion/mptfc.c | 8 +- drivers/message/fusion/mptsas.c | 3 +- drivers/message/fusion/mptscsih.c | 122 ++++++++----- drivers/message/fusion/mptspi.c | 6 +- drivers/s390/scsi/zfcp_fc.h | 2 +- drivers/s390/scsi/zfcp_scsi.c | 4 +- drivers/scsi/3w-9xxx.c | 18 +- drivers/scsi/3w-sas.c | 16 +- drivers/scsi/3w-xxxx.c | 36 ++-- drivers/scsi/53c700.c | 3 +- drivers/scsi/BusLogic.c | 24 ++- drivers/scsi/NCR5380.c | 39 +++-- drivers/scsi/a100u2w.c | 2 +- drivers/scsi/aacraid/aachba.c | 221 +++++++++++++----------- drivers/scsi/aacraid/commsup.c | 5 +- drivers/scsi/aacraid/linit.c | 12 +- drivers/scsi/advansys.c | 58 +++---- drivers/scsi/aha152x.c | 76 ++++---- drivers/scsi/aha1542.c | 2 +- drivers/scsi/aha1740.c | 11 +- drivers/scsi/aha1740.h | 4 +- drivers/scsi/aic7xxx/aic79xx_osm.c | 5 +- drivers/scsi/aic7xxx/aic79xx_osm.h | 6 +- drivers/scsi/aic7xxx/aic7xxx_osm.c | 5 +- drivers/scsi/aic7xxx/aic7xxx_osm.h | 6 +- drivers/scsi/arcmsr/arcmsr_hba.c | 56 +++--- drivers/scsi/arm/acornscsi.c | 11 +- drivers/scsi/arm/fas216.c | 6 +- drivers/scsi/atp870u.c | 18 +- drivers/scsi/be2iscsi/be_main.c | 8 +- drivers/scsi/bfa/bfad_im.c | 38 ++-- drivers/scsi/bfa/bfad_im.h | 1 - drivers/scsi/bnx2fc/bnx2fc_io.c | 17 +- drivers/scsi/ch.c | 2 +- drivers/scsi/constants.c | 4 +- drivers/scsi/csiostor/csio_scsi.c | 12 +- drivers/scsi/cxlflash/main.c | 42 +++-- drivers/scsi/dc395x.c | 57 +++--- drivers/scsi/device_handler/scsi_dh_alua.c | 10 +- drivers/scsi/dpt_i2o.c | 45 +++-- drivers/scsi/esas2r/esas2r_main.c | 19 +- drivers/scsi/esp_scsi.c | 18 +- drivers/scsi/fnic/fnic_scsi.c | 48 +++-- drivers/scsi/gdth.c | 105 ++++++----- drivers/scsi/gdth.h | 10 +- drivers/scsi/gdth_proc.c | 2 +- drivers/scsi/hpsa.c | 94 ++++++---- drivers/scsi/hptiop.c | 27 +-- drivers/scsi/ibmvscsi/ibmvfc.c | 26 ++- drivers/scsi/ibmvscsi/ibmvscsi.c | 28 +-- drivers/scsi/imm.c | 12 +- drivers/scsi/initio.c | 2 +- drivers/scsi/ipr.c | 36 ++-- drivers/scsi/ips.c | 112 ++++++++---- drivers/scsi/libfc/fc_fcp.c | 49 ++++-- drivers/scsi/libiscsi.c | 65 ++++--- drivers/scsi/libiscsi_tcp.c | 2 +- drivers/scsi/libsas/sas_ata.c | 5 +- drivers/scsi/libsas/sas_expander.c | 2 +- drivers/scsi/libsas/sas_scsi_host.c | 17 +- drivers/scsi/lpfc/lpfc_crtn.h | 1 - drivers/scsi/lpfc/lpfc_scsi.c | 70 ++++---- drivers/scsi/megaraid.c | 100 ++++++----- drivers/scsi/megaraid.h | 14 +- drivers/scsi/megaraid/megaraid_mbox.c | 84 +++++---- drivers/scsi/megaraid/megaraid_sas_base.c | 44 +++-- drivers/scsi/megaraid/megaraid_sas_fusion.c | 30 ++-- drivers/scsi/mesh.c | 10 +- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 144 +++++++++------ drivers/scsi/mvsas/mv_sas.c | 2 +- drivers/scsi/mvumi.c | 21 +-- drivers/scsi/ncr53c8xx.c | 24 ++- drivers/scsi/nsp32.c | 54 +++--- drivers/scsi/nsp32_debug.c | 2 +- drivers/scsi/osst.c | 3 +- drivers/scsi/pcmcia/nsp_cs.c | 29 ++-- drivers/scsi/pcmcia/sym53c500_cs.c | 19 +- drivers/scsi/pm8001/pm8001_sas.c | 5 +- drivers/scsi/pmcraid.c | 30 ++-- drivers/scsi/ppa.c | 16 +- drivers/scsi/ps3rom.c | 9 +- drivers/scsi/qedf/qedf_io.c | 32 ++-- drivers/scsi/qedi/qedi_fw.c | 2 +- drivers/scsi/qla1280.c | 16 +- drivers/scsi/qla2xxx/qla_iocb.c | 6 +- drivers/scsi/qla2xxx/qla_isr.c | 15 +- drivers/scsi/qla2xxx/qla_mr.c | 4 +- drivers/scsi/qla2xxx/qla_os.c | 32 ++-- drivers/scsi/qla4xxx/ql4_isr.c | 44 +++-- drivers/scsi/qla4xxx/ql4_os.c | 25 ++- drivers/scsi/qlogicfas408.c | 5 +- drivers/scsi/qlogicpti.c | 6 +- drivers/scsi/scsi.c | 7 +- drivers/scsi/scsi.h | 3 - drivers/scsi/scsi_debug.c | 23 ++- drivers/scsi/scsi_debugfs.c | 2 +- drivers/scsi/scsi_error.c | 58 ++++--- drivers/scsi/scsi_ioctl.c | 2 +- drivers/scsi/scsi_lib.c | 35 ++-- drivers/scsi/scsi_logging.c | 5 +- drivers/scsi/scsi_scan.c | 2 +- drivers/scsi/scsi_transport_spi.c | 2 +- drivers/scsi/scsi_typedefs.h | 2 - drivers/scsi/sd.c | 24 +-- drivers/scsi/sd_zbc.c | 4 +- drivers/scsi/sg.c | 10 +- drivers/scsi/smartpqi/smartpqi_init.c | 10 +- drivers/scsi/snic/snic_scsi.c | 18 +- drivers/scsi/sr.c | 4 +- drivers/scsi/sr_ioctl.c | 2 +- drivers/scsi/st.c | 2 +- drivers/scsi/stex.c | 28 +-- drivers/scsi/storvsc_drv.c | 7 +- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- drivers/scsi/sym53c8xx_2/sym_glue.h | 5 +- drivers/scsi/ufs/ufshcd.c | 6 +- drivers/scsi/virtio_scsi.c | 2 +- drivers/scsi/vmw_pvscsi.c | 40 +++-- drivers/scsi/wd33c93.c | 31 ++-- drivers/scsi/wd719x.c | 3 +- drivers/scsi/xen-scsifront.c | 7 +- drivers/staging/rts5208/rtsx.c | 15 +- drivers/staging/rts5208/rtsx_transport.c | 10 +- drivers/staging/unisys/visorhba/visorhba_main.c | 16 +- drivers/target/loopback/tcm_loop.c | 6 +- drivers/target/target_core_pscsi.c | 12 +- drivers/usb/image/microtek.c | 28 ++- drivers/usb/storage/cypress_atacb.c | 13 +- drivers/usb/storage/datafab.c | 4 +- drivers/usb/storage/isd200.c | 40 +++-- drivers/usb/storage/jumpshot.c | 4 +- drivers/usb/storage/realtek_cr.c | 12 +- drivers/usb/storage/scsiglue.c | 3 +- drivers/usb/storage/transport.c | 42 +++-- drivers/usb/storage/uas.c | 24 ++- drivers/usb/storage/usb.c | 18 +- drivers/xen/xen-scsiback.c | 6 +- include/scsi/scsi.h | 194 +++++++++++++-------- include/scsi/scsi_cmnd.h | 40 ++++- include/scsi/scsi_proto.h | 25 +-- include/trace/events/scsi.h | 2 +- 148 files changed, 2122 insertions(+), 1449 deletions(-) delete mode 100644 drivers/scsi/scsi_typedefs.h