All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] scsi: EH rework main part
@ 2022-05-02 21:59 Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
                   ` (18 more replies)
  0 siblings, 19 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

Hi all,

now that the prep is done we can convert the call sequence
of the SCSI EH callbacks to use the respective object
(ie struct Scsi_Host or struct scsi_device) and the Scsi command.
With that we don't have to allocate a 'fake' command for
ioctl reset anymore.

As usual, comments and reviews are welcome.

Hannes Reinecke (7):
  scsi: Use Scsi_Host as argument for eh_host_reset_handler
  scsi: Use Scsi_Host and channel number as argument for
    eh_bus_reset_handler()
  scsi: Use scsi_target as argument for eh_target_reset_handler()
  scsi: Use scsi_device as argument to eh_device_reset_handler()
  scsi: Do not allocate scsi command in scsi_ioctl_reset()
  scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL
  scsi_error: streamline scsi_eh_bus_device_reset()

 Documentation/scsi/scsi_eh.rst                |  16 +-
 Documentation/scsi/scsi_mid_low_api.rst       |  31 +++-
 drivers/infiniband/ulp/srp/ib_srp.c           |  12 +-
 drivers/message/fusion/mptfc.c                |  25 ++-
 drivers/message/fusion/mptsas.c               |  10 +-
 drivers/message/fusion/mptscsih.c             |  86 ++++-----
 drivers/message/fusion/mptscsih.h             |   8 +-
 drivers/message/fusion/mptspi.c               |   8 +-
 drivers/s390/scsi/zfcp_scsi.c                 |  14 +-
 drivers/scsi/3w-9xxx.c                        |  11 +-
 drivers/scsi/3w-sas.c                         |  11 +-
 drivers/scsi/3w-xxxx.c                        |  11 +-
 drivers/scsi/53c700.c                         |  39 ++--
 drivers/scsi/BusLogic.c                       |  14 +-
 drivers/scsi/NCR5380.c                        |   3 +-
 drivers/scsi/a100u2w.c                        |  11 +-
 drivers/scsi/aacraid/linit.c                  |  35 ++--
 drivers/scsi/advansys.c                       |  26 +--
 drivers/scsi/aha152x.c                        |  10 +-
 drivers/scsi/aha1542.c                        |  30 +--
 drivers/scsi/aic7xxx/aic79xx_osm.c            |  37 ++--
 drivers/scsi/aic7xxx/aic7xxx_osm.c            |  10 +-
 drivers/scsi/arcmsr/arcmsr_hba.c              |   6 +-
 drivers/scsi/arm/acornscsi.c                  |   8 +-
 drivers/scsi/arm/fas216.c                     |  18 +-
 drivers/scsi/arm/fas216.h                     |  17 +-
 drivers/scsi/atari_scsi.c                     |   4 +-
 drivers/scsi/be2iscsi/be_main.c               |  12 +-
 drivers/scsi/bfa/bfad_im.c                    |   8 +-
 drivers/scsi/bnx2fc/bnx2fc.h                  |   4 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c               |  10 +-
 drivers/scsi/csiostor/csio_scsi.c             |   3 +-
 drivers/scsi/cxlflash/main.c                  |  10 +-
 drivers/scsi/dc395x.c                         |  25 ++-
 drivers/scsi/dpt_i2o.c                        |  43 +++--
 drivers/scsi/dpti.h                           |   6 +-
 drivers/scsi/esas2r/esas2r.h                  |   8 +-
 drivers/scsi/esas2r/esas2r_main.c             |  55 +++---
 drivers/scsi/esp_scsi.c                       |   8 +-
 drivers/scsi/fdomain.c                        |   3 +-
 drivers/scsi/fnic/fnic.h                      |   4 +-
 drivers/scsi/fnic/fnic_scsi.c                 |   9 +-
 drivers/scsi/hpsa.c                           |  14 +-
 drivers/scsi/hptiop.c                         |   6 +-
 drivers/scsi/ibmvscsi/ibmvfc.c                |  12 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c              |  23 +--
 drivers/scsi/imm.c                            |   4 +-
 drivers/scsi/initio.c                         |  11 +-
 drivers/scsi/ipr.c                            |  35 ++--
 drivers/scsi/ips.c                            |  22 +--
 drivers/scsi/libfc/fc_fcp.c                   |  16 +-
 drivers/scsi/libiscsi.c                       |  19 +-
 drivers/scsi/libsas/sas_scsi_host.c           |  21 ++-
 drivers/scsi/lpfc/lpfc_scsi.c                 |  23 ++-
 drivers/scsi/mac53c94.c                       |   8 +-
 drivers/scsi/megaraid.c                       |   4 +-
 drivers/scsi/megaraid.h                       |   2 +-
 drivers/scsi/megaraid/megaraid_mbox.c         |  14 +-
 drivers/scsi/megaraid/megaraid_sas.h          |   3 +-
 drivers/scsi/megaraid/megaraid_sas_base.c     |  44 ++---
 drivers/scsi/megaraid/megaraid_sas_fusion.c   |  56 +++---
 drivers/scsi/mesh.c                           |  10 +-
 drivers/scsi/mpi3mr/mpi3mr_os.c               | 123 ++++++------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c          |  72 +++----
 drivers/scsi/mvumi.c                          |   7 +-
 drivers/scsi/myrb.c                           |   3 +-
 drivers/scsi/myrs.c                           |   3 +-
 drivers/scsi/ncr53c8xx.c                      |   4 +-
 drivers/scsi/nsp32.c                          |  12 +-
 drivers/scsi/pcmcia/nsp_cs.c                  |  10 +-
 drivers/scsi/pcmcia/nsp_cs.h                  |   6 +-
 drivers/scsi/pcmcia/qlogic_stub.c             |   4 +-
 drivers/scsi/pcmcia/sym53c500_cs.c            |   8 +-
 drivers/scsi/pmcraid.c                        |  27 ++-
 drivers/scsi/ppa.c                            |   4 +-
 drivers/scsi/qedf/qedf_main.c                 |  13 +-
 drivers/scsi/qedi/qedi_iscsi.c                |   3 +-
 drivers/scsi/qla1280.c                        |  36 ++--
 drivers/scsi/qla2xxx/qla_os.c                 |  83 ++++-----
 drivers/scsi/qla4xxx/ql4_os.c                 |  54 +++---
 drivers/scsi/qlogicfas408.c                   |  10 +-
 drivers/scsi/qlogicfas408.h                   |   2 +-
 drivers/scsi/qlogicpti.c                      |   3 +-
 drivers/scsi/scsi_debug.c                     |  78 +++-----
 drivers/scsi/scsi_error.c                     | 175 +++++++++---------
 drivers/scsi/scsi_lib.c                       |   2 -
 drivers/scsi/smartpqi/smartpqi_init.c         |  11 +-
 drivers/scsi/snic/snic.h                      |   5 +-
 drivers/scsi/snic/snic_scsi.c                 |  41 +---
 drivers/scsi/stex.c                           |   7 +-
 drivers/scsi/storvsc_drv.c                    |   4 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c           |  13 +-
 drivers/scsi/ufs/ufshcd.c                     |  14 +-
 drivers/scsi/virtio_scsi.c                    |  12 +-
 drivers/scsi/vmw_pvscsi.c                     |  20 +-
 drivers/scsi/wd33c93.c                        |   5 +-
 drivers/scsi/wd33c93.h                        |   2 +-
 drivers/scsi/wd719x.c                         |  17 +-
 drivers/scsi/xen-scsifront.c                  |  23 ++-
 drivers/staging/rts5208/rtsx.c                |   6 +-
 .../staging/unisys/visorhba/visorhba_main.c   |  24 +--
 drivers/target/loopback/tcm_loop.c            |  17 +-
 drivers/usb/image/microtek.c                  |   4 +-
 drivers/usb/storage/scsiglue.c                |   8 +-
 drivers/usb/storage/uas.c                     |   3 +-
 include/scsi/libfc.h                          |   4 +-
 include/scsi/libiscsi.h                       |   4 +-
 include/scsi/libsas.h                         |   4 +-
 include/scsi/scsi_cmnd.h                      |   1 -
 include/scsi/scsi_host.h                      |   8 +-
 110 files changed, 989 insertions(+), 1076 deletions(-)

-- 
2.29.2


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

The reset code requires a device to be selected, but we shouldn't
rely on the command to provide a device for us. So select the first
device on the bus when sending down a bus reset.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/pmcraid.c | 46 ++++++++++++++++++++++++++++++++++--------
 1 file changed, 38 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 3d5cd337a2a6..d508e81a03db 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -2691,7 +2691,7 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
  *	SUCCESS / FAILED
  */
 static int pmcraid_reset_device(
-	struct scsi_cmnd *scsi_cmd,
+	struct scsi_device *scsi_dev,
 	unsigned long timeout,
 	u8 modifier)
 {
@@ -2703,11 +2703,11 @@ static int pmcraid_reset_device(
 	u32 ioasc;
 
 	pinstance =
-		(struct pmcraid_instance *)scsi_cmd->device->host->hostdata;
-	res = scsi_cmd->device->hostdata;
+		(struct pmcraid_instance *)scsi_dev->host->hostdata;
+	res = scsi_dev->hostdata;
 
 	if (!res) {
-		sdev_printk(KERN_ERR, scsi_cmd->device,
+		sdev_printk(KERN_ERR, scsi_dev,
 			    "reset_device: NULL resource pointer\n");
 		return FAILED;
 	}
@@ -3018,16 +3018,46 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
 {
 	scmd_printk(KERN_INFO, scmd,
 		    "resetting device due to an I/O command timeout.\n");
-	return pmcraid_reset_device(scmd,
+	return pmcraid_reset_device(scmd->device,
 				    PMCRAID_INTERNAL_TIMEOUT,
 				    RESET_DEVICE_LUN);
 }
 
 static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
 {
-	scmd_printk(KERN_INFO, scmd,
+	struct Scsi_Host *host = scmd->device->host;
+	struct pmcraid_instance *pinstance =
+		(struct pmcraid_instance *)host->hostdata;
+	struct pmcraid_resource_entry *res = NULL;
+	struct pmcraid_resource_entry *temp;
+	struct scsi_device *sdev = NULL;
+	unsigned long lock_flags;
+
+	/*
+	 * The reset device code insists on us passing down
+	 * a device, so grab the first device on the bus.
+	 */
+	spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
+	list_for_each_entry(temp, &pinstance->used_res_q, queue) {
+		if (scmd->device->channel == PMCRAID_VSET_BUS_ID &&
+		    RES_IS_VSET(temp->cfg_entry)) {
+			res = temp;
+			break;
+		} else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID &&
+			   RES_IS_GSCSI(temp->cfg_entry)) {
+			res = temp;
+			break;
+		}
+	}
+	if (res)
+		sdev = res->scsi_dev;
+	spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
+	if (!sdev)
+		return FAILED;
+
+	sdev_printk(KERN_INFO, sdev,
 		    "Doing bus reset due to an I/O command timeout.\n");
-	return pmcraid_reset_device(scmd,
+	return pmcraid_reset_device(sdev,
 				    PMCRAID_RESET_BUS_TIMEOUT,
 				    RESET_DEVICE_BUS);
 }
@@ -3036,7 +3066,7 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
 {
 	scmd_printk(KERN_INFO, scmd,
 		    "Doing target reset due to an I/O command timeout.\n");
-	return pmcraid_reset_device(scmd,
+	return pmcraid_reset_device(scmd->device,
 				    PMCRAID_INTERNAL_TIMEOUT,
 				    RESET_DEVICE_TARGET);
 }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-03 21:02   ` Lee Duncan
  2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
                   ` (16 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Bart Van Assche

Issuing a host reset should not rely on any commands.
So use Scsi_Host as argument for eh_host_reset_handler.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
---
 Documentation/scsi/scsi_eh.rst                |  2 +-
 Documentation/scsi/scsi_mid_low_api.rst       |  4 +-
 drivers/infiniband/ulp/srp/ib_srp.c           |  6 +--
 drivers/message/fusion/mptscsih.c             | 19 +++++----
 drivers/message/fusion/mptscsih.h             |  2 +-
 drivers/s390/scsi/zfcp_scsi.c                 |  3 +-
 drivers/scsi/3w-9xxx.c                        | 11 +++---
 drivers/scsi/3w-sas.c                         | 11 +++---
 drivers/scsi/3w-xxxx.c                        | 11 +++---
 drivers/scsi/53c700.c                         | 39 ++++++++++---------
 drivers/scsi/BusLogic.c                       | 14 ++-----
 drivers/scsi/NCR5380.c                        |  3 +-
 drivers/scsi/aacraid/linit.c                  |  6 +--
 drivers/scsi/advansys.c                       | 26 +++++++------
 drivers/scsi/aha1542.c                        | 20 +++++-----
 drivers/scsi/arm/acornscsi.c                  |  8 ++--
 drivers/scsi/arm/fas216.c                     |  4 +-
 drivers/scsi/arm/fas216.h                     |  6 +--
 drivers/scsi/atari_scsi.c                     |  4 +-
 drivers/scsi/cxlflash/main.c                  |  5 +--
 drivers/scsi/dpt_i2o.c                        | 14 +++----
 drivers/scsi/dpti.h                           |  2 +-
 drivers/scsi/esas2r/esas2r.h                  |  2 +-
 drivers/scsi/esas2r/esas2r_main.c             | 16 ++++----
 drivers/scsi/esp_scsi.c                       |  4 +-
 drivers/scsi/fdomain.c                        |  3 +-
 drivers/scsi/fnic/fnic.h                      |  2 +-
 drivers/scsi/fnic/fnic_scsi.c                 |  3 +-
 drivers/scsi/hptiop.c                         |  6 +--
 drivers/scsi/ibmvscsi/ibmvfc.c                |  4 +-
 drivers/scsi/ibmvscsi/ibmvscsi.c              |  4 +-
 drivers/scsi/imm.c                            |  4 +-
 drivers/scsi/ipr.c                            |  4 +-
 drivers/scsi/ips.c                            | 22 ++++-------
 drivers/scsi/libfc/fc_fcp.c                   |  5 +--
 drivers/scsi/lpfc/lpfc_scsi.c                 |  3 +-
 drivers/scsi/mac53c94.c                       |  8 ++--
 drivers/scsi/megaraid.c                       |  4 +-
 drivers/scsi/megaraid.h                       |  2 +-
 drivers/scsi/megaraid/megaraid_mbox.c         | 14 ++-----
 drivers/scsi/megaraid/megaraid_sas_base.c     | 34 ++++++++--------
 drivers/scsi/mesh.c                           | 10 ++---
 drivers/scsi/mpi3mr/mpi3mr_os.c               | 12 +++---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c          | 11 +++---
 drivers/scsi/mvumi.c                          |  7 ++--
 drivers/scsi/myrb.c                           |  3 +-
 drivers/scsi/myrs.c                           |  3 +-
 drivers/scsi/nsp32.c                          | 12 +++---
 drivers/scsi/pcmcia/nsp_cs.c                  |  4 +-
 drivers/scsi/pcmcia/nsp_cs.h                  |  2 +-
 drivers/scsi/pcmcia/qlogic_stub.c             |  4 +-
 drivers/scsi/pcmcia/sym53c500_cs.c            |  8 ++--
 drivers/scsi/pmcraid.c                        |  6 +--
 drivers/scsi/ppa.c                            |  4 +-
 drivers/scsi/qedf/qedf_main.c                 |  4 +-
 drivers/scsi/qedi/qedi_iscsi.c                |  3 +-
 drivers/scsi/qla1280.c                        |  3 +-
 drivers/scsi/qla2xxx/qla_os.c                 | 18 +++------
 drivers/scsi/qla4xxx/ql4_os.c                 | 18 ++++-----
 drivers/scsi/qlogicfas408.c                   | 10 ++---
 drivers/scsi/qlogicfas408.h                   |  2 +-
 drivers/scsi/qlogicpti.c                      |  3 +-
 drivers/scsi/scsi_debug.c                     |  8 ++--
 drivers/scsi/scsi_error.c                     |  2 +-
 drivers/scsi/snic/snic.h                      |  3 +-
 drivers/scsi/snic/snic_scsi.c                 | 37 ++++--------------
 drivers/scsi/stex.c                           |  7 ++--
 drivers/scsi/storvsc_drv.c                    |  4 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c           |  3 +-
 drivers/scsi/ufs/ufshcd.c                     |  6 +--
 drivers/scsi/vmw_pvscsi.c                     |  5 +--
 drivers/scsi/wd33c93.c                        |  5 +--
 drivers/scsi/wd33c93.h                        |  2 +-
 drivers/scsi/wd719x.c                         |  4 +-
 .../staging/unisys/visorhba/visorhba_main.c   |  4 +-
 drivers/usb/image/microtek.c                  |  4 +-
 include/scsi/libfc.h                          |  2 +-
 include/scsi/scsi_host.h                      |  2 +-
 78 files changed, 269 insertions(+), 340 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
index 885395dc1f15..12113cca5ad9 100644
--- a/Documentation/scsi/scsi_eh.rst
+++ b/Documentation/scsi/scsi_eh.rst
@@ -215,7 +215,7 @@ considered to fail always.
     int (* eh_abort_handler)(struct scsi_cmnd *);
     int (* eh_device_reset_handler)(struct scsi_cmnd *);
     int (* eh_bus_reset_handler)(struct scsi_cmnd *);
-    int (* eh_host_reset_handler)(struct scsi_cmnd *);
+    int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 Higher-severity actions are taken only when lower-severity actions
 cannot recover some of failed scmds.  Also, note that failure of the
diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
index 63ddea2b9640..784587ea7eee 100644
--- a/Documentation/scsi/scsi_mid_low_api.rst
+++ b/Documentation/scsi/scsi_mid_low_api.rst
@@ -777,7 +777,7 @@ Details::
 
     /**
     *      eh_host_reset_handler - reset host (host bus adapter)
-    *      @scp: SCSI host that contains this device should be reset
+    *      @shp: SCSI host that contains this device should be reset
     *
     *      Returns SUCCESS if command aborted else FAILED
     *
@@ -794,7 +794,7 @@ Details::
     *
     *      Optionally defined in: LLD
     **/
-	int eh_host_reset_handler(struct scsi_cmnd * scp)
+	int eh_host_reset_handler(struct Scsi_Host * shp)
 
 
     /**
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 285b766e4e70..de901dee6935 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2842,11 +2842,11 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
 	return SUCCESS;
 }
 
-static int srp_reset_host(struct scsi_cmnd *scmnd)
+static int srp_reset_host(struct Scsi_Host *shost)
 {
-	struct srp_target_port *target = host_to_target(scmnd->device->host);
+	struct srp_target_port *target = host_to_target(shost);
 
-	shost_printk(KERN_ERR, target->scsi_host, PFX "SRP reset_host called\n");
+	shost_printk(KERN_ERR, shost, PFX "SRP reset_host called\n");
 
 	return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED;
 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ed21cc4d2c77..3df07e024026 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1956,15 +1956,15 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
- *	mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
- *	@SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
+ *	mptscsih_host_reset - Perform a SCSI host adapter RESET
+ *	@sh: Pointer to Scsi_Host structure, which is reset due to
  *
  *	(linux scsi_host_template.eh_host_reset_handler routine)
  *
  *	Returns SUCCESS or FAILED.
  */
 int
-mptscsih_host_reset(struct scsi_cmnd *SCpnt)
+mptscsih_host_reset(struct Scsi_Host *sh)
 {
 	MPT_SCSI_HOST *  hd;
 	int              status = SUCCESS;
@@ -1972,9 +1972,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
 	int		retval;
 
 	/*  If we can't locate the host to reset, then we failed. */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
-		printk(KERN_ERR MYNAM ": host reset: "
-		    "Can't locate host! (sc=%p)\n", SCpnt);
+	if ((hd = shost_priv(sh)) == NULL){
+		printk(KERN_ERR MYNAM ": host reset: Can't locate host!\n");
 		return FAILED;
 	}
 
@@ -1982,8 +1981,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
 	mptscsih_flush_running_cmds(hd);
 
 	ioc = hd->ioc;
-	printk(MYIOC_s_INFO_FMT "attempting host reset! (sc=%p)\n",
-	    ioc->name, SCpnt);
+	printk(MYIOC_s_INFO_FMT "attempting host reset!\n",
+	    ioc->name);
 
 	/*  If our attempts to reset the host failed, then return a failed
 	 *  status.  The host will be taken off line by the SCSI mid-layer.
@@ -1994,8 +1993,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
 	else
 		status = SUCCESS;
 
-	printk(MYIOC_s_INFO_FMT "host reset: %s (sc=%p)\n",
-	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+	printk(MYIOC_s_INFO_FMT "host reset: %s\n",
+	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
 
 	return status;
 }
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index e3d92c392673..0faefe9c7541 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -122,7 +122,7 @@ extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
 extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
 extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
-extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt);
+extern int mptscsih_host_reset(struct Scsi_Host *sh);
 extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
 extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
 extern int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index fb2b73fca381..873ccc60e4d6 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -371,9 +371,8 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
 	return ret;
 }
 
-static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
+static int zfcp_scsi_eh_host_reset_handler(struct Scsi_Host *host)
 {
-	struct Scsi_Host *host = scpnt->device->host;
 	struct zfcp_adapter *adapter = (struct zfcp_adapter *)host->hostdata[0];
 	int ret = SUCCESS;
 	unsigned long flags;
diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
index cd823ff5deab..61af5c5eaccb 100644
--- a/drivers/scsi/3w-9xxx.c
+++ b/drivers/scsi/3w-9xxx.c
@@ -1717,18 +1717,19 @@ static int twa_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde
 } /* End twa_scsi_biosparam() */
 
 /* This is the new scsi eh reset function */
-static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
+static int twa_scsi_eh_reset(struct Scsi_Host *shost)
 {
 	TW_Device_Extension *tw_dev = NULL;
 	int retval = FAILED;
 
-	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
+	tw_dev = (TW_Device_Extension *)shost->hostdata;
 
 	tw_dev->num_resets++;
 
-	sdev_printk(KERN_WARNING, SCpnt->device,
-		"WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
-		TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
+	shost_printk(KERN_WARNING, shost,
+		     "WARNING: (0x%02X:0x%04X): "
+		     "Command timed out, resetting card.\n",
+		     TW_DRIVER, 0x2c);
 
 	/* Make sure we are not issuing an ioctl or resetting from ioctl */
 	mutex_lock(&tw_dev->ioctl_lock);
diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
index 3ebe66151dcb..c4d1ebf15700 100644
--- a/drivers/scsi/3w-sas.c
+++ b/drivers/scsi/3w-sas.c
@@ -1423,18 +1423,19 @@ static int twl_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde
 } /* End twl_scsi_biosparam() */
 
 /* This is the new scsi eh reset function */
-static int twl_scsi_eh_reset(struct scsi_cmnd *SCpnt)
+static int twl_scsi_eh_reset(struct Scsi_Host *shost)
 {
 	TW_Device_Extension *tw_dev = NULL;
 	int retval = FAILED;
 
-	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
+	tw_dev = (TW_Device_Extension *)shost->hostdata;
 
 	tw_dev->num_resets++;
 
-	sdev_printk(KERN_WARNING, SCpnt->device,
-		"WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
-		TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
+	shost_printk(KERN_WARNING, shost,
+		     "WARNING: (0x%02X:0x%04X): "
+		     "Command timed out, resetting card.\n",
+		     TW_DRIVER, 0x2c);
 
 	/* Make sure we are not issuing an ioctl or resetting from ioctl */
 	mutex_lock(&tw_dev->ioctl_lock);
diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
index a853c5497af6..8c5f37563515 100644
--- a/drivers/scsi/3w-xxxx.c
+++ b/drivers/scsi/3w-xxxx.c
@@ -1366,25 +1366,24 @@ static int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev
 } /* End tw_scsi_biosparam() */
 
 /* This is the new scsi eh reset function */
-static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt)
+static int tw_scsi_eh_reset(struct Scsi_Host *shost)
 {
 	TW_Device_Extension *tw_dev=NULL;
 	int retval = FAILED;
 
-	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
+	tw_dev = (TW_Device_Extension *)shost->hostdata;
 
 	tw_dev->num_resets++;
 
-	sdev_printk(KERN_WARNING, SCpnt->device,
-		"WARNING: Command (0x%x) timed out, resetting card.\n",
-		SCpnt->cmnd[0]);
+	shost_printk(KERN_WARNING, shost,
+		"WARNING: Command timed out, resetting card.\n");
 
 	/* Make sure we are not issuing an ioctl or resetting from ioctl */
 	mutex_lock(&tw_dev->ioctl_lock);
 
 	/* Now reset the card and some of the device extension data */
 	if (tw_reset_device_extension(tw_dev)) {
-		printk(KERN_WARNING "3w-xxxx: scsi%d: Reset failed.\n", tw_dev->host->host_no);
+		shost_printk(KERN_WARNING, shost, "Reset failed.\n");
 		goto out;
 	}
 
diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
index e1e4f9d10887..6a44a0795bb5 100644
--- a/drivers/scsi/53c700.c
+++ b/drivers/scsi/53c700.c
@@ -155,7 +155,7 @@ MODULE_LICENSE("GPL");
 
 STATIC int NCR_700_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *);
 STATIC int NCR_700_abort(struct scsi_cmnd * SCpnt);
-STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt);
+STATIC int NCR_700_host_reset(struct Scsi_Host *host);
 STATIC void NCR_700_chip_setup(struct Scsi_Host *host);
 STATIC void NCR_700_chip_reset(struct Scsi_Host *host);
 STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt);
@@ -1934,40 +1934,41 @@ NCR_700_abort(struct scsi_cmnd * SCp)
 }
 
 STATIC int
-NCR_700_host_reset(struct scsi_cmnd * SCp)
+NCR_700_host_reset(struct Scsi_Host * host)
 {
 	DECLARE_COMPLETION_ONSTACK(complete);
-	struct NCR_700_Host_Parameters *hostdata = 
-		(struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];
+	struct NCR_700_Host_Parameters *hostdata =
+		(struct NCR_700_Host_Parameters *)host->hostdata[0];
 
-	scmd_printk(KERN_INFO, SCp,
-		"New error handler wants HOST reset, cmd %p\n\t", SCp);
-	scsi_print_command(SCp);
+	shost_printk(KERN_INFO, host,
+		"New error handler wants HOST reset\n");
 
 	/* In theory, eh_complete should always be null because the
 	 * eh is single threaded, but just in case we're handling a
 	 * reset via sg or something */
-	spin_lock_irq(SCp->device->host->host_lock);
+	spin_lock_irq(host->host_lock);
 	while (hostdata->eh_complete != NULL) {
-		spin_unlock_irq(SCp->device->host->host_lock);
+		spin_unlock_irq(host->host_lock);
 		msleep_interruptible(100);
-		spin_lock_irq(SCp->device->host->host_lock);
+		spin_lock_irq(host->host_lock);
 	}
 
 	hostdata->eh_complete = &complete;
-	NCR_700_internal_bus_reset(SCp->device->host);
-	NCR_700_chip_reset(SCp->device->host);
+	NCR_700_internal_bus_reset(host);
+	NCR_700_chip_reset(host);
 
-	spin_unlock_irq(SCp->device->host->host_lock);
+	spin_unlock_irq(host->host_lock);
 	wait_for_completion(&complete);
-	spin_lock_irq(SCp->device->host->host_lock);
+	spin_lock_irq(host->host_lock);
 
 	hostdata->eh_complete = NULL;
-	/* Revalidate the transport parameters of the failing device */
-	if(hostdata->fast)
-		spi_schedule_dv_device(SCp->device);
-
-	spin_unlock_irq(SCp->device->host->host_lock);
+	/* Revalidate the transport parameters for attached devices */
+	if(hostdata->fast) {
+		struct scsi_device *sdev;
+		__shost_for_each_device(sdev, host)
+			spi_schedule_dv_device(sdev);
+	}
+	spin_unlock_irq(host->host_lock);
 	return SUCCESS;
 }
 
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
index a897c8f914cf..62c3aa7570ab 100644
--- a/drivers/scsi/BusLogic.c
+++ b/drivers/scsi/BusLogic.c
@@ -2843,21 +2843,15 @@ static bool blogic_write_outbox(struct blogic_adapter *adapter,
 
 /* Error Handling (EH) support */
 
-static int blogic_hostreset(struct scsi_cmnd *SCpnt)
+static int blogic_hostreset(struct Scsi_Host *shost)
 {
 	struct blogic_adapter *adapter =
-		(struct blogic_adapter *) SCpnt->device->host->hostdata;
-
-	unsigned int id = SCpnt->device->id;
-	struct blogic_tgt_stats *stats = &adapter->tgt_stats[id];
+		(struct blogic_adapter *) shost->hostdata;
 	int rc;
 
-	spin_lock_irq(SCpnt->device->host->host_lock);
-
-	blogic_inc_count(&stats->adapter_reset_req);
-
+	spin_lock_irq(shost->host_lock);
 	rc = blogic_resetadapter(adapter, false);
-	spin_unlock_irq(SCpnt->device->host->host_lock);
+	spin_unlock_irq(shost->host_lock);
 	return rc;
 }
 
diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
index dece7d9eb4d3..6704415fb1c2 100644
--- a/drivers/scsi/NCR5380.c
+++ b/drivers/scsi/NCR5380.c
@@ -2379,9 +2379,8 @@ static void bus_reset_cleanup(struct Scsi_Host *instance)
  * Returns SUCCESS
  */
 
-static int NCR5380_host_reset(struct scsi_cmnd *cmd)
+static int NCR5380_host_reset(struct Scsi_Host *instance)
 {
-	struct Scsi_Host *instance = cmd->device->host;
 	struct NCR5380_hostdata *hostdata = shost_priv(instance);
 	unsigned long flags;
 	struct NCR5380_cmd *ncmd;
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 9c27bc37e5de..19a012c9a3c9 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1078,13 +1078,11 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
 
 /*
  *	aac_eh_host_reset	- Host reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
+ *	@host:	SCSI host to be reset
  *
  */
-static int aac_eh_host_reset(struct scsi_cmnd *cmd)
+static int aac_eh_host_reset(struct Scsi_Host *host)
 {
-	struct scsi_device * dev = cmd->device;
-	struct Scsi_Host * host = dev->host;
 	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
 	int ret = FAILED;
 	__le32 supported_options2 = 0;
diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index f301aec044bb..0b7fcf7f9624 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -7016,9 +7016,8 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
  * sleeping is allowed and no locking other than for host structures is
  * required. Returns SUCCESS or FAILED.
  */
-static int advansys_reset(struct scsi_cmnd *scp)
+static int advansys_reset(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = scp->device->host;
 	struct asc_board *boardp = shost_priv(shost);
 	unsigned long flags;
 	int status;
@@ -7028,7 +7027,7 @@ static int advansys_reset(struct scsi_cmnd *scp)
 
 	ASC_STATS(shost, reset);
 
-	scmd_printk(KERN_INFO, scp, "SCSI host reset started...\n");
+	shost_printk(KERN_INFO, shost, "SCSI host reset started...\n");
 
 	if (ASC_NARROW_BOARD(boardp)) {
 		ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
@@ -7039,16 +7038,18 @@ static int advansys_reset(struct scsi_cmnd *scp)
 
 		/* Refer to ASC_IERR_* definitions for meaning of 'err_code'. */
 		if (asc_dvc->err_code || !asc_dvc->overrun_dma) {
-			scmd_printk(KERN_INFO, scp, "SCSI host reset error: "
-				    "0x%x, status: 0x%x\n", asc_dvc->err_code,
+			shost_printk(KERN_INFO, shost,
+				     "SCSI host reset error: 0x%x, status: 0x%x\n",
+				     asc_dvc->err_code,
 				    status);
 			ret = FAILED;
 		} else if (status) {
-			scmd_printk(KERN_INFO, scp, "SCSI host reset warning: "
-				    "0x%x\n", status);
+			shost_printk(KERN_INFO, shost,
+				     "SCSI host reset warning: 0x%x\n",
+				     status);
 		} else {
-			scmd_printk(KERN_INFO, scp, "SCSI host reset "
-				    "successful\n");
+			shost_printk(KERN_INFO, shost,
+				     "SCSI host reset successful\n");
 		}
 
 		ASC_DBG(1, "after AscInitAsc1000Driver()\n");
@@ -7065,12 +7066,13 @@ static int advansys_reset(struct scsi_cmnd *scp)
 		ASC_DBG(1, "before AdvResetChipAndSB()\n");
 		switch (AdvResetChipAndSB(adv_dvc)) {
 		case ASC_TRUE:
-			scmd_printk(KERN_INFO, scp, "SCSI host reset "
-				    "successful\n");
+			shost_printk(KERN_INFO, shost,
+				     "SCSI host reset successful\n");
 			break;
 		case ASC_FALSE:
 		default:
-			scmd_printk(KERN_INFO, scp, "SCSI host reset error\n");
+			shost_printk(KERN_INFO, shost,
+				     "SCSI host reset error\n");
 			ret = FAILED;
 			break;
 		}
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index cf7bba2ca68d..69063fe4aab8 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -913,15 +913,14 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)
 	aha1542_outb(sh->io_port, CMD_START_SCSI);
 	spin_unlock_irqrestore(sh->host_lock, flags);
 
-	scmd_printk(KERN_WARNING, cmd,
+	sdev_printk(KERN_WARNING, sdev,
 		"Trying device reset for target\n");
 
 	return SUCCESS;
 }
 
-static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
+static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
 {
-	struct Scsi_Host *sh = cmd->device->host;
 	struct aha1542_hostdata *aha1542 = shost_priv(sh);
 	unsigned long flags;
 	int i;
@@ -933,9 +932,9 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
 	 * we do this?  Try this first, and we can add that later
 	 * if it turns out to be useful.
 	 */
-	outb(reset_cmd, CONTROL(cmd->device->host->io_port));
+	outb(reset_cmd, CONTROL(sh->io_port));
 
-	if (!wait_mask(STATUS(cmd->device->host->io_port),
+	if (!wait_mask(STATUS(sh->io_port),
 	     STATMASK, IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) {
 		spin_unlock_irqrestore(sh->host_lock, flags);
 		return FAILED;
@@ -946,7 +945,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
 	 * us again after host reset.
 	 */
 	if (reset_cmd & HRST)
-		setup_mailboxes(cmd->device->host);
+		setup_mailboxes(sh);
 
 	/*
 	 * Now try to pick up the pieces.  For all pending commands,
@@ -954,7 +953,8 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
 	 * out.  We do not try and restart any commands or anything -
 	 * the strategy handler takes care of that crap.
 	 */
-	shost_printk(KERN_WARNING, cmd->device->host, "Sent BUS RESET to scsi host %d\n", cmd->device->host->host_no);
+	shost_printk(KERN_WARNING, sh, "Sent BUS RESET to scsi host %d\n",
+		     sh->host_no);
 
 	for (i = 0; i < AHA1542_MAILBOXES; i++) {
 		if (aha1542->int_cmds[i] != NULL) {
@@ -982,12 +982,12 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
 
 static int aha1542_bus_reset(struct scsi_cmnd *cmd)
 {
-	return aha1542_reset(cmd, SCRST);
+	return aha1542_reset(cmd->device->host, SCRST);
 }
 
-static int aha1542_host_reset(struct scsi_cmnd *cmd)
+static int aha1542_host_reset(struct Scsi_Host *sh)
 {
-	return aha1542_reset(cmd, HRST | SCRST);
+	return aha1542_reset(sh, HRST | SCRST);
 }
 
 static int aha1542_biosparam(struct scsi_device *sdev,
diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
index 7602639da9b3..3fc9326fc4c0 100644
--- a/drivers/scsi/arm/acornscsi.c
+++ b/drivers/scsi/arm/acornscsi.c
@@ -2631,13 +2631,13 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt)
 /*
  * Prototype: int acornscsi_reset(struct scsi_cmnd *SCpnt)
  * Purpose  : reset a command on this host/reset this host
- * Params   : SCpnt  - command causing reset
+ * Params   : shost  - host to be reset
  * Returns  : one of SCSI_RESET_ macros
  */
-int acornscsi_host_reset(struct scsi_cmnd *SCpnt)
+int acornscsi_host_reset(struct Scsi_Host *shost)
 {
-	AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata;
-	struct scsi_cmnd *SCptr;
+    AS_Host *host = (AS_Host *)shost->hostdata;
+    struct scsi_cmnd *SCptr;
     
     host->stats.resets += 1;
 
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index e6289c6af5ef..38eec967155d 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2656,9 +2656,9 @@ static void fas216_init_chip(FAS216_Info *info)
  * Returns: FAILED if unable to reset.
  * Notes: io_request_lock is taken, and irqs are disabled
  */
-int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
+int fas216_eh_host_reset(struct Scsi_Host *shost)
 {
-	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+	FAS216_Info *info = (FAS216_Info *)shost->hostdata;
 
 	spin_lock_irq(info->host->host_lock);
 
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index 08113277a2a9..f17583f143b3 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -394,11 +394,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
  */
 extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
 
-/* Function: int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
+/* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
  * Purpose : Reset the host associated with this command
- * Params  : SCpnt - command specifing host to reset
+ * Params  : shost - host to reset
  * Returns : FAILED if unable to reset
  */
-extern int fas216_eh_host_reset(struct scsi_cmnd *SCpnt);
+extern int fas216_eh_host_reset(struct Scsi_Host *shost);
 
 #endif /* FAS216_H */
diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
index d401cf27113a..d967141f366c 100644
--- a/drivers/scsi/atari_scsi.c
+++ b/drivers/scsi/atari_scsi.c
@@ -667,7 +667,7 @@ static void atari_scsi_falcon_reg_write(unsigned int reg, u8 value)
 
 #include "NCR5380.c"
 
-static int atari_scsi_host_reset(struct scsi_cmnd *cmd)
+static int atari_scsi_host_reset(struct Scsi_Host *shost)
 {
 	int rv;
 	unsigned long flags;
@@ -684,7 +684,7 @@ static int atari_scsi_host_reset(struct scsi_cmnd *cmd)
 		atari_dma_orig_addr = NULL;
 	}
 
-	rv = NCR5380_host_reset(cmd);
+	rv = NCR5380_host_reset(shost);
 
 	/* The 5380 raises its IRQ line while _RST is active but the ST DMA
 	 * "lock" has been released so this interrupt may end up handled by
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index e7be95ee7d64..50c04ba85b0b 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -2476,7 +2476,7 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
 
 /**
  * cxlflash_eh_host_reset_handler() - reset the host adapter
- * @scp:	SCSI command from stack identifying host.
+ * @host:	SCSI host adapter.
  *
  * Following a reset, the state is evaluated again in case an EEH occurred
  * during the reset. In such a scenario, the host reset will either yield
@@ -2487,11 +2487,10 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
  *	SUCCESS as defined in scsi/scsi.h
  *	FAILED as defined in scsi/scsi.h
  */
-static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp)
+static int cxlflash_eh_host_reset_handler(struct Scsi_Host *host)
 {
 	int rc = SUCCESS;
 	int rcr = 0;
-	struct Scsi_Host *host = scp->device->host;
 	struct cxlflash_cfg *cfg = shost_priv(host);
 	struct device *dev = &cfg->dev->dev;
 
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 93227c04ef59..6e3ad0e5b533 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -746,15 +746,15 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
 }
 
 // This version of reset is called by the eh_error_handler
-static int __adpt_reset(struct scsi_cmnd* cmd)
+static int __adpt_reset(struct Scsi_Host* shost)
 {
 	adpt_hba* pHba;
 	int rcode;
 	char name[32];
 
-	pHba = (adpt_hba*)cmd->device->host->hostdata[0];
+	pHba = (adpt_hba*)shost->hostdata[0];
 	strncpy(name, pHba->name, sizeof(name));
-	printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device->channel].tid);
+	printk(KERN_WARNING"%s: Hba Reset\n", name);
 	rcode =  adpt_hba_reset(pHba);
 	if(rcode == 0){
 		printk(KERN_WARNING"%s: HBA reset complete\n", name);
@@ -765,13 +765,13 @@ static int __adpt_reset(struct scsi_cmnd* cmd)
 	}
 }
 
-static int adpt_reset(struct scsi_cmnd* cmd)
+static int adpt_reset(struct Scsi_Host* shost)
 {
 	int rc;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = __adpt_reset(cmd);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	rc = __adpt_reset(shost);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 8a079e8d7f65..b77a3625fa6f 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -28,7 +28,7 @@
 static int adpt_detect(struct scsi_host_template * sht);
 static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd);
 static int adpt_abort(struct scsi_cmnd * cmd);
-static int adpt_reset(struct scsi_cmnd* cmd);
+static int adpt_reset(struct Scsi_Host * host);
 static int adpt_slave_configure(struct scsi_device *);
 
 static const char *adpt_info(struct Scsi_Host *pSHost);
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index ed63f7a9ea54..a104d1a3a9da 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -976,7 +976,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 /* SCSI error handler (eh) functions */
 int esas2r_eh_abort(struct scsi_cmnd *cmd);
 int esas2r_device_reset(struct scsi_cmnd *cmd);
-int esas2r_host_reset(struct scsi_cmnd *cmd);
+int esas2r_host_reset(struct Scsi_Host *shost);
 int esas2r_bus_reset(struct scsi_cmnd *cmd);
 int esas2r_target_reset(struct scsi_cmnd *cmd);
 
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 7a4eadad23d7..52494c8bb656 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1059,10 +1059,10 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset)
+static int esas2r_host_bus_reset(struct Scsi_Host *shost, bool host_reset)
 {
 	struct esas2r_adapter *a =
-		(struct esas2r_adapter *)cmd->device->host->hostdata;
+		(struct esas2r_adapter *)shost->hostdata;
 
 	if (test_bit(AF_DEGRADED_MODE, &a->flags))
 		return FAILED;
@@ -1087,18 +1087,20 @@ static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset)
 	return SUCCESS;
 }
 
-int esas2r_host_reset(struct scsi_cmnd *cmd)
+int esas2r_host_reset(struct Scsi_Host *shost)
 {
-	esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", cmd);
+	esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", shost);
 
-	return esas2r_host_bus_reset(cmd, true);
+	return esas2r_host_bus_reset(shost, true);
 }
 
 int esas2r_bus_reset(struct scsi_cmnd *cmd)
 {
-	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", cmd);
+	struct Scsi_Host *shost = cmd->device->host;
+
+	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
 
-	return esas2r_host_bus_reset(cmd, false);
+	return esas2r_host_bus_reset(shost, false);
 }
 
 static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset)
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 64ec6bb84550..b41eac8b5e0f 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2640,9 +2640,9 @@ static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 }
 
 /* All bets are off, reset the entire device.  */
-static int esp_eh_host_reset_handler(struct scsi_cmnd *cmd)
+static int esp_eh_host_reset_handler(struct Scsi_Host *shost)
 {
-	struct esp *esp = shost_priv(cmd->device->host);
+	struct esp *esp = shost_priv(shost);
 	unsigned long flags;
 
 	spin_lock_irqsave(esp->host->host_lock, flags);
diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
index 444eac9b2466..5d3f1520ee50 100644
--- a/drivers/scsi/fdomain.c
+++ b/drivers/scsi/fdomain.c
@@ -456,9 +456,8 @@ static int fdomain_abort(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int fdomain_host_reset(struct scsi_cmnd *cmd)
+static int fdomain_host_reset(struct Scsi_Host *sh)
 {
-	struct Scsi_Host *sh = cmd->device->host;
 	struct fdomain *fd = shost_priv(sh);
 	unsigned long flags;
 
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index aa07189fb5fb..7b81bea3ffa2 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -359,7 +359,7 @@ void fnic_update_mac_locked(struct fnic *, u8 *new);
 int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int fnic_abort_cmd(struct scsi_cmnd *);
 int fnic_device_reset(struct scsi_cmnd *);
-int fnic_host_reset(struct scsi_cmnd *);
+int fnic_host_reset(struct Scsi_Host *);
 int fnic_reset(struct Scsi_Host *);
 void fnic_scsi_cleanup(struct fc_lport *);
 void fnic_scsi_abort_io(struct fc_lport *);
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index fb6dc59a5a7e..b286d5feaca1 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2452,11 +2452,10 @@ int fnic_reset(struct Scsi_Host *shost)
  * host is offlined by SCSI.
  *
  */
-int fnic_host_reset(struct scsi_cmnd *sc)
+int fnic_host_reset(struct Scsi_Host *shost)
 {
 	int ret;
 	unsigned long wait_host_tmo;
-	struct Scsi_Host *shost = sc->device->host;
 	struct fc_lport *lp = shost_priv(shost);
 	struct fnic *fnic = lport_priv(lp);
 	unsigned long flags;
diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
index f18b770626e6..30f6a6891ea2 100644
--- a/drivers/scsi/hptiop.c
+++ b/drivers/scsi/hptiop.c
@@ -1091,12 +1091,12 @@ static int hptiop_reset_hba(struct hptiop_hba *hba)
 	return 0;
 }
 
-static int hptiop_reset(struct scsi_cmnd *scp)
+static int hptiop_reset(struct Scsi_Host *host)
 {
-	struct hptiop_hba * hba = (struct hptiop_hba *)scp->device->host->hostdata;
+	struct hptiop_hba * hba = (struct hptiop_hba *)host->hostdata;
 
 	printk(KERN_WARNING "hptiop_reset(%d/%d/%d)\n",
-	       scp->device->host->host_no, -1, -1);
+	       host->host_no, -1, -1);
 
 	return hptiop_reset_hba(hba)? FAILED : SUCCESS;
 }
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 2e7128f0d905..5fb36cd70dde 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -2984,10 +2984,10 @@ static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd)
  * @cmd:	struct scsi_cmnd having problems
  *
  **/
-static int ibmvfc_eh_host_reset_handler(struct scsi_cmnd *cmd)
+static int ibmvfc_eh_host_reset_handler(struct Scsi_Host *shost)
 {
 	int rc;
-	struct ibmvfc_host *vhost = shost_priv(cmd->device->host);
+	struct ibmvfc_host *vhost = shost_priv(shost);
 
 	dev_err(vhost->dev, "Resetting connection due to error recovery\n");
 	rc = ibmvfc_issue_fc_host_lip(vhost->host);
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 63f32f843e75..892d79e2e7e1 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1735,10 +1735,10 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
  * ibmvscsi_eh_host_reset_handler - Reset the connection to the server
  * @cmd:	struct scsi_cmnd having problems
 */
-static int ibmvscsi_eh_host_reset_handler(struct scsi_cmnd *cmd)
+static int ibmvscsi_eh_host_reset_handler(struct Scsi_Host *shost)
 {
 	unsigned long wait_switch = 0;
-	struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
+	struct ibmvscsi_host_data *hostdata = shost_priv(shost);
 
 	dev_err(hostdata->dev, "Resetting connection due to error recovery\n");
 
diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
index 7a499d621c25..757175d09b2b 100644
--- a/drivers/scsi/imm.c
+++ b/drivers/scsi/imm.c
@@ -984,9 +984,9 @@ static void imm_reset_pulse(unsigned int base)
 	w_ctr(base, 0x04);
 }
 
-static int imm_reset(struct scsi_cmnd *cmd)
+static int imm_reset(struct Scsi_Host *host)
 {
-	imm_struct *dev = imm_dev(cmd->device->host);
+	imm_struct *dev = imm_dev(host);
 
 	if (imm_scsi_pointer(cmd)->phase)
 		imm_disconnect(dev);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 104bee9b3a9d..29893dae7f24 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -5181,14 +5181,14 @@ static int ipr_wait_for_ops(struct ipr_ioa_cfg *ioa_cfg, void *device,
 	return SUCCESS;
 }
 
-static int ipr_eh_host_reset(struct scsi_cmnd *cmd)
+static int ipr_eh_host_reset(struct Scsi_Host *shost)
 {
 	struct ipr_ioa_cfg *ioa_cfg;
 	unsigned long lock_flags = 0;
 	int rc = SUCCESS;
 
 	ENTER;
-	ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata;
+	ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata;
 	spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
 
 	if (!ioa_cfg->in_reset_reload && !ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) {
diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
index d49c1d6df5d6..f57858f561e3 100644
--- a/drivers/scsi/ips.c
+++ b/drivers/scsi/ips.c
@@ -229,7 +229,7 @@ module_param(ips, charp, 0);
  * Function prototypes
  */
 static int ips_eh_abort(struct scsi_cmnd *);
-static int ips_eh_reset(struct scsi_cmnd *);
+static int ips_eh_reset(struct Scsi_Host *);
 static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *);
 static const char *ips_info(struct Scsi_Host *);
 static irqreturn_t do_ipsintr(int, void *);
@@ -829,7 +829,7 @@ int ips_eh_abort(struct scsi_cmnd *SC)
 /* NOTE: this routine is called under the io_request_lock spinlock          */
 /*                                                                          */
 /****************************************************************************/
-static int __ips_eh_reset(struct scsi_cmnd *SC)
+static int __ips_eh_reset(struct Scsi_Host *shost)
 {
 	int ret;
 	int i;
@@ -842,13 +842,7 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)
 	return (FAILED);
 #else
 
-	if (!SC) {
-		DEBUG(1, "Reset called with NULL scsi command");
-
-		return (FAILED);
-	}
-
-	ha = (ips_ha_t *) SC->device->host->hostdata;
+	ha = (ips_ha_t *) shost->hostdata;
 
 	if (!ha) {
 		DEBUG(1, "Reset called with NULL ha struct");
@@ -994,13 +988,13 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)
 
 }
 
-static int ips_eh_reset(struct scsi_cmnd *SC)
+static int ips_eh_reset(struct Scsi_Host *shost)
 {
 	int rc;
 
-	spin_lock_irq(SC->device->host->host_lock);
-	rc = __ips_eh_reset(SC);
-	spin_unlock_irq(SC->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	rc = __ips_eh_reset(shost);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
@@ -1078,7 +1072,7 @@ static int ips_queue_lck(struct scsi_cmnd *SC)
 				return (0);
 			}
 			ha->ioctl_reset = 1;	/* This reset request is from an IOCTL */
-			__ips_eh_reset(SC);
+			__ips_eh_reset(SC->device->host);
 			SC->result = DID_OK << 16;
 			scsi_done(SC);
 			return (0);
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index 074996319df5..ab4a1c01a353 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -2195,11 +2195,10 @@ EXPORT_SYMBOL(fc_eh_device_reset);
 
 /**
  * fc_eh_host_reset() - Reset a Scsi_Host.
- * @sc_cmd: The SCSI command that identifies the SCSI host to be reset
+ * @shost: The SCSI host to be reset
  */
-int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
+int fc_eh_host_reset(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = sc_cmd->device->host;
 	struct fc_lport *lport = shost_priv(shost);
 	unsigned long wait_tmo;
 
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 1959c58d22f8..0443846c9fad 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -6503,9 +6503,8 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
  *  0x2002 - Success
  **/
 static int
-lpfc_host_reset_handler(struct scsi_cmnd *cmnd)
+lpfc_host_reset_handler(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = cmnd->device->host;
 	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
 	struct lpfc_hba *phba = vport->phba;
 	int rc, ret = SUCCESS;
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
index 070ebe352f9e..466efe781376 100644
--- a/drivers/scsi/mac53c94.c
+++ b/drivers/scsi/mac53c94.c
@@ -100,14 +100,14 @@ static int mac53c94_queue_lck(struct scsi_cmnd *cmd)
 
 static DEF_SCSI_QCMD(mac53c94_queue)
 
-static int mac53c94_host_reset(struct scsi_cmnd *cmd)
+static int mac53c94_host_reset(struct Scsi_Host *shost)
 {
-	struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
+	struct fsc_state *state = (struct fsc_state *) shost->hostdata;
 	struct mac53c94_regs __iomem *regs = state->regs;
 	struct dbdma_regs __iomem *dma = state->dma;
 	unsigned long flags;
 
-	spin_lock_irqsave(cmd->device->host->host_lock, flags);
+	spin_lock_irqsave(shost->host_lock, flags);
 
 	writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
 	writeb(CMD_SCSI_RESET, &regs->command);	/* assert RST */
@@ -117,7 +117,7 @@ static int mac53c94_host_reset(struct scsi_cmnd *cmd)
 	mac53c94_init(state);
 	writeb(CMD_NOP, &regs->command);
 
-	spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
+	spin_unlock_irqrestore(shost->host_lock, flags);
 	return SUCCESS;
 }
 
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
index 9484632ffed6..6f6b66715707 100644
--- a/drivers/scsi/megaraid.c
+++ b/drivers/scsi/megaraid.c
@@ -1875,13 +1875,13 @@ megaraid_abort(struct scsi_cmnd *cmd)
 
 
 static int
-megaraid_reset(struct scsi_cmnd *cmd)
+megaraid_reset(struct Scsi_Host *shost)
 {
 	adapter_t	*adapter;
 	megacmd_t	mc;
 	int		rval;
 
-	adapter = (adapter_t *)cmd->device->host->hostdata;
+	adapter = (adapter_t *)shost->hostdata;
 
 #if MEGA_HAVE_CLUSTERING
 	mc.cmd = MEGA_CLUSTER_CMD;
diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
index 013fbfb911b9..43acad67d95f 100644
--- a/drivers/scsi/megaraid.h
+++ b/drivers/scsi/megaraid.h
@@ -973,7 +973,7 @@ static irqreturn_t megaraid_isr_iomapped(int, void *);
 static void mega_free_scb(adapter_t *, scb_t *);
 
 static int megaraid_abort(struct scsi_cmnd *);
-static int megaraid_reset(struct scsi_cmnd *);
+static int megaraid_reset(struct Scsi_Host *);
 static int megaraid_abort_and_reset(adapter_t *, struct scsi_cmnd *, int);
 static int megaraid_biosparam(struct scsi_device *, struct block_device *,
 		sector_t, int []);
diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
index 2a339d4a7e9d..e250566a17b6 100644
--- a/drivers/scsi/megaraid/megaraid_mbox.c
+++ b/drivers/scsi/megaraid/megaraid_mbox.c
@@ -92,7 +92,7 @@ static int megaraid_sysfs_alloc_resources(adapter_t *);
 static void megaraid_sysfs_free_resources(adapter_t *);
 
 static int megaraid_abort_handler(struct scsi_cmnd *);
-static int megaraid_reset_handler(struct scsi_cmnd *);
+static int megaraid_reset_handler(struct Scsi_Host *);
 
 static int mbox_post_sync_cmd(adapter_t *, uint8_t []);
 static int mbox_post_sync_cmd_fast(adapter_t *, uint8_t []);
@@ -2512,7 +2512,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
  * host.
  **/
 static int
-megaraid_reset_handler(struct scsi_cmnd *scp)
+megaraid_reset_handler(struct Scsi_Host *shost)
 {
 	adapter_t	*adapter;
 	scb_t		*scb;
@@ -2525,7 +2525,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
 	int		i;
 	uioc_t		*kioc;
 
-	adapter		= SCP2ADAPTER(scp);
+	adapter		= (adapter_t *)SCSIHOST2ADAP(shost);
 	raid_dev	= ADAP2RAIDDEV(adapter);
 
 	// return failure if adapter is not responding
@@ -2556,15 +2556,9 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
 
 			megaraid_mbox_mm_done(adapter, scb);
 		} else {
-			if (scb->scp == scp) {	// Found command
-				con_log(CL_ANN, (KERN_WARNING
-					"megaraid: %d[%d:%d], reset from pending list\n",
-					scb->sno, scb->dev_channel, scb->dev_target));
-			} else {
-				con_log(CL_ANN, (KERN_WARNING
+			con_log(CL_ANN, (KERN_WARNING
 				"megaraid: IO packet with %d[%d:%d] being reset\n",
 				scb->sno, scb->dev_channel, scb->dev_target));
-			}
 
 			scb->scp->result = (DID_RESET << 16);
 			scsi_done(scb->scp);
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index c95360a3c186..0222e234f108 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2896,15 +2896,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
  * reset requests. Device, bus and host specific reset handlers can use this
  * function after they do their specific tasks.
  */
-static int megasas_generic_reset(struct scsi_cmnd *scmd)
+static int megasas_generic_reset(struct Scsi_Host *shost)
 {
 	int ret_val;
 	struct megasas_instance *instance;
 
-	instance = (struct megasas_instance *)scmd->device->host->hostdata;
+	instance = (struct megasas_instance *)shost->hostdata;
 
-	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n",
-		 scmd->cmnd[0], scmd->retries);
+	shost_printk(KERN_NOTICE, shost, "megasas: RESET\n");
 
 	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
 		dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n");
@@ -3057,31 +3056,30 @@ megasas_dump_sys_regs(void __iomem *reg_set, char *buf)
  * megasas_reset_bus_host -	Bus & host reset handler entry point
  * @scmd:			Mid-layer SCSI command
  */
-static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
+static int megasas_reset_bus_host(struct Scsi_Host *shost)
 {
 	int ret;
 	struct megasas_instance *instance;
 
-	instance = (struct megasas_instance *)scmd->device->host->hostdata;
+	instance = (struct megasas_instance *)shost->hostdata;
 
-	scmd_printk(KERN_INFO, scmd,
+	shost_printk(KERN_INFO, shost,
 		"OCR is requested due to IO timeout!!\n");
 
-	scmd_printk(KERN_INFO, scmd,
-		"SCSI host state: %d  SCSI host busy: %d  FW outstanding: %d\n",
-		scmd->device->host->shost_state,
-		scsi_host_busy(scmd->device->host),
+	shost_printk(KERN_INFO, shost,
+		"Controller reset is requested due to IO timeout\n"
+		"SCSI host state: %d\t"
+		" SCSI host busy: %d\t FW outstanding: %d\n",
+		shost->shost_state,
+		scsi_host_busy(shost),
 		atomic_read(&instance->fw_outstanding));
 	/*
 	 * First wait for all commands to complete
 	 */
-	if (instance->adapter_type == MFI_SERIES) {
-		ret = megasas_generic_reset(scmd);
-	} else {
-		megasas_dump_fusion_io(scmd);
-		ret = megasas_reset_fusion(scmd->device->host,
-				SCSIIO_TIMEOUT_OCR);
-	}
+	if (instance->adapter_type == MFI_SERIES)
+		ret = megasas_generic_reset(shost);
+	else
+		ret = megasas_reset_fusion(shost, SCSIIO_TIMEOUT_OCR);
 
 	return ret;
 }
diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
index 322d3ad38159..5e1d0bde36f3 100644
--- a/drivers/scsi/mesh.c
+++ b/drivers/scsi/mesh.c
@@ -1699,9 +1699,9 @@ static int mesh_abort(struct scsi_cmnd *cmd)
  * The midlayer will wait for devices to come back, we don't need
  * to do that ourselves
  */
-static int mesh_host_reset(struct scsi_cmnd *cmd)
+static int mesh_host_reset(struct Scsi_Host *shost)
 {
-	struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata;
+	struct mesh_state *ms = (struct mesh_state *) shost->hostdata;
 	volatile struct mesh_regs __iomem *mr = ms->mesh;
 	volatile struct dbdma_regs __iomem *md = ms->dma;
 	unsigned long flags;
@@ -1718,7 +1718,7 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
 	out_8(&mr->exception, 0xff);	/* clear all exception bits */
 	out_8(&mr->error, 0xff);	/* clear all error bits */
 	out_8(&mr->sequence, SEQ_RESETMESH);
-       	mesh_flush_io(mr);
+	mesh_flush_io(mr);
 	udelay(1);
 	out_8(&mr->intr_mask, INT_ERROR | INT_EXCEPTION | INT_CMDDONE);
 	out_8(&mr->source_id, ms->host->this_id);
@@ -1727,13 +1727,13 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
 
 	/* Reset the bus */
 	out_8(&mr->bus_status1, BS1_RST);	/* assert RST */
-       	mesh_flush_io(mr);
+	mesh_flush_io(mr);
 	udelay(30);			/* leave it on for >= 25us */
 	out_8(&mr->bus_status1, 0);	/* negate RST */
 
 	/* Complete pending commands */
 	handle_reset(ms);
-	
+
 	spin_unlock_irqrestore(ms->host->host_lock, flags);
 	return SUCCESS;
 }
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 31f05e9f5ee0..bd42d3a56590 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -3335,15 +3335,15 @@ void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout)
 
 /**
  * mpi3mr_eh_host_reset - Host reset error handling callback
- * @scmd: SCSI command reference
+ * @shost: SCSI host reference
  *
  * Issue controller reset
  *
  * Return: SUCCESS of successful reset else FAILED
  */
-static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd)
+static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
 {
-	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
+	struct mpi3mr_ioc *mrioc = shost_priv(shost);
 	int retval = FAILED, ret;
 
 	ret = mpi3mr_soft_reset_handler(mrioc,
@@ -3353,9 +3353,9 @@ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd)
 
 	retval = SUCCESS;
 out:
-	sdev_printk(KERN_INFO, scmd->device,
-	    "Host reset is %s for scmd(%p)\n",
-	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	shost_printk(KERN_INFO, shost,
+	    "Host reset is %s\n",
+	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
 
 	return retval;
 }
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 7e476f50935b..ea9a8799f89a 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3526,13 +3526,12 @@ scsih_target_reset(struct scsi_cmnd *scmd)
  * Return: SUCCESS if command aborted else FAILED
  */
 static int
-scsih_host_reset(struct scsi_cmnd *scmd)
+scsih_host_reset(struct Scsi_Host *shost)
 {
-	struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
+	struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
 	int r, retval;
 
-	ioc_info(ioc, "attempting host reset! scmd(0x%p)\n", scmd);
-	scsi_print_command(scmd);
+	ioc_info(ioc, "attempting host reset\n");
 
 	if (ioc->is_driver_loading || ioc->remove_host) {
 		ioc_info(ioc, "Blocking the host reset\n");
@@ -3543,8 +3542,8 @@ scsih_host_reset(struct scsi_cmnd *scmd)
 	retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
 	r = (retval < 0) ? FAILED : SUCCESS;
 out:
-	ioc_info(ioc, "host reset: %s scmd(0x%p)\n",
-		 r == SUCCESS ? "SUCCESS" : "FAILED", scmd);
+	ioc_info(ioc, "host reset: %s\n",
+		 r == SUCCESS ? "SUCCESS" : "FAILED");
 
 	return r;
 }
diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
index 05d3ce9b72db..249813bc926e 100644
--- a/drivers/scsi/mvumi.c
+++ b/drivers/scsi/mvumi.c
@@ -695,14 +695,13 @@ static int mvumi_reset_host_9143(struct mvumi_hba *mhba)
 	return mvumi_wait_for_outstanding(mhba);
 }
 
-static int mvumi_host_reset(struct scsi_cmnd *scmd)
+static int mvumi_host_reset(struct Scsi_Host *shost)
 {
 	struct mvumi_hba *mhba;
 
-	mhba = (struct mvumi_hba *) scmd->device->host->hostdata;
+	mhba = (struct mvumi_hba *) shost->hostdata;
 
-	scmd_printk(KERN_NOTICE, scmd, "RESET -%u cmd=%x retries=%x\n",
-			scsi_cmd_to_rq(scmd)->tag, scmd->cmnd[0], scmd->retries);
+	shost_printk(KERN_NOTICE, shost, "RESET\n");
 
 	return mhba->instancet->reset_host(mhba);
 }
diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
index 71585528e8db..437b11d48238 100644
--- a/drivers/scsi/myrb.c
+++ b/drivers/scsi/myrb.c
@@ -1251,9 +1251,8 @@ static void myrb_cleanup(struct myrb_hba *cb)
 	scsi_host_put(cb->host);
 }
 
-static int myrb_host_reset(struct scsi_cmnd *scmd)
+static int myrb_host_reset(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = scmd->device->host;
 	struct myrb_hba *cb = shost_priv(shost);
 
 	cb->reset(cb->io_base);
diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
index 7eb8c39da366..caa5511ca923 100644
--- a/drivers/scsi/myrs.c
+++ b/drivers/scsi/myrs.c
@@ -1529,9 +1529,8 @@ ATTRIBUTE_GROUPS(myrs_shost);
 /*
  * SCSI midlayer interface
  */
-static int myrs_host_reset(struct scsi_cmnd *scmd)
+static int myrs_host_reset(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = scmd->device->host;
 	struct myrs_hba *cs = shost_priv(shost);
 
 	cs->reset(cs->io_base);
diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
index 75bb0028ed74..d1f760c8e8ce 100644
--- a/drivers/scsi/nsp32.c
+++ b/drivers/scsi/nsp32.c
@@ -191,7 +191,7 @@ static int	   nsp32_release     (struct Scsi_Host *);
 
 /* SCSI error handler */
 static int	   nsp32_eh_abort     (struct scsi_cmnd *);
-static int	   nsp32_eh_host_reset(struct scsi_cmnd *);
+static int	   nsp32_eh_host_reset(struct Scsi_Host *);
 
 /* generate SCSI message */
 static void nsp32_build_identify(struct scsi_cmnd *);
@@ -2876,23 +2876,21 @@ static void nsp32_do_bus_reset(nsp32_hw_data *data)
 	data->CurrentSC = NULL;
 }
 
-static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt)
+static int nsp32_eh_host_reset(struct Scsi_Host *host)
 {
-	struct Scsi_Host *host = SCpnt->device->host;
-	unsigned int      base = SCpnt->device->host->io_port;
+	unsigned int      base = host->io_port;
 	nsp32_hw_data    *data = (nsp32_hw_data *)host->hostdata;
 
 	nsp32_msg(KERN_INFO, "Host Reset");
-	nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt);
 
-	spin_lock_irq(SCpnt->device->host->host_lock);
+	spin_lock_irq(host->host_lock);
 
 	nsp32hw_init(data);
 	nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK);
 	nsp32_do_bus_reset(data);
 	nsp32_write2(base, IRQ_CONTROL, 0);
 
-	spin_unlock_irq(SCpnt->device->host->host_lock);
+	spin_unlock_irq(host->host_lock);
 	return SUCCESS;	/* Host reset is succeeded at any time. */
 }
 
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 48acab03a8a0..4aa9737fa711 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1497,9 +1497,9 @@ static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
 	return nsp_bus_reset(data);
 }
 
-static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
+static int nsp_eh_host_reset(struct Scsi_Host *host)
 {
-	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
+	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
 
 	nsp_dbg(NSP_DEBUG_BUSRESET, "in");
 
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index e1ee8ef90ad3..f532adb5f166 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -300,7 +300,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
 /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
 /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
 static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
-static int nsp_eh_host_reset   (struct scsi_cmnd *SCpnt);
+static int nsp_eh_host_reset   (struct Scsi_Host *host);
 static int nsp_bus_reset       (nsp_hw_data *data);
 
 /* */
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index 310d0b6586a6..59893db166c9 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -270,8 +270,8 @@ static int qlogic_resume(struct pcmcia_device *link)
 		outb(0x24, link->resource[0]->start + 0x9);
 		outb(0x04, link->resource[0]->start + 0xd);
 	}
-	/* Ugggglllyyyy!!! */
-	qlogicfas408_host_reset(NULL);
+
+	qlogicfas408_host_reset(info->host);
 
 	return 0;
 }
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 5d7dfefd6f6c..79862f17de8d 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -583,14 +583,14 @@ static int SYM53C500_queue_lck(struct scsi_cmnd *SCpnt)
 static DEF_SCSI_QCMD(SYM53C500_queue)
 
 static int 
-SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
+SYM53C500_host_reset(struct Scsi_Host *shost)
 {
-	int port_base = SCpnt->device->host->io_port;
+	int port_base = shost->io_port;
 
 	DEB(printk("SYM53C500_host_reset called\n"));
-	spin_lock_irq(SCpnt->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
 	SYM53C500_int_host_reset(port_base);
-	spin_unlock_irq(SCpnt->device->host->host_lock);
+	spin_unlock_irq(shost->host_lock);
 
 	return SUCCESS;
 }
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 62b9de87ff05..79ca737ac75b 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3086,19 +3086,19 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
 /**
  * pmcraid_eh_host_reset_handler - adapter reset handler callback
  *
- * @scmd: pointer to scsi_cmd that was sent to a resource of adapter
+ * @shost: pointer to scsi_host
  *
  * Initiates adapter reset to bring it up to operational state
  *
  * Return value
  *	SUCCESS or FAILED
  */
-static int pmcraid_eh_host_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_host_reset_handler(struct Scsi_Host *shost)
 {
 	unsigned long interval = 10000; /* 10 seconds interval */
 	int waits = jiffies_to_msecs(PMCRAID_RESET_HOST_TIMEOUT) / interval;
 	struct pmcraid_instance *pinstance =
-		(struct pmcraid_instance *)(scmd->device->host->hostdata);
+		(struct pmcraid_instance *)(shost->hostdata);
 
 
 	/* wait for an additional 150 seconds just in case firmware could come
diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
index c6c1bc608224..14a4b582fa9e 100644
--- a/drivers/scsi/ppa.c
+++ b/drivers/scsi/ppa.c
@@ -867,9 +867,9 @@ static void ppa_reset_pulse(unsigned int base)
 	w_ctr(base, 0xc);
 }
 
-static int ppa_reset(struct scsi_cmnd *cmd)
+static int ppa_reset(struct Scsi_Host *host)
 {
-	ppa_struct *dev = ppa_dev(cmd->device->host);
+	ppa_struct *dev = ppa_dev(host);
 
 	if (ppa_scsi_pointer(cmd)->phase)
 		ppa_disconnect(dev);
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 85ccfbc5cd26..c12fb3465946 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -952,12 +952,12 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
 }
 
 /* Reset the host by gracefully logging out and then logging back in */
-static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd)
+static int qedf_eh_host_reset(struct Scsi_Host *shost)
 {
 	struct fc_lport *lport;
 	struct qedf_ctx *qedf;
 
-	lport = shost_priv(sc_cmd->device->host);
+	lport = shost_priv(shost);
 	qedf = lport_priv(lport);
 
 	if (atomic_read(&qedf->link_state) == QEDF_LINK_DOWN ||
diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
index 31ec429104e2..dfb12f80fd9f 100644
--- a/drivers/scsi/qedi/qedi_iscsi.c
+++ b/drivers/scsi/qedi/qedi_iscsi.c
@@ -30,9 +30,8 @@ int qedi_recover_all_conns(struct qedi_ctx *qedi)
 	return SUCCESS;
 }
 
-static int qedi_eh_host_reset(struct scsi_cmnd *cmd)
+static int qedi_eh_host_reset(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = cmd->device->host;
 	struct qedi_ctx *qedi;
 
 	qedi = iscsi_host_priv(shost);
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index c4466e4e692f..cd4c7126c1c9 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -995,10 +995,9 @@ qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
  *     Reset the specified adapter (both channels)
  **************************************************************************/
 static int
-qla1280_eh_adapter_reset(struct scsi_cmnd *cmd)
+qla1280_eh_adapter_reset(struct Scsi_Host *shost)
 {
 	int rc;
-	struct Scsi_Host *shost = cmd->device->host;
 	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
 
 	spin_lock_irq(shost->host_lock);
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 762229d495a8..5f86e7bd5a0e 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1604,8 +1604,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 *    The reset function will reset the Adapter.
 *
 * Input:
-*      cmd = Linux SCSI command packet of the command that cause the
-*            adapter reset.
+*      shost = Linux SCSI host to be reset
 *
 * Returns:
 *      Either SUCCESS or FAILED.
@@ -1613,13 +1612,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 * Note:
 **************************************************************************/
 static int
-qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_host_reset(struct Scsi_Host *shost)
 {
-	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
+	scsi_qla_host_t *vha = shost_priv(shost);
 	struct qla_hw_data *ha = vha->hw;
 	int ret = FAILED;
-	unsigned int id;
-	uint64_t lun;
 	scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
 
 	if (qla2x00_isp_reg_stat(ha)) {
@@ -1629,11 +1626,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
 		return SUCCESS;
 	}
 
-	id = cmd->device->id;
-	lun = cmd->device->lun;
-
 	ql_log(ql_log_info, vha, 0x8018,
-	    "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
+	    "ADAPTER RESET ISSUED host=%ld.\n", vha->host_no);
 
 	/*
 	 * No point in issuing another reset if one is active.  Also do not
@@ -1679,8 +1673,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
 
 eh_host_reset_lock:
 	ql_log(ql_log_info, vha, 0x8017,
-	    "ADAPTER RESET %s nexus=%ld:%d:%llu.\n",
-	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
+	    "ADAPTER RESET %s host=%ld.\n",
+	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no);
 
 	return ret;
 }
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index f4969b99c07f..8f89080e2580 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -159,7 +159,7 @@ static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
 static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
 static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
 static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd);
-static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
+static int qla4xxx_eh_host_reset(struct Scsi_Host *shost);
 static int qla4xxx_slave_alloc(struct scsi_device *device);
 static umode_t qla4_attr_is_visible(int param_type, int param);
 static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type);
@@ -9411,18 +9411,18 @@ static int qla4xxx_is_eh_active(struct Scsi_Host *shost)
 
 /**
  * qla4xxx_eh_host_reset - kernel callback
- * @cmd: Pointer to Linux's SCSI command structure
+ * @host: Pointer to Linux's SCSI host structure
  *
  * This routine is invoked by the Linux kernel to perform fatal error
  * recovery on the specified adapter.
  **/
-static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
+static int qla4xxx_eh_host_reset(struct Scsi_Host *host)
 {
 	int return_status = FAILED;
 	struct scsi_qla_host *ha;
 	int rval;
 
-	ha = to_qla_host(cmd->device->host);
+	ha = to_qla_host(host);
 
 	rval = qla4xxx_isp_check_reg(ha);
 	if (rval != QLA_SUCCESS) {
@@ -9444,20 +9444,18 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
 		     ha->host_no, __func__));
 
 		/* Clear outstanding srb in queues */
-		if (qla4xxx_is_eh_active(cmd->device->host))
+		if (qla4xxx_is_eh_active(host))
 			qla4xxx_abort_active_cmds(ha, DID_ABORT << 16);
 
 		return FAILED;
 	}
 
 	ql4_printk(KERN_INFO, ha,
-		   "scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no,
-		   cmd->device->channel, cmd->device->id, cmd->device->lun);
+		   "scsi%ld: HOST RESET ISSUED.\n", ha->host_no);
 
 	if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
-		DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host.  Adapter "
-			      "DEAD.\n", ha->host_no, cmd->device->channel,
-			      __func__));
+		DEBUG2(printk("scsi%ld: %s: Unable to reset host.  Adapter "
+			      "DEAD.\n", ha->host_no, __func__));
 
 		return FAILED;
 	}
diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
index 3e065d5fc80c..008e908e3aff 100644
--- a/drivers/scsi/qlogicfas408.c
+++ b/drivers/scsi/qlogicfas408.c
@@ -525,20 +525,18 @@ int qlogicfas408_abort(struct scsi_cmnd *cmd)
 
 /*
  *	Reset SCSI bus
- *	FIXME: This function is invoked with cmd = NULL directly by
- *	the PCMCIA qlogic_stub code. This wants fixing
  */
 
-int qlogicfas408_host_reset(struct scsi_cmnd *cmd)
+int qlogicfas408_host_reset(struct Scsi_Host *host)
 {
-	struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
+	struct qlogicfas408_priv *priv = get_priv_by_host(host);
 	unsigned long flags;
 
 	priv->qabort = 2;
 
-	spin_lock_irqsave(cmd->device->host->host_lock, flags);
+	spin_lock_irqsave(host->host_lock, flags);
 	ql_zap(priv);
-	spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
+	spin_unlock_irqrestore(host->host_lock, flags);
 
 	return SUCCESS;
 }
diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
index a971db11d293..c1b6e9fea9ce 100644
--- a/drivers/scsi/qlogicfas408.h
+++ b/drivers/scsi/qlogicfas408.h
@@ -109,7 +109,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk,
 			   struct block_device *dev,
 			   sector_t capacity, int ip[]);
 int qlogicfas408_abort(struct scsi_cmnd * cmd);
-extern int qlogicfas408_host_reset(struct scsi_cmnd *cmd);
+extern int qlogicfas408_host_reset(struct Scsi_Host *host);
 const char *qlogicfas408_info(struct Scsi_Host *host);
 int qlogicfas408_get_chip_type(int qbase, int int_type);
 void qlogicfas408_setup(int qbase, int id, int int_type);
diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
index 57f2f4135a06..bd3defa15933 100644
--- a/drivers/scsi/qlogicpti.c
+++ b/drivers/scsi/qlogicpti.c
@@ -1260,10 +1260,9 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
 	return return_status;
 }
 
-static int qlogicpti_reset(struct scsi_cmnd *Cmnd)
+static int qlogicpti_reset(struct Scsi_Host *host)
 {
 	u_short param[6];
-	struct Scsi_Host *host = Cmnd->device->host;
 	struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
 	int return_status = SUCCESS;
 
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 592a290e6cfa..6292ac7aef7a 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5357,15 +5357,15 @@ static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
 	return SUCCESS;
 }
 
-static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_host_reset(struct Scsi_Host *shost)
 {
 	struct sdebug_host_info *sdbg_host;
 	struct sdebug_dev_info *devip;
 	int k = 0;
 
 	++num_host_resets;
-	if ((SCpnt->device) && (SDEBUG_OPT_ALL_NOISE & sdebug_opts))
-		sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__);
+	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
+		shost_printk(KERN_INFO, shost, "%s\n", __func__);
 	spin_lock(&sdebug_host_list_lock);
 	list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
 		list_for_each_entry(devip, &sdbg_host->dev_info_list,
@@ -5377,7 +5377,7 @@ static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt)
 	spin_unlock(&sdebug_host_list_lock);
 	stop_all_queued();
 	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, SCpnt->device,
+		shost_printk(KERN_INFO, shost,
 			    "%s: %d device(s) found\n", __func__, k);
 	return SUCCESS;
 }
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index cdaca13ac1f1..747131ca8970 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -841,7 +841,7 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
 	if (!hostt->eh_host_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_host_reset_handler(scmd);
+	rtn = hostt->eh_host_reset_handler(host);
 
 	if (rtn == SUCCESS) {
 		if (!hostt->skip_settle_delay)
diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h
index e40492d36031..79916e803b26 100644
--- a/drivers/scsi/snic/snic.h
+++ b/drivers/scsi/snic/snic.h
@@ -380,8 +380,7 @@ extern const struct attribute_group *snic_host_groups[];
 int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int snic_abort_cmd(struct scsi_cmnd *);
 int snic_device_reset(struct scsi_cmnd *);
-int snic_host_reset(struct scsi_cmnd *);
-int snic_reset(struct Scsi_Host *);
+int snic_host_reset(struct Scsi_Host *);
 void snic_shutdown_scsi_cleanup(struct snic *);
 
 
diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c
index 635656ccf30a..3722383fb529 100644
--- a/drivers/scsi/snic/snic_scsi.c
+++ b/drivers/scsi/snic/snic_scsi.c
@@ -2295,8 +2295,15 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc)
 	return ret;
 } /* end of snic_issue_hba_reset */
 
+/*
+ * SCSI Error handling calls driver's eh_host_reset if all prior
+ * error handling levels return FAILED.
+ *
+ * Host Reset is the highest level of error recovery. If this fails, then
+ * host is offlined by SCSI.
+ */
 int
-snic_reset(struct Scsi_Host *shost)
+snic_host_reset(struct Scsi_Host *shost)
 {
 	struct snic *snic = shost_priv(shost);
 	struct scsi_cmnd *sc = NULL;
@@ -2360,34 +2367,6 @@ snic_reset(struct Scsi_Host *shost)
 		 (ulong) sc, jiffies_to_msecs(jiffies - start_time),
 		 0, 0, 0);
 
-	return ret;
-} /* end of snic_reset */
-
-/*
- * SCSI Error handling calls driver's eh_host_reset if all prior
- * error handling levels return FAILED.
- *
- * Host Reset is the highest level of error recovery. If this fails, then
- * host is offlined by SCSI.
- */
-int
-snic_host_reset(struct scsi_cmnd *sc)
-{
-	struct Scsi_Host *shost = sc->device->host;
-	u32 start_time  = jiffies;
-	int ret;
-
-	SNIC_SCSI_DBG(shost,
-		      "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n",
-		      sc, sc->cmnd[0], scsi_cmd_to_rq(sc),
-		      snic_cmd_tag(sc), CMD_FLAGS(sc));
-
-	ret = snic_reset(shost);
-
-	SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc,
-		 jiffies_to_msecs(jiffies - start_time),
-		 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
-
 	return ret;
 } /* end of snic_host_reset */
 
diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
index e6420f2127ce..d6f7e3f541e2 100644
--- a/drivers/scsi/stex.c
+++ b/drivers/scsi/stex.c
@@ -1433,14 +1433,13 @@ static int stex_do_reset(struct st_hba *hba)
 	return -1;
 }
 
-static int stex_reset(struct scsi_cmnd *cmd)
+static int stex_reset(struct Scsi_Host *shost)
 {
 	struct st_hba *hba;
 
-	hba = (struct st_hba *) &cmd->device->host->hostdata[0];
+	hba = (struct st_hba *) &shost->hostdata[0];
 
-	shost_printk(KERN_INFO, cmd->device->host,
-		     "resetting host\n");
+	shost_printk(KERN_INFO, shost, "resetting host\n");
 
 	return stex_do_reset(hba) ? FAILED : SUCCESS;
 }
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 9a0bba5a51a7..70bc095c6e78 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -1659,9 +1659,9 @@ static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
 	return 0;
 }
 
-static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
+static int storvsc_host_reset_handler(struct Scsi_Host *shost)
 {
-	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
+	struct hv_host_device *host_dev = shost_priv(shost);
 	struct hv_device *device = host_dev->dev;
 
 	struct storvsc_device *stor_device;
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index cb8885eb5a5b..a573baa5bdf2 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -693,9 +693,8 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 	return SCSI_SUCCESS;
 }
 
-static int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd)
+static int sym53c8xx_eh_host_reset_handler(struct Scsi_Host *shost)
 {
-	struct Scsi_Host *shost = cmd->device->host;
 	struct sym_data *sym_data = shost_priv(shost);
 	struct pci_dev *pdev = sym_data->pdev;
 	struct sym_hcb *np = sym_data->ncb;
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3f9caafa91bf..d1f065d4bcce 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -229,7 +229,7 @@ static struct ufs_dev_fix ufs_fixups[] = {
 static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);
 static void ufshcd_async_scan(void *data, async_cookie_t cookie);
 static int ufshcd_reset_and_restore(struct ufs_hba *hba);
-static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
+static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost);
 static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
 static void ufshcd_hba_exit(struct ufs_hba *hba);
 static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params);
@@ -7311,13 +7311,13 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)
  *
  * Returns SUCCESS/FAILED
  */
-static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
+static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost)
 {
 	int err = SUCCESS;
 	unsigned long flags;
 	struct ufs_hba *hba;
 
-	hba = shost_priv(cmd->device->host);
+	hba = shost_priv(shost);
 
 	spin_lock_irqsave(hba->host->host_lock, flags);
 	hba->force_reset = true;
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index f88ecdb93a8a..ddf1837babc0 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -894,14 +894,13 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter)
 	}
 }
 
-static int pvscsi_host_reset(struct scsi_cmnd *cmd)
+static int pvscsi_host_reset(struct Scsi_Host *host)
 {
-	struct Scsi_Host *host = cmd->device->host;
 	struct pvscsi_adapter *adapter = shost_priv(host);
 	unsigned long flags;
 	bool use_msg;
 
-	scmd_printk(KERN_INFO, cmd, "SCSI Host reset\n");
+	shost_printk(KERN_INFO, host, "SCSI Host reset\n");
 
 	spin_lock_irqsave(&adapter->hw_lock, flags);
 
diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
index 3fe562047d85..7cfe736ed6c2 100644
--- a/drivers/scsi/wd33c93.c
+++ b/drivers/scsi/wd33c93.c
@@ -1568,13 +1568,11 @@ reset_wd33c93(struct Scsi_Host *instance)
 }
 
 int
-wd33c93_host_reset(struct scsi_cmnd * SCpnt)
+wd33c93_host_reset(struct Scsi_Host * instance)
 {
-	struct Scsi_Host *instance;
 	struct WD33C93_hostdata *hostdata;
 	int i;
 
-	instance = SCpnt->device->host;
 	spin_lock_irq(instance->host_lock);
 	hostdata = (struct WD33C93_hostdata *) instance->hostdata;
 
@@ -1599,7 +1597,6 @@ wd33c93_host_reset(struct scsi_cmnd * SCpnt)
 	hostdata->outgoing_len = 0;
 
 	reset_wd33c93(instance);
-	SCpnt->result = DID_RESET << 16;
 	enable_irq(instance->irq);
 	spin_unlock_irq(instance->host_lock);
 	return SUCCESS;
diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h
index b3800baccd2c..87119e47836a 100644
--- a/drivers/scsi/wd33c93.h
+++ b/drivers/scsi/wd33c93.h
@@ -341,6 +341,6 @@ int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd);
 void wd33c93_intr (struct Scsi_Host *instance);
 int wd33c93_show_info(struct seq_file *, struct Scsi_Host *);
 int wd33c93_write_info(struct Scsi_Host *, char *, int);
-int wd33c93_host_reset (struct scsi_cmnd *);
+int wd33c93_host_reset (struct Scsi_Host *);
 
 #endif /* WD33C93_H */
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index ff1b22077251..02b8eb153944 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -520,9 +520,9 @@ static int wd719x_bus_reset(struct scsi_cmnd *cmd)
 	return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
 }
 
-static int wd719x_host_reset(struct scsi_cmnd *cmd)
+static int wd719x_host_reset(struct Scsi_Host *host)
 {
-	struct wd719x *wd = shost_priv(cmd->device->host);
+	struct wd719x *wd = shost_priv(host);
 	struct wd719x_scb *scb, *tmp;
 	unsigned long flags;
 
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 48aa18f8b984..0de0dd09cf9d 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -390,11 +390,11 @@ static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd)
 
 /*
  * visorhba_host_reset_handler - Not supported
- * @scsicmd: The scsicmd that needs to be aborted
+ * @shost: The scsi host that needs resetting
  *
  * Return: Not supported, return SUCCESS
  */
-static int visorhba_host_reset_handler(struct scsi_cmnd *scsicmd)
+static int visorhba_host_reset_handler(struct Scsi_Host *shost)
 {
 	/* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */
 	return SUCCESS;
diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
index 874ea4b54ced..8b560772c49a 100644
--- a/drivers/usb/image/microtek.c
+++ b/drivers/usb/image/microtek.c
@@ -345,9 +345,9 @@ static int mts_scsi_abort(struct scsi_cmnd *srb)
 	return FAILED;
 }
 
-static int mts_scsi_host_reset(struct scsi_cmnd *srb)
+static int mts_scsi_host_reset(struct Scsi_Host *shost)
 {
-	struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
+	struct mts_desc* desc = (struct mts_desc*)(shost->hostdata[0]);
 	int result;
 
 	MTS_DEBUG_GOT_HERE();
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 6e29e1719db1..31f60d2ad318 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -950,7 +950,7 @@ void fc_fcp_destroy(struct fc_lport *);
 int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int fc_eh_abort(struct scsi_cmnd *);
 int fc_eh_device_reset(struct scsi_cmnd *);
-int fc_eh_host_reset(struct scsi_cmnd *);
+int fc_eh_host_reset(struct Scsi_Host *);
 int fc_slave_alloc(struct scsi_device *);
 
 /*
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 667d889b92b5..3b8d9e65ea57 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -141,7 +141,7 @@ struct scsi_host_template {
 	int (* eh_device_reset_handler)(struct scsi_cmnd *);
 	int (* eh_target_reset_handler)(struct scsi_cmnd *);
 	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
-	int (* eh_host_reset_handler)(struct scsi_cmnd *);
+	int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 	/*
 	 * Before the mid layer attempts to scan for a new device where none
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-03 21:12   ` Lee Duncan
                     ` (2 more replies)
  2022-05-02 21:59 ` [PATCH 02/11] sym53c8xx_2: rework reset handling Hannes Reinecke
                   ` (15 subsequent siblings)
  18 siblings, 3 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

The bus reset should not depend on any command, but rather only
use the SCSI Host and the channel/bus number as argument.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 Documentation/scsi/scsi_eh.rst                |  2 +-
 Documentation/scsi/scsi_mid_low_api.rst       |  5 ++-
 drivers/message/fusion/mptfc.c                | 13 +++----
 drivers/message/fusion/mptscsih.c             | 21 ++++-------
 drivers/message/fusion/mptscsih.h             |  2 +-
 drivers/scsi/a100u2w.c                        |  4 +-
 drivers/scsi/aacraid/linit.c                  | 11 +++---
 drivers/scsi/aha152x.c                        |  4 +-
 drivers/scsi/aha1542.c                        |  4 +-
 drivers/scsi/aic7xxx/aic79xx_osm.c            | 10 ++---
 drivers/scsi/aic7xxx/aic7xxx_osm.c            |  6 +--
 drivers/scsi/arcmsr/arcmsr_hba.c              |  6 +--
 drivers/scsi/arm/fas216.c                     |  9 +++--
 drivers/scsi/arm/fas216.h                     |  5 ++-
 drivers/scsi/dc395x.c                         | 25 ++++++-------
 drivers/scsi/dpt_i2o.c                        |  9 +++--
 drivers/scsi/dpti.h                           |  2 +-
 drivers/scsi/esas2r/esas2r.h                  |  2 +-
 drivers/scsi/esas2r/esas2r_main.c             |  4 +-
 drivers/scsi/esp_scsi.c                       |  4 +-
 drivers/scsi/initio.c                         | 11 +++---
 drivers/scsi/mpi3mr/mpi3mr_os.c               | 37 +++++++++++--------
 drivers/scsi/ncr53c8xx.c                      |  4 +-
 drivers/scsi/pcmcia/nsp_cs.c                  |  6 +--
 drivers/scsi/pcmcia/nsp_cs.h                  |  2 +-
 drivers/scsi/pmcraid.c                        |  7 ++--
 drivers/scsi/qla1280.c                        | 12 +++---
 drivers/scsi/qla2xxx/qla_os.c                 | 17 +++------
 drivers/scsi/scsi_debug.c                     | 31 ++++++----------
 drivers/scsi/scsi_error.c                     |  2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c           |  7 ++--
 drivers/scsi/vmw_pvscsi.c                     |  5 +--
 drivers/scsi/wd719x.c                         | 11 +++---
 .../staging/unisys/visorhba/visorhba_main.c   |  7 ++--
 drivers/usb/storage/scsiglue.c                |  4 +-
 include/scsi/scsi_host.h                      |  2 +-
 36 files changed, 150 insertions(+), 163 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
index 12113cca5ad9..5e2d04e64005 100644
--- a/Documentation/scsi/scsi_eh.rst
+++ b/Documentation/scsi/scsi_eh.rst
@@ -214,7 +214,7 @@ considered to fail always.
 
     int (* eh_abort_handler)(struct scsi_cmnd *);
     int (* eh_device_reset_handler)(struct scsi_cmnd *);
-    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
+    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
     int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 Higher-severity actions are taken only when lower-severity actions
diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
index 784587ea7eee..1b1c37445580 100644
--- a/Documentation/scsi/scsi_mid_low_api.rst
+++ b/Documentation/scsi/scsi_mid_low_api.rst
@@ -741,7 +741,8 @@ Details::
 
     /**
     *      eh_bus_reset_handler - issue SCSI bus reset
-    *      @scp: SCSI bus that contains this device should be reset
+    *      @host: SCSI Host that contains the channel which should be reset
+    *      @channel: channel to be reset
     *
     *      Returns SUCCESS if command aborted else FAILED
     *
@@ -754,7 +755,7 @@ Details::
     *
     *      Optionally defined in: LLD
     **/
-	int eh_bus_reset_handler(struct scsi_cmnd * scp)
+	int eh_bus_reset_handler(struct Scsi_Host * host, int channel)
 
 
     /**
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 4a621380a4eb..bc62f0cc0cbd 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -103,7 +103,7 @@ static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
 static void mptfc_remove(struct pci_dev *pdev);
 static int mptfc_abort(struct scsi_cmnd *SCpnt);
 static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
-static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
+static int mptfc_bus_reset(struct Scsi_Host *shost, int channel);
 
 static struct scsi_host_template mptfc_driver_template = {
 	.module				= THIS_MODULE,
@@ -259,11 +259,9 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt)
 }
 
 static int
-mptfc_bus_reset(struct scsi_cmnd *SCpnt)
+mptfc_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = SCpnt->device->host;
 	MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost);
-	int channel = SCpnt->device->channel;
 	struct mptfc_rport_info *ri;
 	int rtn;
 
@@ -280,10 +278,9 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt)
 	}
 	if (rtn == 0) {
 		dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
-			"%s.%d: %d:%llu, executing recovery.\n", __func__,
-			hd->ioc->name, shost->host_no,
-			SCpnt->device->id, SCpnt->device->lun));
-		rtn = mptscsih_bus_reset(SCpnt);
+			"%s.%d: 0:0, executing recovery.\n", __func__,
+			hd->ioc->name, shost->host_no));
+		rtn = mptscsih_bus_reset(shost, channel);
 	}
 	return rtn;
 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index 3df07e024026..afdbc8138346 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1914,39 +1914,34 @@ mptscsih_target_reset(struct scsi_cmnd * SCpnt)
  *	Returns SUCCESS or FAILED.
  **/
 int
-mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
+mptscsih_bus_reset(struct Scsi_Host * shost, int channel)
 {
 	MPT_SCSI_HOST	*hd;
 	int		 retval;
-	VirtDevice	 *vdevice;
 	MPT_ADAPTER	*ioc;
 
 	/* If we can't locate our host adapter structure, return FAILED status.
 	 */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
+	if ((hd = shost_priv(shost)) == NULL){
 		printk(KERN_ERR MYNAM ": bus reset: "
-		   "Can't locate host! (sc=%p)\n", SCpnt);
+		   "Can't locate host!\n");
 		return FAILED;
 	}
 
 	ioc = hd->ioc;
-	printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n",
-	       ioc->name, SCpnt);
-	scsi_print_command(SCpnt);
+	printk(MYIOC_s_INFO_FMT "attempting bus reset!\n",
+	       ioc->name);
 
 	if (ioc->timeouts < -1)
 		ioc->timeouts++;
 
-	vdevice = SCpnt->device->hostdata;
-	if (!vdevice || !vdevice->vtarget)
-		return SUCCESS;
 	retval = mptscsih_IssueTaskMgmt(hd,
 					MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
-					vdevice->vtarget->channel, 0, 0, 0,
+					channel, 0, 0, 0,
 					mptscsih_get_tm_timeout(ioc));
 
-	printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
-	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+	printk(MYIOC_s_INFO_FMT "bus reset: %s\n",
+	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
 
 	if (retval == 0)
 		return SUCCESS;
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 0faefe9c7541..9f3756bd25eb 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
 extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
-extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
+extern int mptscsih_bus_reset(struct Scsi_Host *, int);
 extern int mptscsih_host_reset(struct Scsi_Host *sh);
 extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
 extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index bf552c818958..dab79824e2f6 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -934,10 +934,10 @@ static int inia100_abort(struct scsi_cmnd * cmd)
  Output         : None.
  Return         : pSRB  -       Pointer to SCSI request block.
 *****************************************************************************/
-static int inia100_bus_reset(struct scsi_cmnd * cmd)
+static int inia100_bus_reset(struct Scsi_Host * shost, int channel)
 {				/* I need Host Control Block Information */
 	struct orc_host *host;
-	host = (struct orc_host *) cmd->device->host->hostdata;
+	host = (struct orc_host *) shost->hostdata;
 	return orc_reset_scsi_bus(host);
 }
 
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 19a012c9a3c9..de7e0985ac2b 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1025,20 +1025,18 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
 
 /*
  *	aac_eh_bus_reset	- Bus reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
+ *	@host:	SCSI host causing the reset
+ *	@channel:	Number of the bus to be reset
  *
  */
-static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
+static int aac_eh_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct scsi_device * dev = cmd->device;
-	struct Scsi_Host * host = dev->host;
 	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
 	int count;
 	u32 cmd_bus;
 	int status = 0;
 
-
-	cmd_bus = aac_logical_to_phys(scmd_channel(cmd));
+	cmd_bus = aac_logical_to_phys(channel);
 	/* Mark the assoc. FIB to not complete, eh handler does this */
 	for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
 		struct fib *fib = &aac->fibs[count];
@@ -1046,6 +1044,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
 		if (fib->hw_fib_va->header.XferState &&
 		    (fib->flags & FIB_CONTEXT_FLAG) &&
 		    (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) {
+			struct scsi_cmnd *cmd;
 			struct aac_hba_map_info *info;
 			u32 bus, cid;
 
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 7e58f25c599b..1312dc5ef6d2 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1192,9 +1192,9 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
  * Reset the bus
  *
  */
-static int aha152x_bus_reset(struct scsi_cmnd *SCpnt)
+static int aha152x_bus_reset(struct Scsi_Host *shpnt, int channel)
 {
-	return aha152x_bus_reset_host(SCpnt->device->host);
+	return aha152x_bus_reset_host(shpnt);
 }
 
 /*
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 69063fe4aab8..797a49f927dd 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -980,9 +980,9 @@ static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
 	return SUCCESS;
 }
 
-static int aha1542_bus_reset(struct scsi_cmnd *cmd)
+static int aha1542_bus_reset(struct Scsi_Host *sh, int channel)
 {
-	return aha1542_reset(cmd->device->host, SCRST);
+	return aha1542_reset(sh, SCRST);
 }
 
 static int aha1542_host_reset(struct Scsi_Host *sh)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index c46e8152af28..00786c37f39f 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -866,21 +866,21 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
  * Reset the SCSI bus.
  */
 static int
-ahd_linux_bus_reset(struct scsi_cmnd *cmd)
+ahd_linux_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct ahd_softc *ahd;
 	int    found;
 	unsigned long flags;
 
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	ahd = *(struct ahd_softc **)shost->hostdata;
 #ifdef AHD_DEBUG
 	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-		printk("%s: Bus reset called for cmd %p\n",
-		       ahd_name(ahd), cmd);
+		printk("%s: Bus reset called for channel %d\n",
+		       ahd_name(ahd), channel);
 #endif
 	ahd_lock(ahd, &flags);
 
-	found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
+	found = ahd_reset_channel(ahd, channel + 'A',
 				  /*initiate reset*/TRUE);
 	ahd_unlock(ahd, &flags);
 
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 0ad429b7ebcf..f6c547cef26c 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -753,16 +753,16 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
  * Reset the SCSI bus.
  */
 static int
-ahc_linux_bus_reset(struct scsi_cmnd *cmd)
+ahc_linux_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct ahc_softc *ahc;
 	int    found;
 	unsigned long flags;
 
-	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
+	ahc = *(struct ahc_softc **)shost->hostdata;
 
 	ahc_lock(ahc, &flags);
-	found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
+	found = ahc_reset_channel(ahc, channel + 'A',
 				  /*initiate reset*/TRUE);
 	ahc_unlock(ahc, &flags);
 
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index d3fb8a9c1c39..baa03ead75d9 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -111,7 +111,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
 					struct scsi_cmnd *cmd);
 static int arcmsr_iop_confirm(struct AdapterControlBlock *acb);
 static int arcmsr_abort(struct scsi_cmnd *);
-static int arcmsr_bus_reset(struct scsi_cmnd *);
+static int arcmsr_bus_reset(struct Scsi_Host *, int);
 static int arcmsr_bios_param(struct scsi_device *sdev,
 		struct block_device *bdev, sector_t capacity, int *info);
 static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
@@ -4573,12 +4573,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
 	return rtnval;
 }
 
-static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
+static int arcmsr_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct AdapterControlBlock *acb;
 	int retry_count = 0;
 	int rtn = FAILED;
-	acb = (struct AdapterControlBlock *) cmd->device->host->hostdata;
+	acb = (struct AdapterControlBlock *) shost->hostdata;
 	if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
 		return SUCCESS;
 	pr_notice("arcmsr: executing bus reset eh.....num_resets = %d,"
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 38eec967155d..c27b49c42c4f 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2550,15 +2550,16 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 
 /**
  * fas216_eh_bus_reset - Reset the bus associated with the command
- * @SCpnt: command specifing bus to reset
+ * @shost: host to be reset
+ * @channel: bus number to reset
  *
- * Reset the bus associated with the command.
+ * Reset the bus.
  * Returns: FAILED if unable to reset.
  * Notes: Further commands are blocked.
  */
-int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
+int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+	FAS216_Info *info = (FAS216_Info *)shost->hostdata;
 	unsigned long flags;
 	struct scsi_device *SDpnt;
 
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index f17583f143b3..27a4b564f054 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -389,10 +389,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
 
 /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
  * Purpose : Reset the complete bus associated with this command
- * Params  : SCpnt - command specifing bus to reset
+ * Params  : shost - host to be reset
+ *           channel - bus to be reset
  * Returns : FAILED if unable to reset
  */
-extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
+extern int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel);
 
 /* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
  * Purpose : Reset the host associated with this command
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index 67a89715c863..7374eda8cffa 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -1144,19 +1144,18 @@ static void reset_dev_param(struct AdapterCtlBlk *acb)
  * @cmd - some command for this host (for fetching hooks)
  * Returns: SUCCESS (0x2002) on success, else FAILED (0x2003).
  */
-static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
+static int __dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct AdapterCtlBlk *acb =
-		(struct AdapterCtlBlk *)cmd->device->host->hostdata;
+		(struct AdapterCtlBlk *)shost->hostdata;
 	dprintkl(KERN_INFO,
-		"eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
-		cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
+		 "eh_bus_reset: bus=<%02i>\n", channel);
 
 	if (timer_pending(&acb->waiting_timer))
 		del_timer(&acb->waiting_timer);
 
 	/*
-	 * disable interrupt    
+	 * disable interrupt
 	 */
 	DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00);
 	DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00);
@@ -1172,7 +1171,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	    HZ * acb->eeprom.delay_time;
 
 	/*
-	 * re-enable interrupt      
+	 * re-enable interrupt
 	 */
 	/* Clear SCSI FIFO          */
 	DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
@@ -1182,7 +1181,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	set_basic_config(acb);
 
 	reset_dev_param(acb);
-	doing_srb_done(acb, DID_RESET, cmd, 0);
+	doing_srb_done(acb, DID_RESET, NULL, 0);
 	acb->active_dcb = NULL;
 	acb->acb_flag = 0;	/* RESET_DETECT, RESET_DONE ,RESET_DEV */
 	waiting_process_next(acb);
@@ -1190,13 +1189,13 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
+static int dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	int rc;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = __dc395x_eh_bus_reset(cmd);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	rc = __dc395x_eh_bus_reset(shost, channel);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
@@ -3338,7 +3337,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 
 /* abort all cmds in our queues */
 static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
-		struct scsi_cmnd *cmd, u8 force)
+			   struct scsi_cmnd *cmd, u8 force)
 {
 	struct DeviceCtlBlk *dcb;
 	dprintkl(KERN_INFO, "doing_srb_done: pids ");
@@ -3386,7 +3385,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
 			set_status_byte(p, SAM_STAT_GOOD);
 			pci_unmap_srb_sense(acb, srb);
 			pci_unmap_srb(acb, srb);
-			if (force) {
+			if (force && cmd) {
 				/* For new EH, we normally don't need to give commands back,
 				 * as they all complete or all time out */
 				scsi_done(cmd);
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index 6e3ad0e5b533..b1ab772aff0e 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -718,17 +718,18 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
 
 #define I2O_HBA_BUS_RESET 0x87
 // This version of bus reset is called by the eh_error handler
-static int adpt_bus_reset(struct scsi_cmnd* cmd)
+static int adpt_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	adpt_hba* pHba;
 	u32 msg[4];
 	u32 rcode;
 
-	pHba = (adpt_hba*)cmd->device->host->hostdata[0];
+	pHba = (adpt_hba*)shost->hostdata[0];
 	memset(msg, 0, sizeof(msg));
-	printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid );
+	printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",
+	       pHba->name, channel, pHba->channel[channel].tid );
 	msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
-	msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
+	msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[channel].tid);
 	msg[2] = 0;
 	msg[3] = 0;
 	if (pHba->host)
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index b77a3625fa6f..48878e69ab2c 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -35,7 +35,7 @@ static const char *adpt_info(struct Scsi_Host *pSHost);
 static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
 		sector_t, int geom[]);
 
-static int adpt_bus_reset(struct scsi_cmnd* cmd);
+static int adpt_bus_reset(struct Scsi_Host* shost, int channel);
 static int adpt_device_reset(struct scsi_cmnd* cmd);
 
 
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index a104d1a3a9da..5c1eeaffc090 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -977,7 +977,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 int esas2r_eh_abort(struct scsi_cmnd *cmd);
 int esas2r_device_reset(struct scsi_cmnd *cmd);
 int esas2r_host_reset(struct Scsi_Host *shost);
-int esas2r_bus_reset(struct scsi_cmnd *cmd);
+int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
 int esas2r_target_reset(struct scsi_cmnd *cmd);
 
 /* Internal functions */
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 52494c8bb656..315b8a61d0d7 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1094,10 +1094,8 @@ int esas2r_host_reset(struct Scsi_Host *shost)
 	return esas2r_host_bus_reset(shost, true);
 }
 
-int esas2r_bus_reset(struct scsi_cmnd *cmd)
+int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = cmd->device->host;
-
 	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
 
 	return esas2r_host_bus_reset(shost, false);
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index b41eac8b5e0f..2fa53100df24 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2604,9 +2604,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
 	return FAILED;
 }
 
-static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
+static int esp_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
 {
-	struct esp *esp = shost_priv(cmd->device->host);
+	struct esp *esp = shost_priv(shost);
 	struct completion eh_reset;
 	unsigned long flags;
 
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index f585d6e5fab9..adddedfdbcc7 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2625,20 +2625,21 @@ static DEF_SCSI_QCMD(i91u_queuecommand)
 
 /**
  *	i91u_bus_reset		-	reset the SCSI bus
- *	@cmnd: Command block we want to trigger the reset for
+ *	@shost: SCSI host to be reset
+ *	@channel: Bus number to be reset
  *
  *	Initiate a SCSI bus reset sequence
  */
 
-static int i91u_bus_reset(struct scsi_cmnd * cmnd)
+static int i91u_bus_reset(struct Scsi_Host * shost, int channel)
 {
 	struct initio_host *host;
 
-	host = (struct initio_host *) cmnd->device->host->hostdata;
+	host = (struct initio_host *) shost->hostdata;
 
-	spin_lock_irq(cmnd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
 	initio_reset_scsi(host, 0);
-	spin_unlock_irq(cmnd->device->host->host_lock);
+	spin_unlock_irq(shost->host_lock);
 
 	return SUCCESS;
 }
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index bd42d3a56590..88fbd01c05d0 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -3362,39 +3362,46 @@ static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
 
 /**
  * mpi3mr_eh_bus_reset - Bus reset error handling callback
- * @scmd: SCSI command reference
+ * @shost: SCSI host reference
+ * @channel: bus number
  *
  * Checks whether pending I/Os are present for the RAID volume;
  * if not there's no need to reset the adapter.
  *
  * Return: SUCCESS of successful reset else FAILED
  */
-static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd)
+static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
+	struct mpi3mr_ioc *mrioc = shost_priv(shost);
+	struct mpi3mr_tgt_dev *tgtdev;
 	struct mpi3mr_stgt_priv_data *stgt_priv_data;
-	struct mpi3mr_sdev_priv_data *sdev_priv_data;
-	u8 dev_type = MPI3_DEVICE_DEVFORM_VD;
 	int retval = FAILED;
 
-	sdev_priv_data = scmd->device->hostdata;
-	if (sdev_priv_data && sdev_priv_data->tgt_priv_data) {
-		stgt_priv_data = sdev_priv_data->tgt_priv_data;
-		dev_type = stgt_priv_data->dev_type;
+	spin_lock(&mrioc->tgtdev_lock);
+	list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
+		if (!tgtdev->starget || !tgtdev->starget->hostdata)
+			continue;
+		stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
+			tgtdev->starget->hostdata;
+		if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_VD) {
+			retval = SUCCESS;
+			break;
+		}
 	}
+	spin_unlock(&mrioc->tgtdev_lock);
 
-	if (dev_type == MPI3_DEVICE_DEVFORM_VD) {
+	if (retval == SUCCESS) {
 		mpi3mr_wait_for_host_io(mrioc,
 			MPI3MR_RAID_ERRREC_RESET_TIMEOUT);
-		if (!mpi3mr_get_fw_pending_ios(mrioc))
-			retval = SUCCESS;
+		if (mpi3mr_get_fw_pending_ios(mrioc))
+			retval = FAILED;
 	}
 	if (retval == FAILED)
 		mpi3mr_print_pending_host_io(mrioc);
 
-	sdev_printk(KERN_INFO, scmd->device,
-		"Bus reset is %s for scmd(%p)\n",
-		((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	shost_printk(KERN_INFO, shost,
+		"Bus reset is %s\n",
+		((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
 	return retval;
 }
 
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 4458449c960b..2d4470686a4b 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -7936,9 +7936,9 @@ static void ncr53c8xx_timeout(struct timer_list *t)
 		ncr_flush_done_cmds(done_list);
 }
 
-static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
+static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
+	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
 	int sts;
 	unsigned long flags;
 	struct scsi_cmnd *done_list;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 4aa9737fa711..b1bce76c83b9 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1488,11 +1488,11 @@ static int nsp_bus_reset(nsp_hw_data *data)
 	return SUCCESS;
 }
 
-static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
+static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel)
 {
-	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
+	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
 
-	nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
+	nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel);
 
 	return nsp_bus_reset(data);
 }
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index f532adb5f166..8636f0053c02 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
 /* Error handler */
 /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
 /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
-static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
+static int nsp_eh_bus_reset    (struct Scsi_Host *host, int channel);
 static int nsp_eh_host_reset   (struct Scsi_Host *host);
 static int nsp_bus_reset       (nsp_hw_data *data);
 
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 79ca737ac75b..14e90807d38c 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3023,9 +3023,8 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
 				    RESET_DEVICE_LUN);
 }
 
-static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel)
 {
-	struct Scsi_Host *host = scmd->device->host;
 	struct pmcraid_instance *pinstance =
 		(struct pmcraid_instance *)host->hostdata;
 	struct pmcraid_resource_entry *res = NULL;
@@ -3039,11 +3038,11 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
 	 */
 	spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
 	list_for_each_entry(temp, &pinstance->used_res_q, queue) {
-		if (scmd->device->channel == PMCRAID_VSET_BUS_ID &&
+		if (channel == PMCRAID_VSET_BUS_ID &&
 		    RES_IS_VSET(temp->cfg_entry)) {
 			res = temp;
 			break;
-		} else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID &&
+		} else if (channel == PMCRAID_PHYS_BUS_ID &&
 			   RES_IS_GSCSI(temp->cfg_entry)) {
 			res = temp;
 			break;
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index cd4c7126c1c9..f32f00c7a390 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -979,13 +979,15 @@ qla1280_eh_device_reset(struct scsi_cmnd *cmd)
  *     Reset the specified bus.
  **************************************************************************/
 static int
-qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
+qla1280_eh_bus_reset(struct Scsi_Host *shost, int bus)
 {
-	int rc;
+	int rc = FAILED;
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = qla1280_error_action(cmd, BUS_RESET);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	if (qla1280_bus_reset(ha, bus) == 0)
+		rc = qla1280_wait_for_pending_commands(ha, 1, 0);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 5f86e7bd5a0e..11e7dc22b94d 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1537,7 +1537,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
 *    commands.
 *
 * Input:
-*    cmd = Linux SCSI command packet of the command that cause the
+*    host = Linux SCSI command packet of the command that cause the
 *          bus reset.
 *
 * Returns:
@@ -1545,12 +1545,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
 *
 **************************************************************************/
 static int
-qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
+	scsi_qla_host_t *vha = shost_priv(shost);
 	int ret = FAILED;
-	unsigned int id;
-	uint64_t lun;
 	struct qla_hw_data *ha = vha->hw;
 
 	if (qla2x00_isp_reg_stat(ha)) {
@@ -1560,14 +1558,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 		return FAILED;
 	}
 
-	id = cmd->device->id;
-	lun = cmd->device->lun;
-
 	if (qla2x00_chip_is_down(vha))
 		return ret;
 
 	ql_log(ql_log_info, vha, 0x8012,
-	    "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
+	    "BUS RESET ISSUED nexus=%ld:%d.\n", vha->host_no, channel);
 
 	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 		ql_log(ql_log_fatal, vha, 0x8013,
@@ -1591,8 +1586,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 
 eh_bus_reset_done:
 	ql_log(ql_log_warn, vha, 0x802b,
-	    "BUS RESET %s nexus=%ld:%d:%llu.\n",
-	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
+	    "BUS RESET %s nexus=%ld:%d.\n",
+	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, channel);
 
 	return ret;
 }
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 6292ac7aef7a..f2d3271bc80b 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5324,36 +5324,27 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
 	return SUCCESS;
 }
 
-static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_bus_reset(struct Scsi_Host * hp, int channel)
 {
-	struct sdebug_host_info *sdbg_host;
+	struct sdebug_host_info *sdbg_host =
+		*(struct sdebug_host_info **)shost_priv(hp);
 	struct sdebug_dev_info *devip;
-	struct scsi_device *sdp;
-	struct Scsi_Host *hp;
 	int k = 0;
 
 	++num_bus_resets;
-	if (!(SCpnt && SCpnt->device))
-		goto lie;
-	sdp = SCpnt->device;
 	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
-	hp = sdp->host;
-	if (hp) {
-		sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
-		if (sdbg_host) {
-			list_for_each_entry(devip,
-					    &sdbg_host->dev_info_list,
-					    dev_list) {
-				set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
-				++k;
-			}
+		shost_printk(KERN_INFO, hp, "%s\n", __func__);
+	if (sdbg_host) {
+		list_for_each_entry(devip,
+				    &sdbg_host->dev_info_list,
+				    dev_list) {
+			set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
+			++k;
 		}
 	}
 	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp,
+		shost_printk(KERN_INFO, hp,
 			    "%s: %d device(s) found in host\n", __func__, k);
-lie:
 	return SUCCESS;
 }
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 747131ca8970..148cab3e61c0 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -871,7 +871,7 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
 	if (!hostt->eh_bus_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_bus_reset_handler(scmd);
+	rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
 
 	if (rtn == SUCCESS) {
 		if (!hostt->skip_settle_delay)
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index a573baa5bdf2..aef828731995 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -670,14 +670,13 @@ static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
 	return SCSI_SUCCESS;
 }
 
-static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
+static int sym53c8xx_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = cmd->device->host;
 	struct sym_data *sym_data = shost_priv(shost);
 	struct pci_dev *pdev = sym_data->pdev;
 	struct sym_hcb *np = sym_data->ncb;
 
-	scmd_printk(KERN_WARNING, cmd, "BUS RESET operation started\n");
+	shost_printk(KERN_WARNING, shost, "BUS RESET operation started\n");
 
 	/*
 	 * Escalate to host reset if the PCI bus went down
@@ -689,7 +688,7 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 	sym_reset_scsi_bus(np, 1);
 	spin_unlock_irq(shost->host_lock);
 
-	dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n");
+	shost_printk(KERN_WARNING, shost, "BUS RESET operation complete.\n");
 	return SCSI_SUCCESS;
 }
 
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index ddf1837babc0..9c62d446ea9e 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -947,13 +947,12 @@ static int pvscsi_host_reset(struct Scsi_Host *host)
 	return SUCCESS;
 }
 
-static int pvscsi_bus_reset(struct scsi_cmnd *cmd)
+static int pvscsi_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct Scsi_Host *host = cmd->device->host;
 	struct pvscsi_adapter *adapter = shost_priv(host);
 	unsigned long flags;
 
-	scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n");
+	shost_printk(KERN_INFO, host, "SCSI Bus reset\n");
 
 	/*
 	 * We don't want to queue new requests for this bus after
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index 02b8eb153944..fd297c7517cd 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -484,11 +484,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
+static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device)
 {
 	int result;
 	unsigned long flags;
-	struct wd719x *wd = shost_priv(cmd->device->host);
+	struct wd719x *wd = shost_priv(shost);
 	struct wd719x_scb *scb, *tmp;
 
 	dev_info(&wd->pdev->dev, "%s reset requested\n",
@@ -512,12 +512,13 @@ static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
 
 static int wd719x_dev_reset(struct scsi_cmnd *cmd)
 {
-	return wd719x_reset(cmd, WD719X_CMD_RESET, cmd->device->id);
+	return wd719x_reset(cmd->device->host, WD719X_CMD_RESET,
+			    cmd->device->id);
 }
 
-static int wd719x_bus_reset(struct scsi_cmnd *cmd)
+static int wd719x_bus_reset(struct Scsi_Host *host, int channel)
 {
-	return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
+	return wd719x_reset(host, WD719X_CMD_BUSRESET, 0);
 }
 
 static int wd719x_host_reset(struct Scsi_Host *host)
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 0de0dd09cf9d..28c59218077d 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -366,14 +366,15 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd)
  *
  * Return: SUCCESS if inserted, FAILED otherwise
  */
-static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd)
+static int visorhba_bus_reset_handler(struct Scsi_Host *scsihost, int channel)
 {
 	struct scsi_device *scsidev;
 	struct visordisk_info *vdisk;
 	int rtn;
 
-	scsidev = scsicmd->device;
-	shost_for_each_device(scsidev, scsidev->host) {
+	shost_for_each_device(scsidev, scsihost) {
+		if (scsidev->channel != channel)
+			continue;
 		vdisk = scsidev->hostdata;
 		if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT)
 			atomic_inc(&vdisk->error_count);
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 8931df5a85fd..17dabfba6b2b 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -464,9 +464,9 @@ static int device_reset(struct scsi_cmnd *srb)
 }
 
 /* Simulate a SCSI bus reset by resetting the device's USB port. */
-static int bus_reset(struct scsi_cmnd *srb)
+static int bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct us_data *us = host_to_us(srb->device->host);
+	struct us_data *us = host_to_us(shost);
 	int result;
 
 	usb_stor_dbg(us, "%s called\n", __func__);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 3b8d9e65ea57..73c9971e7334 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -140,7 +140,7 @@ struct scsi_host_template {
 	int (* eh_abort_handler)(struct scsi_cmnd *);
 	int (* eh_device_reset_handler)(struct scsi_cmnd *);
 	int (* eh_target_reset_handler)(struct scsi_cmnd *);
-	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
+	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
 	int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 	/*
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 02/11] sym53c8xx_2: rework reset handling
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (2 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Split off the combined abort and device reset handling into
distinct functions.
And the current device reset handler really is a target reset,
so rename it.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 82 +++++++++++++++++++----------
 1 file changed, 55 insertions(+), 27 deletions(-)

diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 9166af69bbb4..cb8885eb5a5b 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -564,7 +564,10 @@ static void sym53c8xx_timer(struct timer_list *t)
  *  Generic method for our eh processing.
  *  The 'op' argument tells what we have to do.
  */
-static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
+/*
+ * Error handlers called from the eh thread (one thread per HBA).
+ */
+static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
 {
 	struct sym_ucmd *ucmd = SYM_UCMD_PTR(cmd);
 	struct Scsi_Host *shost = cmd->device->host;
@@ -576,7 +579,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
 	int sts = -1;
 	struct completion eh_done;
 
-	scmd_printk(KERN_WARNING, cmd, "%s operation started\n", opname);
+	scmd_printk(KERN_WARNING, cmd, "ABORT operation started\n");
 
 	/*
 	 * Escalate to host reset if the PCI bus went down
@@ -594,19 +597,7 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
 		}
 	}
 
-	/* Try to proceed the operation we have been asked for */
-	sts = -1;
-	switch(op) {
-	case SYM_EH_ABORT:
-		sts = sym_abort_scsiio(np, cmd, 1);
-		break;
-	case SYM_EH_DEVICE_RESET:
-		sts = sym_reset_scsi_target(np, cmd->device->id);
-		break;
-	default:
-		break;
-	}
-
+	sts = sym_abort_scsiio(np, cmd, 1);
 	/* On error, restore everything and cross fingers :) */
 	if (sts)
 		cmd_queued = 0;
@@ -623,23 +614,60 @@ static int sym_eh_handler(int op, char *opname, struct scsi_cmnd *cmd)
 		spin_unlock_irq(shost->host_lock);
 	}
 
-	dev_warn(&cmd->device->sdev_gendev, "%s operation %s.\n", opname,
+	dev_warn(&cmd->device->sdev_gendev, "ABORT operation %s.\n",
 			sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed");
 	return sts ? SCSI_FAILED : SCSI_SUCCESS;
 }
 
-
-/*
- * Error handlers called from the eh thread (one thread per HBA).
- */
-static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
+static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
 {
-	return sym_eh_handler(SYM_EH_ABORT, "ABORT", cmd);
-}
+	struct scsi_target *starget = scsi_target(cmd->device);
+	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
+	struct sym_data *sym_data = shost_priv(shost);
+	struct pci_dev *pdev = sym_data->pdev;
+	struct sym_hcb *np = sym_data->ncb;
+	SYM_QUEHEAD *qp;
+	int sts;
+	struct completion eh_done;
 
-static int sym53c8xx_eh_device_reset_handler(struct scsi_cmnd *cmd)
-{
-	return sym_eh_handler(SYM_EH_DEVICE_RESET, "DEVICE RESET", cmd);
+	starget_printk(KERN_WARNING, starget,
+		       "TARGET RESET operation started\n");
+
+	/*
+	 * Escalate to host reset if the PCI bus went down
+	 */
+	if (pci_channel_offline(pdev))
+		return SCSI_FAILED;
+
+	spin_lock_irq(shost->host_lock);
+	sts = sym_reset_scsi_target(np, starget->id);
+	if (!sts) {
+		FOR_EACH_QUEUED_ELEMENT(&np->busy_ccbq, qp) {
+			struct sym_ccb *cp = sym_que_entry(qp, struct sym_ccb,
+							   link_ccbq);
+			struct scsi_cmnd *cmd = cp->cmd;
+			struct sym_ucmd *ucmd;
+
+			if (!cmd || cmd->device->channel != starget->channel ||
+			    cmd->device->id != starget->id)
+				continue;
+
+			ucmd = SYM_UCMD_PTR(cmd);
+			init_completion(&eh_done);
+			ucmd->eh_done = &eh_done;
+			spin_unlock_irq(shost->host_lock);
+			if (!wait_for_completion_timeout(&eh_done, 5*HZ)) {
+				ucmd->eh_done = NULL;
+				sts = -2;
+			}
+			spin_lock_irq(shost->host_lock);
+		}
+	}
+	spin_unlock_irq(shost->host_lock);
+
+	starget_printk(KERN_WARNING, starget, "TARGET RESET operation %s.\n",
+			sts==0 ? "complete" :sts==-2 ? "timed-out" : "failed");
+	return SCSI_SUCCESS;
 }
 
 static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
@@ -1660,7 +1688,7 @@ static struct scsi_host_template sym2_template = {
 	.slave_configure	= sym53c8xx_slave_configure,
 	.slave_destroy		= sym53c8xx_slave_destroy,
 	.eh_abort_handler	= sym53c8xx_eh_abort_handler,
-	.eh_device_reset_handler = sym53c8xx_eh_device_reset_handler,
+	.eh_target_reset_handler = sym53c8xx_eh_target_reset_handler,
 	.eh_bus_reset_handler	= sym53c8xx_eh_bus_reset_handler,
 	.eh_host_reset_handler	= sym53c8xx_eh_host_reset_handler,
 	.this_id		= 7,
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (3 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 02/11] sym53c8xx_2: rework reset handling Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-03 20:04   ` michael.christie
  2022-05-02 21:59 ` [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
                   ` (13 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

iscsi_eh_target_reset() and iscsi_eh_session_reset() only depend
on the cls_session, so use that as an argument.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/be2iscsi/be_main.c | 10 +++++++++-
 drivers/scsi/libiscsi.c         | 21 +++++++++------------
 include/scsi/libiscsi.h         |  2 +-
 3 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 3bb0adefbe06..55addd7f5c81 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -370,6 +370,14 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 	return rc;
 }
 
+static int beiscsi_eh_session_reset(struct scsi_cmnd *sc)
+{
+	struct iscsi_cls_session *cls_session;
+
+	cls_session = starget_to_session(scsi_target(sc->device));
+	return iscsi_eh_session_reset(cls_session);
+}
+
 /*------------------- PCI Driver operations and data ----------------- */
 static const struct pci_device_id beiscsi_pci_id_table[] = {
 	{ PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) },
@@ -393,7 +401,7 @@ static struct scsi_host_template beiscsi_sht = {
 	.eh_timed_out = iscsi_eh_cmd_timed_out,
 	.eh_abort_handler = beiscsi_eh_abort,
 	.eh_device_reset_handler = beiscsi_eh_device_reset,
-	.eh_target_reset_handler = iscsi_eh_session_reset,
+	.eh_target_reset_handler = beiscsi_eh_session_reset,
 	.shost_groups = beiscsi_groups,
 	.sg_tablesize = BEISCSI_SGLIST_ELEMENTS,
 	.can_queue = BE2_IO_DEPTH,
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 797abf4f5399..30f7737928bb 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2494,13 +2494,11 @@ EXPORT_SYMBOL_GPL(iscsi_session_recovery_timedout);
  * This function will wait for a relogin, session termination from
  * userspace, or a recovery/replacement timeout.
  */
-int iscsi_eh_session_reset(struct scsi_cmnd *sc)
+int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session)
 {
-	struct iscsi_cls_session *cls_session;
 	struct iscsi_session *session;
 	struct iscsi_conn *conn;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
 	session = cls_session->dd_data;
 
 	mutex_lock(&session->eh_mutex);
@@ -2547,7 +2545,7 @@ int iscsi_eh_session_reset(struct scsi_cmnd *sc)
 }
 EXPORT_SYMBOL_GPL(iscsi_eh_session_reset);
 
-static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
+static void iscsi_prep_tgt_reset_pdu(struct iscsi_tm *hdr)
 {
 	memset(hdr, 0, sizeof(*hdr));
 	hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
@@ -2562,19 +2560,16 @@ static void iscsi_prep_tgt_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
  *
  * This will attempt to send a warm target reset.
  */
-static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
+static int iscsi_eh_target_reset(struct iscsi_cls_session *cls_session)
 {
-	struct iscsi_cls_session *cls_session;
 	struct iscsi_session *session;
 	struct iscsi_conn *conn;
 	struct iscsi_tm *hdr;
 	int rc = FAILED;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
 	session = cls_session->dd_data;
 
-	ISCSI_DBG_EH(session, "tgt Reset [sc %p tgt %s]\n", sc,
-		     session->targetname);
+	ISCSI_DBG_EH(session, "tgt Reset [tgt %s]\n", session->targetname);
 
 	mutex_lock(&session->eh_mutex);
 	spin_lock_bh(&session->frwd_lock);
@@ -2592,7 +2587,7 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
 	session->tmf_state = TMF_QUEUED;
 
 	hdr = &session->tmhdr;
-	iscsi_prep_tgt_reset_pdu(sc, hdr);
+	iscsi_prep_tgt_reset_pdu(hdr);
 
 	if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
 				    session->tgt_reset_timeout)) {
@@ -2644,11 +2639,13 @@ static int iscsi_eh_target_reset(struct scsi_cmnd *sc)
  */
 int iscsi_eh_recover_target(struct scsi_cmnd *sc)
 {
+	struct iscsi_cls_session *cls_session;
 	int rc;
 
-	rc = iscsi_eh_target_reset(sc);
+	cls_session = starget_to_session(scsi_target(sc->device));
+	rc = iscsi_eh_target_reset(cls_session);
 	if (rc == FAILED)
-		rc = iscsi_eh_session_reset(sc);
+		rc = iscsi_eh_session_reset(cls_session);
 	return rc;
 }
 EXPORT_SYMBOL_GPL(iscsi_eh_recover_target);
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index d0a24779c52d..ce8d5b5dc0d3 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -391,7 +391,7 @@ struct iscsi_host {
  */
 extern int iscsi_eh_abort(struct scsi_cmnd *sc);
 extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
-extern int iscsi_eh_session_reset(struct scsi_cmnd *sc);
+extern int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session);
 extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
 extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
 extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (4 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-06 10:18   ` Steffen Maier
  2022-05-02 21:59 ` [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
                   ` (12 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke, James Smart

The target reset function should only depend on the scsi target,
not the scsi command.

Signed-off-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
---
 Documentation/scsi/scsi_eh.rst              | 10 ++++
 Documentation/scsi/scsi_mid_low_api.rst     | 18 +++++++
 drivers/message/fusion/mptsas.c             | 10 +++-
 drivers/message/fusion/mptscsih.c           | 27 ++++------
 drivers/message/fusion/mptscsih.h           |  2 +-
 drivers/message/fusion/mptspi.c             |  8 ++-
 drivers/s390/scsi/zfcp_scsi.c               |  7 ++-
 drivers/scsi/aacraid/linit.c                |  9 ++--
 drivers/scsi/be2iscsi/be_main.c             |  4 +-
 drivers/scsi/bfa/bfad_im.c                  |  5 +-
 drivers/scsi/bnx2fc/bnx2fc.h                |  2 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c             |  4 +-
 drivers/scsi/esas2r/esas2r.h                |  2 +-
 drivers/scsi/esas2r/esas2r_main.c           | 38 +++++++-------
 drivers/scsi/ibmvscsi/ibmvfc.c              |  3 +-
 drivers/scsi/libiscsi.c                     |  4 +-
 drivers/scsi/libsas/sas_scsi_host.c         |  9 ++--
 drivers/scsi/lpfc/lpfc_scsi.c               | 10 ++--
 drivers/scsi/megaraid/megaraid_sas.h        |  3 +-
 drivers/scsi/megaraid/megaraid_sas_base.c   | 10 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 56 +++++++++++++--------
 drivers/scsi/mpi3mr/mpi3mr_os.c             | 40 ++++++---------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c        | 31 +++++-------
 drivers/scsi/pmcraid.c                      |  8 +--
 drivers/scsi/qedf/qedf_main.c               |  3 +-
 drivers/scsi/qla2xxx/qla_os.c               | 26 +++++-----
 drivers/scsi/qla4xxx/ql4_os.c               | 13 ++---
 drivers/scsi/scsi_debug.c                   | 21 +++-----
 drivers/scsi/scsi_error.c                   |  5 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c         |  3 +-
 drivers/target/loopback/tcm_loop.c          |  9 ++--
 include/scsi/libiscsi.h                     |  2 +-
 include/scsi/libsas.h                       |  2 +-
 include/scsi/scsi_host.h                    |  2 +-
 34 files changed, 216 insertions(+), 190 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
index 5e2d04e64005..cfa14ad55dda 100644
--- a/Documentation/scsi/scsi_eh.rst
+++ b/Documentation/scsi/scsi_eh.rst
@@ -214,6 +214,7 @@ considered to fail always.
 
     int (* eh_abort_handler)(struct scsi_cmnd *);
     int (* eh_device_reset_handler)(struct scsi_cmnd *);
+    int (* eh_target_reset_handler)(struct scsi_target *);
     int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
     int (* eh_host_reset_handler)(struct Scsi_Host *);
 
@@ -409,6 +410,15 @@ scmd->allowed.
 	    resetting clears all scmds on the sdev, there is no need
 	    to choose error-completed scmds.
 
+	2. If !list_empty(&eh_work_q), invoke scsi_eh_target_reset().
+
+	``scsi_eh_target_reset``
+
+	    hostt->eh_target_reset_handler() is invoked for each target
+	    with failed scmds.  If bus reset succeeds, all failed
+	    scmds on all ready or offline sdevs on the target are
+	    EH-finished.
+
 	3. If !list_empty(&eh_work_q), invoke scsi_eh_bus_reset()
 
 	``scsi_eh_bus_reset``
diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
index 1b1c37445580..0afc1b4f89af 100644
--- a/Documentation/scsi/scsi_mid_low_api.rst
+++ b/Documentation/scsi/scsi_mid_low_api.rst
@@ -758,6 +758,24 @@ Details::
 	int eh_bus_reset_handler(struct Scsi_Host * host, int channel)
 
 
+    /**
+    *      eh_target_reset_handler - issue SCSI target reset
+    *      @starget: identifies SCSI target to be reset
+    *
+    *      Returns SUCCESS if command aborted else FAILED
+    *
+    *      Locks: None held
+    *
+    *      Calling context: kernel thread
+    *
+    *      Notes: Invoked from scsi_eh thread. No other commands will be
+    *      queued on current host during eh.
+    *
+    *      Optionally defined in: LLD
+    **/
+	int eh_target_reset_handler(struct scsi_target * starget)
+
+
     /**
     *      eh_device_reset_handler - issue SCSI device reset
     *      @scp: identifies SCSI device to be reset
diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 34901bcd1ce8..52f73e29c2d8 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -1997,6 +1997,14 @@ static enum blk_eh_timer_return mptsas_eh_timed_out(struct scsi_cmnd *sc)
 }
 
 
+static int mptsas_eh_target_reset(struct scsi_target *starget)
+{
+	struct sas_rphy *rphy = dev_to_rphy(starget->dev.parent);
+	MPT_ADAPTER *ioc = rphy_to_ioc(rphy);
+
+	return mptscsih_target_reset(ioc->sh, starget);
+}
+
 static struct scsi_host_template mptsas_driver_template = {
 	.module				= THIS_MODULE,
 	.proc_name			= "mptsas",
@@ -2012,7 +2020,7 @@ static struct scsi_host_template mptsas_driver_template = {
 	.change_queue_depth 		= mptscsih_change_queue_depth,
 	.eh_timed_out			= mptsas_eh_timed_out,
 	.eh_abort_handler		= mptscsih_abort,
-	.eh_device_reset_handler	= mptscsih_dev_reset,
+	.eh_target_reset_handler	= mptsas_eh_target_reset,
 	.eh_host_reset_handler		= mptscsih_host_reset,
 	.bios_param			= mptscsih_bios_param,
 	.can_queue			= MPT_SAS_CAN_QUEUE,
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index afdbc8138346..af140dbd63d9 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1854,48 +1854,43 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
  *	Returns SUCCESS or FAILED.
  **/
 int
-mptscsih_target_reset(struct scsi_cmnd * SCpnt)
+mptscsih_target_reset(struct Scsi_Host *shost, struct scsi_target * starget)
 {
 	MPT_SCSI_HOST	*hd;
 	int		 retval;
-	VirtDevice	 *vdevice;
+	VirtTarget	 *vtarget;
 	MPT_ADAPTER	*ioc;
 
 	/* If we can't locate our host adapter structure, return FAILED status.
 	 */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
-		printk(KERN_ERR MYNAM ": target reset: "
-		   "Can't locate host! (sc=%p)\n", SCpnt);
+	if ((hd = shost_priv(shost)) == NULL){
+		printk(KERN_ERR MYNAM ": target reset: Can't locate host!\n");
 		return FAILED;
 	}
 
 	ioc = hd->ioc;
-	printk(MYIOC_s_INFO_FMT "attempting target reset! (sc=%p)\n",
-	       ioc->name, SCpnt);
-	scsi_print_command(SCpnt);
-
-	vdevice = SCpnt->device->hostdata;
-	if (!vdevice || !vdevice->vtarget) {
+	printk(MYIOC_s_INFO_FMT "attempting target reset!\n", ioc->name);
+	vtarget = starget->hostdata;
+	if (!vtarget) {
 		retval = 0;
 		goto out;
 	}
 
 	/* Target reset to hidden raid component is not supported
 	 */
-	if (vdevice->vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
+	if (vtarget->tflags & MPT_TARGET_FLAGS_RAID_COMPONENT) {
 		retval = FAILED;
 		goto out;
 	}
 
 	retval = mptscsih_IssueTaskMgmt(hd,
 				MPI_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
-				vdevice->vtarget->channel,
-				vdevice->vtarget->id, 0, 0,
+				vtarget->channel, vtarget->id, 0, 0,
 				mptscsih_get_tm_timeout(ioc));
 
  out:
-	printk (MYIOC_s_INFO_FMT "target reset: %s (sc=%p)\n",
-	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+	printk (MYIOC_s_INFO_FMT "target reset: %s\n",
+	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
 
 	if (retval == 0)
 		return SUCCESS;
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 9f3756bd25eb..c4eaf3554c7d 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -120,7 +120,7 @@ extern void mptscsih_slave_destroy(struct scsi_device *device);
 extern int mptscsih_slave_configure(struct scsi_device *device);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
-extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
+extern int mptscsih_target_reset(struct Scsi_Host *, struct scsi_target *);
 extern int mptscsih_bus_reset(struct Scsi_Host *, int);
 extern int mptscsih_host_reset(struct Scsi_Host *sh);
 extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 388675cc1765..12af128c2894 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -820,6 +820,12 @@ static void mptspi_slave_destroy(struct scsi_device *sdev)
 	mptscsih_slave_destroy(sdev);
 }
 
+static int mptspi_eh_target_reset(struct scsi_target *starget)
+{
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+	return mptscsih_target_reset(shost, starget);
+}
+
 static struct scsi_host_template mptspi_driver_template = {
 	.module				= THIS_MODULE,
 	.proc_name			= "mptspi",
@@ -834,7 +840,7 @@ static struct scsi_host_template mptspi_driver_template = {
 	.slave_destroy			= mptspi_slave_destroy,
 	.change_queue_depth 		= mptscsih_change_queue_depth,
 	.eh_abort_handler		= mptscsih_abort,
-	.eh_device_reset_handler	= mptscsih_dev_reset,
+	.eh_target_reset_handler	= mptspi_eh_target_reset,
 	.eh_bus_reset_handler		= mptscsih_bus_reset,
 	.eh_host_reset_handler		= mptscsih_host_reset,
 	.bios_param			= mptscsih_bios_param,
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 873ccc60e4d6..10bbe56189b3 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -340,9 +340,12 @@ static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
 	return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET);
 }
 
-static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
+/*
+ * Note: We need to select a LUN as the storage array doesn't
+ * necessarily supports LUN 0 and might refuse the target reset.
+ */
+static int zfcp_scsi_eh_target_reset_handler(struct scsi_target *starget)
 {
-	struct scsi_target *starget = scsi_target(scpnt->device);
 	struct fc_rport *rport = starget_to_rport(starget);
 	struct Scsi_Host *shost = rport_to_shost(rport);
 	struct scsi_device *sdev = NULL, *tmp_sdev;
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index de7e0985ac2b..a63e03203679 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -962,10 +962,9 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd)
  *	@scsi_cmd:	SCSI command block causing the reset
  *
  */
-static int aac_eh_target_reset(struct scsi_cmnd *cmd)
+static int aac_eh_target_reset(struct scsi_target *starget)
 {
-	struct scsi_device * dev = cmd->device;
-	struct Scsi_Host * host = dev->host;
+	struct Scsi_Host * host = dev_to_shost(&starget->dev);
 	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
 	struct aac_hba_map_info *info;
 	int count;
@@ -975,8 +974,8 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
 	int status;
 	u8 command;
 
-	bus = aac_logical_to_phys(scmd_channel(cmd));
-	cid = scmd_id(cmd);
+	bus = aac_logical_to_phys(starget->channel);
+	cid = starget->id;
 
 	if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS)
 		return FAILED;
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index 55addd7f5c81..f954c6f869fb 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -370,11 +370,11 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 	return rc;
 }
 
-static int beiscsi_eh_session_reset(struct scsi_cmnd *sc)
+static int beiscsi_eh_session_reset(struct scsi_target *starget)
 {
 	struct iscsi_cls_session *cls_session;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
+	cls_session = starget_to_session(starget);
 	return iscsi_eh_session_reset(cls_session);
 }
 
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index a446aa2d6b9a..272dedfee1a7 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -362,11 +362,10 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
  * Scsi_Host template entry, resets the target and abort all commands.
  */
 static int
-bfad_im_reset_target_handler(struct scsi_cmnd *cmnd)
+bfad_im_reset_target_handler(struct scsi_target *starget)
 {
-	struct Scsi_Host *shost = cmnd->device->host;
-	struct scsi_target *starget = scsi_target(cmnd->device);
 	struct fc_rport *rport = starget_to_rport(starget);
+	struct Scsi_Host *shost = rport_to_shost(rport);
 	struct bfad_im_port_s *im_port =
 				(struct bfad_im_port_s *) shost->hostdata[0];
 	struct bfad_s *bfad = im_port->bfad;
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index 7e74f77da14f..b3ed22d97572 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -551,7 +551,7 @@ void bnx2fc_init_task(struct bnx2fc_cmd *io_req,
 void bnx2fc_add_2_sq(struct bnx2fc_rport *tgt, u16 xid);
 void bnx2fc_ring_doorbell(struct bnx2fc_rport *tgt);
 int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd);
-int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd);
+int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt);
 int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd);
 void bnx2fc_rport_event_handler(struct fc_lport *lport,
 				struct fc_rport_priv *rport,
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 055d9424bc0d..0f5218eb9732 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1058,9 +1058,9 @@ int bnx2fc_initiate_cleanup(struct bnx2fc_cmd *io_req)
  * Set from SCSI host template to send task mgmt command to the target
  *	and wait for the response
  */
-int bnx2fc_eh_target_reset(struct scsi_cmnd *sc_cmd)
+int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt)
 {
-	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
+	struct fc_rport *rport = starget_to_rport(sc_tgt);
 	struct fc_lport *lport = shost_priv(rport_to_shost(rport));
 
 	return bnx2fc_initiate_tmf(lport, rport, 0, FCP_TMF_TGT_RESET);
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index 5c1eeaffc090..56d8ff63372a 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -978,7 +978,7 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd);
 int esas2r_device_reset(struct scsi_cmnd *cmd);
 int esas2r_host_reset(struct Scsi_Host *shost);
 int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
-int esas2r_target_reset(struct scsi_cmnd *cmd);
+int esas2r_target_reset(struct scsi_target *starget);
 
 /* Internal functions */
 int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 315b8a61d0d7..1ad39c1ae085 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1101,10 +1101,11 @@ int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
 	return esas2r_host_bus_reset(shost, false);
 }
 
-static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset)
+static int esas2r_dev_targ_reset(struct Scsi_Host *shost, int id, u64 lun,
+				 bool target_reset)
 {
 	struct esas2r_adapter *a =
-		(struct esas2r_adapter *)cmd->device->host->hostdata;
+		(struct esas2r_adapter *)shost->hostdata;
 	struct esas2r_request *rq;
 	u8 task_management_status = RS_PENDING;
 	bool completed;
@@ -1118,34 +1119,30 @@ static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset)
 		if (target_reset) {
 			esas2r_log(ESAS2R_LOG_CRIT,
 				   "unable to allocate a request for a "
-				   "target reset (%d)!",
-				   cmd->device->id);
+				   "target reset (%d)!", id);
 		} else {
 			esas2r_log(ESAS2R_LOG_CRIT,
 				   "unable to allocate a request for a "
-				   "device reset (%d:%llu)!",
-				   cmd->device->id,
-				   cmd->device->lun);
+				   "device reset (%d:%llu)!", id, lun);
 		}
 
 
 		return FAILED;
 	}
 
-	rq->target_id = cmd->device->id;
-	rq->vrq->scsi.flags |= cpu_to_le32(cmd->device->lun);
+	rq->target_id = id;
+	rq->vrq->scsi.flags |= cpu_to_le32(lun);
 	rq->req_stat = RS_PENDING;
 
 	rq->comp_cb = complete_task_management_request;
 	rq->task_management_status_ptr = &task_management_status;
 
 	if (target_reset) {
-		esas2r_debug("issuing target reset (%p) to id %d", rq,
-			     cmd->device->id);
+		esas2r_debug("issuing target reset (%p) to id %d", rq, id);
 		completed = esas2r_send_task_mgmt(a, rq, 0x20);
 	} else {
-		esas2r_debug("issuing device reset (%p) to id %d lun %d", rq,
-			     cmd->device->id, cmd->device->lun);
+		esas2r_debug("issuing device reset (%p) to id %d lun %llu", rq,
+			     id, lun);
 		completed = esas2r_send_task_mgmt(a, rq, 0x10);
 	}
 
@@ -1179,17 +1176,22 @@ static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset)
 
 int esas2r_device_reset(struct scsi_cmnd *cmd)
 {
-	esas2r_log(ESAS2R_LOG_INFO, "device_reset (%p)", cmd);
+	struct scsi_device *sdev = cmd->device;
+	struct Scsi_Host *shost = sdev->host;
+
+	esas2r_log(ESAS2R_LOG_INFO, "device_reset");
 
-	return esas2r_dev_targ_reset(cmd, false);
+	return esas2r_dev_targ_reset(shost, sdev->id, sdev->lun, false);
 
 }
 
-int esas2r_target_reset(struct scsi_cmnd *cmd)
+int esas2r_target_reset(struct scsi_target *starget)
 {
-	esas2r_log(ESAS2R_LOG_INFO, "target_reset (%p)", cmd);
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+
+	esas2r_log(ESAS2R_LOG_INFO, "target_reset");
 
-	return esas2r_dev_targ_reset(cmd, true);
+	return esas2r_dev_targ_reset(shost, starget->id, 0, true);
 }
 
 void esas2r_log_request_failure(struct esas2r_adapter *a,
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 5fb36cd70dde..9b9f6a0122e4 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -2934,9 +2934,8 @@ static void ibmvfc_dev_cancel_all_noreset(struct scsi_device *sdev, void *data)
  * Returns:
  *	SUCCESS / FAST_IO_FAIL / FAILED
  **/
-static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd)
+static int ibmvfc_eh_target_reset_handler(struct scsi_target *starget)
 {
-	struct scsi_target *starget = scsi_target(cmd->device);
 	struct fc_rport *rport = starget_to_rport(starget);
 	struct Scsi_Host *shost = rport_to_shost(rport);
 	struct ibmvfc_host *vhost = shost_priv(shost);
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index 30f7737928bb..ac3708b65938 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2637,12 +2637,12 @@ static int iscsi_eh_target_reset(struct iscsi_cls_session *cls_session)
  * This will attempt to send a warm target reset. If that fails,
  * we will escalate to ERL0 session recovery.
  */
-int iscsi_eh_recover_target(struct scsi_cmnd *sc)
+int iscsi_eh_recover_target(struct scsi_target *starget)
 {
 	struct iscsi_cls_session *cls_session;
 	int rc;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
+	cls_session = starget_to_session(starget);
 	rc = iscsi_eh_target_reset(cls_session);
 	if (rc == FAILED)
 		rc = iscsi_eh_session_reset(cls_session);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 9c82e5dc4fcc..ae7e093eff4b 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -514,11 +514,12 @@ int sas_eh_device_reset_handler(struct scsi_cmnd *cmd)
 }
 EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler);
 
-int sas_eh_target_reset_handler(struct scsi_cmnd *cmd)
+int sas_eh_target_reset_handler(struct scsi_target *starget)
 {
 	int res;
-	struct Scsi_Host *host = cmd->device->host;
-	struct domain_device *dev = cmd_to_domain_dev(cmd);
+	struct domain_device *dev = starget_to_domain_dev(starget);
+	struct sas_rphy *rphy = dev->rphy;
+	struct Scsi_Host *host = dev_to_shost(rphy->dev.parent);
 	struct sas_internal *i = to_sas_internal(host->transportt);
 
 	if (current != host->ehandler)
@@ -551,7 +552,7 @@ static int try_to_reset_cmd_device(struct scsi_cmnd *cmd)
 
 try_target_reset:
 	if (shost->hostt->eh_target_reset_handler)
-		return shost->hostt->eh_target_reset_handler(cmd);
+		return shost->hostt->eh_target_reset_handler(scsi_target(cmd->device));
 
 	return FAILED;
 }
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 0443846c9fad..834c3f31f327 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -6376,15 +6376,15 @@ lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
  *  0x2002 - Success
  **/
 static int
-lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
+lpfc_target_reset_handler(struct scsi_target *starget)
 {
-	struct Scsi_Host  *shost = cmnd->device->host;
-	struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
+	struct fc_rport *rport = starget_to_rport(starget);
+	struct Scsi_Host  *shost = rport_to_shost(rport);
 	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
 	struct lpfc_rport_data *rdata;
 	struct lpfc_nodelist *pnode;
-	unsigned tgt_id = cmnd->device->id;
-	uint64_t lun_id = cmnd->device->lun;
+	unsigned tgt_id = starget->id;
+	uint64_t lun_id = 0;
 	struct lpfc_scsi_event_header scsi_event;
 	int status;
 	u32 logit = LOG_FCP;
diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 4919ea54b827..85f5ebc6c69f 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2723,7 +2723,8 @@ void megasas_setup_jbod_map(struct megasas_instance *instance);
 void megasas_update_sdev_properties(struct scsi_device *sdev);
 int megasas_reset_fusion(struct Scsi_Host *shost, int reason);
 int megasas_task_abort_fusion(struct scsi_cmnd *scmd);
-int megasas_reset_target_fusion(struct scsi_cmnd *scmd);
+int megasas_reset_target_fusion(struct Scsi_Host *shost,
+				struct scsi_target *starget);
 u32 mega_mod64(u64 dividend, u32 divisor);
 int megasas_alloc_fusion_context(struct megasas_instance *instance);
 void megasas_free_fusion_context(struct megasas_instance *instance);
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 0222e234f108..79ab96aa3044 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -3111,17 +3111,19 @@ static int megasas_task_abort(struct scsi_cmnd *scmd)
  *                        (supported only for fusion adapters)
  * @scmd:                 SCSI command pointer
  */
-static int megasas_reset_target(struct scsi_cmnd *scmd)
+static int megasas_reset_target(struct scsi_target *starget)
 {
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
 	int ret;
 	struct megasas_instance *instance;
 
-	instance = (struct megasas_instance *)scmd->device->host->hostdata;
+	instance = (struct megasas_instance *)shost->hostdata;
 
 	if (instance->adapter_type != MFI_SERIES)
-		ret = megasas_reset_target_fusion(scmd);
+		ret = megasas_reset_target_fusion(shost, starget);
 	else {
-		sdev_printk(KERN_NOTICE, scmd->device, "TARGET RESET not supported\n");
+		starget_printk(KERN_NOTICE, starget,
+			       "TARGET RESET not supported\n");
 		ret = FAILED;
 	}
 
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 54fde2661952..427312b542cb 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -4801,21 +4801,25 @@ int megasas_task_abort_fusion(struct scsi_cmnd *scmd)
 
 /*
  * megasas_reset_target_fusion : target reset function for fusion adapters
- * scmd: SCSI command pointer
+ * shost: SCSI host pointer
+ * starget: SCSI target pointer
  *
  * Returns SUCCESS if all commands associated with target aborted else FAILED
  */
 
-int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
+int megasas_reset_target_fusion(struct Scsi_Host *shost,
+				struct scsi_target *starget)
 {
 
 	struct megasas_instance *instance;
+	struct scsi_device *sdev;
 	int ret = FAILED;
-	u16 devhandle;
-	struct MR_PRIV_DEVICE *mr_device_priv_data;
-	mr_device_priv_data = scmd->device->hostdata;
+	u16 devhandle = USHRT_MAX;
+	struct MR_PRIV_DEVICE *mr_device_priv_data = NULL;
 
-	instance = (struct megasas_instance *)scmd->device->host->hostdata;
+	instance = (struct megasas_instance *)shost->hostdata;
+	starget_printk(KERN_INFO, starget,
+		    "target reset called\n");
 
 	if (atomic_read(&instance->adprecovery) != MEGASAS_HBA_OPERATIONAL) {
 		dev_err(&instance->pdev->dev, "Controller is not OPERATIONAL,"
@@ -4824,44 +4828,52 @@ int megasas_reset_target_fusion(struct scsi_cmnd *scmd)
 		return ret;
 	}
 
+	shost_for_each_device(sdev, shost) {
+		if (!sdev->hostdata)
+			continue;
+		mr_device_priv_data = sdev->hostdata;
+		if (mr_device_priv_data->is_tm_capable) {
+			devhandle = megasas_get_tm_devhandle(sdev);
+			break;
+		}
+	}
+
 	if (!mr_device_priv_data) {
-		sdev_printk(KERN_INFO, scmd->device,
-			    "device been deleted! scmd: (0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
+		starget_printk(KERN_INFO, starget,
+			    "all devices have been deleted\n");
 		ret = SUCCESS;
 		goto out;
 	}
 
 	if (!mr_device_priv_data->is_tm_capable) {
+		ret = SUCCESS;
+		goto out;
+	} else if (!mr_device_priv_data->is_tm_capable) {
 		ret = FAILED;
 		goto out;
 	}
 
 	mutex_lock(&instance->reset_mutex);
-	devhandle = megasas_get_tm_devhandle(scmd->device);
-
-	if (devhandle == (u16)ULONG_MAX) {
-		ret = SUCCESS;
-		sdev_printk(KERN_INFO, scmd->device,
+	if (devhandle == USHRT_MAX) {
+		starget_printk(KERN_INFO, starget,
 			"target reset issued for invalid devhandle\n");
 		mutex_unlock(&instance->reset_mutex);
-		goto out;
+		return SUCCESS;
 	}
 
-	sdev_printk(KERN_INFO, scmd->device,
-		"attempting target reset! scmd(0x%p) tm_dev_handle: 0x%x\n",
-		scmd, devhandle);
+	starget_printk(KERN_INFO, starget,
+		"attempting target reset! tm_dev_handle: 0x%x\n",
+		devhandle);
 	mr_device_priv_data->tm_busy = true;
 	ret = megasas_issue_tm(instance, devhandle,
-			scmd->device->channel, scmd->device->id, 0,
+			starget->channel, starget->id, 0,
 			MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET,
 			mr_device_priv_data);
 	mr_device_priv_data->tm_busy = false;
 	mutex_unlock(&instance->reset_mutex);
-	scmd_printk(KERN_NOTICE, scmd, "target reset %s!!\n",
-		(ret == SUCCESS) ? "SUCCESS" : "FAILED");
-
 out:
+	starget_printk(KERN_NOTICE, starget, "target reset %s!!\n",
+		(ret == SUCCESS) ? "SUCCESS" : "FAILED");
 	return ret;
 }
 
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 88fbd01c05d0..2c4a2f31be76 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -3407,7 +3407,7 @@ static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
 
 /**
  * mpi3mr_eh_target_reset - Target reset error handling callback
- * @scmd: SCSI command reference
+ * @starget: SCSI target reference
  *
  * Issue Target reset Task Management and verify the scmd is
  * terminated successfully and return status accordingly.
@@ -3415,50 +3415,42 @@ static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
  * Return: SUCCESS of successful termination of the scmd else
  *         FAILED
  */
-static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd)
+static int mpi3mr_eh_target_reset(struct scsi_target *starget)
 {
-	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+	struct mpi3mr_ioc *mrioc = shost_priv(shost);
 	struct mpi3mr_stgt_priv_data *stgt_priv_data;
-	struct mpi3mr_sdev_priv_data *sdev_priv_data;
 	u16 dev_handle;
 	u8 resp_code = 0;
 	int retval = FAILED, ret = 0;
 
-	sdev_printk(KERN_INFO, scmd->device,
-	    "Attempting Target Reset! scmd(%p)\n", scmd);
-	scsi_print_command(scmd);
+	starget_printk(KERN_INFO, starget,
+	    "Attempting Target Reset!\n");
 
-	sdev_priv_data = scmd->device->hostdata;
-	if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {
-		sdev_printk(KERN_INFO, scmd->device,
-		    "SCSI device is not available\n");
-		retval = SUCCESS;
-		goto out;
-	}
-
-	stgt_priv_data = sdev_priv_data->tgt_priv_data;
+	stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
+		starget->hostdata;
 	dev_handle = stgt_priv_data->dev_handle;
 	if (stgt_priv_data->dev_removed) {
-		sdev_printk(KERN_INFO, scmd->device,
+		starget_printk(KERN_INFO, starget,
 		    "%s:target(handle = 0x%04x) is removed, target reset is not issued\n",
 		    mrioc->name, dev_handle);
 		retval = FAILED;
 		goto out;
 	}
-	sdev_printk(KERN_INFO, scmd->device,
+	starget_printk(KERN_INFO, starget,
 	    "Target Reset is issued to handle(0x%04x)\n",
 	    dev_handle);
 
 	ret = mpi3mr_issue_tm(mrioc,
 	    MPI3_SCSITASKMGMT_TASKTYPE_TARGET_RESET, dev_handle,
-	    sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS,
-	    MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
+	    /* lun */ 0, MPI3MR_HOSTTAG_BLK_TMS,
+	    MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL);
 
 	if (ret)
 		goto out;
 
 	if (stgt_priv_data->pend_count) {
-		sdev_printk(KERN_INFO, scmd->device,
+		starget_printk(KERN_INFO, starget,
 		    "%s: target has %d pending commands, target reset is failed\n",
 		    mrioc->name, stgt_priv_data->pend_count);
 		goto out;
@@ -3466,9 +3458,9 @@ static int mpi3mr_eh_target_reset(struct scsi_cmnd *scmd)
 
 	retval = SUCCESS;
 out:
-	sdev_printk(KERN_INFO, scmd->device,
-	    "%s: target reset is %s for scmd(%p)\n", mrioc->name,
-	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	starget_printk(KERN_INFO, starget,
+	    "%s: target reset is %s\n", mrioc->name,
+	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
 
 	return retval;
 }
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index ea9a8799f89a..4c84fd9774ab 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3447,47 +3447,40 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
  * Return: SUCCESS if command aborted else FAILED
  */
 static int
-scsih_target_reset(struct scsi_cmnd *scmd)
+scsih_target_reset(struct scsi_target *starget)
 {
-	struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
-	struct MPT3SAS_DEVICE *sas_device_priv_data;
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
+	struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
 	struct _sas_device *sas_device = NULL;
 	struct _pcie_device *pcie_device = NULL;
 	u16	handle;
 	u8	tr_method = 0;
 	u8	tr_timeout = 30;
 	int r;
-	struct scsi_target *starget = scmd->device->sdev_target;
 	struct MPT3SAS_TARGET *target_priv_data = starget->hostdata;
 
 	starget_printk(KERN_INFO, starget,
-	    "attempting target reset! scmd(0x%p)\n", scmd);
-	_scsih_tm_display_info(ioc, scmd);
+	    "attempting target reset!\n");
 
-	sas_device_priv_data = scmd->device->hostdata;
-	if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
-	    ioc->remove_host) {
+	if (!target_priv_data || ioc->remove_host) {
 		starget_printk(KERN_INFO, starget,
-		    "target been deleted! scmd(0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
-		scsi_done(scmd);
+		    "target been deleted!\n");
 		r = SUCCESS;
 		goto out;
 	}
 
 	/* for hidden raid components obtain the volume_handle */
 	handle = 0;
-	if (sas_device_priv_data->sas_target->flags &
+	if (target_priv_data->flags &
 	    MPT_TARGET_FLAGS_RAID_COMPONENT) {
 		sas_device = mpt3sas_get_sdev_from_target(ioc,
 				target_priv_data);
 		if (sas_device)
 			handle = sas_device->volume_handle;
 	} else
-		handle = sas_device_priv_data->sas_target->handle;
+		handle = target_priv_data->handle;
 
 	if (!handle) {
-		scmd->result = DID_RESET << 16;
 		r = FAILED;
 		goto out;
 	}
@@ -3500,16 +3493,16 @@ scsih_target_reset(struct scsi_cmnd *scmd)
 		tr_method = MPI26_SCSITASKMGMT_MSGFLAGS_PROTOCOL_LVL_RST_PCIE;
 	} else
 		tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
-	r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel,
-		scmd->device->id, 0,
+	r = mpt3sas_scsih_issue_locked_tm(ioc, handle, starget->channel,
+		starget->id, 0,
 		MPI2_SCSITASKMGMT_TASKTYPE_TARGET_RESET, 0, 0,
 	    tr_timeout, tr_method);
 	/* Check for busy commands after reset */
 	if (r == SUCCESS && atomic_read(&starget->target_busy))
 		r = FAILED;
  out:
-	starget_printk(KERN_INFO, starget, "target reset: %s scmd(0x%p)\n",
-	    ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	starget_printk(KERN_INFO, starget, "target reset: %s\n",
+	    ((r == SUCCESS) ? "SUCCESS" : "FAILED"));
 
 	if (sas_device)
 		sas_device_put(sas_device);
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 14e90807d38c..44ff1f7fbbc0 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3061,14 +3061,14 @@ static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel)
 				    RESET_DEVICE_BUS);
 }
 
-static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_target_reset_handler(struct scsi_target *starget)
 {
-	struct Scsi_Host *shost = scmd->device->host;
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
 	struct scsi_device *scsi_dev = NULL, *tmp;
 
 	shost_for_each_device(tmp, shost) {
-		if ((tmp->channel == scmd->device->channel) &&
-		    (tmp->id == scmd->device->id)) {
+		if ((tmp->channel == starget->channel) &&
+		    (tmp->id == starget->id)) {
 			scsi_dev = tmp;
 			break;
 		}
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index c12fb3465946..c90a2c449978 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -855,9 +855,8 @@ static int qedf_eh_abort(struct scsi_cmnd *sc_cmd)
 	return rc;
 }
 
-static int qedf_eh_target_reset(struct scsi_cmnd *sc_cmd)
+static int qedf_eh_target_reset(struct scsi_target *starget)
 {
-	struct scsi_target *starget = scsi_target(sc_cmd->device);
 	struct fc_rport *rport = starget_to_rport(starget);
 
 	QEDF_ERR(NULL, "TARGET RESET Issued...");
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 11e7dc22b94d..35cf2c3dbe01 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1463,10 +1463,9 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
 }
 
 static int
-qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_target_reset(struct scsi_target *starget)
 {
-	struct scsi_device *sdev = cmd->device;
-	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+	struct fc_rport *rport = starget_to_rport(starget);
 	scsi_qla_host_t *vha = shost_priv(rport_to_shost(rport));
 	struct qla_hw_data *ha = vha->hw;
 	fc_port_t *fcport = *(fc_port_t **)rport->dd_data;
@@ -1491,40 +1490,39 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
 		return SUCCESS;
 
 	ql_log(ql_log_info, vha, 0x8009,
-	    "TARGET RESET ISSUED nexus=%ld:%d cmd=%p.\n", vha->host_no,
-	    sdev->id, cmd);
+	    "TARGET RESET ISSUED nexus=%ld:%d.\n", vha->host_no,
+	    starget->id);
 
 	err = 0;
 	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800a,
-		    "Wait for hba online failed for cmd=%p.\n", cmd);
+		    "Wait for hba online failed.\n");
 		goto eh_reset_failed;
 	}
 	err = 2;
 	if (ha->isp_ops->target_reset(fcport, 0, 0) != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800c,
-		    "target_reset failed for cmd=%p.\n", cmd);
+		    "target_reset failed.\n");
 		goto eh_reset_failed;
 	}
 	err = 3;
-	if (qla2x00_eh_wait_for_pending_commands(vha, sdev->id,
+	if (qla2x00_eh_wait_for_pending_commands(vha, starget->id,
 	    0, WAIT_TARGET) != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800d,
-		    "wait for pending cmds failed for cmd=%p.\n", cmd);
+		    "wait for pending cmds failed.\n");
 		goto eh_reset_failed;
 	}
 
 	ql_log(ql_log_info, vha, 0x800e,
-	    "TARGET RESET SUCCEEDED nexus:%ld:%d cmd=%p.\n",
-	    vha->host_no, sdev->id, cmd);
+	    "TARGET RESET SUCCEEDED nexus:%ld:%d.\n",
+	    vha->host_no, starget->id);
 
 	return SUCCESS;
 
 eh_reset_failed:
 	ql_log(ql_log_info, vha, 0x800f,
-	    "TARGET RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n",
-	    reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun,
-	    cmd);
+	    "TARGET RESET FAILED: %s nexus=%ld:%d.\n",
+	    reset_errors[err], vha->host_no, starget->id);
 	vha->reset_cmd_err_cnt++;
 	return FAILED;
 }
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 8f89080e2580..90828d4eb26d 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -158,7 +158,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len);
 static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
 static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
 static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
-static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd);
+static int qla4xxx_eh_target_reset(struct scsi_target *starget);
 static int qla4xxx_eh_host_reset(struct Scsi_Host *shost);
 static int qla4xxx_slave_alloc(struct scsi_device *device);
 static umode_t qla4_attr_is_visible(int param_type, int param);
@@ -9332,9 +9332,8 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
  *
  * This routine is called by the Linux OS to reset the target.
  **/
-static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
+static int qla4xxx_eh_target_reset(struct scsi_target *starget)
 {
-	struct scsi_target *starget = scsi_target(cmd->device);
 	struct iscsi_cls_session *cls_session = starget_to_session(starget);
 	struct iscsi_session *sess;
 	struct scsi_qla_host *ha;
@@ -9356,10 +9355,8 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 		       "WARM TARGET RESET ISSUED.\n");
 
 	DEBUG2(printk(KERN_INFO
-		      "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, "
-		      "to=%x,dpc_flags=%lx, status=%x allowed=%d\n",
-		      ha->host_no, cmd, jiffies, scsi_cmd_to_rq(cmd)->timeout / HZ,
-		      ha->dpc_flags, cmd->result, cmd->allowed));
+		      "scsi%ld: TARGET_DEVICE_RESET dpc_flags=%lx\n",
+		      ha->host_no, ha->dpc_flags));
 
 	rval = qla4xxx_isp_check_reg(ha);
 	if (rval != QLA_SUCCESS) {
@@ -9382,7 +9379,7 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 	}
 
 	/* Send marker. */
-	if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun,
+	if (qla4xxx_send_marker_iocb(ha, ddb_entry, 0,
 		MM_TGT_WARM_RESET) != QLA_SUCCESS) {
 		starget_printk(KERN_INFO, starget,
 			       "WARM TARGET DEVICE RESET FAILED - "
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index f2d3271bc80b..2e9daf8c7e83 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5288,39 +5288,30 @@ static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
 	return SUCCESS;
 }
 
-static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_target_reset(struct scsi_target *starget)
 {
+	struct Scsi_Host *hp = dev_to_shost(&starget->dev);
 	struct sdebug_host_info *sdbg_host;
 	struct sdebug_dev_info *devip;
-	struct scsi_device *sdp;
-	struct Scsi_Host *hp;
 	int k = 0;
 
 	++num_target_resets;
-	if (!SCpnt)
-		goto lie;
-	sdp = SCpnt->device;
-	if (!sdp)
-		goto lie;
 	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
-	hp = sdp->host;
-	if (!hp)
-		goto lie;
+		starget_printk(KERN_INFO, starget, "%s\n", __func__);
 	sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
 	if (sdbg_host) {
 		list_for_each_entry(devip,
 				    &sdbg_host->dev_info_list,
 				    dev_list)
-			if (devip->target == sdp->id) {
+			if (devip->target == starget->id) {
 				set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
 				++k;
 			}
 	}
 	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp,
+		starget_printk(KERN_INFO, starget,
 			    "%s: %d device(s) found in target\n", __func__, k);
-lie:
+
 	return SUCCESS;
 }
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 148cab3e61c0..3ee4393a1f1e 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -906,14 +906,15 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
 	enum scsi_disposition rtn;
 	struct Scsi_Host *host = scmd->device->host;
 	struct scsi_host_template *hostt = host->hostt;
+	struct scsi_target *starget = scsi_target(scmd->device);
 
 	if (!hostt->eh_target_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_target_reset_handler(scmd);
+	rtn = hostt->eh_target_reset_handler(starget);
 	if (rtn == SUCCESS) {
 		spin_lock_irqsave(host->host_lock, flags);
-		__starget_for_each_device(scsi_target(scmd->device), NULL,
+		__starget_for_each_device(starget, NULL,
 					  __scsi_report_device_reset);
 		spin_unlock_irqrestore(host->host_lock, flags);
 	}
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index aef828731995..6290f69faa47 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -619,9 +619,8 @@ static int sym53c8xx_eh_abort_handler(struct scsi_cmnd *cmd)
 	return sts ? SCSI_FAILED : SCSI_SUCCESS;
 }
 
-static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
+static int sym53c8xx_eh_target_reset_handler(struct scsi_target *starget)
 {
-	struct scsi_target *starget = scsi_target(cmd->device);
 	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
 	struct sym_data *sym_data = shost_priv(shost);
 	struct pci_dev *pdev = sym_data->pdev;
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 4407b56aa6d1..4dabdbf167f6 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -274,23 +274,24 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
 	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
 
-static int tcm_loop_target_reset(struct scsi_cmnd *sc)
+static int tcm_loop_target_reset(struct scsi_target *starget)
 {
 	struct tcm_loop_hba *tl_hba;
 	struct tcm_loop_tpg *tl_tpg;
+	struct Scsi_Host *shost = dev_to_shost(&starget->dev);
 
 	/*
 	 * Locate the tcm_loop_hba_t pointer
 	 */
-	tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
+	tl_hba = *(struct tcm_loop_hba **)shost_priv(shost);
 	if (!tl_hba) {
 		pr_err("Unable to perform device reset without active I_T Nexus\n");
 		return FAILED;
 	}
 	/*
-	 * Locate the tl_tpg pointer from TargetID in sc->device->id
+	 * Locate the tl_tpg pointer from TargetID in starget->id
 	 */
-	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
+	tl_tpg = &tl_hba->tl_hba_tpgs[starget->id];
 	if (tl_tpg) {
 		tl_tpg->tl_transport_status = TCM_TRANSPORT_ONLINE;
 		return SUCCESS;
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index ce8d5b5dc0d3..f27fcffa2fd9 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -390,7 +390,7 @@ struct iscsi_host {
  * scsi host template
  */
 extern int iscsi_eh_abort(struct scsi_cmnd *sc);
-extern int iscsi_eh_recover_target(struct scsi_cmnd *sc);
+extern int iscsi_eh_recover_target(struct scsi_target *starget);
 extern int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session);
 extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
 extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index ff04eb6d250b..bbc4176d2d37 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -731,7 +731,7 @@ void sas_init_dev(struct domain_device *);
 void sas_task_abort(struct sas_task *);
 int sas_eh_abort_handler(struct scsi_cmnd *cmd);
 int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
-int sas_eh_target_reset_handler(struct scsi_cmnd *cmd);
+int sas_eh_target_reset_handler(struct scsi_target *starget);
 
 extern void sas_target_destroy(struct scsi_target *);
 extern int sas_slave_alloc(struct scsi_device *);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 73c9971e7334..b4acae42a2ca 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -139,7 +139,7 @@ struct scsi_host_template {
 	 */
 	int (* eh_abort_handler)(struct scsi_cmnd *);
 	int (* eh_device_reset_handler)(struct scsi_cmnd *);
-	int (* eh_target_reset_handler)(struct scsi_cmnd *);
+	int (* eh_target_reset_handler)(struct scsi_target *);
 	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
 	int (* eh_host_reset_handler)(struct Scsi_Host *);
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (5 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-03 20:32   ` michael.christie
  2022-05-02 21:59 ` [PATCH 4/7] scsi: Use scsi_device as argument to eh_device_reset_handler() Hannes Reinecke
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

We should be passing in the session directly instead of deriving it
from the scsi command.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/qla4xxx/ql4_os.c       | 34 ++++++++++++++++++-----------
 drivers/scsi/scsi_transport_iscsi.c |  6 ++---
 include/scsi/scsi_transport_iscsi.h |  2 +-
 3 files changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 3f6cb2a5c2c2..f4969b99c07f 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -9262,15 +9262,18 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd)
  **/
 static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
 {
-	struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
-	struct ddb_entry *ddb_entry = cmd->device->hostdata;
+	struct scsi_device *sdev = cmd->device;
+	struct scsi_qla_host *ha = to_qla_host(sdev->host);
+	struct iscsi_cls_session *session;
+	struct ddb_entry *ddb_entry = sdev->hostdata;
 	int ret = FAILED, stat;
 	int rval;
 
 	if (!ddb_entry)
 		return ret;
 
-	ret = iscsi_block_scsi_eh(cmd);
+	session = starget_to_session(scsi_target(sdev));
+	ret = iscsi_block_scsi_eh(session);
 	if (ret)
 		return ret;
 	ret = FAILED;
@@ -9331,19 +9334,25 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
  **/
 static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 {
-	struct scsi_qla_host *ha = to_qla_host(cmd->device->host);
-	struct ddb_entry *ddb_entry = cmd->device->hostdata;
+	struct scsi_target *starget = scsi_target(cmd->device);
+	struct iscsi_cls_session *cls_session = starget_to_session(starget);
+	struct iscsi_session *sess;
+	struct scsi_qla_host *ha;
+	struct ddb_entry *ddb_entry;
 	int stat, ret;
 	int rval;
 
+	sess = cls_session->dd_data;
+	ddb_entry = sess->dd_data;
 	if (!ddb_entry)
 		return FAILED;
+	ha = ddb_entry->ha;
 
-	ret = iscsi_block_scsi_eh(cmd);
+	ret = iscsi_block_scsi_eh(cls_session);
 	if (ret)
 		return ret;
 
-	starget_printk(KERN_INFO, scsi_target(cmd->device),
+	starget_printk(KERN_INFO, starget,
 		       "WARM TARGET RESET ISSUED.\n");
 
 	DEBUG2(printk(KERN_INFO
@@ -9360,14 +9369,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 
 	stat = qla4xxx_reset_target(ha, ddb_entry);
 	if (stat != QLA_SUCCESS) {
-		starget_printk(KERN_INFO, scsi_target(cmd->device),
+		starget_printk(KERN_INFO, starget,
 			       "WARM TARGET RESET FAILED.\n");
 		return FAILED;
 	}
 
-	if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device),
-					 NULL)) {
-		starget_printk(KERN_INFO, scsi_target(cmd->device),
+	if (qla4xxx_eh_wait_for_commands(ha, starget, NULL)) {
+		starget_printk(KERN_INFO, starget,
 			       "WARM TARGET DEVICE RESET FAILED - "
 			       "waiting for commands.\n");
 		return FAILED;
@@ -9376,13 +9384,13 @@ static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd)
 	/* Send marker. */
 	if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun,
 		MM_TGT_WARM_RESET) != QLA_SUCCESS) {
-		starget_printk(KERN_INFO, scsi_target(cmd->device),
+		starget_printk(KERN_INFO, starget,
 			       "WARM TARGET DEVICE RESET FAILED - "
 			       "marker iocb failed.\n");
 		return FAILED;
 	}
 
-	starget_printk(KERN_INFO, scsi_target(cmd->device),
+	starget_printk(KERN_INFO, starget,
 		       "WARM TARGET RESET SUCCEEDED.\n");
 	return SUCCESS;
 }
diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
index 2c0dd64159b0..bdc9ef29fe9c 100644
--- a/drivers/scsi/scsi_transport_iscsi.c
+++ b/drivers/scsi/scsi_transport_iscsi.c
@@ -1821,17 +1821,15 @@ static void iscsi_scan_session(struct work_struct *work)
 
 /**
  * iscsi_block_scsi_eh - block scsi eh until session state has transistioned
- * @cmd: scsi cmd passed to scsi eh handler
+ * @session: iscsi session derived from scsi eh handler argument
  *
  * If the session is down this function will wait for the recovery
  * timer to fire or for the session to be logged back in. If the
  * recovery timer fires then FAST_IO_FAIL is returned. The caller
  * should pass this error value to the scsi eh.
  */
-int iscsi_block_scsi_eh(struct scsi_cmnd *cmd)
+int iscsi_block_scsi_eh(struct iscsi_cls_session *session)
 {
-	struct iscsi_cls_session *session =
-			starget_to_session(scsi_target(cmd->device));
 	unsigned long flags;
 	int ret = 0;
 
diff --git a/include/scsi/scsi_transport_iscsi.h b/include/scsi/scsi_transport_iscsi.h
index 9acb8422f680..5771275f8bf3 100644
--- a/include/scsi/scsi_transport_iscsi.h
+++ b/include/scsi/scsi_transport_iscsi.h
@@ -456,7 +456,7 @@ extern struct iscsi_endpoint *iscsi_create_endpoint(int dd_size);
 extern void iscsi_destroy_endpoint(struct iscsi_endpoint *ep);
 extern struct iscsi_endpoint *iscsi_lookup_endpoint(u64 handle);
 extern void iscsi_put_endpoint(struct iscsi_endpoint *ep);
-extern int iscsi_block_scsi_eh(struct scsi_cmnd *cmd);
+extern int iscsi_block_scsi_eh(struct iscsi_cls_session *session);
 extern struct iscsi_iface *iscsi_create_iface(struct Scsi_Host *shost,
 					      struct iscsi_transport *t,
 					      uint32_t iface_type,
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 4/7] scsi: Use scsi_device as argument to eh_device_reset_handler()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (6 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 05/11] pmcraid: select first available device for target reset Hannes Reinecke
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

The device reset function should only depend on the scsi device,
not the scsi command.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 Documentation/scsi/scsi_eh.rst                |  2 +-
 Documentation/scsi/scsi_mid_low_api.rst       |  4 +--
 drivers/infiniband/ulp/srp/ib_srp.c           |  6 ++--
 drivers/message/fusion/mptfc.c                | 12 +++----
 drivers/message/fusion/mptscsih.c             | 19 +++++-----
 drivers/message/fusion/mptscsih.h             |  2 +-
 drivers/s390/scsi/zfcp_scsi.c                 |  4 +--
 drivers/scsi/a100u2w.c                        |  7 ++--
 drivers/scsi/aacraid/linit.c                  |  9 +++--
 drivers/scsi/aha152x.c                        |  6 ++--
 drivers/scsi/aha1542.c                        |  8 ++---
 drivers/scsi/aic7xxx/aic79xx_osm.c            | 27 ++++++--------
 drivers/scsi/aic7xxx/aic7xxx_osm.c            |  4 +--
 drivers/scsi/arm/fas216.c                     |  5 ++-
 drivers/scsi/arm/fas216.h                     |  6 ++--
 drivers/scsi/be2iscsi/be_main.c               |  8 ++---
 drivers/scsi/bfa/bfad_im.c                    |  3 +-
 drivers/scsi/bnx2fc/bnx2fc.h                  |  2 +-
 drivers/scsi/bnx2fc/bnx2fc_io.c               |  6 ++--
 drivers/scsi/csiostor/csio_scsi.c             |  3 +-
 drivers/scsi/cxlflash/main.c                  |  5 ++-
 drivers/scsi/dpt_i2o.c                        | 20 ++++++-----
 drivers/scsi/dpti.h                           |  2 +-
 drivers/scsi/esas2r/esas2r.h                  |  2 +-
 drivers/scsi/esas2r/esas2r_main.c             |  3 +-
 drivers/scsi/fnic/fnic.h                      |  2 +-
 drivers/scsi/fnic/fnic_scsi.c                 |  6 ++--
 drivers/scsi/hpsa.c                           | 14 ++++----
 drivers/scsi/ibmvscsi/ibmvfc.c                |  5 ++-
 drivers/scsi/ibmvscsi/ibmvscsi.c              | 19 +++++-----
 drivers/scsi/ipr.c                            | 31 ++++++++--------
 drivers/scsi/libfc/fc_fcp.c                   | 11 +++---
 drivers/scsi/libiscsi.c                       | 15 ++++----
 drivers/scsi/libsas/sas_scsi_host.c           | 12 +++----
 drivers/scsi/lpfc/lpfc_scsi.c                 | 10 +++---
 drivers/scsi/mpi3mr/mpi3mr_os.c               | 34 +++++++++---------
 drivers/scsi/mpt3sas/mpt3sas_scsih.c          | 30 +++++++---------
 drivers/scsi/pcmcia/nsp_cs.h                  |  2 --
 drivers/scsi/pmcraid.c                        |  6 ++--
 drivers/scsi/qedf/qedf_main.c                 |  6 ++--
 drivers/scsi/qla1280.c                        | 21 ++++++++---
 drivers/scsi/qla2xxx/qla_os.c                 | 22 ++++++------
 drivers/scsi/qla4xxx/ql4_os.c                 | 23 +++++-------
 drivers/scsi/scsi_debug.c                     | 18 +++++-----
 drivers/scsi/scsi_error.c                     | 35 +++++++++++++------
 drivers/scsi/smartpqi/smartpqi_init.c         | 11 +++---
 drivers/scsi/snic/snic.h                      |  2 +-
 drivers/scsi/snic/snic_scsi.c                 |  4 +--
 drivers/scsi/ufs/ufshcd.c                     |  8 ++---
 drivers/scsi/virtio_scsi.c                    | 12 +++----
 drivers/scsi/vmw_pvscsi.c                     | 10 +++---
 drivers/scsi/wd719x.c                         |  6 ++--
 drivers/scsi/xen-scsifront.c                  | 23 +++++++-----
 drivers/staging/rts5208/rtsx.c                |  6 +++-
 .../staging/unisys/visorhba/visorhba_main.c   | 13 ++-----
 drivers/target/loopback/tcm_loop.c            |  8 ++---
 drivers/usb/storage/scsiglue.c                |  4 +--
 drivers/usb/storage/uas.c                     |  3 +-
 include/scsi/libfc.h                          |  2 +-
 include/scsi/libiscsi.h                       |  2 +-
 include/scsi/libsas.h                         |  2 +-
 include/scsi/scsi_host.h                      |  2 +-
 62 files changed, 302 insertions(+), 313 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
index cfa14ad55dda..5b654a42de90 100644
--- a/Documentation/scsi/scsi_eh.rst
+++ b/Documentation/scsi/scsi_eh.rst
@@ -213,7 +213,7 @@ considered to fail always.
 ::
 
     int (* eh_abort_handler)(struct scsi_cmnd *);
-    int (* eh_device_reset_handler)(struct scsi_cmnd *);
+    int (* eh_device_reset_handler)(struct scsi_device *);
     int (* eh_target_reset_handler)(struct scsi_target *);
     int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
     int (* eh_host_reset_handler)(struct Scsi_Host *);
diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
index 0afc1b4f89af..4650c0c6a22a 100644
--- a/Documentation/scsi/scsi_mid_low_api.rst
+++ b/Documentation/scsi/scsi_mid_low_api.rst
@@ -778,7 +778,7 @@ Details::
 
     /**
     *      eh_device_reset_handler - issue SCSI device reset
-    *      @scp: identifies SCSI device to be reset
+    *      @sdev: identifies SCSI device to be reset
     *
     *      Returns SUCCESS if command aborted else FAILED
     *
@@ -791,7 +791,7 @@ Details::
     *
     *      Optionally defined in: LLD
     **/
-	int eh_device_reset_handler(struct scsi_cmnd * scp)
+	int eh_device_reset_handler(struct scsi_device * sdev)
 
 
     /**
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index de901dee6935..bc1200c3a101 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -2824,16 +2824,16 @@ static int srp_abort(struct scsi_cmnd *scmnd)
 	return ret;
 }
 
-static int srp_reset_device(struct scsi_cmnd *scmnd)
+static int srp_reset_device(struct scsi_device *sdev)
 {
-	struct srp_target_port *target = host_to_target(scmnd->device->host);
+	struct srp_target_port *target = host_to_target(sdev->host);
 	struct srp_rdma_ch *ch;
 	u8 status;
 
 	shost_printk(KERN_ERR, target->scsi_host, "SRP reset_device called\n");
 
 	ch = &target->ch[0];
-	if (srp_send_tsk_mgmt(ch, SRP_TAG_NO_REQ, scmnd->device->lun,
+	if (srp_send_tsk_mgmt(ch, SRP_TAG_NO_REQ, sdev->lun,
 			      SRP_TSK_LUN_RESET, &status))
 		return FAILED;
 	if (status)
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index bc62f0cc0cbd..be69b8b746c0 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -102,7 +102,7 @@ static void mptfc_target_destroy(struct scsi_target *starget);
 static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
 static void mptfc_remove(struct pci_dev *pdev);
 static int mptfc_abort(struct scsi_cmnd *SCpnt);
-static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
+static int mptfc_dev_reset(struct scsi_device *sdev);
 static int mptfc_bus_reset(struct Scsi_Host *shost, int channel);
 
 static struct scsi_host_template mptfc_driver_template = {
@@ -240,10 +240,10 @@ mptfc_abort(struct scsi_cmnd *SCpnt)
 }
 
 static int
-mptfc_dev_reset(struct scsi_cmnd *SCpnt)
+mptfc_dev_reset(struct scsi_device *sdev)
 {
-	struct Scsi_Host *shost = SCpnt->device->host;
-	struct fc_rport *rport = starget_to_rport(scsi_target(SCpnt->device));
+	struct Scsi_Host *shost = sdev->host;
+	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost);
 	int rtn;
 
@@ -252,8 +252,8 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt)
 		dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
 			"%s.%d: %d:%llu, executing recovery.\n", __func__,
 			hd->ioc->name, shost->host_no,
-			SCpnt->device->id, SCpnt->device->lun));
-		rtn = mptscsih_dev_reset(SCpnt);
+			sdev->id, sdev->lun));
+		rtn = mptscsih_dev_reset(sdev);
 	}
 	return rtn;
 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index af140dbd63d9..d5b5a850633e 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1795,14 +1795,14 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  *	mptscsih_dev_reset - Perform a SCSI LOGICAL_UNIT_RESET!
- *	@SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
+ *	@device: Pointer to scsi_device structure, which reset is due to
  *
  *	(linux scsi_host_template.eh_dev_reset_handler routine)
  *
  *	Returns SUCCESS or FAILED.
  **/
 int
-mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
+mptscsih_dev_reset(struct scsi_device * device)
 {
 	MPT_SCSI_HOST	*hd;
 	int		 retval;
@@ -1811,18 +1811,15 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
 
 	/* If we can't locate our host adapter structure, return FAILED status.
 	 */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
-		printk(KERN_ERR MYNAM ": lun reset: "
-		   "Can't locate host! (sc=%p)\n", SCpnt);
+	if ((hd = shost_priv(device->host)) == NULL){
+		printk(KERN_ERR MYNAM ": lun reset: Can't locate host!\n");
 		return FAILED;
 	}
 
 	ioc = hd->ioc;
-	printk(MYIOC_s_INFO_FMT "attempting lun reset! (sc=%p)\n",
-	       ioc->name, SCpnt);
-	scsi_print_command(SCpnt);
+	printk(MYIOC_s_INFO_FMT "attempting lun reset!\n", ioc->name);
 
-	vdevice = SCpnt->device->hostdata;
+	vdevice = device->hostdata;
 	if (!vdevice || !vdevice->vtarget) {
 		retval = 0;
 		goto out;
@@ -1835,8 +1832,8 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
 				mptscsih_get_tm_timeout(ioc));
 
  out:
-	printk (MYIOC_s_INFO_FMT "lun reset: %s (sc=%p)\n",
-	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+	printk (MYIOC_s_INFO_FMT "lun reset: %s\n",
+	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
 
 	if (retval == 0)
 		return SUCCESS;
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index c4eaf3554c7d..70ed021bd458 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -119,7 +119,7 @@ extern int mptscsih_IssueTaskMgmt(MPT_SCSI_HOST *hd, u8 type, u8 channel,
 extern void mptscsih_slave_destroy(struct scsi_device *device);
 extern int mptscsih_slave_configure(struct scsi_device *device);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
-extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
+extern int mptscsih_dev_reset(struct scsi_device *);
 extern int mptscsih_target_reset(struct Scsi_Host *, struct scsi_target *);
 extern int mptscsih_bus_reset(struct Scsi_Host *, int);
 extern int mptscsih_host_reset(struct Scsi_Host *sh);
diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
index 10bbe56189b3..7343c7543e60 100644
--- a/drivers/s390/scsi/zfcp_scsi.c
+++ b/drivers/s390/scsi/zfcp_scsi.c
@@ -333,10 +333,8 @@ static int zfcp_scsi_task_mgmt_function(struct scsi_device *sdev, u8 tm_flags)
 	return retval;
 }
 
-static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
+static int zfcp_scsi_eh_device_reset_handler(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = scpnt->device;
-
 	return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET);
 }
 
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index dab79824e2f6..23c248e35536 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -948,12 +948,11 @@ static int inia100_bus_reset(struct Scsi_Host * shost, int channel)
  Output         : None.
  Return         : pSRB  -       Pointer to SCSI request block.
 *****************************************************************************/
-static int inia100_device_reset(struct scsi_cmnd * cmd)
+static int inia100_device_reset(struct scsi_device * dev)
 {				/* I need Host Control Block Information */
 	struct orc_host *host;
-	host = (struct orc_host *) cmd->device->host->hostdata;
-	return orc_device_reset(host, cmd->device);
-
+	host = (struct orc_host *) dev->host->hostdata;
+	return orc_device_reset(host, dev);
 }
 
 /**
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index a63e03203679..9acb63cf29dd 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -896,12 +896,11 @@ static void aac_tmf_callback(void *context, struct fib *fibptr)
 
 /*
  *	aac_eh_dev_reset	- Device reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
+ *	@dev:	SCSI device to be reset
  *
  */
-static int aac_eh_dev_reset(struct scsi_cmnd *cmd)
+static int aac_eh_dev_reset(struct scsi_device *dev)
 {
-	struct scsi_device * dev = cmd->device;
 	struct Scsi_Host * host = dev->host;
 	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
 	struct aac_hba_map_info *info;
@@ -912,8 +911,8 @@ static int aac_eh_dev_reset(struct scsi_cmnd *cmd)
 	int status;
 	u8 command;
 
-	bus = aac_logical_to_phys(scmd_channel(cmd));
-	cid = scmd_id(cmd);
+	bus = aac_logical_to_phys(sdev_channel(dev));
+	cid = sdev_id(dev);
 
 	if (bus >= AAC_MAX_BUSES || cid >= AAC_MAX_TARGETS)
 		return FAILED;
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 1312dc5ef6d2..b697b33ab335 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1068,12 +1068,12 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt)
  * Reset a device
  *
  */
-static int aha152x_device_reset(struct scsi_cmnd * SCpnt)
+static int aha152x_device_reset(struct scsi_device * sdev)
 {
-	struct scsi_device *sdev = SCpnt->device;
 	struct Scsi_Host *shpnt = sdev->host;
+	struct scsi_cmnd *SCpnt;
 	DECLARE_COMPLETION(done);
-	int ret, issued, disconnected;
+	int ret, issued, disconnected = 0;
 	unsigned char old_cmd_len;
 	unsigned long flags;
 	unsigned long timeleft;
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 797a49f927dd..d6d8b9827978 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -860,14 +860,14 @@ static int aha1542_release(struct Scsi_Host *sh)
  * This is a device reset.  This is handled by sending a special command
  * to the device.
  */
-static int aha1542_dev_reset(struct scsi_cmnd *cmd)
+static int aha1542_dev_reset(struct scsi_device *sdev)
 {
-	struct Scsi_Host *sh = cmd->device->host;
+	struct Scsi_Host *sh = sdev->host;
 	struct aha1542_hostdata *aha1542 = shost_priv(sh);
 	unsigned long flags;
 	struct mailbox *mb = aha1542->mb;
-	u8 target = cmd->device->id;
-	u8 lun = cmd->device->lun;
+	u8 target = sdev->id;
+	u8 lun = sdev->lun;
 	int mbo;
 	struct ccb *ccb = aha1542->ccb;
 
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index 00786c37f39f..3d9c6fbc2f2d 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -770,12 +770,11 @@ ahd_linux_abort(struct scsi_cmnd *cmd)
  * Attempt to send a target reset message to the device that timed out.
  */
 static int
-ahd_linux_dev_reset(struct scsi_cmnd *cmd)
+ahd_linux_dev_reset(struct scsi_device *sdev)
 {
 	struct ahd_softc *ahd;
 	struct ahd_linux_device *dev;
 	struct scb *reset_scb;
-	u_int  cdb_byte;
 	int    retval = SUCCESS;
 	struct	ahd_initiator_tinfo *tinfo;
 	struct	ahd_tmode_tstate *tstate;
@@ -784,27 +783,22 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
 
 	reset_scb = NULL;
 
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	ahd = *(struct ahd_softc **)sdev->host->hostdata;
 
-	scmd_printk(KERN_INFO, cmd,
+	sdev_printk(KERN_INFO, sdev,
 		    "Attempting to queue a TARGET RESET message:");
 
-	printk("CDB:");
-	for (cdb_byte = 0; cdb_byte < cmd->cmd_len; cdb_byte++)
-		printk(" 0x%x", cmd->cmnd[cdb_byte]);
-	printk("\n");
-
 	/*
 	 * Determine if we currently own this command.
 	 */
-	dev = scsi_transport_device_data(cmd->device);
+	dev = scsi_transport_device_data(sdev);
 
 	if (dev == NULL) {
 		/*
 		 * No target device for this command exists,
 		 * so we must not still own the command.
 		 */
-		scmd_printk(KERN_INFO, cmd, "Is not an active device\n");
+		sdev_printk(KERN_INFO, sdev, "Is not an active device\n");
 		return SUCCESS;
 	}
 
@@ -813,12 +807,12 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
 	 */
 	reset_scb = ahd_get_scb(ahd, AHD_NEVER_COL_IDX);
 	if (!reset_scb) {
-		scmd_printk(KERN_INFO, cmd, "No SCB available\n");
+		sdev_printk(KERN_INFO, sdev, "No SCB available\n");
 		return FAILED;
 	}
 
 	tinfo = ahd_fetch_transinfo(ahd, 'A', ahd->our_id,
-				    cmd->device->id, &tstate);
+				    sdev->id, &tstate);
 	reset_scb->io_ctx = NULL;
 	reset_scb->platform_data->dev = dev;
 	reset_scb->sg_count = 0;
@@ -826,8 +820,8 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
 	ahd_set_sense_residual(reset_scb, 0);
 	reset_scb->platform_data->xfer_len = 0;
 	reset_scb->hscb->control = 0;
-	reset_scb->hscb->scsiid = ahd_build_scsiid(ahd, cmd->device);
-	reset_scb->hscb->lun = cmd->device->lun;
+	reset_scb->hscb->scsiid = ahd_build_scsiid(ahd, sdev);
+	reset_scb->hscb->lun = sdev->lun;
 	reset_scb->hscb->cdb_len = 0;
 	reset_scb->hscb->task_management = SIU_TASKMGMT_LUN_RESET;
 	reset_scb->flags |= SCB_DEVICE_RESET|SCB_RECOVERY_SCB|SCB_ACTIVE;
@@ -1793,7 +1787,8 @@ ahd_done(struct ahd_softc *ahd, struct scb *scb)
 	 * was retrieved anytime the first byte of
 	 * the sense buffer looks "sane".
 	 */
-	cmd->sense_buffer[0] = 0;
+	if (cmd)
+		cmd->sense_buffer[0] = 0;
 	if (ahd_get_transaction_status(scb) == CAM_REQ_INPROG) {
 #ifdef AHD_REPORT_UNDERFLOWS
 		uint32_t amount_xferred;
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index f6c547cef26c..2b06473c2f2b 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -739,11 +739,11 @@ ahc_linux_abort(struct scsi_cmnd *cmd)
  * Attempt to send a target reset message to the device that timed out.
  */
 static int
-ahc_linux_dev_reset(struct scsi_cmnd *cmd)
+ahc_linux_dev_reset(struct scsi_device *sdev)
 {
 	int error;
 
-	error = ahc_linux_queue_recovery_cmd(cmd->device, NULL);
+	error = ahc_linux_queue_recovery_cmd(sdev, NULL);
 	if (error != SUCCESS)
 		printk("aic7xxx_dev_reset returns 0x%x\n", error);
 	return (error);
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index c27b49c42c4f..9015755d26bd 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2474,16 +2474,15 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
 
 /**
  * fas216_eh_device_reset - Reset the device associated with this command
- * @SCpnt: command specifing device to reset
+ * @sdev: device to reset
  *
  * Reset the device associated with this command.
  * Returns: FAILED if unable to reset.
  * Notes: We won't be re-entered, so we'll only have one device
  * reset on the go at one time.
  */
-int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
+int fas216_eh_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = SCpnt->device;
 	FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata;
 	unsigned long flags;
 	int i, res = FAILED, target = sdev->id;
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index 27a4b564f054..af405ecc2128 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -380,12 +380,12 @@ extern void fas216_print_devices(FAS216_Info *info, struct seq_file *m);
  */
 extern int fas216_eh_abort(struct scsi_cmnd *SCpnt);
 
-/* Function: int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
+/* Function: int fas216_eh_device_reset(struct scsi_device *sdev)
  * Purpose : Reset the device associated with this command
- * Params  : SCpnt - command specifing device to reset
+ * Params  : sdev - device to be reset
  * Returns : FAILED if unable to reset
  */
-extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
+extern int fas216_eh_device_reset(struct scsi_device *sdev);
 
 /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
  * Purpose : Reset the complete bus associated with this command
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c
index f954c6f869fb..b55226161f53 100644
--- a/drivers/scsi/be2iscsi/be_main.c
+++ b/drivers/scsi/be2iscsi/be_main.c
@@ -267,7 +267,7 @@ static int beiscsi_eh_abort(struct scsi_cmnd *sc)
 	return iscsi_eh_abort(sc);
 }
 
-static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
+static int beiscsi_eh_device_reset(struct scsi_device *sdev)
 {
 	struct beiscsi_invldt_cmd_tbl {
 		struct invldt_cmd_tbl tbl[BE_INVLDT_CMD_TBL_SZ];
@@ -283,7 +283,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 	unsigned int i, nents;
 	int rc, more = 0;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
+	cls_session = starget_to_session(scsi_target(sdev));
 	session = cls_session->dd_data;
 
 	spin_lock_bh(&session->frwd_lock);
@@ -311,7 +311,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 		if (!task->sc)
 			continue;
 
-		if (sc->device->lun != task->sc->device->lun)
+		if (sdev->lun != task->sc->device->lun)
 			continue;
 		/**
 		 * Can't fit in more cmds? Normally this won't happen b'coz
@@ -366,7 +366,7 @@ static int beiscsi_eh_device_reset(struct scsi_cmnd *sc)
 	kfree(inv_tbl);
 
 	if (rc == SUCCESS)
-		rc = iscsi_eh_device_reset(sc);
+		rc = iscsi_eh_device_reset(sdev);
 	return rc;
 }
 
diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 272dedfee1a7..39d3fb80b2fc 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -283,9 +283,8 @@ bfad_im_target_reset_send(struct bfad_s *bfad,
  *
  */
 static int
-bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
+bfad_im_reset_lun_handler(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmnd->device;
 	struct Scsi_Host *shost = sdev->host;
 	struct bfad_im_port_s *im_port =
 			(struct bfad_im_port_s *) shost->hostdata[0];
diff --git a/drivers/scsi/bnx2fc/bnx2fc.h b/drivers/scsi/bnx2fc/bnx2fc.h
index b3ed22d97572..8c47e2a39d91 100644
--- a/drivers/scsi/bnx2fc/bnx2fc.h
+++ b/drivers/scsi/bnx2fc/bnx2fc.h
@@ -552,7 +552,7 @@ void bnx2fc_add_2_sq(struct bnx2fc_rport *tgt, u16 xid);
 void bnx2fc_ring_doorbell(struct bnx2fc_rport *tgt);
 int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd);
 int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt);
-int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd);
+int bnx2fc_eh_device_reset(struct scsi_device *sdev);
 void bnx2fc_rport_event_handler(struct fc_lport *lport,
 				struct fc_rport_priv *rport,
 				enum fc_rport_event event);
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c
index 0f5218eb9732..3968a99c89da 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_io.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_io.c
@@ -1074,12 +1074,12 @@ int bnx2fc_eh_target_reset(struct scsi_target *sc_tgt)
  * Set from SCSI host template to send task mgmt command to the target
  *	and wait for the response
  */
-int bnx2fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
+int bnx2fc_eh_device_reset(struct scsi_device *sdev)
 {
-	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
+	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	struct fc_lport *lport = shost_priv(rport_to_shost(rport));
 
-	return bnx2fc_initiate_tmf(lport, rport, sc_cmd->device->lun,
+	return bnx2fc_initiate_tmf(lport, rport, sdev->lun,
 				   FCP_TMF_LUN_RESET);
 }
 
diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index b21aa2c43051..f1a647d8a6a4 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -2060,9 +2060,8 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req)
 }
 
 static int
-csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
+csio_eh_lun_reset_handler(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmnd->device;
 	struct csio_lnode *ln = shost_priv(sdev->host);
 	struct csio_hw *hw = csio_lnode_to_hw(ln);
 	struct csio_scsim *scsim = csio_hw_to_scsim(hw);
diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
index 50c04ba85b0b..2bc18f775385 100644
--- a/drivers/scsi/cxlflash/main.c
+++ b/drivers/scsi/cxlflash/main.c
@@ -2438,16 +2438,15 @@ static int cxlflash_eh_abort_handler(struct scsi_cmnd *scp)
 
 /**
  * cxlflash_eh_device_reset_handler() - reset a single LUN
- * @scp:	SCSI command to send.
+ * @sdev:	SCSI device to be reset.
  *
  * Return:
  *	SUCCESS as defined in scsi/scsi.h
  *	FAILED as defined in scsi/scsi.h
  */
-static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
+static int cxlflash_eh_device_reset_handler(struct scsi_device *sdev)
 {
 	int rc = SUCCESS;
-	struct scsi_device *sdev = scp->device;
 	struct Scsi_Host *host = sdev->host;
 	struct cxlflash_cfg *cfg = shost_priv(host);
 	struct device *dev = &cfg->dev->dev;
diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
index b1ab772aff0e..480735cc00d3 100644
--- a/drivers/scsi/dpt_i2o.c
+++ b/drivers/scsi/dpt_i2o.c
@@ -674,18 +674,19 @@ static int adpt_abort(struct scsi_cmnd * cmd)
 // This is the same for BLK and SCSI devices
 // NOTE this is wrong in the i2o.h definitions
 // This is not currently supported by our adapter but we issue it anyway
-static int adpt_device_reset(struct scsi_cmnd* cmd)
+static int adpt_device_reset(struct scsi_device * sdev)
 {
 	adpt_hba* pHba;
 	u32 msg[4];
 	u32 rcode;
 	int old_state;
-	struct adpt_device* d = cmd->device->hostdata;
+	struct adpt_device* d = sdev->hostdata;
 
-	pHba = (void*) cmd->device->host->hostdata[0];
-	printk(KERN_INFO"%s: Trying to reset device\n",pHba->name);
+	pHba = (void*) sdev->host->hostdata[0];
+	printk(KERN_INFO "%s: Trying to reset device\n", pHba->name);
 	if (!d) {
-		printk(KERN_INFO"%s: Reset Device: Device Not found\n",pHba->name);
+		printk(KERN_INFO "%s: Reset Device: Device Not found\n",
+		       pHba->name);
 		return FAILED;
 	}
 	memset(msg, 0, sizeof(msg));
@@ -698,19 +699,20 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
 		spin_lock_irq(pHba->host->host_lock);
 	old_state = d->state;
 	d->state |= DPTI_DEV_RESET;
-	rcode = adpt_i2o_post_wait(pHba, msg,sizeof(msg), FOREVER);
+	rcode = adpt_i2o_post_wait(pHba, msg, sizeof(msg), FOREVER);
 	d->state = old_state;
 	if (pHba->host)
 		spin_unlock_irq(pHba->host->host_lock);
 	if (rcode != 0) {
 		if(rcode == -EOPNOTSUPP ){
-			printk(KERN_INFO"%s: Device reset not supported\n",pHba->name);
+			printk(KERN_INFO "%s: Device reset not supported\n",
+			       pHba->name);
 			return FAILED;
 		}
-		printk(KERN_INFO"%s: Device reset failed\n",pHba->name);
+		printk(KERN_INFO "%s: Device reset failed\n", pHba->name);
 		return FAILED;
 	} else {
-		printk(KERN_INFO"%s: Device reset successful\n",pHba->name);
+		printk(KERN_INFO "%s: Device reset successful\n", pHba->name);
 		return SUCCESS;
 	}
 }
diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
index 48878e69ab2c..763b4cadb21e 100644
--- a/drivers/scsi/dpti.h
+++ b/drivers/scsi/dpti.h
@@ -36,7 +36,7 @@ static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
 		sector_t, int geom[]);
 
 static int adpt_bus_reset(struct Scsi_Host* shost, int channel);
-static int adpt_device_reset(struct scsi_cmnd* cmd);
+static int adpt_device_reset(struct scsi_device * sdev);
 
 
 /*
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index 56d8ff63372a..eb5d1dc3049d 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -975,7 +975,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 
 /* SCSI error handler (eh) functions */
 int esas2r_eh_abort(struct scsi_cmnd *cmd);
-int esas2r_device_reset(struct scsi_cmnd *cmd);
+int esas2r_device_reset(struct scsi_device *sdev);
 int esas2r_host_reset(struct Scsi_Host *shost);
 int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
 int esas2r_target_reset(struct scsi_target *starget);
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 1ad39c1ae085..1c5e93a85af9 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1174,9 +1174,8 @@ static int esas2r_dev_targ_reset(struct Scsi_Host *shost, int id, u64 lun,
 	return SUCCESS;
 }
 
-int esas2r_device_reset(struct scsi_cmnd *cmd)
+int esas2r_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmd->device;
 	struct Scsi_Host *shost = sdev->host;
 
 	esas2r_log(ESAS2R_LOG_INFO, "device_reset");
diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
index 7b81bea3ffa2..73329f9fd343 100644
--- a/drivers/scsi/fnic/fnic.h
+++ b/drivers/scsi/fnic/fnic.h
@@ -358,7 +358,7 @@ void fnic_update_mac_locked(struct fnic *, u8 *new);
 
 int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int fnic_abort_cmd(struct scsi_cmnd *);
-int fnic_device_reset(struct scsi_cmnd *);
+int fnic_device_reset(struct scsi_device *);
 int fnic_host_reset(struct Scsi_Host *);
 int fnic_reset(struct Scsi_Host *);
 void fnic_scsi_cleanup(struct fc_lport *);
diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
index b286d5feaca1..3ab2ad49abf7 100644
--- a/drivers/scsi/fnic/fnic_scsi.c
+++ b/drivers/scsi/fnic/fnic_scsi.c
@@ -2177,9 +2177,9 @@ static int fnic_clean_pending_aborts(struct fnic *fnic,
  * fail to get aborted. It calls driver's eh_device_reset with a SCSI command
  * on the LUN.
  */
-int fnic_device_reset(struct scsi_cmnd *sc)
+int fnic_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = sc->device;
+	struct scsi_cmnd *sc;
 	struct fc_lport *lp;
 	struct fnic *fnic;
 	struct fnic_io_req *io_req = NULL;
@@ -2207,7 +2207,7 @@ int fnic_device_reset(struct scsi_cmnd *sc)
 	fnic = lport_priv(lp);
 	fnic_stats = &fnic->fnic_stats;
 	reset_stats = &fnic->fnic_stats.reset_stats;
-
+	tag = fnic->fnic_max_tag_id - 1;
 	atomic64_inc(&reset_stats->device_resets);
 
 	FNIC_SCSI_DBG(KERN_DEBUG, fnic->lport->host,
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
index a47bcce3c9c7..844efffcfe27 100644
--- a/drivers/scsi/hpsa.c
+++ b/drivers/scsi/hpsa.c
@@ -282,7 +282,7 @@ static int hpsa_scan_finished(struct Scsi_Host *sh,
 	unsigned long elapsed_time);
 static int hpsa_change_queue_depth(struct scsi_device *sdev, int qdepth);
 
-static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd);
+static int hpsa_eh_device_reset_handler(struct scsi_device *sdev);
 static int hpsa_slave_alloc(struct scsi_device *sdev);
 static int hpsa_slave_configure(struct scsi_device *sdev);
 static void hpsa_slave_destroy(struct scsi_device *sdev);
@@ -6021,7 +6021,7 @@ static int wait_for_device_to_become_ready(struct ctlr_info *h,
 /* Need at least one of these error handlers to keep ../scsi/hosts.c from
  * complaining.  Doing a host- or bus-reset can't do anything good here.
  */
-static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
+static int hpsa_eh_device_reset_handler(struct scsi_device *sdev)
 {
 	int rc = SUCCESS;
 	int i;
@@ -6032,7 +6032,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 	unsigned long flags;
 
 	/* find the controller to which the command to be aborted was sent */
-	h = sdev_to_hba(scsicmd->device);
+	h = sdev_to_hba(sdev);
 	if (h == NULL) /* paranoia */
 		return FAILED;
 
@@ -6045,7 +6045,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 		goto return_reset_status;
 	}
 
-	dev = scsicmd->device->hostdata;
+	dev = sdev->hostdata;
 	if (!dev) {
 		dev_err(&h->pdev->dev, "%s: device lookup failed\n", __func__);
 		rc = FAILED;
@@ -6060,8 +6060,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 	/* if controller locked up, we can guarantee command won't complete */
 	if (lockup_detected(h)) {
 		snprintf(msg, sizeof(msg),
-			 "cmd %d RESET FAILED, lockup detected",
-			 hpsa_get_cmd_index(scsicmd));
+			 "RESET FAILED, lockup detected");
 		hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 		rc = FAILED;
 		goto return_reset_status;
@@ -6070,8 +6069,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)
 	/* this reset request might be the result of a lockup; check */
 	if (detect_controller_lockup(h)) {
 		snprintf(msg, sizeof(msg),
-			 "cmd %d RESET FAILED, new lockup detected",
-			 hpsa_get_cmd_index(scsicmd));
+			 "RESET FAILED, new lockup detected");
 		hpsa_show_dev_msg(KERN_WARNING, h, dev, msg);
 		rc = FAILED;
 		goto return_reset_status;
diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
index 9b9f6a0122e4..06dfff541f24 100644
--- a/drivers/scsi/ibmvscsi/ibmvfc.c
+++ b/drivers/scsi/ibmvscsi/ibmvfc.c
@@ -2883,14 +2883,13 @@ static int ibmvfc_eh_abort_handler(struct scsi_cmnd *cmd)
 
 /**
  * ibmvfc_eh_device_reset_handler - Reset a single LUN
- * @cmd:	scsi command struct
+ * @sdev:	scsi devicestruct
  *
  * Returns:
  *	SUCCESS / FAST_IO_FAIL / FAILED
  **/
-static int ibmvfc_eh_device_reset_handler(struct scsi_cmnd *cmd)
+static int ibmvfc_eh_device_reset_handler(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmd->device;
 	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	struct ibmvfc_host *vhost = shost_priv(sdev->host);
 	int cancel_rc, block_rc, reset_rc = 0;
diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
index 892d79e2e7e1..2fd63fc85b63 100644
--- a/drivers/scsi/ibmvscsi/ibmvscsi.c
+++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
@@ -1624,16 +1624,16 @@ static int ibmvscsi_eh_abort_handler(struct scsi_cmnd *cmd)
  * template send this over to the server and wait synchronously for the 
  * response
  */
-static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
+static int ibmvscsi_eh_device_reset_handler(struct scsi_device *sdev)
 {
-	struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
+	struct ibmvscsi_host_data *hostdata = shost_priv(sdev->host);
 	struct srp_tsk_mgmt *tsk_mgmt;
 	struct srp_event_struct *evt;
 	struct srp_event_struct *tmp_evt, *pos;
 	union viosrp_iu srp_rsp;
 	int rsp_rc;
 	unsigned long flags;
-	u16 lun = lun_from_dev(cmd->device);
+	u16 lun = lun_from_dev(sdev);
 	unsigned long wait_switch = 0;
 
 	spin_lock_irqsave(hostdata->host->host_lock, flags);
@@ -1642,7 +1642,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 		evt = get_event_struct(&hostdata->pool);
 		if (evt == NULL) {
 			spin_unlock_irqrestore(hostdata->host->host_lock, flags);
-			sdev_printk(KERN_ERR, cmd->device,
+			sdev_printk(KERN_ERR, sdev,
 				"failed to allocate reset event\n");
 			return FAILED;
 		}
@@ -1676,12 +1676,12 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 	spin_unlock_irqrestore(hostdata->host->host_lock, flags);
 
 	if (rsp_rc != 0) {
-		sdev_printk(KERN_ERR, cmd->device,
+		sdev_printk(KERN_ERR, sdev,
 			    "failed to send reset event. rc=%d\n", rsp_rc);
 		return FAILED;
 	}
 
-	sdev_printk(KERN_INFO, cmd->device, "resetting device. lun 0x%llx\n",
+	sdev_printk(KERN_INFO, sdev, "resetting device. lun 0x%llx\n",
 		    (((u64) lun) << 48));
 
 	wait_for_completion(&evt->comp);
@@ -1689,7 +1689,8 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 	/* make sure we got a good response */
 	if (unlikely(srp_rsp.srp.rsp.opcode != SRP_RSP)) {
 		if (printk_ratelimit())
-			sdev_printk(KERN_WARNING, cmd->device, "reset bad SRP RSP type %d\n",
+			sdev_printk(KERN_WARNING, sdev,
+				    "reset bad SRP RSP type %d\n",
 				    srp_rsp.srp.rsp.opcode);
 		return FAILED;
 	}
@@ -1701,7 +1702,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 
 	if (rsp_rc) {
 		if (printk_ratelimit())
-			sdev_printk(KERN_WARNING, cmd->device,
+			sdev_printk(KERN_WARNING, sdev,
 				    "reset code %d for task tag 0x%llx\n",
 				    rsp_rc, tsk_mgmt->task_tag);
 		return FAILED;
@@ -1712,7 +1713,7 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
 	 */
 	spin_lock_irqsave(hostdata->host->host_lock, flags);
 	list_for_each_entry_safe(tmp_evt, pos, &hostdata->sent, list) {
-		if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == cmd->device)) {
+		if ((tmp_evt->cmnd) && (tmp_evt->cmnd->device == sdev)) {
 			if (tmp_evt->cmnd)
 				tmp_evt->cmnd->result = (DID_RESET << 16);
 			list_del(&tmp_evt->list);
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 29893dae7f24..c980c4c58a29 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -5326,7 +5326,7 @@ static int ipr_sata_reset(struct ata_link *link, unsigned int *classes,
 
 /**
  * __ipr_eh_dev_reset - Reset the device
- * @scsi_cmd:	scsi command struct
+ * @scsi_dev:	scsi device struct
  *
  * This function issues a device reset to the affected device.
  * A LUN reset will be sent to the device first. If that does
@@ -5335,7 +5335,7 @@ static int ipr_sata_reset(struct ata_link *link, unsigned int *classes,
  * Return value:
  *	SUCCESS / FAILED
  **/
-static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd)
+static int __ipr_eh_dev_reset(struct scsi_device *scsi_dev)
 {
 	struct ipr_cmnd *ipr_cmd;
 	struct ipr_ioa_cfg *ioa_cfg;
@@ -5345,8 +5345,8 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd)
 	struct ipr_hrr_queue *hrrq;
 
 	ENTER;
-	ioa_cfg = (struct ipr_ioa_cfg *) scsi_cmd->device->host->hostdata;
-	res = scsi_cmd->device->hostdata;
+	ioa_cfg = (struct ipr_ioa_cfg *) scsi_dev->host->hostdata;
+	res = scsi_dev->hostdata;
 
 	/*
 	 * If we are currently going through reset/reload, return failed. This will force the
@@ -5363,7 +5363,8 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd)
 		for (i = hrrq->min_cmd_id; i <= hrrq->max_cmd_id; i++) {
 			ipr_cmd = ioa_cfg->ipr_cmnd_list[i];
 
-			if (ipr_cmd->ioarcb.res_handle == res->res_handle) {
+			if (ipr_cmd->scsi_cmd &&
+			    ipr_cmd->scsi_cmd->device == scsi_dev) {
 				if (!ipr_cmd->qc)
 					continue;
 				if (ipr_cmnd_is_free(ipr_cmd))
@@ -5379,13 +5380,13 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd)
 		spin_unlock(&hrrq->_lock);
 	}
 	res->resetting_device = 1;
-	scmd_printk(KERN_ERR, scsi_cmd, "Resetting device\n");
+	sdev_printk(KERN_ERR, scsi_dev, "Resetting device\n");
 
 	if (ipr_is_gata(res) && res->sata_port) {
 		ap = res->sata_port->ap;
-		spin_unlock_irq(scsi_cmd->device->host->host_lock);
+		spin_unlock_irq(scsi_dev->host->host_lock);
 		ata_std_error_handler(ap);
-		spin_lock_irq(scsi_cmd->device->host->host_lock);
+		spin_lock_irq(scsi_dev->host->host_lock);
 	} else
 		rc = ipr_device_reset(ioa_cfg, res);
 	res->resetting_device = 0;
@@ -5395,27 +5396,27 @@ static int __ipr_eh_dev_reset(struct scsi_cmnd *scsi_cmd)
 	return rc ? FAILED : SUCCESS;
 }
 
-static int ipr_eh_dev_reset(struct scsi_cmnd *cmd)
+static int ipr_eh_dev_reset(struct scsi_device *sdev)
 {
 	int rc;
 	struct ipr_ioa_cfg *ioa_cfg;
 	struct ipr_resource_entry *res;
 
-	ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata;
-	res = cmd->device->hostdata;
+	ioa_cfg = (struct ipr_ioa_cfg *) sdev->host->hostdata;
+	res = sdev->hostdata;
 
 	if (!res)
 		return FAILED;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = __ipr_eh_dev_reset(cmd);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(sdev->host->host_lock);
+	rc = __ipr_eh_dev_reset(sdev);
+	spin_unlock_irq(sdev->host->host_lock);
 
 	if (rc == SUCCESS) {
 		if (ipr_is_gata(res) && res->sata_port)
 			rc = ipr_wait_for_ops(ioa_cfg, res, ipr_match_res);
 		else
-			rc = ipr_wait_for_ops(ioa_cfg, cmd->device, ipr_match_lun);
+			rc = ipr_wait_for_ops(ioa_cfg, sdev, ipr_match_lun);
 	}
 
 	return rc;
diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
index ab4a1c01a353..c71e24730ac2 100644
--- a/drivers/scsi/libfc/fc_fcp.c
+++ b/drivers/scsi/libfc/fc_fcp.c
@@ -2144,16 +2144,15 @@ EXPORT_SYMBOL(fc_eh_abort);
 
 /**
  * fc_eh_device_reset() - Reset a single LUN
- * @sc_cmd: The SCSI command which identifies the device whose
- *	    LUN is to be reset
+ * @sdev: The SCSI device whose LUN is to be reset
  *
  * Set from SCSI host template.
  */
-int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
+int fc_eh_device_reset(struct scsi_device *sdev)
 {
 	struct fc_lport *lport;
 	struct fc_fcp_pkt *fsp;
-	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
+	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	int rc = FAILED;
 	int rval;
 
@@ -2161,7 +2160,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
 	if (rval)
 		return rval;
 
-	lport = shost_priv(sc_cmd->device->host);
+	lport = shost_priv(sdev->host);
 
 	if (lport->state != LPORT_ST_READY)
 		return rc;
@@ -2184,7 +2183,7 @@ int fc_eh_device_reset(struct scsi_cmnd *sc_cmd)
 	/*
 	 * flush outstanding commands
 	 */
-	rc = fc_lun_reset(lport, fsp, scmd_id(sc_cmd), sc_cmd->device->lun);
+	rc = fc_lun_reset(lport, fsp, sdev->id, sdev->lun);
 	fsp->state = FC_SRB_FREE;
 	fc_fcp_pkt_release(fsp);
 
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c
index ac3708b65938..c76df7152b5c 100644
--- a/drivers/scsi/libiscsi.c
+++ b/drivers/scsi/libiscsi.c
@@ -2390,17 +2390,17 @@ int iscsi_eh_abort(struct scsi_cmnd *sc)
 }
 EXPORT_SYMBOL_GPL(iscsi_eh_abort);
 
-static void iscsi_prep_lun_reset_pdu(struct scsi_cmnd *sc, struct iscsi_tm *hdr)
+static void iscsi_prep_lun_reset_pdu(struct scsi_device *sdev, struct iscsi_tm *hdr)
 {
 	memset(hdr, 0, sizeof(*hdr));
 	hdr->opcode = ISCSI_OP_SCSI_TMFUNC | ISCSI_OP_IMMEDIATE;
 	hdr->flags = ISCSI_TM_FUNC_LOGICAL_UNIT_RESET & ISCSI_FLAG_TM_FUNC_MASK;
 	hdr->flags |= ISCSI_FLAG_CMD_FINAL;
-	int_to_scsilun(sc->device->lun, &hdr->lun);
+	int_to_scsilun(sdev->lun, &hdr->lun);
 	hdr->rtt = RESERVED_ITT;
 }
 
-int iscsi_eh_device_reset(struct scsi_cmnd *sc)
+int iscsi_eh_device_reset(struct scsi_device *sdev)
 {
 	struct iscsi_cls_session *cls_session;
 	struct iscsi_session *session;
@@ -2408,11 +2408,10 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
 	struct iscsi_tm *hdr;
 	int rc = FAILED;
 
-	cls_session = starget_to_session(scsi_target(sc->device));
+	cls_session = starget_to_session(scsi_target(sdev));
 	session = cls_session->dd_data;
 
-	ISCSI_DBG_EH(session, "LU Reset [sc %p lun %llu]\n", sc,
-		     sc->device->lun);
+	ISCSI_DBG_EH(session, "LU Reset [lun %llu]\n", sdev->lun);
 
 	mutex_lock(&session->eh_mutex);
 	spin_lock_bh(&session->frwd_lock);
@@ -2430,7 +2429,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
 	session->tmf_state = TMF_QUEUED;
 
 	hdr = &session->tmhdr;
-	iscsi_prep_lun_reset_pdu(sc, hdr);
+	iscsi_prep_lun_reset_pdu(sdev, hdr);
 
 	if (iscsi_exec_task_mgmt_fn(conn, hdr, session->age,
 				    session->lu_reset_timeout)) {
@@ -2457,7 +2456,7 @@ int iscsi_eh_device_reset(struct scsi_cmnd *sc)
 
 	spin_lock_bh(&session->frwd_lock);
 	memset(hdr, 0, sizeof(*hdr));
-	fail_scsi_tasks(conn, sc->device->lun, DID_ERROR);
+	fail_scsi_tasks(conn, sdev->lun, DID_ERROR);
 	session->tmf_state = TMF_INITIAL;
 	spin_unlock_bh(&session->frwd_lock);
 
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index ae7e093eff4b..e8a8c14ad1af 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -490,18 +490,18 @@ int sas_eh_abort_handler(struct scsi_cmnd *cmd)
 EXPORT_SYMBOL_GPL(sas_eh_abort_handler);
 
 /* Attempt to send a LUN reset message to a device */
-int sas_eh_device_reset_handler(struct scsi_cmnd *cmd)
+int sas_eh_device_reset_handler(struct scsi_device *sdev)
 {
 	int res;
 	struct scsi_lun lun;
-	struct Scsi_Host *host = cmd->device->host;
-	struct domain_device *dev = cmd_to_domain_dev(cmd);
+	struct Scsi_Host *host = sdev->host;
+	struct domain_device *dev = sdev_to_domain_dev(sdev);
 	struct sas_internal *i = to_sas_internal(host->transportt);
 
 	if (current != host->ehandler)
-		return sas_queue_reset(dev, SAS_DEV_LU_RESET, cmd->device->lun, 0);
+		return sas_queue_reset(dev, SAS_DEV_LU_RESET, sdev->lun, 0);
 
-	int_to_scsilun(cmd->device->lun, &lun);
+	int_to_scsilun(sdev->lun, &lun);
 
 	if (!i->dft->lldd_lu_reset)
 		return FAILED;
@@ -546,7 +546,7 @@ static int try_to_reset_cmd_device(struct scsi_cmnd *cmd)
 	if (!shost->hostt->eh_device_reset_handler)
 		goto try_target_reset;
 
-	res = shost->hostt->eh_device_reset_handler(cmd);
+	res = shost->hostt->eh_device_reset_handler(cmd->device);
 	if (res == SUCCESS)
 		return res;
 
diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
index 834c3f31f327..3895ab41a1cb 100644
--- a/drivers/scsi/lpfc/lpfc_scsi.c
+++ b/drivers/scsi/lpfc/lpfc_scsi.c
@@ -6301,15 +6301,15 @@ lpfc_reset_flush_io_context(struct lpfc_vport *vport, uint16_t tgt_id,
  *  0x2002 - Success
  **/
 static int
-lpfc_device_reset_handler(struct scsi_cmnd *cmnd)
+lpfc_device_reset_handler(struct scsi_device *sdev)
 {
-	struct Scsi_Host  *shost = cmnd->device->host;
-	struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
+	struct Scsi_Host  *shost = sdev->host;
+	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
 	struct lpfc_rport_data *rdata;
 	struct lpfc_nodelist *pnode;
-	unsigned tgt_id = cmnd->device->id;
-	uint64_t lun_id = cmnd->device->lun;
+	unsigned tgt_id = sdev->id;
+	uint64_t lun_id = sdev->lun;
 	struct lpfc_scsi_event_header scsi_event;
 	int status;
 	u32 logit = LOG_FCP;
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 2c4a2f31be76..f215b866bddb 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -3467,30 +3467,28 @@ static int mpi3mr_eh_target_reset(struct scsi_target *starget)
 
 /**
  * mpi3mr_eh_dev_reset- Device reset error handling callback
- * @scmd: SCSI command reference
+ * @sdev: SCSI device reference
  *
- * Issue lun reset Task Management and verify the scmd is
- * terminated successfully and return status accordingly.
+ * Issue lun reset Task Management and return status accordingly.
  *
- * Return: SUCCESS of successful termination of the scmd else
+ * Return: SUCCESS of successful lun reset else
  *         FAILED
  */
-static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd)
+static int mpi3mr_eh_dev_reset(struct scsi_device *sdev)
 {
-	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
+	struct mpi3mr_ioc *mrioc = shost_priv(sdev->host);
 	struct mpi3mr_stgt_priv_data *stgt_priv_data;
 	struct mpi3mr_sdev_priv_data *sdev_priv_data;
 	u16 dev_handle;
 	u8 resp_code = 0;
 	int retval = FAILED, ret = 0;
 
-	sdev_printk(KERN_INFO, scmd->device,
-	    "Attempting Device(lun) Reset! scmd(%p)\n", scmd);
-	scsi_print_command(scmd);
+	sdev_printk(KERN_INFO, sdev,
+	    "Attempting Device(lun) Reset!\n");
 
-	sdev_priv_data = scmd->device->hostdata;
+	sdev_priv_data = sdev->hostdata;
 	if (!sdev_priv_data || !sdev_priv_data->tgt_priv_data) {
-		sdev_printk(KERN_INFO, scmd->device,
+		sdev_printk(KERN_INFO, sdev,
 		    "SCSI device is not available\n");
 		retval = SUCCESS;
 		goto out;
@@ -3499,34 +3497,34 @@ static int mpi3mr_eh_dev_reset(struct scsi_cmnd *scmd)
 	stgt_priv_data = sdev_priv_data->tgt_priv_data;
 	dev_handle = stgt_priv_data->dev_handle;
 	if (stgt_priv_data->dev_removed) {
-		sdev_printk(KERN_INFO, scmd->device,
+		sdev_printk(KERN_INFO, sdev,
 		    "%s: device(handle = 0x%04x) is removed, device(LUN) reset is not issued\n",
 		    mrioc->name, dev_handle);
 		retval = FAILED;
 		goto out;
 	}
-	sdev_printk(KERN_INFO, scmd->device,
+	sdev_printk(KERN_INFO, sdev,
 	    "Device(lun) Reset is issued to handle(0x%04x)\n", dev_handle);
 
 	ret = mpi3mr_issue_tm(mrioc,
 	    MPI3_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, dev_handle,
 	    sdev_priv_data->lun_id, MPI3MR_HOSTTAG_BLK_TMS,
-	    MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, scmd);
+	    MPI3MR_RESETTM_TIMEOUT, &mrioc->host_tm_cmds, &resp_code, NULL);
 
 	if (ret)
 		goto out;
 
 	if (sdev_priv_data->pend_count) {
-		sdev_printk(KERN_INFO, scmd->device,
+		sdev_printk(KERN_INFO, sdev,
 		    "%s: device has %d pending commands, device(LUN) reset is failed\n",
 		    mrioc->name, sdev_priv_data->pend_count);
 		goto out;
 	}
 	retval = SUCCESS;
 out:
-	sdev_printk(KERN_INFO, scmd->device,
-	    "%s: device(LUN) reset is %s for scmd(%p)\n", mrioc->name,
-	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	sdev_printk(KERN_INFO, sdev,
+	    "%s: device(LUN) reset is %s\n", mrioc->name,
+	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
 
 	return retval;
 }
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index 4c84fd9774ab..f59a0749ae8c 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3366,9 +3366,9 @@ scsih_abort(struct scsi_cmnd *scmd)
  * Return: SUCCESS if command aborted else FAILED
  */
 static int
-scsih_dev_reset(struct scsi_cmnd *scmd)
+scsih_dev_reset(struct scsi_device *sdev)
 {
-	struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
+	struct MPT3SAS_ADAPTER *ioc = shost_priv(sdev->host);
 	struct MPT3SAS_DEVICE *sas_device_priv_data;
 	struct _sas_device *sas_device = NULL;
 	struct _pcie_device *pcie_device = NULL;
@@ -3377,20 +3377,17 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
 	u8	tr_timeout = 30;
 	int r;
 
-	struct scsi_target *starget = scmd->device->sdev_target;
+	struct scsi_target *starget = sdev->sdev_target;
 	struct MPT3SAS_TARGET *target_priv_data = starget->hostdata;
 
-	sdev_printk(KERN_INFO, scmd->device,
-	    "attempting device reset! scmd(0x%p)\n", scmd);
-	_scsih_tm_display_info(ioc, scmd);
+	sdev_printk(KERN_INFO, sdev,
+	    "attempting device reset!\n");
 
-	sas_device_priv_data = scmd->device->hostdata;
+	sas_device_priv_data = sdev->hostdata;
 	if (!sas_device_priv_data || !sas_device_priv_data->sas_target ||
 	    ioc->remove_host) {
-		sdev_printk(KERN_INFO, scmd->device,
-		    "device been deleted! scmd(0x%p)\n", scmd);
-		scmd->result = DID_NO_CONNECT << 16;
-		scsi_done(scmd);
+		sdev_printk(KERN_INFO, sdev,
+		    "device been deleted!\n");
 		r = SUCCESS;
 		goto out;
 	}
@@ -3407,7 +3404,6 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
 		handle = sas_device_priv_data->sas_target->handle;
 
 	if (!handle) {
-		scmd->result = DID_RESET << 16;
 		r = FAILED;
 		goto out;
 	}
@@ -3421,16 +3417,16 @@ scsih_dev_reset(struct scsi_cmnd *scmd)
 	} else
 		tr_method = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
 
-	r = mpt3sas_scsih_issue_locked_tm(ioc, handle, scmd->device->channel,
-		scmd->device->id, scmd->device->lun,
+	r = mpt3sas_scsih_issue_locked_tm(ioc, handle, sdev->channel,
+		sdev->id, sdev->lun,
 		MPI2_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET, 0, 0,
 		tr_timeout, tr_method);
 	/* Check for busy commands after reset */
-	if (r == SUCCESS && scsi_device_busy(scmd->device))
+	if (r == SUCCESS && scsi_device_busy(sdev))
 		r = FAILED;
  out:
-	sdev_printk(KERN_INFO, scmd->device, "device reset: %s scmd(0x%p)\n",
-	    ((r == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	sdev_printk(KERN_INFO, sdev, "device reset: %s\n",
+	    ((r == SUCCESS) ? "SUCCESS" : "FAILED"));
 
 	if (sas_device)
 		sas_device_put(sas_device);
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index 8636f0053c02..c2b522a194fc 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -297,8 +297,6 @@ static        int        nsp_show_info  (struct seq_file *m,
 static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
 
 /* Error handler */
-/*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
-/*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
 static int nsp_eh_bus_reset    (struct Scsi_Host *host, int channel);
 static int nsp_eh_host_reset   (struct Scsi_Host *host);
 static int nsp_bus_reset       (nsp_hw_data *data);
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 44ff1f7fbbc0..86d8e6a06831 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3014,11 +3014,11 @@ static int pmcraid_eh_abort_handler(struct scsi_cmnd *scsi_cmd)
  * Return value
  *	SUCCESS or FAILED
  */
-static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_device_reset_handler(struct scsi_device *sdev)
 {
-	scmd_printk(KERN_INFO, scmd,
+	sdev_printk(KERN_INFO, sdev,
 		    "resetting device due to an I/O command timeout.\n");
-	return pmcraid_reset_device(scmd->device,
+	return pmcraid_reset_device(sdev,
 				    PMCRAID_INTERNAL_TIMEOUT,
 				    RESET_DEVICE_LUN);
 }
diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index c90a2c449978..21c94ba448af 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -863,12 +863,12 @@ static int qedf_eh_target_reset(struct scsi_target *starget)
 	return qedf_initiate_tmf(rport, 0, FCP_TMF_TGT_RESET);
 }
 
-static int qedf_eh_device_reset(struct scsi_cmnd *sc_cmd)
+static int qedf_eh_device_reset(struct scsi_device *sdev)
 {
-	struct fc_rport *rport = starget_to_rport(scsi_target(sc_cmd->device));
+	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 
 	QEDF_ERR(NULL, "LUN RESET Issued...\n");
-	return qedf_initiate_tmf(rport, sc_cmd->device->lun, FCP_TMF_LUN_RESET);
+	return qedf_initiate_tmf(rport, sdev->lun, FCP_TMF_LUN_RESET);
 }
 
 bool qedf_wait_for_upload(struct qedf_ctx *qedf)
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index f32f00c7a390..44f4359777ae 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -963,13 +963,24 @@ qla1280_eh_abort(struct scsi_cmnd * cmd)
  *     Reset the specified SCSI device
  **************************************************************************/
 static int
-qla1280_eh_device_reset(struct scsi_cmnd *cmd)
+qla1280_eh_device_reset(struct scsi_device *sdev)
 {
-	int rc;
+	struct Scsi_Host *shost = sdev->host;
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
+	int rc = FAILED;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = qla1280_error_action(cmd, DEVICE_RESET);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	if (qla1280_verbose)
+		printk(KERN_INFO
+		       "scsi(%ld:%d:%d:%llu): Queueing device reset "
+		       "command.\n", ha->host_no, sdev->channel,
+		       sdev->id, sdev->lun);
+	if (qla1280_device_reset(ha, sdev->channel, sdev->id) == 0) {
+		/* issued device reset, set wait conditions */
+		rc = qla1280_wait_for_pending_commands(ha,
+			sdev->channel, sdev->id);
+	}
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 35cf2c3dbe01..1bcbadb8b664 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1395,9 +1395,8 @@ static char *reset_errors[] = {
 };
 
 static int
-qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmd->device;
 	scsi_qla_host_t *vha = shost_priv(sdev->host);
 	struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
 	fc_port_t *fcport = (struct fc_port *) sdev->hostdata;
@@ -1423,41 +1422,40 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
 		return SUCCESS;
 
 	ql_log(ql_log_info, vha, 0x8009,
-	    "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no,
-	    sdev->id, sdev->lun, cmd);
+	    "DEVICE RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no,
+	    sdev->id, sdev->lun);
 
 	err = 0;
 	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800a,
-		    "Wait for hba online failed for cmd=%p.\n", cmd);
+		    "Wait for hba online failed.\n");
 		goto eh_reset_failed;
 	}
 	err = 2;
 	if (ha->isp_ops->lun_reset(fcport, sdev->lun, 1)
 		!= QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800c,
-		    "do_reset failed for cmd=%p.\n", cmd);
+		    "do_reset failed.\n");
 		goto eh_reset_failed;
 	}
 	err = 3;
 	if (qla2x00_eh_wait_for_pending_commands(vha, sdev->id,
 	    sdev->lun, WAIT_LUN) != QLA_SUCCESS) {
 		ql_log(ql_log_warn, vha, 0x800d,
-		    "wait for pending cmds failed for cmd=%p.\n", cmd);
+		    "wait for pending cmds failed.\n");
 		goto eh_reset_failed;
 	}
 
 	ql_log(ql_log_info, vha, 0x800e,
-	    "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n",
-	    vha->host_no, sdev->id, sdev->lun, cmd);
+	    "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu.\n",
+	    vha->host_no, sdev->id, sdev->lun);
 
 	return SUCCESS;
 
 eh_reset_failed:
 	ql_log(ql_log_info, vha, 0x800f,
-	    "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n",
-	    reset_errors[err], vha->host_no, sdev->id, sdev->lun,
-	    cmd);
+	    "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu.\n",
+	    reset_errors[err], vha->host_no, sdev->id, sdev->lun);
 	vha->reset_cmd_err_cnt++;
 	return FAILED;
 }
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 90828d4eb26d..6a6c159b618c 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -157,7 +157,7 @@ static int qla4xxx_get_host_stats(struct Scsi_Host *shost, char *buf, int len);
  */
 static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
 static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
-static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
+static int qla4xxx_eh_device_reset(struct scsi_device *sdev);
 static int qla4xxx_eh_target_reset(struct scsi_target *starget);
 static int qla4xxx_eh_host_reset(struct Scsi_Host *shost);
 static int qla4xxx_slave_alloc(struct scsi_device *device);
@@ -9260,9 +9260,8 @@ static int qla4xxx_eh_abort(struct scsi_cmnd *cmd)
  * This routine is called by the Linux OS to reset all luns on the
  * specified target.
  **/
-static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
+static int qla4xxx_eh_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmd->device;
 	struct scsi_qla_host *ha = to_qla_host(sdev->host);
 	struct iscsi_cls_session *session;
 	struct ddb_entry *ddb_entry = sdev->hostdata;
@@ -9280,13 +9279,11 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
 
 	ql4_printk(KERN_INFO, ha,
 		   "scsi%ld:%d:%d:%llu: DEVICE RESET ISSUED.\n", ha->host_no,
-		   cmd->device->channel, cmd->device->id, cmd->device->lun);
+		   sdev->channel, sdev->id, sdev->lun);
 
 	DEBUG2(printk(KERN_INFO
-		      "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x,"
-		      "dpc_flags=%lx, status=%x allowed=%d\n", ha->host_no,
-		      cmd, jiffies, scsi_cmd_to_rq(cmd)->timeout / HZ,
-		      ha->dpc_flags, cmd->result, cmd->allowed));
+		      "scsi%ld: DEVICE_RESET dpc_flags=%lx\n",
+		      ha->host_no, ha->dpc_flags));
 
 	rval = qla4xxx_isp_check_reg(ha);
 	if (rval != QLA_SUCCESS) {
@@ -9295,14 +9292,13 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
 	}
 
 	/* FIXME: wait for hba to go online */
-	stat = qla4xxx_reset_lun(ha, ddb_entry, cmd->device->lun);
+	stat = qla4xxx_reset_lun(ha, ddb_entry, sdev->lun);
 	if (stat != QLA_SUCCESS) {
 		ql4_printk(KERN_INFO, ha, "DEVICE RESET FAILED. %d\n", stat);
 		goto eh_dev_reset_done;
 	}
 
-	if (qla4xxx_eh_wait_for_commands(ha, scsi_target(cmd->device),
-					 cmd->device)) {
+	if (qla4xxx_eh_wait_for_commands(ha, scsi_target(sdev), sdev)) {
 		ql4_printk(KERN_INFO, ha,
 			   "DEVICE RESET FAILED - waiting for "
 			   "commands.\n");
@@ -9310,14 +9306,13 @@ static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd)
 	}
 
 	/* Send marker. */
-	if (qla4xxx_send_marker_iocb(ha, ddb_entry, cmd->device->lun,
+	if (qla4xxx_send_marker_iocb(ha, ddb_entry, sdev->lun,
 		MM_LUN_RESET) != QLA_SUCCESS)
 		goto eh_dev_reset_done;
 
 	ql4_printk(KERN_INFO, ha,
 		   "scsi(%ld:%d:%d:%llu): DEVICE RESET SUCCEEDED.\n",
-		   ha->host_no, cmd->device->channel, cmd->device->id,
-		   cmd->device->lun);
+		   ha->host_no, sdev->channel, sdev->id, sdev->lun);
 
 	ret = SUCCESS;
 
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 2e9daf8c7e83..b7f3d728d13e 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5272,19 +5272,17 @@ static int scsi_debug_abort(struct scsi_cmnd *SCpnt)
 	return SUCCESS;
 }
 
-static int scsi_debug_device_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_device_reset(struct scsi_device * sdp)
 {
+	struct sdebug_dev_info *devip =
+		(struct sdebug_dev_info *)sdp->hostdata;
+
 	++num_dev_resets;
-	if (SCpnt && SCpnt->device) {
-		struct scsi_device *sdp = SCpnt->device;
-		struct sdebug_dev_info *devip =
-				(struct sdebug_dev_info *)sdp->hostdata;
 
-		if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
-			sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
-		if (devip)
-			set_bit(SDEBUG_UA_POR, devip->uas_bm);
-	}
+	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
+		sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
+	if (devip)
+		set_bit(SDEBUG_UA_POR, devip->uas_bm);
 	return SUCCESS;
 }
 
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 3ee4393a1f1e..93f7006982d8 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -940,7 +940,7 @@ static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
 	if (!hostt->eh_device_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_device_reset_handler(scmd);
+	rtn = hostt->eh_device_reset_handler(scmd->device);
 	if (rtn == SUCCESS)
 		__scsi_report_device_reset(scmd->device, NULL);
 	return rtn;
@@ -1225,6 +1225,7 @@ scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn)
  * scsi_eh_finish_cmd - Handle a cmd that eh is finished with.
  * @scmd:	Original SCSI cmd that eh has finished.
  * @done_q:	Queue for processed commands.
+ * @result:	Final command status to be set
  *
  * Notes:
  *    We don't want to use the normal command completion while we are are
@@ -1233,10 +1234,18 @@ scsi_eh_action(struct scsi_cmnd *scmd, enum scsi_disposition rtn)
  *    keep a list of pending commands for final completion, and once we
  *    are ready to leave error handling we handle completion for real.
  */
-void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
+void __scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q,
+			int host_byte)
 {
+	if (host_byte)
+		set_host_byte(scmd, host_byte);
 	list_move_tail(&scmd->eh_entry, done_q);
 }
+
+void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
+{
+	__scsi_eh_finish_cmd(scmd, done_q, 0);
+}
 EXPORT_SYMBOL(scsi_eh_finish_cmd);
 
 /**
@@ -1411,7 +1420,8 @@ static int scsi_eh_test_devices(struct list_head *cmd_list,
 				if (finish_cmds &&
 				    (try_stu ||
 				     scsi_eh_action(scmd, SUCCESS) == SUCCESS))
-					scsi_eh_finish_cmd(scmd, done_q);
+					__scsi_eh_finish_cmd(scmd, done_q,
+							     DID_RESET);
 				else
 					list_move_tail(&scmd->eh_entry, work_q);
 			}
@@ -1560,8 +1570,9 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
 							 work_q, eh_entry) {
 					if (scmd->device == sdev &&
 					    scsi_eh_action(scmd, rtn) != FAILED)
-						scsi_eh_finish_cmd(scmd,
-								   done_q);
+						__scsi_eh_finish_cmd(scmd,
+								     done_q,
+								     DID_RESET);
 				}
 			}
 		} else {
@@ -1629,7 +1640,8 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost,
 			if (rtn == SUCCESS)
 				list_move_tail(&scmd->eh_entry, &check_list);
 			else if (rtn == FAST_IO_FAIL)
-				scsi_eh_finish_cmd(scmd, done_q);
+				__scsi_eh_finish_cmd(scmd, done_q,
+						     DID_TRANSPORT_DISRUPTED);
 			else
 				/* push back on work queue for further processing */
 				list_move(&scmd->eh_entry, work_q);
@@ -1694,8 +1706,9 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
 			list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
 				if (channel == scmd_channel(scmd)) {
 					if (rtn == FAST_IO_FAIL)
-						scsi_eh_finish_cmd(scmd,
-								   done_q);
+						__scsi_eh_finish_cmd(scmd,
+								     done_q,
+								     DID_TRANSPORT_DISRUPTED);
 					else
 						list_move_tail(&scmd->eh_entry,
 							       &check_list);
@@ -1738,9 +1751,9 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost,
 		if (rtn == SUCCESS) {
 			list_splice_init(work_q, &check_list);
 		} else if (rtn == FAST_IO_FAIL) {
-			list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
-					scsi_eh_finish_cmd(scmd, done_q);
-			}
+			list_for_each_entry_safe(scmd, next, work_q, eh_entry)
+				__scsi_eh_finish_cmd(scmd, done_q,
+						     DID_TRANSPORT_DISRUPTED);
 		} else {
 			SCSI_LOG_ERROR_RECOVERY(3,
 				shost_printk(KERN_INFO, shost,
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 7c0d069a3158..cca67898384e 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6289,24 +6289,23 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info,
 	return rc;
 }
 
-static int pqi_eh_device_reset_handler(struct scsi_cmnd *scmd)
+static int pqi_eh_device_reset_handler(struct scsi_device *sdev)
 {
 	int rc;
 	struct Scsi_Host *shost;
 	struct pqi_ctrl_info *ctrl_info;
 	struct pqi_scsi_dev *device;
 
-	shost = scmd->device->host;
+	shost = sdev->host;
 	ctrl_info = shost_to_hba(shost);
-	device = scmd->device->hostdata;
+	device = sdev->hostdata;
 
 	mutex_lock(&ctrl_info->lun_reset_mutex);
 
 	dev_err(&ctrl_info->pci_dev->dev,
-		"resetting scsi %d:%d:%d:%d due to cmd 0x%02x\n",
+		"resetting scsi %d:%d:%d:%d\n",
 		shost->host_no,
-		device->bus, device->target, device->lun,
-		scmd->cmd_len > 0 ? scmd->cmnd[0] : 0xff);
+		device->bus, device->target, device->lun);
 
 	pqi_check_ctrl_health(ctrl_info);
 	if (pqi_ctrl_offline(ctrl_info))
diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h
index 79916e803b26..cab74d300eca 100644
--- a/drivers/scsi/snic/snic.h
+++ b/drivers/scsi/snic/snic.h
@@ -379,7 +379,7 @@ extern const struct attribute_group *snic_host_groups[];
 
 int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int snic_abort_cmd(struct scsi_cmnd *);
-int snic_device_reset(struct scsi_cmnd *);
+int snic_device_reset(struct scsi_device *);
 int snic_host_reset(struct Scsi_Host *);
 void snic_shutdown_scsi_cleanup(struct snic *);
 
diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c
index 3722383fb529..8f459c9c407f 100644
--- a/drivers/scsi/snic/snic_scsi.c
+++ b/drivers/scsi/snic/snic_scsi.c
@@ -2126,15 +2126,15 @@ snic_unlink_and_release_req(struct snic *snic, struct scsi_cmnd *sc, int flag)
  * command on the LUN.
  */
 int
-snic_device_reset(struct scsi_cmnd *sc)
+snic_device_reset(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = sc->device;
 	struct Scsi_Host *shost = sdev->host;
 	struct snic *snic = shost_priv(shost);
 	struct snic_req_info *rqi = NULL;
 	int start_time = jiffies;
 	int ret = FAILED;
 	int dr_supp = 0;
+	struct scsi_cmnd tmf_sc, *sc = &tmf_sc;
 
 	SNIC_SCSI_DBG(shost, "dev_reset\n");
 	dr_supp = snic_dev_reset_supported(sdev);
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index d1f065d4bcce..376e661fd353 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6957,11 +6957,11 @@ int ufshcd_exec_raw_upiu_cmd(struct ufs_hba *hba,
 /**
  * ufshcd_eh_device_reset_handler - device reset handler registered to
  *                                    scsi layer.
- * @cmd: SCSI command pointer
+ * @sdev: SCSI device pointer
  *
  * Returns SUCCESS/FAILED
  */
-static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
+static int ufshcd_eh_device_reset_handler(struct scsi_device *sdev)
 {
 	struct Scsi_Host *host;
 	struct ufs_hba *hba;
@@ -6969,10 +6969,10 @@ static int ufshcd_eh_device_reset_handler(struct scsi_cmnd *cmd)
 	int err;
 	u8 resp = 0xF, lun;
 
-	host = cmd->device->host;
+	host = sdev->host;
 	hba = shost_priv(host);
 
-	lun = ufshcd_scsi_to_upiu_lun(cmd->device->lun);
+	lun = ufshcd_scsi_to_upiu_lun(sdev->lun);
 	err = ufshcd_issue_tm_cmd(hba, lun, 0, UFS_LOGICAL_RESET, &resp);
 	if (err || resp != UPIU_TASK_MANAGEMENT_FUNC_COMPL) {
 		if (!err)
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 578c4b6d0f7d..d69e37943130 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -630,12 +630,12 @@ static int virtscsi_tmf(struct virtio_scsi *vscsi, struct virtio_scsi_cmd *cmd)
 	return ret;
 }
 
-static int virtscsi_device_reset(struct scsi_cmnd *sc)
+static int virtscsi_device_reset(struct scsi_device *sdev)
 {
-	struct virtio_scsi *vscsi = shost_priv(sc->device->host);
+	struct virtio_scsi *vscsi = shost_priv(sdev->host);
 	struct virtio_scsi_cmd *cmd;
 
-	sdev_printk(KERN_INFO, sc->device, "device reset\n");
+	sdev_printk(KERN_INFO, sdev, "device reset\n");
 	cmd = mempool_alloc(virtscsi_cmd_pool, GFP_NOIO);
 	if (!cmd)
 		return FAILED;
@@ -646,9 +646,9 @@ static int virtscsi_device_reset(struct scsi_cmnd *sc)
 		.subtype = cpu_to_virtio32(vscsi->vdev,
 					     VIRTIO_SCSI_T_TMF_LOGICAL_UNIT_RESET),
 		.lun[0] = 1,
-		.lun[1] = sc->device->id,
-		.lun[2] = (sc->device->lun >> 8) | 0x40,
-		.lun[3] = sc->device->lun & 0xff,
+		.lun[1] = sdev->id,
+		.lun[2] = (sdev->lun >> 8) | 0x40,
+		.lun[3] = sdev->lun & 0xff,
 	};
 	return virtscsi_tmf(vscsi, cmd);
 }
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 9c62d446ea9e..1624c9b400e9 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -971,14 +971,14 @@ static int pvscsi_bus_reset(struct Scsi_Host *host, int channel)
 	return SUCCESS;
 }
 
-static int pvscsi_device_reset(struct scsi_cmnd *cmd)
+static int pvscsi_device_reset(struct scsi_device *sdev)
 {
-	struct Scsi_Host *host = cmd->device->host;
+	struct Scsi_Host *host = sdev->host;
 	struct pvscsi_adapter *adapter = shost_priv(host);
 	unsigned long flags;
 
-	scmd_printk(KERN_INFO, cmd, "SCSI device reset on scsi%u:%u\n",
-		    host->host_no, cmd->device->id);
+	sdev_printk(KERN_INFO, sdev, "SCSI device reset on scsi%u:%u\n",
+		    host->host_no, sdev->id);
 
 	/*
 	 * We don't want to queue new requests for this device after flushing
@@ -988,7 +988,7 @@ static int pvscsi_device_reset(struct scsi_cmnd *cmd)
 	spin_lock_irqsave(&adapter->hw_lock, flags);
 
 	pvscsi_process_request_ring(adapter);
-	ll_device_reset(adapter, cmd->device->id);
+	ll_device_reset(adapter, sdev->id);
 	pvscsi_process_completion_ring(adapter);
 
 	spin_unlock_irqrestore(&adapter->hw_lock, flags);
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index fd297c7517cd..1cda6f20ff88 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -510,10 +510,10 @@ static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device)
 	return SUCCESS;
 }
 
-static int wd719x_dev_reset(struct scsi_cmnd *cmd)
+static int wd719x_dev_reset(struct scsi_device *sdev)
 {
-	return wd719x_reset(cmd->device->host, WD719X_CMD_RESET,
-			    cmd->device->id);
+	return wd719x_reset(sdev->host, WD719X_CMD_RESET,
+			    sdev->id);
 }
 
 static int wd719x_bus_reset(struct Scsi_Host *host, int channel)
diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 9de099532f8b..3dd5d62d5433 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -592,21 +592,26 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,
  * We have to wait until an answer is returned. This answer contains the
  * result to be returned to the requestor.
  */
-static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
+static int scsifront_action_handler(struct scsi_device *sdev,
+				    struct scsi_cmnd *sc)
 {
-	struct Scsi_Host *host = sc->device->host;
+	struct Scsi_Host *host = sdev->host;
 	struct vscsifrnt_info *info = shost_priv(host);
-	struct vscsifrnt_shadow *shadow, *s = scsi_cmd_priv(sc);
+	struct vscsifrnt_shadow *shadow;
 	int err = 0;
 
 	shadow = kzalloc(sizeof(*shadow), GFP_NOIO);
 	if (!shadow)
 		return FAILED;
 
-	shadow->act = act;
+	shadow->act = sc ? VSCSIIF_ACT_SCSI_ABORT : VSCSIIF_ACT_SCSI_RESET;
 	shadow->rslt_reset = RSLT_RESET_WAITING;
 	shadow->sc = sc;
-	shadow->ref_rqid = s->rqid;
+	if (sc) {
+		struct vscsifrnt_shadow *s = scsi_cmd_priv(sc);
+
+		shadow->ref_rqid = s->rqid;
+	}
 	init_waitqueue_head(&shadow->wq_reset);
 
 	spin_lock_irq(host->host_lock);
@@ -615,7 +620,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
 		if (scsifront_enter(info))
 			goto fail;
 
-		if (!scsifront_do_request(sc->device, info, shadow))
+		if (!scsifront_do_request(sdev, info, shadow))
 			break;
 
 		scsifront_return(info);
@@ -656,13 +661,13 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
 static int scsifront_eh_abort_handler(struct scsi_cmnd *sc)
 {
 	pr_debug("%s\n", __func__);
-	return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_ABORT);
+	return scsifront_action_handler(sc->device, sc);
 }
 
-static int scsifront_dev_reset_handler(struct scsi_cmnd *sc)
+static int scsifront_dev_reset_handler(struct scsi_device *sdev)
 {
 	pr_debug("%s\n", __func__);
-	return scsifront_action_handler(sc, VSCSIIF_ACT_SCSI_RESET);
+	return scsifront_action_handler(sdev, NULL);
 }
 
 static int scsifront_sdev_configure(struct scsi_device *sdev)
diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index 2284a96abcff..1f3b9382f894 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -182,8 +182,12 @@ static int command_abort(struct scsi_cmnd *srb)
  * This invokes the transport reset mechanism to reset the state of the
  * device
  */
-static int device_reset(struct scsi_cmnd *srb)
+static int device_reset(struct scsi_device *sdev)
 {
+	struct rtsx_dev *dev = host_to_rtsx(sdev->host);
+
+	dev_info(&dev->pci->dev, "%s called\n", __func__);
+
 	return SUCCESS;
 }
 
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
index 28c59218077d..939e83eef2a6 100644
--- a/drivers/staging/unisys/visorhba/visorhba_main.c
+++ b/drivers/staging/unisys/visorhba/visorhba_main.c
@@ -334,29 +334,22 @@ static int visorhba_abort_handler(struct scsi_cmnd *scsicmd)
 
 /*
  * visorhba_device_reset_handler - Send TASK_MGMT_LUN_RESET
- * @scsicmd: The scsicmd that needs aborted
+ * @scsidev: The scsidev that needs to reset
  *
  * Return: SUCCESS if inserted, FAILED otherwise
  */
-static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd)
+static int visorhba_device_reset_handler(struct scsi_device *scsidev)
 {
 	/* issue TASK_MGMT_LUN_RESET */
-	struct scsi_device *scsidev;
 	struct visordisk_info *vdisk;
 	int rtn;
 
-	scsidev = scsicmd->device;
 	vdisk = scsidev->hostdata;
 	if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT)
 		atomic_inc(&vdisk->error_count);
 	else
 		atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD);
-	rtn = forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsidev);
-	if (rtn == SUCCESS) {
-		scsicmd->result = DID_RESET << 16;
-		scsi_done(scsicmd);
-	}
-	return rtn;
+	return forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsidev);
 }
 
 /*
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 4dabdbf167f6..089e7300a115 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -257,7 +257,7 @@ static int tcm_loop_abort_task(struct scsi_cmnd *sc)
  * Called from SCSI EH process context to issue a LUN_RESET TMR
  * to struct scsi_device
  */
-static int tcm_loop_device_reset(struct scsi_cmnd *sc)
+static int tcm_loop_device_reset(struct scsi_device *sdev)
 {
 	struct tcm_loop_hba *tl_hba;
 	struct tcm_loop_tpg *tl_tpg;
@@ -266,10 +266,10 @@ static int tcm_loop_device_reset(struct scsi_cmnd *sc)
 	/*
 	 * Locate the tcm_loop_hba_t pointer
 	 */
-	tl_hba = *(struct tcm_loop_hba **)shost_priv(sc->device->host);
-	tl_tpg = &tl_hba->tl_hba_tpgs[sc->device->id];
+	tl_hba = *(struct tcm_loop_hba **)shost_priv(sdev->host);
+	tl_tpg = &tl_hba->tl_hba_tpgs[sdev->id];
 
-	ret = tcm_loop_issue_tmr(tl_tpg, sc->device->lun,
+	ret = tcm_loop_issue_tmr(tl_tpg, sdev->lun,
 				 0, TMR_LUN_RESET);
 	return (ret == TMR_FUNCTION_COMPLETE) ? SUCCESS : FAILED;
 }
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index 17dabfba6b2b..7a5462e3927f 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -448,9 +448,9 @@ static int command_abort(struct scsi_cmnd *srb)
  * This invokes the transport reset mechanism to reset the state of the
  * device
  */
-static int device_reset(struct scsi_cmnd *srb)
+static int device_reset(struct scsi_device *sdev)
 {
-	struct us_data *us = host_to_us(srb->device->host);
+	struct us_data *us = host_to_us(sdev->host);
 	int result;
 
 	usb_stor_dbg(us, "%s called\n", __func__);
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 84dc270f6f73..95a5abad81da 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -762,9 +762,8 @@ static int uas_eh_abort_handler(struct scsi_cmnd *cmnd)
 	return FAILED;
 }
 
-static int uas_eh_device_reset_handler(struct scsi_cmnd *cmnd)
+static int uas_eh_device_reset_handler(struct scsi_device *sdev)
 {
-	struct scsi_device *sdev = cmnd->device;
 	struct uas_dev_info *devinfo = sdev->hostdata;
 	struct usb_device *udev = devinfo->udev;
 	unsigned long flags;
diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
index 31f60d2ad318..d11f024e3f0b 100644
--- a/include/scsi/libfc.h
+++ b/include/scsi/libfc.h
@@ -949,7 +949,7 @@ void fc_fcp_destroy(struct fc_lport *);
  *****************************/
 int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
 int fc_eh_abort(struct scsi_cmnd *);
-int fc_eh_device_reset(struct scsi_cmnd *);
+int fc_eh_device_reset(struct scsi_device *);
 int fc_eh_host_reset(struct Scsi_Host *);
 int fc_slave_alloc(struct scsi_device *);
 
diff --git a/include/scsi/libiscsi.h b/include/scsi/libiscsi.h
index f27fcffa2fd9..205db854b3a4 100644
--- a/include/scsi/libiscsi.h
+++ b/include/scsi/libiscsi.h
@@ -392,7 +392,7 @@ struct iscsi_host {
 extern int iscsi_eh_abort(struct scsi_cmnd *sc);
 extern int iscsi_eh_recover_target(struct scsi_target *starget);
 extern int iscsi_eh_session_reset(struct iscsi_cls_session *cls_session);
-extern int iscsi_eh_device_reset(struct scsi_cmnd *sc);
+extern int iscsi_eh_device_reset(struct scsi_device *sdev);
 extern int iscsi_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *sc);
 extern enum blk_eh_timer_return iscsi_eh_cmd_timed_out(struct scsi_cmnd *sc);
 
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index bbc4176d2d37..bf57ff3b2df3 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -730,7 +730,7 @@ void sas_init_dev(struct domain_device *);
 
 void sas_task_abort(struct sas_task *);
 int sas_eh_abort_handler(struct scsi_cmnd *cmd);
-int sas_eh_device_reset_handler(struct scsi_cmnd *cmd);
+int sas_eh_device_reset_handler(struct scsi_device *sdev);
 int sas_eh_target_reset_handler(struct scsi_target *starget);
 
 extern void sas_target_destroy(struct scsi_target *);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index b4acae42a2ca..2faa11035d7f 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -138,7 +138,7 @@ struct scsi_host_template {
 	 * Status: REQUIRED	(at least one of them)
 	 */
 	int (* eh_abort_handler)(struct scsi_cmnd *);
-	int (* eh_device_reset_handler)(struct scsi_cmnd *);
+	int (* eh_device_reset_handler)(struct scsi_device *);
 	int (* eh_target_reset_handler)(struct scsi_target *);
 	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
 	int (* eh_host_reset_handler)(struct Scsi_Host *);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 05/11] pmcraid: select first available device for target reset
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (7 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 4/7] scsi: Use scsi_device as argument to eh_device_reset_handler() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 5/7] scsi: Do not allocate scsi command in scsi_ioctl_reset() Hannes Reinecke
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

As we're moving away from using a scsi command as argument for
eh_XX callbacks we should be selecting the first available device
for sending a target reset to.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/pmcraid.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index d508e81a03db..62b9de87ff05 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3064,9 +3064,21 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
 
 static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
 {
-	scmd_printk(KERN_INFO, scmd,
+	struct Scsi_Host *shost = scmd->device->host;
+	struct scsi_device *scsi_dev = NULL, *tmp;
+
+	shost_for_each_device(tmp, shost) {
+		if ((tmp->channel == scmd->device->channel) &&
+		    (tmp->id == scmd->device->id)) {
+			scsi_dev = tmp;
+			break;
+		}
+	}
+	if (!scsi_dev)
+		return FAILED;
+	sdev_printk(KERN_INFO, scsi_dev,
 		    "Doing target reset due to an I/O command timeout.\n");
-	return pmcraid_reset_device(scmd->device,
+	return pmcraid_reset_device(scsi_dev,
 				    PMCRAID_INTERNAL_TIMEOUT,
 				    RESET_DEVICE_TARGET);
 }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 5/7] scsi: Do not allocate scsi command in scsi_ioctl_reset()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (8 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 05/11] pmcraid: select first available device for target reset Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 06/11] bfa: Do not use scsi command to signal TMF status Hannes Reinecke
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

As we now have moved the error handler functions to not rely on
a scsi command we can drop the out-of-band scsi command allocation
from scsi_ioctl_reset().

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_error.c | 119 +++++++++++++++++---------------------
 1 file changed, 54 insertions(+), 65 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 93f7006982d8..ad68149ab8a1 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -824,16 +824,22 @@ void scsi_eh_done(struct scsi_cmnd *scmd)
 		complete(eh_action);
 }
 
+static void __scsi_report_device_reset(struct scsi_device *sdev)
+{
+	sdev->was_reset = 1;
+	sdev->expecting_cc_ua = 1;
+}
+
 /**
  * scsi_try_host_reset - ask host adapter to reset itself
- * @scmd:	SCSI cmd to send host reset.
+ * @host:	SCSI host to be reset.
  */
-static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
+static enum scsi_disposition scsi_try_host_reset(struct Scsi_Host *host)
 {
 	unsigned long flags;
 	enum scsi_disposition rtn;
-	struct Scsi_Host *host = scmd->device->host;
 	struct scsi_host_template *hostt = host->hostt;
+	struct scsi_device *sdev;
 
 	SCSI_LOG_ERROR_RECOVERY(3,
 		shost_printk(KERN_INFO, host, "Snd Host RST\n"));
@@ -847,7 +853,8 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
 		if (!hostt->skip_settle_delay)
 			ssleep(HOST_RESET_SETTLE_TIME);
 		spin_lock_irqsave(host->host_lock, flags);
-		scsi_report_bus_reset(host, scmd_channel(scmd));
+		__shost_for_each_device(sdev, host)
+			__scsi_report_device_reset(sdev);
 		spin_unlock_irqrestore(host->host_lock, flags);
 	}
 
@@ -856,43 +863,39 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
 
 /**
  * scsi_try_bus_reset - ask host to perform a bus reset
- * @scmd:	SCSI cmd to send bus reset.
+ * @host:	SCSI host to send bus reset.
+ * @channel:	Number of the bus to be reset
  */
-static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
+static enum scsi_disposition scsi_try_bus_reset(struct Scsi_Host *host,
+						int channel)
 {
 	unsigned long flags;
 	enum scsi_disposition rtn;
-	struct Scsi_Host *host = scmd->device->host;
 	struct scsi_host_template *hostt = host->hostt;
 
-	SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
-		"%s: Snd Bus RST\n", __func__));
+	SCSI_LOG_ERROR_RECOVERY(3, shost_printk(KERN_INFO, host,
+		"%s: Snd Bus RST to bus %d\n", __func__, channel));
 
 	if (!hostt->eh_bus_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
+	rtn = hostt->eh_bus_reset_handler(host, channel);
 
 	if (rtn == SUCCESS) {
 		if (!hostt->skip_settle_delay)
 			ssleep(BUS_RESET_SETTLE_TIME);
 		spin_lock_irqsave(host->host_lock, flags);
-		scsi_report_bus_reset(host, scmd_channel(scmd));
+		scsi_report_bus_reset(host, channel);
 		spin_unlock_irqrestore(host->host_lock, flags);
 	}
 
 	return rtn;
 }
 
-static void __scsi_report_device_reset(struct scsi_device *sdev, void *data)
-{
-	sdev->was_reset = 1;
-	sdev->expecting_cc_ua = 1;
-}
-
 /**
  * scsi_try_target_reset - Ask host to perform a target reset
- * @scmd:	SCSI cmd used to send a target reset
+ * @host:	SCSI Host
+ * @starget:	SCSI target to be reset
  *
  * Notes:
  *    There is no timeout for this operation.  if this operation is
@@ -900,13 +903,13 @@ static void __scsi_report_device_reset(struct scsi_device *sdev, void *data)
  *    timer on it, and set the host back to a consistent state prior to
  *    returning.
  */
-static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
+static enum scsi_disposition scsi_try_target_reset(struct Scsi_Host *host,
+						   struct scsi_target *starget)
 {
 	unsigned long flags;
 	enum scsi_disposition rtn;
-	struct Scsi_Host *host = scmd->device->host;
+	struct scsi_device *sdev;
 	struct scsi_host_template *hostt = host->hostt;
-	struct scsi_target *starget = scsi_target(scmd->device);
 
 	if (!hostt->eh_target_reset_handler)
 		return FAILED;
@@ -914,8 +917,11 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
 	rtn = hostt->eh_target_reset_handler(starget);
 	if (rtn == SUCCESS) {
 		spin_lock_irqsave(host->host_lock, flags);
-		__starget_for_each_device(starget, NULL,
-					  __scsi_report_device_reset);
+		__shost_for_each_device(sdev, host) {
+			if ((sdev->channel == starget->channel) &&
+			    (sdev->id == starget->id))
+				__scsi_report_device_reset(sdev);
+		}
 		spin_unlock_irqrestore(host->host_lock, flags);
 	}
 
@@ -924,7 +930,7 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
 
 /**
  * scsi_try_bus_device_reset - Ask host to perform a BDR on a dev
- * @scmd:	SCSI cmd used to send BDR
+ * @sdev:	SCSI device to perform the BDR on
  *
  * Notes:
  *    There is no timeout for this operation.  if this operation is
@@ -932,17 +938,17 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
  *    timer on it, and set the host back to a consistent state prior to
  *    returning.
  */
-static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_cmnd *scmd)
+static enum scsi_disposition scsi_try_bus_device_reset(struct scsi_device *sdev)
 {
 	enum scsi_disposition rtn;
-	struct scsi_host_template *hostt = scmd->device->host->hostt;
+	struct scsi_host_template *hostt = sdev->host->hostt;
 
 	if (!hostt->eh_device_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_device_reset_handler(scmd->device);
+	rtn = hostt->eh_device_reset_handler(sdev);
 	if (rtn == SUCCESS)
-		__scsi_report_device_reset(scmd->device, NULL);
+		__scsi_report_device_reset(sdev);
 	return rtn;
 }
 
@@ -974,11 +980,15 @@ scsi_try_to_abort_cmd(struct scsi_host_template *hostt, struct scsi_cmnd *scmd)
 
 static void scsi_abort_eh_cmnd(struct scsi_cmnd *scmd)
 {
-	if (scsi_try_to_abort_cmd(scmd->device->host->hostt, scmd) != SUCCESS)
-		if (scsi_try_bus_device_reset(scmd) != SUCCESS)
-			if (scsi_try_target_reset(scmd) != SUCCESS)
-				if (scsi_try_bus_reset(scmd) != SUCCESS)
-					scsi_try_host_reset(scmd);
+	struct Scsi_Host *host = scmd->device->host;
+	struct scsi_target *starget = scsi_target(scmd->device);
+	int channel = scmd->device->channel;
+
+	if (scsi_try_to_abort_cmd(host->hostt, scmd) != SUCCESS)
+		if (scsi_try_bus_device_reset(scmd->device) != SUCCESS)
+			if (scsi_try_target_reset(host, starget) != SUCCESS)
+				if (scsi_try_bus_reset(host, channel) != SUCCESS)
+					scsi_try_host_reset(host);
 }
 
 /**
@@ -1561,7 +1571,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
 		SCSI_LOG_ERROR_RECOVERY(3,
 			sdev_printk(KERN_INFO, sdev,
 				     "%s: Sending BDR\n", current->comm));
-		rtn = scsi_try_bus_device_reset(bdr_scmd);
+		rtn = scsi_try_bus_device_reset(sdev);
 		if (rtn == SUCCESS || rtn == FAST_IO_FAIL) {
 			if (!scsi_device_online(sdev) ||
 			    rtn == FAST_IO_FAIL ||
@@ -1626,7 +1636,7 @@ static int scsi_eh_target_reset(struct Scsi_Host *shost,
 			shost_printk(KERN_INFO, shost,
 				     "%s: Sending target reset to target %d\n",
 				     current->comm, id));
-		rtn = scsi_try_target_reset(scmd);
+		rtn = scsi_try_target_reset(shost, scsi_target(scmd->device));
 		if (rtn != SUCCESS && rtn != FAST_IO_FAIL)
 			SCSI_LOG_ERROR_RECOVERY(3,
 				shost_printk(KERN_INFO, shost,
@@ -1701,7 +1711,7 @@ static int scsi_eh_bus_reset(struct Scsi_Host *shost,
 			shost_printk(KERN_INFO, shost,
 				     "%s: Sending BRST chan: %d\n",
 				     current->comm, channel));
-		rtn = scsi_try_bus_reset(chan_scmd);
+		rtn = scsi_try_bus_reset(shost, channel);
 		if (rtn == SUCCESS || rtn == FAST_IO_FAIL) {
 			list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
 				if (channel == scmd_channel(scmd)) {
@@ -1747,7 +1757,7 @@ static int scsi_eh_host_reset(struct Scsi_Host *shost,
 				     "%s: Sending HRST\n",
 				     current->comm));
 
-		rtn = scsi_try_host_reset(scmd);
+		rtn = scsi_try_host_reset(shost);
 		if (rtn == SUCCESS) {
 			list_splice_init(work_q, &check_list);
 		} else if (rtn == FAST_IO_FAIL) {
@@ -2342,7 +2352,7 @@ void scsi_report_bus_reset(struct Scsi_Host *shost, int channel)
 
 	__shost_for_each_device(sdev, shost) {
 		if (channel == sdev_channel(sdev))
-			__scsi_report_device_reset(sdev, NULL);
+			__scsi_report_device_reset(sdev);
 	}
 }
 EXPORT_SYMBOL(scsi_report_bus_reset);
@@ -2376,7 +2386,7 @@ void scsi_report_device_reset(struct Scsi_Host *shost, int channel, int target)
 	__shost_for_each_device(sdev, shost) {
 		if (channel == sdev_channel(sdev) &&
 		    target == sdev_id(sdev))
-			__scsi_report_device_reset(sdev, NULL);
+			__scsi_report_device_reset(sdev);
 	}
 }
 EXPORT_SYMBOL(scsi_report_device_reset);
@@ -2389,9 +2399,8 @@ EXPORT_SYMBOL(scsi_report_device_reset);
 int
 scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 {
-	struct scsi_cmnd *scmd;
 	struct Scsi_Host *shost = dev->host;
-	struct request *rq;
+	struct scsi_target *starget = scsi_target(dev);
 	unsigned long flags;
 	int error = 0, val;
 	enum scsi_disposition rtn;
@@ -2406,23 +2415,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 	if (scsi_autopm_get_host(shost) < 0)
 		return -EIO;
 
-	error = -EIO;
-	rq = kzalloc(sizeof(struct request) + sizeof(struct scsi_cmnd) +
-			shost->hostt->cmd_size, GFP_KERNEL);
-	if (!rq)
-		goto out_put_autopm_host;
-	blk_rq_init(NULL, rq);
-
-	scmd = (struct scsi_cmnd *)(rq + 1);
-	scsi_init_command(dev, scmd);
-
-	scmd->submitter = SUBMITTED_BY_SCSI_RESET_IOCTL;
-	memset(&scmd->sdb, 0, sizeof(scmd->sdb));
-
-	scmd->cmd_len			= 0;
-
-	scmd->sc_data_direction		= DMA_BIDIRECTIONAL;
-
 	spin_lock_irqsave(shost->host_lock, flags);
 	shost->tmf_in_progress = 1;
 	spin_unlock_irqrestore(shost->host_lock, flags);
@@ -2432,22 +2424,22 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 		rtn = SUCCESS;
 		break;
 	case SG_SCSI_RESET_DEVICE:
-		rtn = scsi_try_bus_device_reset(scmd);
+		rtn = scsi_try_bus_device_reset(dev);
 		if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
 			break;
 		fallthrough;
 	case SG_SCSI_RESET_TARGET:
-		rtn = scsi_try_target_reset(scmd);
+		rtn = scsi_try_target_reset(shost, starget);
 		if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
 			break;
 		fallthrough;
 	case SG_SCSI_RESET_BUS:
-		rtn = scsi_try_bus_reset(scmd);
+		rtn = scsi_try_bus_reset(shost, dev->channel);
 		if (rtn == SUCCESS || (val & SG_SCSI_RESET_NO_ESCALATE))
 			break;
 		fallthrough;
 	case SG_SCSI_RESET_HOST:
-		rtn = scsi_try_host_reset(scmd);
+		rtn = scsi_try_host_reset(shost);
 		if (rtn == SUCCESS)
 			break;
 		fallthrough;
@@ -2473,9 +2465,6 @@ scsi_ioctl_reset(struct scsi_device *dev, int __user *arg)
 	wake_up(&shost->host_wait);
 	scsi_run_host_queues(shost);
 
-	kfree(rq);
-
-out_put_autopm_host:
 	scsi_autopm_put_host(shost);
 	return error;
 }
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 06/11] bfa: Do not use scsi command to signal TMF status
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (9 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 5/7] scsi: Do not allocate scsi command in scsi_ioctl_reset() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 6/7] scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL Hannes Reinecke
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

The bfa driver hijacks the scsi command to signal the TMF status,
which will no longer work if the TMF handler will be converted.
So rework TMF handling to not use a scsi command but rather add
new TMF fields to the per-device structure.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/bfa/bfad_im.c | 112 ++++++++++++++++++++-----------------
 drivers/scsi/bfa/bfad_im.h |   2 +
 2 files changed, 63 insertions(+), 51 deletions(-)

diff --git a/drivers/scsi/bfa/bfad_im.c b/drivers/scsi/bfa/bfad_im.c
index 8419a1a89485..a446aa2d6b9a 100644
--- a/drivers/scsi/bfa/bfad_im.c
+++ b/drivers/scsi/bfa/bfad_im.c
@@ -147,13 +147,13 @@ void
 bfa_cb_tskim_done(void *bfad, struct bfad_tskim_s *dtsk,
 		   enum bfi_tskim_status tsk_status)
 {
-	struct scsi_cmnd *cmnd = (struct scsi_cmnd *)dtsk;
+	struct bfad_itnim_data_s *itnim_data =
+		(struct bfad_itnim_data_s *)dtsk;
 	wait_queue_head_t *wq;
 
-	bfad_priv(cmnd)->status |= tsk_status << 1;
-	set_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status);
-	wq = bfad_priv(cmnd)->wq;
-	bfad_priv(cmnd)->wq = NULL;
+	itnim_data->tmf_status |= tsk_status << 1;
+	set_bit(IO_DONE_BIT, &itnim_data->tmf_status);
+	wq = itnim_data->tmf_wq;
 
 	if (wq)
 		wake_up(wq);
@@ -238,15 +238,16 @@ bfad_im_abort_handler(struct scsi_cmnd *cmnd)
 }
 
 static bfa_status_t
-bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
-		     struct bfad_itnim_s *itnim)
+bfad_im_target_reset_send(struct bfad_s *bfad,
+			  struct bfad_itnim_data_s *itnim_data)
 {
+	struct bfad_itnim_s *itnim = itnim_data->itnim;
 	struct bfa_tskim_s *tskim;
 	struct bfa_itnim_s *bfa_itnim;
 	bfa_status_t    rc = BFA_STATUS_OK;
 	struct scsi_lun scsilun;
 
-	tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
+	tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data);
 	if (!tskim) {
 		BFA_LOG(KERN_ERR, bfad, bfa_log_level,
 			"target reset, fail to allocate tskim\n");
@@ -254,12 +255,6 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
 		goto out;
 	}
 
-	/*
-	 * Set host_scribble to NULL to avoid aborting a task command if
-	 * happens.
-	 */
-	cmnd->host_scribble = NULL;
-	bfad_priv(cmnd)->status = 0;
 	bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
 	/*
 	 * bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -290,10 +285,11 @@ bfad_im_target_reset_send(struct bfad_s *bfad, struct scsi_cmnd *cmnd,
 static int
 bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
 {
-	struct Scsi_Host *shost = cmnd->device->host;
+	struct scsi_device *sdev = cmnd->device;
+	struct Scsi_Host *shost = sdev->host;
 	struct bfad_im_port_s *im_port =
 			(struct bfad_im_port_s *) shost->hostdata[0];
-	struct bfad_itnim_data_s *itnim_data = cmnd->device->hostdata;
+	struct bfad_itnim_data_s *itnim_data = sdev->hostdata;
 	struct bfad_s         *bfad = im_port->bfad;
 	struct bfa_tskim_s *tskim;
 	struct bfad_itnim_s   *itnim;
@@ -305,14 +301,20 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
 	struct scsi_lun scsilun;
 
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
+	if (itnim_data->tmf_wq) {
+		BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+			"LUN reset, TMF already active");
+		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+		rc = FAILED;
+		goto out;
+	}
 	itnim = itnim_data->itnim;
 	if (!itnim) {
 		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
 		rc = FAILED;
 		goto out;
 	}
-
-	tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) cmnd);
+	tskim = bfa_tskim_alloc(&bfad->bfa, (struct bfad_tskim_s *) itnim_data);
 	if (!tskim) {
 		BFA_LOG(KERN_ERR, bfad, bfa_log_level,
 				"LUN reset, fail to allocate tskim");
@@ -321,13 +323,8 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
 		goto out;
 	}
 
-	/*
-	 * Set host_scribble to NULL to avoid aborting a task command
-	 * if happens.
-	 */
-	cmnd->host_scribble = NULL;
-	bfad_priv(cmnd)->wq = &wq;
-	bfad_priv(cmnd)->status = 0;
+	itnim_data->tmf_wq = &wq;
+	itnim_data->tmf_status = 0;
 	bfa_itnim = bfa_fcs_itnim_get_halitn(&itnim->fcs_itnim);
 	/*
 	 * bfa_itnim can be NULL if the port gets disconnected and the bfa
@@ -342,14 +339,15 @@ bfad_im_reset_lun_handler(struct scsi_cmnd *cmnd)
 		rc = FAILED;
 		goto out;
 	}
-	int_to_scsilun(cmnd->device->lun, &scsilun);
+	int_to_scsilun(sdev->lun, &scsilun);
 	bfa_tskim_start(tskim, bfa_itnim, scsilun,
 			    FCP_TM_LUN_RESET, BFAD_LUN_RESET_TMO);
 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
 
-	wait_event(wq, test_bit(IO_DONE_BIT, &bfad_priv(cmnd)->status));
+	wait_event(wq, test_bit(IO_DONE_BIT, &itnim_data->tmf_status));
 
-	task_status = bfad_priv(cmnd)->status >> 1;
+	itnim_data->tmf_wq = NULL;
+	task_status = itnim_data->tmf_status >> 1;
 	if (task_status != BFI_TSKIM_STS_OK) {
 		BFA_LOG(KERN_ERR, bfad, bfa_log_level,
 			"LUN reset failure, status: %d\n", task_status);
@@ -368,35 +366,47 @@ bfad_im_reset_target_handler(struct scsi_cmnd *cmnd)
 {
 	struct Scsi_Host *shost = cmnd->device->host;
 	struct scsi_target *starget = scsi_target(cmnd->device);
+	struct fc_rport *rport = starget_to_rport(starget);
 	struct bfad_im_port_s *im_port =
 				(struct bfad_im_port_s *) shost->hostdata[0];
-	struct bfad_s         *bfad = im_port->bfad;
-	struct bfad_itnim_s   *itnim;
-	unsigned long   flags;
-	u32        rc, rtn = FAILED;
+	struct bfad_s *bfad = im_port->bfad;
+	struct bfad_itnim_data_s *itnim_data;
+	struct bfad_itnim_s *itnim;
+	unsigned long flags;
+	u32 rc, rtn = FAILED;
 	DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
 	enum bfi_tskim_status task_status;
 
 	spin_lock_irqsave(&bfad->bfad_lock, flags);
-	itnim = bfad_get_itnim(im_port, starget->id);
-	if (itnim) {
-		bfad_priv(cmnd)->wq = &wq;
-		rc = bfad_im_target_reset_send(bfad, cmnd, itnim);
-		if (rc == BFA_STATUS_OK) {
-			/* wait target reset to complete */
-			spin_unlock_irqrestore(&bfad->bfad_lock, flags);
-			wait_event(wq, test_bit(IO_DONE_BIT,
-						&bfad_priv(cmnd)->status));
-			spin_lock_irqsave(&bfad->bfad_lock, flags);
-
-			task_status = bfad_priv(cmnd)->status >> 1;
-			if (task_status != BFI_TSKIM_STS_OK)
-				BFA_LOG(KERN_ERR, bfad, bfa_log_level,
-					"target reset failure,"
-					" status: %d\n", task_status);
-			else
-				rtn = SUCCESS;
-		}
+	if (!rport->dd_data) {
+		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+		return rtn;
+	}
+	itnim_data = rport->dd_data;
+	if (itnim_data->tmf_wq) {
+		BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+			"target reset failed, TMF already active");
+		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+		return rtn;
+	}
+	itnim = itnim_data->itnim;
+	itnim_data->tmf_wq = &wq;
+	itnim_data->tmf_status = 0;
+	rc = bfad_im_target_reset_send(bfad, itnim_data);
+	if (rc == BFA_STATUS_OK) {
+		/* wait target reset to complete */
+		spin_unlock_irqrestore(&bfad->bfad_lock, flags);
+		wait_event(wq, test_bit(IO_DONE_BIT,
+					&itnim_data->tmf_status));
+		spin_lock_irqsave(&bfad->bfad_lock, flags);
+
+		task_status = itnim_data->tmf_status >> 1;
+		if (task_status != BFI_TSKIM_STS_OK)
+			BFA_LOG(KERN_ERR, bfad, bfa_log_level,
+				"target reset failure,"
+				" status: %d\n", task_status);
+		else
+			rtn = SUCCESS;
 	}
 	spin_unlock_irqrestore(&bfad->bfad_lock, flags);
 
diff --git a/drivers/scsi/bfa/bfad_im.h b/drivers/scsi/bfa/bfad_im.h
index c03b225ea1ba..c9ead4217a7d 100644
--- a/drivers/scsi/bfa/bfad_im.h
+++ b/drivers/scsi/bfa/bfad_im.h
@@ -61,6 +61,8 @@ static inline struct bfad_cmd_priv *bfad_priv(struct scsi_cmnd *cmd)
 
 struct bfad_itnim_data_s {
 	struct bfad_itnim_s *itnim;
+	wait_queue_head_t *tmf_wq;
+	unsigned long tmf_status;
 };
 
 struct bfad_im_port_s {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 6/7] scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (10 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 06/11] bfa: Do not use scsi command to signal TMF status Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 07/11] aha152x: look for stuck command when resetting device Hannes Reinecke
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

Unused now.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/scsi_lib.c  | 2 --
 include/scsi/scsi_cmnd.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 8d18cc7e510e..98b1e836231f 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1613,8 +1613,6 @@ static void scsi_done_internal(struct scsi_cmnd *cmd, bool complete_directly)
 		break;
 	case SUBMITTED_BY_SCSI_ERROR_HANDLER:
 		return scsi_eh_done(cmd);
-	case SUBMITTED_BY_SCSI_RESET_IOCTL:
-		return;
 	}
 
 	if (unlikely(blk_should_fake_timeout(scsi_cmd_to_rq(cmd)->q)))
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 1e80e70dfa92..6fb3311bd704 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -62,7 +62,6 @@ struct scsi_pointer {
 enum scsi_cmnd_submitter {
 	SUBMITTED_BY_BLOCK_LAYER = 0,
 	SUBMITTED_BY_SCSI_ERROR_HANDLER = 1,
-	SUBMITTED_BY_SCSI_RESET_IOCTL = 2,
 } __packed;
 
 struct scsi_cmnd {
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 07/11] aha152x: look for stuck command when resetting device
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (11 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 6/7] scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 7/7] scsi_error: streamline scsi_eh_bus_device_reset() Hannes Reinecke
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

From: Hannes Reinecke <hare@suse.com>

The LLDD needs a command to send the reset with, so look at the
list of outstanding commands to get one.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/aha152x.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index caeebfb67149..7e58f25c599b 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1070,24 +1070,28 @@ static int aha152x_abort(struct scsi_cmnd *SCpnt)
  */
 static int aha152x_device_reset(struct scsi_cmnd * SCpnt)
 {
-	struct Scsi_Host *shpnt = SCpnt->device->host;
+	struct scsi_device *sdev = SCpnt->device;
+	struct Scsi_Host *shpnt = sdev->host;
 	DECLARE_COMPLETION(done);
 	int ret, issued, disconnected;
-	unsigned char old_cmd_len = SCpnt->cmd_len;
+	unsigned char old_cmd_len;
 	unsigned long flags;
 	unsigned long timeleft;
 
-	if(CURRENT_SC==SCpnt) {
-		scmd_printk(KERN_ERR, SCpnt, "cannot reset current device\n");
-		return FAILED;
-	}
-
 	DO_LOCK(flags);
-	issued       = remove_SC(&ISSUE_SC, SCpnt) == NULL;
-	disconnected = issued && remove_SC(&DISCONNECTED_SC, SCpnt);
+	/* Look for the stuck command */
+	SCpnt = remove_lun_SC(&ISSUE_SC, sdev->id, sdev->lun);
+	if (SCpnt)
+		issued = 1;
+	else
+		SCpnt = remove_lun_SC(&DISCONNECTED_SC, sdev->id, sdev->lun);
+	if (!issued && SCpnt)
+		disconnected = 1;
 	DO_UNLOCK(flags);
-
-	SCpnt->cmd_len         = 0;
+	if (!SCpnt)
+		return FAILED;
+	old_cmd_len = SCpnt->cmd_len;
+	SCpnt->cmd_len = 0;
 
 	aha152x_internal_queue(SCpnt, &done, resetting);
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 7/7] scsi_error: streamline scsi_eh_bus_device_reset()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (12 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 07/11] aha152x: look for stuck command when resetting device Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

From: Hannes Reinecke <hare@suse.com>

Streamline to use a similar code flow as the other reset functions.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/scsi_error.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index ad68149ab8a1..b2e70e262095 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1547,6 +1547,7 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
 {
 	struct scsi_cmnd *scmd, *bdr_scmd, *next;
 	struct scsi_device *sdev;
+	LIST_HEAD(check_list);
 	enum scsi_disposition rtn;
 
 	shost_for_each_device(sdev, shost) {
@@ -1572,27 +1573,22 @@ static int scsi_eh_bus_device_reset(struct Scsi_Host *shost,
 			sdev_printk(KERN_INFO, sdev,
 				     "%s: Sending BDR\n", current->comm));
 		rtn = scsi_try_bus_device_reset(sdev);
-		if (rtn == SUCCESS || rtn == FAST_IO_FAIL) {
-			if (!scsi_device_online(sdev) ||
-			    rtn == FAST_IO_FAIL ||
-			    !scsi_eh_tur(bdr_scmd)) {
-				list_for_each_entry_safe(scmd, next,
-							 work_q, eh_entry) {
-					if (scmd->device == sdev &&
-					    scsi_eh_action(scmd, rtn) != FAILED)
-						__scsi_eh_finish_cmd(scmd,
-								     done_q,
-								     DID_RESET);
-				}
-			}
-		} else {
+		if (rtn != SUCCESS && rtn != FAST_IO_FAIL)
 			SCSI_LOG_ERROR_RECOVERY(3,
 				sdev_printk(KERN_INFO, sdev,
 					    "%s: BDR failed\n", current->comm));
+		list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
+			if (scmd->device != sdev)
+				continue;
+			if (rtn == SUCCESS)
+				list_move_tail(&scmd->eh_entry, &check_list);
+			else if (rtn == FAST_IO_FAIL)
+				__scsi_eh_finish_cmd(scmd, done_q,
+						     DID_TRANSPORT_DISRUPTED);
 		}
 	}
 
-	return list_empty(work_q);
+	return scsi_eh_test_devices(&check_list, work_q, done_q, 0);
 }
 
 /**
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (13 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 7/7] scsi_error: streamline scsi_eh_bus_device_reset() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Use the scsi device as argument to orc_device_reset() instead
of relying on the passed in scsi command.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/a100u2w.c | 43 +++++++++++-------------------------------
 1 file changed, 11 insertions(+), 32 deletions(-)

diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index d02eb5b213d0..bf552c818958 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -592,39 +592,20 @@ static int orc_reset_scsi_bus(struct orc_host * host)
  *	commands for target w/o soft reset
  */
 
-static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsigned int target)
+static int orc_device_reset(struct orc_host * host, struct scsi_device *sdev)
 {				/* I need Host Control Block Information */
 	struct orc_scb *scb;
 	struct orc_extended_scb *escb;
-	struct orc_scb *host_scb;
-	u8 i;
 	unsigned long flags;
 
 	spin_lock_irqsave(&(host->allocation_lock), flags);
 	scb = (struct orc_scb *) NULL;
 	escb = (struct orc_extended_scb *) NULL;
 
-	/* setup scatter list address with one buffer */
-	host_scb = host->scb_virt;
-
 	/* FIXME: is this safe if we then fail to issue the reset or race
 	   a completion ? */
 	init_alloc_map(host);
 
-	/* Find the scb corresponding to the command */
-	for (i = 0; i < ORC_MAXQUEUE; i++) {
-		escb = host_scb->escb;
-		if (host_scb->status && escb->srb == cmd)
-			break;
-		host_scb++;
-	}
-
-	if (i == ORC_MAXQUEUE) {
-		printk(KERN_ERR "Unable to Reset - No SCB Found\n");
-		spin_unlock_irqrestore(&(host->allocation_lock), flags);
-		return FAILED;
-	}
-
 	/* Allocate a new SCB for the reset command to the firmware */
 	if ((scb = __orc_alloc_scb(host)) == NULL) {
 		/* Can't happen.. */
@@ -635,7 +616,7 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig
 	/* Reset device is handled by the firmware, we fill in an SCB and
 	   fire it at the controller, it does the rest */
 	scb->opcode = ORC_BUSDEVRST;
-	scb->target = target;
+	scb->target = sdev->id;
 	scb->hastat = 0;
 	scb->tastat = 0;
 	scb->status = 0x0;
@@ -645,8 +626,8 @@ static int orc_device_reset(struct orc_host * host, struct scsi_cmnd *cmd, unsig
 	scb->xferlen = cpu_to_le32(0);
 	scb->sg_len = cpu_to_le32(0);
 
+	escb = scb->escb;
 	escb->srb = NULL;
-	escb->srb = cmd;
 	orc_exec_scb(host, scb);	/* Start execute SCB            */
 	spin_unlock_irqrestore(&host->allocation_lock, flags);
 	return SUCCESS;
@@ -971,7 +952,7 @@ static int inia100_device_reset(struct scsi_cmnd * cmd)
 {				/* I need Host Control Block Information */
 	struct orc_host *host;
 	host = (struct orc_host *) cmd->device->host->hostdata;
-	return orc_device_reset(host, cmd, scmd_id(cmd));
+	return orc_device_reset(host, cmd->device);
 
 }
 
@@ -991,11 +972,7 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)
 	struct orc_extended_scb *escb;
 
 	escb = scb->escb;
-	if ((cmd = (struct scsi_cmnd *) escb->srb) == NULL) {
-		printk(KERN_ERR "inia100_scb_handler: SRB pointer is empty\n");
-		orc_release_scb(host, scb);	/* Release SCB for current channel */
-		return;
-	}
+	cmd = (struct scsi_cmnd *)escb->srb;
 	escb->srb = NULL;
 
 	switch (scb->hastat) {
@@ -1033,13 +1010,15 @@ static void inia100_scb_handler(struct orc_host *host, struct orc_scb *scb)
 		break;
 	}
 
-	if (scb->tastat == 2) {	/* Check condition              */
+	if (cmd && scb->tastat == 2) {	/* Check condition              */
 		memcpy((unsigned char *) &cmd->sense_buffer[0],
 		   (unsigned char *) &escb->sglist[0], SENSE_SIZE);
 	}
-	cmd->result = scb->tastat | (scb->hastat << 16);
-	scsi_dma_unmap(cmd);
-	scsi_done(cmd);		/* Notify system DONE           */
+	if (cmd) {
+		cmd->result = scb->tastat | (scb->hastat << 16);
+		scsi_dma_unmap(cmd);
+		scsi_done(cmd);		/* Notify system DONE           */
+	}
 	orc_release_scb(host, scb);	/* Release SCB for current channel */
 }
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request()
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (14 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Add scsi device as argument to scsifront_do_request() so that it
will be possible to call it with a NULL command pointer.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/xen-scsifront.c | 31 ++++++++++++++++++++-----------
 1 file changed, 20 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/xen-scsifront.c b/drivers/scsi/xen-scsifront.c
index 12109e4c73d4..9de099532f8b 100644
--- a/drivers/scsi/xen-scsifront.c
+++ b/drivers/scsi/xen-scsifront.c
@@ -175,7 +175,8 @@ static void scsifront_put_rqid(struct vscsifrnt_info *info, uint32_t id)
 		scsifront_wake_up(info);
 }
 
-static int scsifront_do_request(struct vscsifrnt_info *info,
+static int scsifront_do_request(struct scsi_device *sdev,
+				struct vscsifrnt_info *info,
 				struct vscsifrnt_shadow *shadow)
 {
 	struct vscsiif_front_ring *ring = &(info->ring);
@@ -202,17 +203,25 @@ static int scsifront_do_request(struct vscsifrnt_info *info,
 	ring_req->ref_rqid    = shadow->ref_rqid;
 	ring_req->nr_segments = shadow->nr_segments;
 
-	ring_req->id      = sc->device->id;
-	ring_req->lun     = sc->device->lun;
-	ring_req->channel = sc->device->channel;
-	ring_req->cmd_len = sc->cmd_len;
+	ring_req->id      = sdev->id;
+	ring_req->lun     = sdev->lun;
+	ring_req->channel = sdev->channel;
 
-	BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE);
+	if (sc) {
+		ring_req->cmd_len = sc->cmd_len;
 
-	memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len);
+		BUG_ON(sc->cmd_len > VSCSIIF_MAX_COMMAND_SIZE);
 
-	ring_req->sc_data_direction   = (uint8_t)sc->sc_data_direction;
-	ring_req->timeout_per_command = scsi_cmd_to_rq(sc)->timeout / HZ;
+		memcpy(ring_req->cmnd, sc->cmnd, sc->cmd_len);
+
+		ring_req->sc_data_direction   = (uint8_t)sc->sc_data_direction;
+		ring_req->timeout_per_command =
+			scsi_cmd_to_rq(sc)->timeout / HZ;
+	} else {
+		ring_req->cmd_len = VSCSIIF_MAX_COMMAND_SIZE;
+		memset(ring_req->cmnd, 0, VSCSIIF_MAX_COMMAND_SIZE);
+		ring_req->sc_data_direction = DMA_NONE;
+	}
 
 	for (i = 0; i < (shadow->nr_segments & ~VSCSIIF_SG_GRANT); i++)
 		ring_req->seg[i] = shadow->seg[i];
@@ -561,7 +570,7 @@ static int scsifront_queuecommand(struct Scsi_Host *shost,
 		return 0;
 	}
 
-	if (scsifront_do_request(info, shadow)) {
+	if (scsifront_do_request(sc->device, info, shadow)) {
 		scsifront_gnttab_done(info, shadow);
 		goto busy;
 	}
@@ -606,7 +615,7 @@ static int scsifront_action_handler(struct scsi_cmnd *sc, uint8_t act)
 		if (scsifront_enter(info))
 			goto fail;
 
-		if (!scsifront_do_request(info, shadow))
+		if (!scsifront_do_request(sc->device, info, shadow))
 			break;
 
 		scsifront_return(info);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (15 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-02 21:59 ` [PATCH 11/11] csiostor: use separate TMF command Hannes Reinecke
  2022-05-05  2:27 ` [PATCH 0/7] scsi: EH rework main part chenxiang (M)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

The device reset code should not rely on the SCSI command pointer;
it will be going away with the device reset handler rework.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/arm/fas216.c | 39 +++++++++++++++++++--------------------
 1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 4ce0b2d73614..e6289c6af5ef 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -1985,7 +1985,6 @@ static void fas216_devicereset_done(FAS216_Info *info, struct scsi_cmnd *SCpnt,
 {
 	fas216_log(info, LOG_ERROR, "fas216 device reset complete");
 
-	info->rstSCpnt = NULL;
 	info->rst_dev_status = 1;
 	wake_up(&info->eh_wait);
 }
@@ -2143,12 +2142,12 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 
 	fas216_checkmagic(info);
 
-	if (!info->SCpnt)
+	if (!info->SCpnt && info->rst_dev_status)
 		goto no_command;
 
 	SCpnt = info->SCpnt;
 	info->SCpnt = NULL;
-    	info->scsi.phase = PHASE_IDLE;
+	info->scsi.phase = PHASE_IDLE;
 
 	if (info->scsi.aborting) {
 		fas216_log(info, 0, "uncaught abort - returning DID_ABORT");
@@ -2160,7 +2159,7 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 	 * Sanity check the completion - if we have zero bytes left
 	 * to transfer, we should not have a valid pointer.
 	 */
-	if (info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
+	if (SCpnt && info->scsi.SCp.ptr && info->scsi.SCp.this_residual == 0) {
 		scmd_printk(KERN_INFO, SCpnt,
 			    "zero bytes left to transfer, but buffer pointer still valid: ptr=%p len=%08x\n",
 			    info->scsi.SCp.ptr, info->scsi.SCp.this_residual);
@@ -2173,12 +2172,18 @@ static void fas216_done(FAS216_Info *info, unsigned int result)
 	 * the sense information, fas216_kick will re-assert the busy
 	 * status.
 	 */
-	info->device[SCpnt->device->id].parity_check = 0;
-	clear_bit(SCpnt->device->id * 8 +
-		  (u8)(SCpnt->device->lun & 0x7), info->busyluns);
-
-	fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
-	fn(info, SCpnt, result);
+	if (SCpnt) {
+		info->device[SCpnt->device->id].parity_check = 0;
+		clear_bit(SCpnt->device->id * 8 +
+			  (u8)(SCpnt->device->lun & 0x7), info->busyluns);
+	}
+	if (!info->rst_dev_status) {
+		info->rst_dev_status = 1;
+		wake_up(&info->eh_wait);
+	} else {
+		fn = (void (*)(FAS216_Info *, struct scsi_cmnd *, unsigned int))SCpnt->host_scribble;
+		fn(info, SCpnt, result);
+	}
 
 	if (info->scsi.irq) {
 		spin_lock_irqsave(&info->host_lock, flags);
@@ -2478,9 +2483,10 @@ int fas216_eh_abort(struct scsi_cmnd *SCpnt)
  */
 int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 {
-	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+	struct scsi_device *sdev = SCpnt->device;
+	FAS216_Info *info = (FAS216_Info *)sdev->host->hostdata;
 	unsigned long flags;
-	int i, res = FAILED, target = SCpnt->device->id;
+	int i, res = FAILED, target = sdev->id;
 
 	fas216_log(info, LOG_ERROR, "device reset for target %d", target);
 
@@ -2494,7 +2500,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 		 * and we need a bus reset.
 		 */
 		if (info->SCpnt && !info->scsi.disconnectable &&
-		    info->SCpnt->device->id == SCpnt->device->id)
+		    info->SCpnt->device->id == sdev->id)
 			break;
 
 		/*
@@ -2512,14 +2518,7 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 		for (i = 0; i < 8; i++)
 			clear_bit(target * 8 + i, info->busyluns);
 
-		/*
-		 * Hijack this SCSI command structure to send
-		 * a bus device reset message to this device.
-		 */
-		SCpnt->host_scribble = (void *)fas216_devicereset_done;
-
 		info->rst_dev_status = 0;
-		info->rstSCpnt = SCpnt;
 
 		if (info->scsi.phase == PHASE_IDLE)
 			fas216_kick(info);
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* [PATCH 11/11] csiostor: use separate TMF command
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (16 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
@ 2022-05-02 21:59 ` Hannes Reinecke
  2022-05-05  2:27 ` [PATCH 0/7] scsi: EH rework main part chenxiang (M)
  18 siblings, 0 replies; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-02 21:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	Hannes Reinecke

Set one command aside as a TMF command, and use this command to
send the TMF. This avoids having to rely on the passed-in scsi
command when resetting the device.

Signed-off-by: Hannes Reinecke <hare@suse.com>
---
 drivers/scsi/csiostor/csio_hw.h   |  2 ++
 drivers/scsi/csiostor/csio_init.c |  2 +-
 drivers/scsi/csiostor/csio_scsi.c | 48 +++++++++++++++++++------------
 3 files changed, 33 insertions(+), 19 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_hw.h b/drivers/scsi/csiostor/csio_hw.h
index e351af6e7c81..8e22dccd6d88 100644
--- a/drivers/scsi/csiostor/csio_hw.h
+++ b/drivers/scsi/csiostor/csio_hw.h
@@ -68,6 +68,8 @@
 
 #define CSIO_MAX_LUN		0xFFFF
 #define CSIO_MAX_QUEUE		2048
+#define CSIO_TMF_TAG		(CSIO_MAX_QUEUE - 1)
+
 #define CSIO_MAX_CMD_PER_LUN	32
 #define CSIO_MAX_DDP_BUF_SIZE	(1024 * 1024)
 #define CSIO_MAX_SECTOR_SIZE	128
diff --git a/drivers/scsi/csiostor/csio_init.c b/drivers/scsi/csiostor/csio_init.c
index ccbded3353bd..6a5529d6440f 100644
--- a/drivers/scsi/csiostor/csio_init.c
+++ b/drivers/scsi/csiostor/csio_init.c
@@ -621,7 +621,7 @@ csio_shost_init(struct csio_hw *hw, struct device *dev,
 	/* Link common lnode to this lnode */
 	ln->dev_num = (shost->host_no << 16);
 
-	shost->can_queue = CSIO_MAX_QUEUE;
+	shost->can_queue = CSIO_MAX_QUEUE - 1;
 	shost->this_id = -1;
 	shost->unique_id = shost->host_no;
 	shost->max_cmd_len = 16; /* Max CDB length supported */
diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index c1c410a1cfe0..b21aa2c43051 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -2056,17 +2056,20 @@ csio_tm_cbfn(struct csio_hw *hw, struct csio_ioreq *req)
 
 	/* Wake up the TM handler thread */
 	csio_scsi_cmnd(req) = NULL;
+	cmnd->host_scribble = NULL;
 }
 
 static int
 csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 {
-	struct csio_lnode *ln = shost_priv(cmnd->device->host);
+	struct scsi_device *sdev = cmnd->device;
+	struct csio_lnode *ln = shost_priv(sdev->host);
 	struct csio_hw *hw = csio_lnode_to_hw(ln);
 	struct csio_scsim *scsim = csio_hw_to_scsim(hw);
-	struct csio_rnode *rn = (struct csio_rnode *)(cmnd->device->hostdata);
+	struct csio_rnode *rn = (struct csio_rnode *)(sdev->hostdata);
 	struct csio_ioreq *ioreq = NULL;
 	struct csio_scsi_qset *sqset;
+	struct scsi_cmnd *tmf_cmnd;
 	unsigned long flags;
 	int retval;
 	int count, ret;
@@ -2077,13 +2080,13 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 		goto fail;
 
 	csio_dbg(hw, "Request to reset LUN:%llu (ssni:0x%x tgtid:%d)\n",
-		      cmnd->device->lun, rn->flowid, rn->scsi_id);
+		      sdev->lun, rn->flowid, rn->scsi_id);
 
 	if (!csio_is_lnode_ready(ln)) {
 		csio_err(hw,
 			 "LUN reset cannot be issued on non-ready"
 			 " local node vnpi:0x%x (LUN:%llu)\n",
-			 ln->vnp_flowid, cmnd->device->lun);
+			 ln->vnp_flowid, sdev->lun);
 		goto fail;
 	}
 
@@ -2103,7 +2106,15 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 		csio_err(hw,
 			 "LUN reset cannot be issued on non-ready"
 			 " remote node ssni:0x%x (LUN:%llu)\n",
-			 rn->flowid, cmnd->device->lun);
+			 rn->flowid, sdev->lun);
+		goto fail;
+	}
+
+	tmf_cmnd = scsi_host_find_tag(sdev->host, CSIO_TMF_TAG);
+	if (!tmf_cmnd || tmf_cmnd->host_scribble) {
+		csio_err(hw,
+			 "LUN reset TMF already busy (LUN:%llu)\n",
+			 sdev->lun);
 		goto fail;
 	}
 
@@ -2123,11 +2134,11 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	ioreq->iq_idx		= sqset->iq_idx;
 	ioreq->eq_idx		= sqset->eq_idx;
 
-	csio_scsi_cmnd(ioreq)	= cmnd;
-	cmnd->host_scribble	= (unsigned char *)ioreq;
-	csio_priv(cmnd)->wr_status = 0;
+	csio_scsi_cmnd(ioreq)	= tmf_cmnd;
+	tmf_cmnd->host_scribble	= (unsigned char *)ioreq;
+	csio_priv(tmf_cmnd)->wr_status = 0;
 
-	csio_priv(cmnd)->fc_tm_flags = FCP_TMF_LUN_RESET;
+	csio_priv(tmf_cmnd)->fc_tm_flags = FCP_TMF_LUN_RESET;
 	ioreq->tmo		= CSIO_SCSI_LUNRST_TMO_MS / 1000;
 
 	/*
@@ -2144,7 +2155,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	sld.level = CSIO_LEV_LUN;
 	sld.lnode = ioreq->lnode;
 	sld.rnode = ioreq->rnode;
-	sld.oslun = cmnd->device->lun;
+	sld.oslun = sdev->lun;
 
 	spin_lock_irqsave(&hw->lock, flags);
 	/* Kick off TM SM on the ioreq */
@@ -2154,20 +2165,21 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	if (retval != 0) {
 		csio_err(hw, "Failed to issue LUN reset, req:%p, status:%d\n",
 			    ioreq, retval);
+		tmf_cmnd->host_scribble = NULL;
 		goto fail_ret_ioreq;
 	}
 
 	csio_dbg(hw, "Waiting max %d secs for LUN reset completion\n",
 		    count * (CSIO_SCSI_TM_POLL_MS / 1000));
 	/* Wait for completion */
-	while ((((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == cmnd)
+	while ((((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == tmf_cmnd)
 								&& count--)
 		msleep(CSIO_SCSI_TM_POLL_MS);
 
 	/* LUN reset timed-out */
-	if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == cmnd) {
+	if (((struct scsi_cmnd *)csio_scsi_cmnd(ioreq)) == tmf_cmnd) {
 		csio_err(hw, "LUN reset (%d:%llu) timed out\n",
-			 cmnd->device->id, cmnd->device->lun);
+			 sdev->id, sdev->lun);
 
 		spin_lock_irq(&hw->lock);
 		csio_scsi_drvcleanup(ioreq);
@@ -2178,10 +2190,10 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	}
 
 	/* LUN reset returned, check cached status */
-	if (csio_priv(cmnd)->wr_status != FW_SUCCESS) {
+	if (csio_priv(tmf_cmnd)->wr_status != FW_SUCCESS) {
 		csio_err(hw, "LUN reset failed (%d:%llu), status: %d\n",
-			 cmnd->device->id, cmnd->device->lun,
-			 csio_priv(cmnd)->wr_status);
+			 sdev->id, sdev->lun,
+			 csio_priv(tmf_cmnd)->wr_status);
 		goto fail;
 	}
 
@@ -2201,7 +2213,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	if (retval != 0) {
 		csio_err(hw,
 			 "Attempt to abort I/Os during LUN reset of %llu"
-			 " returned %d\n", cmnd->device->lun, retval);
+			 " returned %d\n", sdev->lun, retval);
 		/* Return I/Os back to active_q */
 		spin_lock_irq(&hw->lock);
 		list_splice_tail_init(&local_q, &scsim->active_q);
@@ -2212,7 +2224,7 @@ csio_eh_lun_reset_handler(struct scsi_cmnd *cmnd)
 	CSIO_INC_STATS(rn, n_lun_rst);
 
 	csio_info(hw, "LUN reset occurred (%d:%llu)\n",
-		  cmnd->device->id, cmnd->device->lun);
+		  sdev->id, sdev->lun);
 
 	return SUCCESS;
 
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 31+ messages in thread

* Re: [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset
  2022-05-02 21:59 ` [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
@ 2022-05-03 20:04   ` michael.christie
  0 siblings, 0 replies; 31+ messages in thread
From: michael.christie @ 2022-05-03 20:04 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

On 5/2/22 2:59 PM, Hannes Reinecke wrote:
> iscsi_eh_target_reset() and iscsi_eh_session_reset() only depend
> on the cls_session, so use that as an argument.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  drivers/scsi/be2iscsi/be_main.c | 10 +++++++++-
>  drivers/scsi/libiscsi.c         | 21 +++++++++------------
>  include/scsi/libiscsi.h         |  2 +-
>  3 files changed, 19 insertions(+), 14 deletions(-)
> 

Reviewed-by: Mike Christie <michael.christie@oracle.com>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh()
  2022-05-02 21:59 ` [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
@ 2022-05-03 20:32   ` michael.christie
  0 siblings, 0 replies; 31+ messages in thread
From: michael.christie @ 2022-05-03 20:32 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

On 5/2/22 2:59 PM, Hannes Reinecke wrote:
> We should be passing in the session directly instead of deriving it
> from the scsi command.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  drivers/scsi/qla4xxx/ql4_os.c       | 34 ++++++++++++++++++-----------
>  drivers/scsi/scsi_transport_iscsi.c |  6 ++---
>  include/scsi/scsi_transport_iscsi.h |  2 +-
>  3 files changed, 24 insertions(+), 18 deletions(-)

Reviewed-by: Mike Christie <michael.christie@oracle.com>

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler
  2022-05-02 21:59 ` [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
@ 2022-05-03 21:02   ` Lee Duncan
  0 siblings, 0 replies; 31+ messages in thread
From: Lee Duncan @ 2022-05-03 21:02 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Bart Van Assche

On 5/2/22 14:59, Hannes Reinecke wrote:
> Issuing a host reset should not rely on any commands.
> So use Scsi_Host as argument for eh_host_reset_handler.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>
> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>   Documentation/scsi/scsi_eh.rst                |  2 +-
>   Documentation/scsi/scsi_mid_low_api.rst       |  4 +-
>   drivers/infiniband/ulp/srp/ib_srp.c           |  6 +--
>   drivers/message/fusion/mptscsih.c             | 19 +++++----
>   drivers/message/fusion/mptscsih.h             |  2 +-
>   drivers/s390/scsi/zfcp_scsi.c                 |  3 +-
>   drivers/scsi/3w-9xxx.c                        | 11 +++---
>   drivers/scsi/3w-sas.c                         | 11 +++---
>   drivers/scsi/3w-xxxx.c                        | 11 +++---
>   drivers/scsi/53c700.c                         | 39 ++++++++++---------
>   drivers/scsi/BusLogic.c                       | 14 ++-----
>   drivers/scsi/NCR5380.c                        |  3 +-
>   drivers/scsi/aacraid/linit.c                  |  6 +--
>   drivers/scsi/advansys.c                       | 26 +++++++------
>   drivers/scsi/aha1542.c                        | 20 +++++-----
>   drivers/scsi/arm/acornscsi.c                  |  8 ++--
>   drivers/scsi/arm/fas216.c                     |  4 +-
>   drivers/scsi/arm/fas216.h                     |  6 +--
>   drivers/scsi/atari_scsi.c                     |  4 +-
>   drivers/scsi/cxlflash/main.c                  |  5 +--
>   drivers/scsi/dpt_i2o.c                        | 14 +++----
>   drivers/scsi/dpti.h                           |  2 +-
>   drivers/scsi/esas2r/esas2r.h                  |  2 +-
>   drivers/scsi/esas2r/esas2r_main.c             | 16 ++++----
>   drivers/scsi/esp_scsi.c                       |  4 +-
>   drivers/scsi/fdomain.c                        |  3 +-
>   drivers/scsi/fnic/fnic.h                      |  2 +-
>   drivers/scsi/fnic/fnic_scsi.c                 |  3 +-
>   drivers/scsi/hptiop.c                         |  6 +--
>   drivers/scsi/ibmvscsi/ibmvfc.c                |  4 +-
>   drivers/scsi/ibmvscsi/ibmvscsi.c              |  4 +-
>   drivers/scsi/imm.c                            |  4 +-
>   drivers/scsi/ipr.c                            |  4 +-
>   drivers/scsi/ips.c                            | 22 ++++-------
>   drivers/scsi/libfc/fc_fcp.c                   |  5 +--
>   drivers/scsi/lpfc/lpfc_scsi.c                 |  3 +-
>   drivers/scsi/mac53c94.c                       |  8 ++--
>   drivers/scsi/megaraid.c                       |  4 +-
>   drivers/scsi/megaraid.h                       |  2 +-
>   drivers/scsi/megaraid/megaraid_mbox.c         | 14 ++-----
>   drivers/scsi/megaraid/megaraid_sas_base.c     | 34 ++++++++--------
>   drivers/scsi/mesh.c                           | 10 ++---
>   drivers/scsi/mpi3mr/mpi3mr_os.c               | 12 +++---
>   drivers/scsi/mpt3sas/mpt3sas_scsih.c          | 11 +++---
>   drivers/scsi/mvumi.c                          |  7 ++--
>   drivers/scsi/myrb.c                           |  3 +-
>   drivers/scsi/myrs.c                           |  3 +-
>   drivers/scsi/nsp32.c                          | 12 +++---
>   drivers/scsi/pcmcia/nsp_cs.c                  |  4 +-
>   drivers/scsi/pcmcia/nsp_cs.h                  |  2 +-
>   drivers/scsi/pcmcia/qlogic_stub.c             |  4 +-
>   drivers/scsi/pcmcia/sym53c500_cs.c            |  8 ++--
>   drivers/scsi/pmcraid.c                        |  6 +--
>   drivers/scsi/ppa.c                            |  4 +-
>   drivers/scsi/qedf/qedf_main.c                 |  4 +-
>   drivers/scsi/qedi/qedi_iscsi.c                |  3 +-
>   drivers/scsi/qla1280.c                        |  3 +-
>   drivers/scsi/qla2xxx/qla_os.c                 | 18 +++------
>   drivers/scsi/qla4xxx/ql4_os.c                 | 18 ++++-----
>   drivers/scsi/qlogicfas408.c                   | 10 ++---
>   drivers/scsi/qlogicfas408.h                   |  2 +-
>   drivers/scsi/qlogicpti.c                      |  3 +-
>   drivers/scsi/scsi_debug.c                     |  8 ++--
>   drivers/scsi/scsi_error.c                     |  2 +-
>   drivers/scsi/snic/snic.h                      |  3 +-
>   drivers/scsi/snic/snic_scsi.c                 | 37 ++++--------------
>   drivers/scsi/stex.c                           |  7 ++--
>   drivers/scsi/storvsc_drv.c                    |  4 +-
>   drivers/scsi/sym53c8xx_2/sym_glue.c           |  3 +-
>   drivers/scsi/ufs/ufshcd.c                     |  6 +--
>   drivers/scsi/vmw_pvscsi.c                     |  5 +--
>   drivers/scsi/wd33c93.c                        |  5 +--
>   drivers/scsi/wd33c93.h                        |  2 +-
>   drivers/scsi/wd719x.c                         |  4 +-
>   .../staging/unisys/visorhba/visorhba_main.c   |  4 +-
>   drivers/usb/image/microtek.c                  |  4 +-
>   include/scsi/libfc.h                          |  2 +-
>   include/scsi/scsi_host.h                      |  2 +-
>   78 files changed, 269 insertions(+), 340 deletions(-)
> 
> diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
> index 885395dc1f15..12113cca5ad9 100644
> --- a/Documentation/scsi/scsi_eh.rst
> +++ b/Documentation/scsi/scsi_eh.rst
> @@ -215,7 +215,7 @@ considered to fail always.
>       int (* eh_abort_handler)(struct scsi_cmnd *);
>       int (* eh_device_reset_handler)(struct scsi_cmnd *);
>       int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> -    int (* eh_host_reset_handler)(struct scsi_cmnd *);
> +    int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   Higher-severity actions are taken only when lower-severity actions
>   cannot recover some of failed scmds.  Also, note that failure of the
> diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
> index 63ddea2b9640..784587ea7eee 100644
> --- a/Documentation/scsi/scsi_mid_low_api.rst
> +++ b/Documentation/scsi/scsi_mid_low_api.rst
> @@ -777,7 +777,7 @@ Details::
>   
>       /**
>       *      eh_host_reset_handler - reset host (host bus adapter)
> -    *      @scp: SCSI host that contains this device should be reset
> +    *      @shp: SCSI host that contains this device should be reset
>       *
>       *      Returns SUCCESS if command aborted else FAILED
>       *
> @@ -794,7 +794,7 @@ Details::
>       *
>       *      Optionally defined in: LLD
>       **/
> -	int eh_host_reset_handler(struct scsi_cmnd * scp)
> +	int eh_host_reset_handler(struct Scsi_Host * shp)
>   
>   
>       /**
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index 285b766e4e70..de901dee6935 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -2842,11 +2842,11 @@ static int srp_reset_device(struct scsi_cmnd *scmnd)
>   	return SUCCESS;
>   }
>   
> -static int srp_reset_host(struct scsi_cmnd *scmnd)
> +static int srp_reset_host(struct Scsi_Host *shost)
>   {
> -	struct srp_target_port *target = host_to_target(scmnd->device->host);
> +	struct srp_target_port *target = host_to_target(shost);
>   
> -	shost_printk(KERN_ERR, target->scsi_host, PFX "SRP reset_host called\n");
> +	shost_printk(KERN_ERR, shost, PFX "SRP reset_host called\n");
>   
>   	return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED;
>   }
> diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
> index ed21cc4d2c77..3df07e024026 100644
> --- a/drivers/message/fusion/mptscsih.c
> +++ b/drivers/message/fusion/mptscsih.c
> @@ -1956,15 +1956,15 @@ mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
>   
>   /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
>   /**
> - *	mptscsih_host_reset - Perform a SCSI host adapter RESET (new_eh variant)
> - *	@SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
> + *	mptscsih_host_reset - Perform a SCSI host adapter RESET
> + *	@sh: Pointer to Scsi_Host structure, which is reset due to
>    *
>    *	(linux scsi_host_template.eh_host_reset_handler routine)
>    *
>    *	Returns SUCCESS or FAILED.
>    */
>   int
> -mptscsih_host_reset(struct scsi_cmnd *SCpnt)
> +mptscsih_host_reset(struct Scsi_Host *sh)
>   {
>   	MPT_SCSI_HOST *  hd;
>   	int              status = SUCCESS;
> @@ -1972,9 +1972,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
>   	int		retval;
>   
>   	/*  If we can't locate the host to reset, then we failed. */
> -	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
> -		printk(KERN_ERR MYNAM ": host reset: "
> -		    "Can't locate host! (sc=%p)\n", SCpnt);
> +	if ((hd = shost_priv(sh)) == NULL){
> +		printk(KERN_ERR MYNAM ": host reset: Can't locate host!\n");
>   		return FAILED;
>   	}
>   
> @@ -1982,8 +1981,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
>   	mptscsih_flush_running_cmds(hd);
>   
>   	ioc = hd->ioc;
> -	printk(MYIOC_s_INFO_FMT "attempting host reset! (sc=%p)\n",
> -	    ioc->name, SCpnt);
> +	printk(MYIOC_s_INFO_FMT "attempting host reset!\n",
> +	    ioc->name);
>   
>   	/*  If our attempts to reset the host failed, then return a failed
>   	 *  status.  The host will be taken off line by the SCSI mid-layer.
> @@ -1994,8 +1993,8 @@ mptscsih_host_reset(struct scsi_cmnd *SCpnt)
>   	else
>   		status = SUCCESS;
>   
> -	printk(MYIOC_s_INFO_FMT "host reset: %s (sc=%p)\n",
> -	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
> +	printk(MYIOC_s_INFO_FMT "host reset: %s\n",
> +	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
>   
>   	return status;
>   }
> diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
> index e3d92c392673..0faefe9c7541 100644
> --- a/drivers/message/fusion/mptscsih.h
> +++ b/drivers/message/fusion/mptscsih.h
> @@ -122,7 +122,7 @@ extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
>   extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
>   extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
>   extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
> -extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt);
> +extern int mptscsih_host_reset(struct Scsi_Host *sh);
>   extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
>   extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
>   extern int mptscsih_taskmgmt_complete(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
> diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
> index fb2b73fca381..873ccc60e4d6 100644
> --- a/drivers/s390/scsi/zfcp_scsi.c
> +++ b/drivers/s390/scsi/zfcp_scsi.c
> @@ -371,9 +371,8 @@ static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)
>   	return ret;
>   }
>   
> -static int zfcp_scsi_eh_host_reset_handler(struct scsi_cmnd *scpnt)
> +static int zfcp_scsi_eh_host_reset_handler(struct Scsi_Host *host)
>   {
> -	struct Scsi_Host *host = scpnt->device->host;
>   	struct zfcp_adapter *adapter = (struct zfcp_adapter *)host->hostdata[0];
>   	int ret = SUCCESS;
>   	unsigned long flags;
> diff --git a/drivers/scsi/3w-9xxx.c b/drivers/scsi/3w-9xxx.c
> index cd823ff5deab..61af5c5eaccb 100644
> --- a/drivers/scsi/3w-9xxx.c
> +++ b/drivers/scsi/3w-9xxx.c
> @@ -1717,18 +1717,19 @@ static int twa_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde
>   } /* End twa_scsi_biosparam() */
>   
>   /* This is the new scsi eh reset function */
> -static int twa_scsi_eh_reset(struct scsi_cmnd *SCpnt)
> +static int twa_scsi_eh_reset(struct Scsi_Host *shost)
>   {
>   	TW_Device_Extension *tw_dev = NULL;
>   	int retval = FAILED;
>   
> -	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
> +	tw_dev = (TW_Device_Extension *)shost->hostdata;
>   
>   	tw_dev->num_resets++;
>   
> -	sdev_printk(KERN_WARNING, SCpnt->device,
> -		"WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
> -		TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
> +	shost_printk(KERN_WARNING, shost,
> +		     "WARNING: (0x%02X:0x%04X): "
> +		     "Command timed out, resetting card.\n",
> +		     TW_DRIVER, 0x2c);
>   
>   	/* Make sure we are not issuing an ioctl or resetting from ioctl */
>   	mutex_lock(&tw_dev->ioctl_lock);
> diff --git a/drivers/scsi/3w-sas.c b/drivers/scsi/3w-sas.c
> index 3ebe66151dcb..c4d1ebf15700 100644
> --- a/drivers/scsi/3w-sas.c
> +++ b/drivers/scsi/3w-sas.c
> @@ -1423,18 +1423,19 @@ static int twl_scsi_biosparam(struct scsi_device *sdev, struct block_device *bde
>   } /* End twl_scsi_biosparam() */
>   
>   /* This is the new scsi eh reset function */
> -static int twl_scsi_eh_reset(struct scsi_cmnd *SCpnt)
> +static int twl_scsi_eh_reset(struct Scsi_Host *shost)
>   {
>   	TW_Device_Extension *tw_dev = NULL;
>   	int retval = FAILED;
>   
> -	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
> +	tw_dev = (TW_Device_Extension *)shost->hostdata;
>   
>   	tw_dev->num_resets++;
>   
> -	sdev_printk(KERN_WARNING, SCpnt->device,
> -		"WARNING: (0x%02X:0x%04X): Command (0x%x) timed out, resetting card.\n",
> -		TW_DRIVER, 0x2c, SCpnt->cmnd[0]);
> +	shost_printk(KERN_WARNING, shost,
> +		     "WARNING: (0x%02X:0x%04X): "
> +		     "Command timed out, resetting card.\n",
> +		     TW_DRIVER, 0x2c);
>   
>   	/* Make sure we are not issuing an ioctl or resetting from ioctl */
>   	mutex_lock(&tw_dev->ioctl_lock);
> diff --git a/drivers/scsi/3w-xxxx.c b/drivers/scsi/3w-xxxx.c
> index a853c5497af6..8c5f37563515 100644
> --- a/drivers/scsi/3w-xxxx.c
> +++ b/drivers/scsi/3w-xxxx.c
> @@ -1366,25 +1366,24 @@ static int tw_scsi_biosparam(struct scsi_device *sdev, struct block_device *bdev
>   } /* End tw_scsi_biosparam() */
>   
>   /* This is the new scsi eh reset function */
> -static int tw_scsi_eh_reset(struct scsi_cmnd *SCpnt)
> +static int tw_scsi_eh_reset(struct Scsi_Host *shost)
>   {
>   	TW_Device_Extension *tw_dev=NULL;
>   	int retval = FAILED;
>   
> -	tw_dev = (TW_Device_Extension *)SCpnt->device->host->hostdata;
> +	tw_dev = (TW_Device_Extension *)shost->hostdata;
>   
>   	tw_dev->num_resets++;
>   
> -	sdev_printk(KERN_WARNING, SCpnt->device,
> -		"WARNING: Command (0x%x) timed out, resetting card.\n",
> -		SCpnt->cmnd[0]);
> +	shost_printk(KERN_WARNING, shost,
> +		"WARNING: Command timed out, resetting card.\n");
>   
>   	/* Make sure we are not issuing an ioctl or resetting from ioctl */
>   	mutex_lock(&tw_dev->ioctl_lock);
>   
>   	/* Now reset the card and some of the device extension data */
>   	if (tw_reset_device_extension(tw_dev)) {
> -		printk(KERN_WARNING "3w-xxxx: scsi%d: Reset failed.\n", tw_dev->host->host_no);
> +		shost_printk(KERN_WARNING, shost, "Reset failed.\n");
>   		goto out;
>   	}
>   
> diff --git a/drivers/scsi/53c700.c b/drivers/scsi/53c700.c
> index e1e4f9d10887..6a44a0795bb5 100644
> --- a/drivers/scsi/53c700.c
> +++ b/drivers/scsi/53c700.c
> @@ -155,7 +155,7 @@ MODULE_LICENSE("GPL");
>   
>   STATIC int NCR_700_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *);
>   STATIC int NCR_700_abort(struct scsi_cmnd * SCpnt);
> -STATIC int NCR_700_host_reset(struct scsi_cmnd * SCpnt);
> +STATIC int NCR_700_host_reset(struct Scsi_Host *host);
>   STATIC void NCR_700_chip_setup(struct Scsi_Host *host);
>   STATIC void NCR_700_chip_reset(struct Scsi_Host *host);
>   STATIC int NCR_700_slave_alloc(struct scsi_device *SDpnt);
> @@ -1934,40 +1934,41 @@ NCR_700_abort(struct scsi_cmnd * SCp)
>   }
>   
>   STATIC int
> -NCR_700_host_reset(struct scsi_cmnd * SCp)
> +NCR_700_host_reset(struct Scsi_Host * host)
>   {
>   	DECLARE_COMPLETION_ONSTACK(complete);
> -	struct NCR_700_Host_Parameters *hostdata =
> -		(struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];
> +	struct NCR_700_Host_Parameters *hostdata =
> +		(struct NCR_700_Host_Parameters *)host->hostdata[0];
>   
> -	scmd_printk(KERN_INFO, SCp,
> -		"New error handler wants HOST reset, cmd %p\n\t", SCp);
> -	scsi_print_command(SCp);
> +	shost_printk(KERN_INFO, host,
> +		"New error handler wants HOST reset\n");
>   
>   	/* In theory, eh_complete should always be null because the
>   	 * eh is single threaded, but just in case we're handling a
>   	 * reset via sg or something */
> -	spin_lock_irq(SCp->device->host->host_lock);
> +	spin_lock_irq(host->host_lock);
>   	while (hostdata->eh_complete != NULL) {
> -		spin_unlock_irq(SCp->device->host->host_lock);
> +		spin_unlock_irq(host->host_lock);
>   		msleep_interruptible(100);
> -		spin_lock_irq(SCp->device->host->host_lock);
> +		spin_lock_irq(host->host_lock);
>   	}
>   
>   	hostdata->eh_complete = &complete;
> -	NCR_700_internal_bus_reset(SCp->device->host);
> -	NCR_700_chip_reset(SCp->device->host);
> +	NCR_700_internal_bus_reset(host);
> +	NCR_700_chip_reset(host);
>   
> -	spin_unlock_irq(SCp->device->host->host_lock);
> +	spin_unlock_irq(host->host_lock);
>   	wait_for_completion(&complete);
> -	spin_lock_irq(SCp->device->host->host_lock);
> +	spin_lock_irq(host->host_lock);
>   
>   	hostdata->eh_complete = NULL;
> -	/* Revalidate the transport parameters of the failing device */
> -	if(hostdata->fast)
> -		spi_schedule_dv_device(SCp->device);
> -
> -	spin_unlock_irq(SCp->device->host->host_lock);
> +	/* Revalidate the transport parameters for attached devices */
> +	if(hostdata->fast) {
> +		struct scsi_device *sdev;
> +		__shost_for_each_device(sdev, host)
> +			spi_schedule_dv_device(sdev);
> +	}
> +	spin_unlock_irq(host->host_lock);
>   	return SUCCESS;
>   }
>   
> diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c
> index a897c8f914cf..62c3aa7570ab 100644
> --- a/drivers/scsi/BusLogic.c
> +++ b/drivers/scsi/BusLogic.c
> @@ -2843,21 +2843,15 @@ static bool blogic_write_outbox(struct blogic_adapter *adapter,
>   
>   /* Error Handling (EH) support */
>   
> -static int blogic_hostreset(struct scsi_cmnd *SCpnt)
> +static int blogic_hostreset(struct Scsi_Host *shost)
>   {
>   	struct blogic_adapter *adapter =
> -		(struct blogic_adapter *) SCpnt->device->host->hostdata;
> -
> -	unsigned int id = SCpnt->device->id;
> -	struct blogic_tgt_stats *stats = &adapter->tgt_stats[id];
> +		(struct blogic_adapter *) shost->hostdata;
>   	int rc;
>   
> -	spin_lock_irq(SCpnt->device->host->host_lock);
> -
> -	blogic_inc_count(&stats->adapter_reset_req);
> -
> +	spin_lock_irq(shost->host_lock);
>   	rc = blogic_resetadapter(adapter, false);
> -	spin_unlock_irq(SCpnt->device->host->host_lock);
> +	spin_unlock_irq(shost->host_lock);
>   	return rc;
>   }
>   
> diff --git a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
> index dece7d9eb4d3..6704415fb1c2 100644
> --- a/drivers/scsi/NCR5380.c
> +++ b/drivers/scsi/NCR5380.c
> @@ -2379,9 +2379,8 @@ static void bus_reset_cleanup(struct Scsi_Host *instance)
>    * Returns SUCCESS
>    */
>   
> -static int NCR5380_host_reset(struct scsi_cmnd *cmd)
> +static int NCR5380_host_reset(struct Scsi_Host *instance)
>   {
> -	struct Scsi_Host *instance = cmd->device->host;
>   	struct NCR5380_hostdata *hostdata = shost_priv(instance);
>   	unsigned long flags;
>   	struct NCR5380_cmd *ncmd;
> diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
> index 9c27bc37e5de..19a012c9a3c9 100644
> --- a/drivers/scsi/aacraid/linit.c
> +++ b/drivers/scsi/aacraid/linit.c
> @@ -1078,13 +1078,11 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
>   
>   /*
>    *	aac_eh_host_reset	- Host reset command handling
> - *	@scsi_cmd:	SCSI command block causing the reset
> + *	@host:	SCSI host to be reset
>    *
>    */
> -static int aac_eh_host_reset(struct scsi_cmnd *cmd)
> +static int aac_eh_host_reset(struct Scsi_Host *host)
>   {
> -	struct scsi_device * dev = cmd->device;
> -	struct Scsi_Host * host = dev->host;
>   	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
>   	int ret = FAILED;
>   	__le32 supported_options2 = 0;
> diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
> index f301aec044bb..0b7fcf7f9624 100644
> --- a/drivers/scsi/advansys.c
> +++ b/drivers/scsi/advansys.c
> @@ -7016,9 +7016,8 @@ static int AscISR(ASC_DVC_VAR *asc_dvc)
>    * sleeping is allowed and no locking other than for host structures is
>    * required. Returns SUCCESS or FAILED.
>    */
> -static int advansys_reset(struct scsi_cmnd *scp)
> +static int advansys_reset(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = scp->device->host;
>   	struct asc_board *boardp = shost_priv(shost);
>   	unsigned long flags;
>   	int status;
> @@ -7028,7 +7027,7 @@ static int advansys_reset(struct scsi_cmnd *scp)
>   
>   	ASC_STATS(shost, reset);
>   
> -	scmd_printk(KERN_INFO, scp, "SCSI host reset started...\n");
> +	shost_printk(KERN_INFO, shost, "SCSI host reset started...\n");
>   
>   	if (ASC_NARROW_BOARD(boardp)) {
>   		ASC_DVC_VAR *asc_dvc = &boardp->dvc_var.asc_dvc_var;
> @@ -7039,16 +7038,18 @@ static int advansys_reset(struct scsi_cmnd *scp)
>   
>   		/* Refer to ASC_IERR_* definitions for meaning of 'err_code'. */
>   		if (asc_dvc->err_code || !asc_dvc->overrun_dma) {
> -			scmd_printk(KERN_INFO, scp, "SCSI host reset error: "
> -				    "0x%x, status: 0x%x\n", asc_dvc->err_code,
> +			shost_printk(KERN_INFO, shost,
> +				     "SCSI host reset error: 0x%x, status: 0x%x\n",
> +				     asc_dvc->err_code,
>   				    status);
>   			ret = FAILED;
>   		} else if (status) {
> -			scmd_printk(KERN_INFO, scp, "SCSI host reset warning: "
> -				    "0x%x\n", status);
> +			shost_printk(KERN_INFO, shost,
> +				     "SCSI host reset warning: 0x%x\n",
> +				     status);
>   		} else {
> -			scmd_printk(KERN_INFO, scp, "SCSI host reset "
> -				    "successful\n");
> +			shost_printk(KERN_INFO, shost,
> +				     "SCSI host reset successful\n");
>   		}
>   
>   		ASC_DBG(1, "after AscInitAsc1000Driver()\n");
> @@ -7065,12 +7066,13 @@ static int advansys_reset(struct scsi_cmnd *scp)
>   		ASC_DBG(1, "before AdvResetChipAndSB()\n");
>   		switch (AdvResetChipAndSB(adv_dvc)) {
>   		case ASC_TRUE:
> -			scmd_printk(KERN_INFO, scp, "SCSI host reset "
> -				    "successful\n");
> +			shost_printk(KERN_INFO, shost,
> +				     "SCSI host reset successful\n");
>   			break;
>   		case ASC_FALSE:
>   		default:
> -			scmd_printk(KERN_INFO, scp, "SCSI host reset error\n");
> +			shost_printk(KERN_INFO, shost,
> +				     "SCSI host reset error\n");
>   			ret = FAILED;
>   			break;
>   		}
> diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
> index cf7bba2ca68d..69063fe4aab8 100644
> --- a/drivers/scsi/aha1542.c
> +++ b/drivers/scsi/aha1542.c
> @@ -913,15 +913,14 @@ static int aha1542_dev_reset(struct scsi_cmnd *cmd)
>   	aha1542_outb(sh->io_port, CMD_START_SCSI);
>   	spin_unlock_irqrestore(sh->host_lock, flags);
>   
> -	scmd_printk(KERN_WARNING, cmd,
> +	sdev_printk(KERN_WARNING, sdev,
>   		"Trying device reset for target\n");
>   
>   	return SUCCESS;
>   }
>   
> -static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
> +static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
>   {
> -	struct Scsi_Host *sh = cmd->device->host;
>   	struct aha1542_hostdata *aha1542 = shost_priv(sh);
>   	unsigned long flags;
>   	int i;
> @@ -933,9 +932,9 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
>   	 * we do this?  Try this first, and we can add that later
>   	 * if it turns out to be useful.
>   	 */
> -	outb(reset_cmd, CONTROL(cmd->device->host->io_port));
> +	outb(reset_cmd, CONTROL(sh->io_port));
>   
> -	if (!wait_mask(STATUS(cmd->device->host->io_port),
> +	if (!wait_mask(STATUS(sh->io_port),
>   	     STATMASK, IDLE, STST | DIAGF | INVDCMD | DF | CDF, 0)) {
>   		spin_unlock_irqrestore(sh->host_lock, flags);
>   		return FAILED;
> @@ -946,7 +945,7 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
>   	 * us again after host reset.
>   	 */
>   	if (reset_cmd & HRST)
> -		setup_mailboxes(cmd->device->host);
> +		setup_mailboxes(sh);
>   
>   	/*
>   	 * Now try to pick up the pieces.  For all pending commands,
> @@ -954,7 +953,8 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
>   	 * out.  We do not try and restart any commands or anything -
>   	 * the strategy handler takes care of that crap.
>   	 */
> -	shost_printk(KERN_WARNING, cmd->device->host, "Sent BUS RESET to scsi host %d\n", cmd->device->host->host_no);
> +	shost_printk(KERN_WARNING, sh, "Sent BUS RESET to scsi host %d\n",
> +		     sh->host_no);
>   
>   	for (i = 0; i < AHA1542_MAILBOXES; i++) {
>   		if (aha1542->int_cmds[i] != NULL) {
> @@ -982,12 +982,12 @@ static int aha1542_reset(struct scsi_cmnd *cmd, u8 reset_cmd)
>   
>   static int aha1542_bus_reset(struct scsi_cmnd *cmd)
>   {
> -	return aha1542_reset(cmd, SCRST);
> +	return aha1542_reset(cmd->device->host, SCRST);
>   }
>   
> -static int aha1542_host_reset(struct scsi_cmnd *cmd)
> +static int aha1542_host_reset(struct Scsi_Host *sh)
>   {
> -	return aha1542_reset(cmd, HRST | SCRST);
> +	return aha1542_reset(sh, HRST | SCRST);
>   }
>   
>   static int aha1542_biosparam(struct scsi_device *sdev,
> diff --git a/drivers/scsi/arm/acornscsi.c b/drivers/scsi/arm/acornscsi.c
> index 7602639da9b3..3fc9326fc4c0 100644
> --- a/drivers/scsi/arm/acornscsi.c
> +++ b/drivers/scsi/arm/acornscsi.c
> @@ -2631,13 +2631,13 @@ int acornscsi_abort(struct scsi_cmnd *SCpnt)
>   /*
>    * Prototype: int acornscsi_reset(struct scsi_cmnd *SCpnt)
>    * Purpose  : reset a command on this host/reset this host
> - * Params   : SCpnt  - command causing reset
> + * Params   : shost  - host to be reset
>    * Returns  : one of SCSI_RESET_ macros
>    */
> -int acornscsi_host_reset(struct scsi_cmnd *SCpnt)
> +int acornscsi_host_reset(struct Scsi_Host *shost)
>   {
> -	AS_Host *host = (AS_Host *)SCpnt->device->host->hostdata;
> -	struct scsi_cmnd *SCptr;
> +    AS_Host *host = (AS_Host *)shost->hostdata;
> +    struct scsi_cmnd *SCptr;
>       
>       host->stats.resets += 1;
>   
> diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
> index e6289c6af5ef..38eec967155d 100644
> --- a/drivers/scsi/arm/fas216.c
> +++ b/drivers/scsi/arm/fas216.c
> @@ -2656,9 +2656,9 @@ static void fas216_init_chip(FAS216_Info *info)
>    * Returns: FAILED if unable to reset.
>    * Notes: io_request_lock is taken, and irqs are disabled
>    */
> -int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
> +int fas216_eh_host_reset(struct Scsi_Host *shost)
>   {
> -	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
> +	FAS216_Info *info = (FAS216_Info *)shost->hostdata;
>   
>   	spin_lock_irq(info->host->host_lock);
>   
> diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
> index 08113277a2a9..f17583f143b3 100644
> --- a/drivers/scsi/arm/fas216.h
> +++ b/drivers/scsi/arm/fas216.h
> @@ -394,11 +394,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
>    */
>   extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
>   
> -/* Function: int fas216_eh_host_reset(struct scsi_cmnd *SCpnt)
> +/* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
>    * Purpose : Reset the host associated with this command
> - * Params  : SCpnt - command specifing host to reset
> + * Params  : shost - host to reset
>    * Returns : FAILED if unable to reset
>    */
> -extern int fas216_eh_host_reset(struct scsi_cmnd *SCpnt);
> +extern int fas216_eh_host_reset(struct Scsi_Host *shost);
>   
>   #endif /* FAS216_H */
> diff --git a/drivers/scsi/atari_scsi.c b/drivers/scsi/atari_scsi.c
> index d401cf27113a..d967141f366c 100644
> --- a/drivers/scsi/atari_scsi.c
> +++ b/drivers/scsi/atari_scsi.c
> @@ -667,7 +667,7 @@ static void atari_scsi_falcon_reg_write(unsigned int reg, u8 value)
>   
>   #include "NCR5380.c"
>   
> -static int atari_scsi_host_reset(struct scsi_cmnd *cmd)
> +static int atari_scsi_host_reset(struct Scsi_Host *shost)
>   {
>   	int rv;
>   	unsigned long flags;
> @@ -684,7 +684,7 @@ static int atari_scsi_host_reset(struct scsi_cmnd *cmd)
>   		atari_dma_orig_addr = NULL;
>   	}
>   
> -	rv = NCR5380_host_reset(cmd);
> +	rv = NCR5380_host_reset(shost);
>   
>   	/* The 5380 raises its IRQ line while _RST is active but the ST DMA
>   	 * "lock" has been released so this interrupt may end up handled by
> diff --git a/drivers/scsi/cxlflash/main.c b/drivers/scsi/cxlflash/main.c
> index e7be95ee7d64..50c04ba85b0b 100644
> --- a/drivers/scsi/cxlflash/main.c
> +++ b/drivers/scsi/cxlflash/main.c
> @@ -2476,7 +2476,7 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
>   
>   /**
>    * cxlflash_eh_host_reset_handler() - reset the host adapter
> - * @scp:	SCSI command from stack identifying host.
> + * @host:	SCSI host adapter.
>    *
>    * Following a reset, the state is evaluated again in case an EEH occurred
>    * during the reset. In such a scenario, the host reset will either yield
> @@ -2487,11 +2487,10 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
>    *	SUCCESS as defined in scsi/scsi.h
>    *	FAILED as defined in scsi/scsi.h
>    */
> -static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp)
> +static int cxlflash_eh_host_reset_handler(struct Scsi_Host *host)
>   {
>   	int rc = SUCCESS;
>   	int rcr = 0;
> -	struct Scsi_Host *host = scp->device->host;
>   	struct cxlflash_cfg *cfg = shost_priv(host);
>   	struct device *dev = &cfg->dev->dev;
>   
> diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
> index 93227c04ef59..6e3ad0e5b533 100644
> --- a/drivers/scsi/dpt_i2o.c
> +++ b/drivers/scsi/dpt_i2o.c
> @@ -746,15 +746,15 @@ static int adpt_bus_reset(struct scsi_cmnd* cmd)
>   }
>   
>   // This version of reset is called by the eh_error_handler
> -static int __adpt_reset(struct scsi_cmnd* cmd)
> +static int __adpt_reset(struct Scsi_Host* shost)
>   {
>   	adpt_hba* pHba;
>   	int rcode;
>   	char name[32];
>   
> -	pHba = (adpt_hba*)cmd->device->host->hostdata[0];
> +	pHba = (adpt_hba*)shost->hostdata[0];
>   	strncpy(name, pHba->name, sizeof(name));
> -	printk(KERN_WARNING"%s: Hba Reset: scsi id %d: tid: %d\n", name, cmd->device->channel, pHba->channel[cmd->device->channel].tid);
> +	printk(KERN_WARNING"%s: Hba Reset\n", name);
>   	rcode =  adpt_hba_reset(pHba);
>   	if(rcode == 0){
>   		printk(KERN_WARNING"%s: HBA reset complete\n", name);
> @@ -765,13 +765,13 @@ static int __adpt_reset(struct scsi_cmnd* cmd)
>   	}
>   }
>   
> -static int adpt_reset(struct scsi_cmnd* cmd)
> +static int adpt_reset(struct Scsi_Host* shost)
>   {
>   	int rc;
>   
> -	spin_lock_irq(cmd->device->host->host_lock);
> -	rc = __adpt_reset(cmd);
> -	spin_unlock_irq(cmd->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
> +	rc = __adpt_reset(shost);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return rc;
>   }
> diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
> index 8a079e8d7f65..b77a3625fa6f 100644
> --- a/drivers/scsi/dpti.h
> +++ b/drivers/scsi/dpti.h
> @@ -28,7 +28,7 @@
>   static int adpt_detect(struct scsi_host_template * sht);
>   static int adpt_queue(struct Scsi_Host *h, struct scsi_cmnd * cmd);
>   static int adpt_abort(struct scsi_cmnd * cmd);
> -static int adpt_reset(struct scsi_cmnd* cmd);
> +static int adpt_reset(struct Scsi_Host * host);
>   static int adpt_slave_configure(struct scsi_device *);
>   
>   static const char *adpt_info(struct Scsi_Host *pSHost);
> diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
> index ed63f7a9ea54..a104d1a3a9da 100644
> --- a/drivers/scsi/esas2r/esas2r.h
> +++ b/drivers/scsi/esas2r/esas2r.h
> @@ -976,7 +976,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
>   /* SCSI error handler (eh) functions */
>   int esas2r_eh_abort(struct scsi_cmnd *cmd);
>   int esas2r_device_reset(struct scsi_cmnd *cmd);
> -int esas2r_host_reset(struct scsi_cmnd *cmd);
> +int esas2r_host_reset(struct Scsi_Host *shost);
>   int esas2r_bus_reset(struct scsi_cmnd *cmd);
>   int esas2r_target_reset(struct scsi_cmnd *cmd);
>   
> diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
> index 7a4eadad23d7..52494c8bb656 100644
> --- a/drivers/scsi/esas2r/esas2r_main.c
> +++ b/drivers/scsi/esas2r/esas2r_main.c
> @@ -1059,10 +1059,10 @@ int esas2r_eh_abort(struct scsi_cmnd *cmd)
>   	return SUCCESS;
>   }
>   
> -static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset)
> +static int esas2r_host_bus_reset(struct Scsi_Host *shost, bool host_reset)
>   {
>   	struct esas2r_adapter *a =
> -		(struct esas2r_adapter *)cmd->device->host->hostdata;
> +		(struct esas2r_adapter *)shost->hostdata;
>   
>   	if (test_bit(AF_DEGRADED_MODE, &a->flags))
>   		return FAILED;
> @@ -1087,18 +1087,20 @@ static int esas2r_host_bus_reset(struct scsi_cmnd *cmd, bool host_reset)
>   	return SUCCESS;
>   }
>   
> -int esas2r_host_reset(struct scsi_cmnd *cmd)
> +int esas2r_host_reset(struct Scsi_Host *shost)
>   {
> -	esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", cmd);
> +	esas2r_log(ESAS2R_LOG_INFO, "host_reset (%p)", shost);
>   
> -	return esas2r_host_bus_reset(cmd, true);
> +	return esas2r_host_bus_reset(shost, true);
>   }
>   
>   int esas2r_bus_reset(struct scsi_cmnd *cmd)
>   {
> -	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", cmd);
> +	struct Scsi_Host *shost = cmd->device->host;
> +
> +	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
>   
> -	return esas2r_host_bus_reset(cmd, false);
> +	return esas2r_host_bus_reset(shost, false);
>   }
>   
>   static int esas2r_dev_targ_reset(struct scsi_cmnd *cmd, bool target_reset)
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index 64ec6bb84550..b41eac8b5e0f 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2640,9 +2640,9 @@ static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
>   }
>   
>   /* All bets are off, reset the entire device.  */
> -static int esp_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +static int esp_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
> -	struct esp *esp = shost_priv(cmd->device->host);
> +	struct esp *esp = shost_priv(shost);
>   	unsigned long flags;
>   
>   	spin_lock_irqsave(esp->host->host_lock, flags);
> diff --git a/drivers/scsi/fdomain.c b/drivers/scsi/fdomain.c
> index 444eac9b2466..5d3f1520ee50 100644
> --- a/drivers/scsi/fdomain.c
> +++ b/drivers/scsi/fdomain.c
> @@ -456,9 +456,8 @@ static int fdomain_abort(struct scsi_cmnd *cmd)
>   	return SUCCESS;
>   }
>   
> -static int fdomain_host_reset(struct scsi_cmnd *cmd)
> +static int fdomain_host_reset(struct Scsi_Host *sh)
>   {
> -	struct Scsi_Host *sh = cmd->device->host;
>   	struct fdomain *fd = shost_priv(sh);
>   	unsigned long flags;
>   
> diff --git a/drivers/scsi/fnic/fnic.h b/drivers/scsi/fnic/fnic.h
> index aa07189fb5fb..7b81bea3ffa2 100644
> --- a/drivers/scsi/fnic/fnic.h
> +++ b/drivers/scsi/fnic/fnic.h
> @@ -359,7 +359,7 @@ void fnic_update_mac_locked(struct fnic *, u8 *new);
>   int fnic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
>   int fnic_abort_cmd(struct scsi_cmnd *);
>   int fnic_device_reset(struct scsi_cmnd *);
> -int fnic_host_reset(struct scsi_cmnd *);
> +int fnic_host_reset(struct Scsi_Host *);
>   int fnic_reset(struct Scsi_Host *);
>   void fnic_scsi_cleanup(struct fc_lport *);
>   void fnic_scsi_abort_io(struct fc_lport *);
> diff --git a/drivers/scsi/fnic/fnic_scsi.c b/drivers/scsi/fnic/fnic_scsi.c
> index fb6dc59a5a7e..b286d5feaca1 100644
> --- a/drivers/scsi/fnic/fnic_scsi.c
> +++ b/drivers/scsi/fnic/fnic_scsi.c
> @@ -2452,11 +2452,10 @@ int fnic_reset(struct Scsi_Host *shost)
>    * host is offlined by SCSI.
>    *
>    */
> -int fnic_host_reset(struct scsi_cmnd *sc)
> +int fnic_host_reset(struct Scsi_Host *shost)
>   {
>   	int ret;
>   	unsigned long wait_host_tmo;
> -	struct Scsi_Host *shost = sc->device->host;
>   	struct fc_lport *lp = shost_priv(shost);
>   	struct fnic *fnic = lport_priv(lp);
>   	unsigned long flags;
> diff --git a/drivers/scsi/hptiop.c b/drivers/scsi/hptiop.c
> index f18b770626e6..30f6a6891ea2 100644
> --- a/drivers/scsi/hptiop.c
> +++ b/drivers/scsi/hptiop.c
> @@ -1091,12 +1091,12 @@ static int hptiop_reset_hba(struct hptiop_hba *hba)
>   	return 0;
>   }
>   
> -static int hptiop_reset(struct scsi_cmnd *scp)
> +static int hptiop_reset(struct Scsi_Host *host)
>   {
> -	struct hptiop_hba * hba = (struct hptiop_hba *)scp->device->host->hostdata;
> +	struct hptiop_hba * hba = (struct hptiop_hba *)host->hostdata;
>   
>   	printk(KERN_WARNING "hptiop_reset(%d/%d/%d)\n",
> -	       scp->device->host->host_no, -1, -1);
> +	       host->host_no, -1, -1);
>   
>   	return hptiop_reset_hba(hba)? FAILED : SUCCESS;
>   }
> diff --git a/drivers/scsi/ibmvscsi/ibmvfc.c b/drivers/scsi/ibmvscsi/ibmvfc.c
> index 2e7128f0d905..5fb36cd70dde 100644
> --- a/drivers/scsi/ibmvscsi/ibmvfc.c
> +++ b/drivers/scsi/ibmvscsi/ibmvfc.c
> @@ -2984,10 +2984,10 @@ static int ibmvfc_eh_target_reset_handler(struct scsi_cmnd *cmd)
>    * @cmd:	struct scsi_cmnd having problems
>    *
>    **/
> -static int ibmvfc_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +static int ibmvfc_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
>   	int rc;
> -	struct ibmvfc_host *vhost = shost_priv(cmd->device->host);
> +	struct ibmvfc_host *vhost = shost_priv(shost);
>   
>   	dev_err(vhost->dev, "Resetting connection due to error recovery\n");
>   	rc = ibmvfc_issue_fc_host_lip(vhost->host);
> diff --git a/drivers/scsi/ibmvscsi/ibmvscsi.c b/drivers/scsi/ibmvscsi/ibmvscsi.c
> index 63f32f843e75..892d79e2e7e1 100644
> --- a/drivers/scsi/ibmvscsi/ibmvscsi.c
> +++ b/drivers/scsi/ibmvscsi/ibmvscsi.c
> @@ -1735,10 +1735,10 @@ static int ibmvscsi_eh_device_reset_handler(struct scsi_cmnd *cmd)
>    * ibmvscsi_eh_host_reset_handler - Reset the connection to the server
>    * @cmd:	struct scsi_cmnd having problems
>   */
> -static int ibmvscsi_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +static int ibmvscsi_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
>   	unsigned long wait_switch = 0;
> -	struct ibmvscsi_host_data *hostdata = shost_priv(cmd->device->host);
> +	struct ibmvscsi_host_data *hostdata = shost_priv(shost);
>   
>   	dev_err(hostdata->dev, "Resetting connection due to error recovery\n");
>   
> diff --git a/drivers/scsi/imm.c b/drivers/scsi/imm.c
> index 7a499d621c25..757175d09b2b 100644
> --- a/drivers/scsi/imm.c
> +++ b/drivers/scsi/imm.c
> @@ -984,9 +984,9 @@ static void imm_reset_pulse(unsigned int base)
>   	w_ctr(base, 0x04);
>   }
>   
> -static int imm_reset(struct scsi_cmnd *cmd)
> +static int imm_reset(struct Scsi_Host *host)
>   {
> -	imm_struct *dev = imm_dev(cmd->device->host);
> +	imm_struct *dev = imm_dev(host);
>   
>   	if (imm_scsi_pointer(cmd)->phase)
>   		imm_disconnect(dev);
> diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
> index 104bee9b3a9d..29893dae7f24 100644
> --- a/drivers/scsi/ipr.c
> +++ b/drivers/scsi/ipr.c
> @@ -5181,14 +5181,14 @@ static int ipr_wait_for_ops(struct ipr_ioa_cfg *ioa_cfg, void *device,
>   	return SUCCESS;
>   }
>   
> -static int ipr_eh_host_reset(struct scsi_cmnd *cmd)
> +static int ipr_eh_host_reset(struct Scsi_Host *shost)
>   {
>   	struct ipr_ioa_cfg *ioa_cfg;
>   	unsigned long lock_flags = 0;
>   	int rc = SUCCESS;
>   
>   	ENTER;
> -	ioa_cfg = (struct ipr_ioa_cfg *) cmd->device->host->hostdata;
> +	ioa_cfg = (struct ipr_ioa_cfg *) shost->hostdata;
>   	spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
>   
>   	if (!ioa_cfg->in_reset_reload && !ioa_cfg->hrrq[IPR_INIT_HRRQ].ioa_is_dead) {
> diff --git a/drivers/scsi/ips.c b/drivers/scsi/ips.c
> index d49c1d6df5d6..f57858f561e3 100644
> --- a/drivers/scsi/ips.c
> +++ b/drivers/scsi/ips.c
> @@ -229,7 +229,7 @@ module_param(ips, charp, 0);
>    * Function prototypes
>    */
>   static int ips_eh_abort(struct scsi_cmnd *);
> -static int ips_eh_reset(struct scsi_cmnd *);
> +static int ips_eh_reset(struct Scsi_Host *);
>   static int ips_queue(struct Scsi_Host *, struct scsi_cmnd *);
>   static const char *ips_info(struct Scsi_Host *);
>   static irqreturn_t do_ipsintr(int, void *);
> @@ -829,7 +829,7 @@ int ips_eh_abort(struct scsi_cmnd *SC)
>   /* NOTE: this routine is called under the io_request_lock spinlock          */
>   /*                                                                          */
>   /****************************************************************************/
> -static int __ips_eh_reset(struct scsi_cmnd *SC)
> +static int __ips_eh_reset(struct Scsi_Host *shost)
>   {
>   	int ret;
>   	int i;
> @@ -842,13 +842,7 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)
>   	return (FAILED);
>   #else
>   
> -	if (!SC) {
> -		DEBUG(1, "Reset called with NULL scsi command");
> -
> -		return (FAILED);
> -	}
> -
> -	ha = (ips_ha_t *) SC->device->host->hostdata;
> +	ha = (ips_ha_t *) shost->hostdata;
>   
>   	if (!ha) {
>   		DEBUG(1, "Reset called with NULL ha struct");
> @@ -994,13 +988,13 @@ static int __ips_eh_reset(struct scsi_cmnd *SC)
>   
>   }
>   
> -static int ips_eh_reset(struct scsi_cmnd *SC)
> +static int ips_eh_reset(struct Scsi_Host *shost)
>   {
>   	int rc;
>   
> -	spin_lock_irq(SC->device->host->host_lock);
> -	rc = __ips_eh_reset(SC);
> -	spin_unlock_irq(SC->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
> +	rc = __ips_eh_reset(shost);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return rc;
>   }
> @@ -1078,7 +1072,7 @@ static int ips_queue_lck(struct scsi_cmnd *SC)
>   				return (0);
>   			}
>   			ha->ioctl_reset = 1;	/* This reset request is from an IOCTL */
> -			__ips_eh_reset(SC);
> +			__ips_eh_reset(SC->device->host);
>   			SC->result = DID_OK << 16;
>   			scsi_done(SC);
>   			return (0);
> diff --git a/drivers/scsi/libfc/fc_fcp.c b/drivers/scsi/libfc/fc_fcp.c
> index 074996319df5..ab4a1c01a353 100644
> --- a/drivers/scsi/libfc/fc_fcp.c
> +++ b/drivers/scsi/libfc/fc_fcp.c
> @@ -2195,11 +2195,10 @@ EXPORT_SYMBOL(fc_eh_device_reset);
>   
>   /**
>    * fc_eh_host_reset() - Reset a Scsi_Host.
> - * @sc_cmd: The SCSI command that identifies the SCSI host to be reset
> + * @shost: The SCSI host to be reset
>    */
> -int fc_eh_host_reset(struct scsi_cmnd *sc_cmd)
> +int fc_eh_host_reset(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = sc_cmd->device->host;
>   	struct fc_lport *lport = shost_priv(shost);
>   	unsigned long wait_tmo;
>   
> diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
> index 1959c58d22f8..0443846c9fad 100644
> --- a/drivers/scsi/lpfc/lpfc_scsi.c
> +++ b/drivers/scsi/lpfc/lpfc_scsi.c
> @@ -6503,9 +6503,8 @@ lpfc_target_reset_handler(struct scsi_cmnd *cmnd)
>    *  0x2002 - Success
>    **/
>   static int
> -lpfc_host_reset_handler(struct scsi_cmnd *cmnd)
> +lpfc_host_reset_handler(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = cmnd->device->host;
>   	struct lpfc_vport *vport = (struct lpfc_vport *) shost->hostdata;
>   	struct lpfc_hba *phba = vport->phba;
>   	int rc, ret = SUCCESS;
> diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c
> index 070ebe352f9e..466efe781376 100644
> --- a/drivers/scsi/mac53c94.c
> +++ b/drivers/scsi/mac53c94.c
> @@ -100,14 +100,14 @@ static int mac53c94_queue_lck(struct scsi_cmnd *cmd)
>   
>   static DEF_SCSI_QCMD(mac53c94_queue)
>   
> -static int mac53c94_host_reset(struct scsi_cmnd *cmd)
> +static int mac53c94_host_reset(struct Scsi_Host *shost)
>   {
> -	struct fsc_state *state = (struct fsc_state *) cmd->device->host->hostdata;
> +	struct fsc_state *state = (struct fsc_state *) shost->hostdata;
>   	struct mac53c94_regs __iomem *regs = state->regs;
>   	struct dbdma_regs __iomem *dma = state->dma;
>   	unsigned long flags;
>   
> -	spin_lock_irqsave(cmd->device->host->host_lock, flags);
> +	spin_lock_irqsave(shost->host_lock, flags);
>   
>   	writel((RUN|PAUSE|FLUSH|WAKE) << 16, &dma->control);
>   	writeb(CMD_SCSI_RESET, &regs->command);	/* assert RST */
> @@ -117,7 +117,7 @@ static int mac53c94_host_reset(struct scsi_cmnd *cmd)
>   	mac53c94_init(state);
>   	writeb(CMD_NOP, &regs->command);
>   
> -	spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
> +	spin_unlock_irqrestore(shost->host_lock, flags);
>   	return SUCCESS;
>   }
>   
> diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c
> index 9484632ffed6..6f6b66715707 100644
> --- a/drivers/scsi/megaraid.c
> +++ b/drivers/scsi/megaraid.c
> @@ -1875,13 +1875,13 @@ megaraid_abort(struct scsi_cmnd *cmd)
>   
>   
>   static int
> -megaraid_reset(struct scsi_cmnd *cmd)
> +megaraid_reset(struct Scsi_Host *shost)
>   {
>   	adapter_t	*adapter;
>   	megacmd_t	mc;
>   	int		rval;
>   
> -	adapter = (adapter_t *)cmd->device->host->hostdata;
> +	adapter = (adapter_t *)shost->hostdata;
>   
>   #if MEGA_HAVE_CLUSTERING
>   	mc.cmd = MEGA_CLUSTER_CMD;
> diff --git a/drivers/scsi/megaraid.h b/drivers/scsi/megaraid.h
> index 013fbfb911b9..43acad67d95f 100644
> --- a/drivers/scsi/megaraid.h
> +++ b/drivers/scsi/megaraid.h
> @@ -973,7 +973,7 @@ static irqreturn_t megaraid_isr_iomapped(int, void *);
>   static void mega_free_scb(adapter_t *, scb_t *);
>   
>   static int megaraid_abort(struct scsi_cmnd *);
> -static int megaraid_reset(struct scsi_cmnd *);
> +static int megaraid_reset(struct Scsi_Host *);
>   static int megaraid_abort_and_reset(adapter_t *, struct scsi_cmnd *, int);
>   static int megaraid_biosparam(struct scsi_device *, struct block_device *,
>   		sector_t, int []);
> diff --git a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
> index 2a339d4a7e9d..e250566a17b6 100644
> --- a/drivers/scsi/megaraid/megaraid_mbox.c
> +++ b/drivers/scsi/megaraid/megaraid_mbox.c
> @@ -92,7 +92,7 @@ static int megaraid_sysfs_alloc_resources(adapter_t *);
>   static void megaraid_sysfs_free_resources(adapter_t *);
>   
>   static int megaraid_abort_handler(struct scsi_cmnd *);
> -static int megaraid_reset_handler(struct scsi_cmnd *);
> +static int megaraid_reset_handler(struct Scsi_Host *);
>   
>   static int mbox_post_sync_cmd(adapter_t *, uint8_t []);
>   static int mbox_post_sync_cmd_fast(adapter_t *, uint8_t []);
> @@ -2512,7 +2512,7 @@ megaraid_abort_handler(struct scsi_cmnd *scp)
>    * host.
>    **/
>   static int
> -megaraid_reset_handler(struct scsi_cmnd *scp)
> +megaraid_reset_handler(struct Scsi_Host *shost)
>   {
>   	adapter_t	*adapter;
>   	scb_t		*scb;
> @@ -2525,7 +2525,7 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
>   	int		i;
>   	uioc_t		*kioc;
>   
> -	adapter		= SCP2ADAPTER(scp);
> +	adapter		= (adapter_t *)SCSIHOST2ADAP(shost);
>   	raid_dev	= ADAP2RAIDDEV(adapter);
>   
>   	// return failure if adapter is not responding
> @@ -2556,15 +2556,9 @@ megaraid_reset_handler(struct scsi_cmnd *scp)
>   
>   			megaraid_mbox_mm_done(adapter, scb);
>   		} else {
> -			if (scb->scp == scp) {	// Found command
> -				con_log(CL_ANN, (KERN_WARNING
> -					"megaraid: %d[%d:%d], reset from pending list\n",
> -					scb->sno, scb->dev_channel, scb->dev_target));
> -			} else {
> -				con_log(CL_ANN, (KERN_WARNING
> +			con_log(CL_ANN, (KERN_WARNING
>   				"megaraid: IO packet with %d[%d:%d] being reset\n",
>   				scb->sno, scb->dev_channel, scb->dev_target));
> -			}
>   
>   			scb->scp->result = (DID_RESET << 16);
>   			scsi_done(scb->scp);
> diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
> index c95360a3c186..0222e234f108 100644
> --- a/drivers/scsi/megaraid/megaraid_sas_base.c
> +++ b/drivers/scsi/megaraid/megaraid_sas_base.c
> @@ -2896,15 +2896,14 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
>    * reset requests. Device, bus and host specific reset handlers can use this
>    * function after they do their specific tasks.
>    */
> -static int megasas_generic_reset(struct scsi_cmnd *scmd)
> +static int megasas_generic_reset(struct Scsi_Host *shost)
>   {
>   	int ret_val;
>   	struct megasas_instance *instance;
>   
> -	instance = (struct megasas_instance *)scmd->device->host->hostdata;
> +	instance = (struct megasas_instance *)shost->hostdata;
>   
> -	scmd_printk(KERN_NOTICE, scmd, "megasas: RESET cmd=%x retries=%x\n",
> -		 scmd->cmnd[0], scmd->retries);
> +	shost_printk(KERN_NOTICE, shost, "megasas: RESET\n");
>   
>   	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR) {
>   		dev_err(&instance->pdev->dev, "cannot recover from previous reset failures\n");
> @@ -3057,31 +3056,30 @@ megasas_dump_sys_regs(void __iomem *reg_set, char *buf)
>    * megasas_reset_bus_host -	Bus & host reset handler entry point
>    * @scmd:			Mid-layer SCSI command
>    */
> -static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
> +static int megasas_reset_bus_host(struct Scsi_Host *shost)
>   {
>   	int ret;
>   	struct megasas_instance *instance;
>   
> -	instance = (struct megasas_instance *)scmd->device->host->hostdata;
> +	instance = (struct megasas_instance *)shost->hostdata;
>   
> -	scmd_printk(KERN_INFO, scmd,
> +	shost_printk(KERN_INFO, shost,
>   		"OCR is requested due to IO timeout!!\n");
>   
> -	scmd_printk(KERN_INFO, scmd,
> -		"SCSI host state: %d  SCSI host busy: %d  FW outstanding: %d\n",
> -		scmd->device->host->shost_state,
> -		scsi_host_busy(scmd->device->host),
> +	shost_printk(KERN_INFO, shost,
> +		"Controller reset is requested due to IO timeout\n"
> +		"SCSI host state: %d\t"
> +		" SCSI host busy: %d\t FW outstanding: %d\n",
> +		shost->shost_state,
> +		scsi_host_busy(shost),
>   		atomic_read(&instance->fw_outstanding));
>   	/*
>   	 * First wait for all commands to complete
>   	 */
> -	if (instance->adapter_type == MFI_SERIES) {
> -		ret = megasas_generic_reset(scmd);
> -	} else {
> -		megasas_dump_fusion_io(scmd);
> -		ret = megasas_reset_fusion(scmd->device->host,
> -				SCSIIO_TIMEOUT_OCR);
> -	}
> +	if (instance->adapter_type == MFI_SERIES)
> +		ret = megasas_generic_reset(shost);
> +	else
> +		ret = megasas_reset_fusion(shost, SCSIIO_TIMEOUT_OCR);
>   
>   	return ret;
>   }
> diff --git a/drivers/scsi/mesh.c b/drivers/scsi/mesh.c
> index 322d3ad38159..5e1d0bde36f3 100644
> --- a/drivers/scsi/mesh.c
> +++ b/drivers/scsi/mesh.c
> @@ -1699,9 +1699,9 @@ static int mesh_abort(struct scsi_cmnd *cmd)
>    * The midlayer will wait for devices to come back, we don't need
>    * to do that ourselves
>    */
> -static int mesh_host_reset(struct scsi_cmnd *cmd)
> +static int mesh_host_reset(struct Scsi_Host *shost)
>   {
> -	struct mesh_state *ms = (struct mesh_state *) cmd->device->host->hostdata;
> +	struct mesh_state *ms = (struct mesh_state *) shost->hostdata;
>   	volatile struct mesh_regs __iomem *mr = ms->mesh;
>   	volatile struct dbdma_regs __iomem *md = ms->dma;
>   	unsigned long flags;
> @@ -1718,7 +1718,7 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
>   	out_8(&mr->exception, 0xff);	/* clear all exception bits */
>   	out_8(&mr->error, 0xff);	/* clear all error bits */
>   	out_8(&mr->sequence, SEQ_RESETMESH);
> -       	mesh_flush_io(mr);
> +	mesh_flush_io(mr);
>   	udelay(1);
>   	out_8(&mr->intr_mask, INT_ERROR | INT_EXCEPTION | INT_CMDDONE);
>   	out_8(&mr->source_id, ms->host->this_id);
> @@ -1727,13 +1727,13 @@ static int mesh_host_reset(struct scsi_cmnd *cmd)
>   
>   	/* Reset the bus */
>   	out_8(&mr->bus_status1, BS1_RST);	/* assert RST */
> -       	mesh_flush_io(mr);
> +	mesh_flush_io(mr);
>   	udelay(30);			/* leave it on for >= 25us */
>   	out_8(&mr->bus_status1, 0);	/* negate RST */
>   
>   	/* Complete pending commands */
>   	handle_reset(ms);
> -	
> +
>   	spin_unlock_irqrestore(ms->host->host_lock, flags);
>   	return SUCCESS;
>   }
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index 31f05e9f5ee0..bd42d3a56590 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -3335,15 +3335,15 @@ void mpi3mr_wait_for_host_io(struct mpi3mr_ioc *mrioc, u32 timeout)
>   
>   /**
>    * mpi3mr_eh_host_reset - Host reset error handling callback
> - * @scmd: SCSI command reference
> + * @shost: SCSI host reference
>    *
>    * Issue controller reset
>    *
>    * Return: SUCCESS of successful reset else FAILED
>    */
> -static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd)
> +static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
>   {
> -	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
>   	int retval = FAILED, ret;
>   
>   	ret = mpi3mr_soft_reset_handler(mrioc,
> @@ -3353,9 +3353,9 @@ static int mpi3mr_eh_host_reset(struct scsi_cmnd *scmd)
>   
>   	retval = SUCCESS;
>   out:
> -	sdev_printk(KERN_INFO, scmd->device,
> -	    "Host reset is %s for scmd(%p)\n",
> -	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
> +	shost_printk(KERN_INFO, shost,
> +	    "Host reset is %s\n",
> +	    ((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
>   
>   	return retval;
>   }
> diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> index 7e476f50935b..ea9a8799f89a 100644
> --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
> @@ -3526,13 +3526,12 @@ scsih_target_reset(struct scsi_cmnd *scmd)
>    * Return: SUCCESS if command aborted else FAILED
>    */
>   static int
> -scsih_host_reset(struct scsi_cmnd *scmd)
> +scsih_host_reset(struct Scsi_Host *shost)
>   {
> -	struct MPT3SAS_ADAPTER *ioc = shost_priv(scmd->device->host);
> +	struct MPT3SAS_ADAPTER *ioc = shost_priv(shost);
>   	int r, retval;
>   
> -	ioc_info(ioc, "attempting host reset! scmd(0x%p)\n", scmd);
> -	scsi_print_command(scmd);
> +	ioc_info(ioc, "attempting host reset\n");
>   
>   	if (ioc->is_driver_loading || ioc->remove_host) {
>   		ioc_info(ioc, "Blocking the host reset\n");
> @@ -3543,8 +3542,8 @@ scsih_host_reset(struct scsi_cmnd *scmd)
>   	retval = mpt3sas_base_hard_reset_handler(ioc, FORCE_BIG_HAMMER);
>   	r = (retval < 0) ? FAILED : SUCCESS;
>   out:
> -	ioc_info(ioc, "host reset: %s scmd(0x%p)\n",
> -		 r == SUCCESS ? "SUCCESS" : "FAILED", scmd);
> +	ioc_info(ioc, "host reset: %s\n",
> +		 r == SUCCESS ? "SUCCESS" : "FAILED");
>   
>   	return r;
>   }
> diff --git a/drivers/scsi/mvumi.c b/drivers/scsi/mvumi.c
> index 05d3ce9b72db..249813bc926e 100644
> --- a/drivers/scsi/mvumi.c
> +++ b/drivers/scsi/mvumi.c
> @@ -695,14 +695,13 @@ static int mvumi_reset_host_9143(struct mvumi_hba *mhba)
>   	return mvumi_wait_for_outstanding(mhba);
>   }
>   
> -static int mvumi_host_reset(struct scsi_cmnd *scmd)
> +static int mvumi_host_reset(struct Scsi_Host *shost)
>   {
>   	struct mvumi_hba *mhba;
>   
> -	mhba = (struct mvumi_hba *) scmd->device->host->hostdata;
> +	mhba = (struct mvumi_hba *) shost->hostdata;
>   
> -	scmd_printk(KERN_NOTICE, scmd, "RESET -%u cmd=%x retries=%x\n",
> -			scsi_cmd_to_rq(scmd)->tag, scmd->cmnd[0], scmd->retries);
> +	shost_printk(KERN_NOTICE, shost, "RESET\n");
>   
>   	return mhba->instancet->reset_host(mhba);
>   }
> diff --git a/drivers/scsi/myrb.c b/drivers/scsi/myrb.c
> index 71585528e8db..437b11d48238 100644
> --- a/drivers/scsi/myrb.c
> +++ b/drivers/scsi/myrb.c
> @@ -1251,9 +1251,8 @@ static void myrb_cleanup(struct myrb_hba *cb)
>   	scsi_host_put(cb->host);
>   }
>   
> -static int myrb_host_reset(struct scsi_cmnd *scmd)
> +static int myrb_host_reset(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = scmd->device->host;
>   	struct myrb_hba *cb = shost_priv(shost);
>   
>   	cb->reset(cb->io_base);
> diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c
> index 7eb8c39da366..caa5511ca923 100644
> --- a/drivers/scsi/myrs.c
> +++ b/drivers/scsi/myrs.c
> @@ -1529,9 +1529,8 @@ ATTRIBUTE_GROUPS(myrs_shost);
>   /*
>    * SCSI midlayer interface
>    */
> -static int myrs_host_reset(struct scsi_cmnd *scmd)
> +static int myrs_host_reset(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = scmd->device->host;
>   	struct myrs_hba *cs = shost_priv(shost);
>   
>   	cs->reset(cs->io_base);
> diff --git a/drivers/scsi/nsp32.c b/drivers/scsi/nsp32.c
> index 75bb0028ed74..d1f760c8e8ce 100644
> --- a/drivers/scsi/nsp32.c
> +++ b/drivers/scsi/nsp32.c
> @@ -191,7 +191,7 @@ static int	   nsp32_release     (struct Scsi_Host *);
>   
>   /* SCSI error handler */
>   static int	   nsp32_eh_abort     (struct scsi_cmnd *);
> -static int	   nsp32_eh_host_reset(struct scsi_cmnd *);
> +static int	   nsp32_eh_host_reset(struct Scsi_Host *);
>   
>   /* generate SCSI message */
>   static void nsp32_build_identify(struct scsi_cmnd *);
> @@ -2876,23 +2876,21 @@ static void nsp32_do_bus_reset(nsp32_hw_data *data)
>   	data->CurrentSC = NULL;
>   }
>   
> -static int nsp32_eh_host_reset(struct scsi_cmnd *SCpnt)
> +static int nsp32_eh_host_reset(struct Scsi_Host *host)
>   {
> -	struct Scsi_Host *host = SCpnt->device->host;
> -	unsigned int      base = SCpnt->device->host->io_port;
> +	unsigned int      base = host->io_port;
>   	nsp32_hw_data    *data = (nsp32_hw_data *)host->hostdata;
>   
>   	nsp32_msg(KERN_INFO, "Host Reset");
> -	nsp32_dbg(NSP32_DEBUG_BUSRESET, "SCpnt=0x%x", SCpnt);
>   
> -	spin_lock_irq(SCpnt->device->host->host_lock);
> +	spin_lock_irq(host->host_lock);
>   
>   	nsp32hw_init(data);
>   	nsp32_write2(base, IRQ_CONTROL, IRQ_CONTROL_ALL_IRQ_MASK);
>   	nsp32_do_bus_reset(data);
>   	nsp32_write2(base, IRQ_CONTROL, 0);
>   
> -	spin_unlock_irq(SCpnt->device->host->host_lock);
> +	spin_unlock_irq(host->host_lock);
>   	return SUCCESS;	/* Host reset is succeeded at any time. */
>   }
>   
> diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
> index 48acab03a8a0..4aa9737fa711 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.c
> +++ b/drivers/scsi/pcmcia/nsp_cs.c
> @@ -1497,9 +1497,9 @@ static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
>   	return nsp_bus_reset(data);
>   }
>   
> -static int nsp_eh_host_reset(struct scsi_cmnd *SCpnt)
> +static int nsp_eh_host_reset(struct Scsi_Host *host)
>   {
> -	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
> +	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
>   
>   	nsp_dbg(NSP_DEBUG_BUSRESET, "in");
>   
> diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
> index e1ee8ef90ad3..f532adb5f166 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.h
> +++ b/drivers/scsi/pcmcia/nsp_cs.h
> @@ -300,7 +300,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
>   /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
>   /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
>   static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
> -static int nsp_eh_host_reset   (struct scsi_cmnd *SCpnt);
> +static int nsp_eh_host_reset   (struct Scsi_Host *host);
>   static int nsp_bus_reset       (nsp_hw_data *data);
>   
>   /* */
> diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
> index 310d0b6586a6..59893db166c9 100644
> --- a/drivers/scsi/pcmcia/qlogic_stub.c
> +++ b/drivers/scsi/pcmcia/qlogic_stub.c
> @@ -270,8 +270,8 @@ static int qlogic_resume(struct pcmcia_device *link)
>   		outb(0x24, link->resource[0]->start + 0x9);
>   		outb(0x04, link->resource[0]->start + 0xd);
>   	}
> -	/* Ugggglllyyyy!!! */
> -	qlogicfas408_host_reset(NULL);
> +
> +	qlogicfas408_host_reset(info->host);
>   
>   	return 0;
>   }
> diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
> index 5d7dfefd6f6c..79862f17de8d 100644
> --- a/drivers/scsi/pcmcia/sym53c500_cs.c
> +++ b/drivers/scsi/pcmcia/sym53c500_cs.c
> @@ -583,14 +583,14 @@ static int SYM53C500_queue_lck(struct scsi_cmnd *SCpnt)
>   static DEF_SCSI_QCMD(SYM53C500_queue)
>   
>   static int
> -SYM53C500_host_reset(struct scsi_cmnd *SCpnt)
> +SYM53C500_host_reset(struct Scsi_Host *shost)
>   {
> -	int port_base = SCpnt->device->host->io_port;
> +	int port_base = shost->io_port;
>   
>   	DEB(printk("SYM53C500_host_reset called\n"));
> -	spin_lock_irq(SCpnt->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
>   	SYM53C500_int_host_reset(port_base);
> -	spin_unlock_irq(SCpnt->device->host->host_lock);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return SUCCESS;
>   }
> diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
> index 62b9de87ff05..79ca737ac75b 100644
> --- a/drivers/scsi/pmcraid.c
> +++ b/drivers/scsi/pmcraid.c
> @@ -3086,19 +3086,19 @@ static int pmcraid_eh_target_reset_handler(struct scsi_cmnd *scmd)
>   /**
>    * pmcraid_eh_host_reset_handler - adapter reset handler callback
>    *
> - * @scmd: pointer to scsi_cmd that was sent to a resource of adapter
> + * @shost: pointer to scsi_host
>    *
>    * Initiates adapter reset to bring it up to operational state
>    *
>    * Return value
>    *	SUCCESS or FAILED
>    */
> -static int pmcraid_eh_host_reset_handler(struct scsi_cmnd *scmd)
> +static int pmcraid_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
>   	unsigned long interval = 10000; /* 10 seconds interval */
>   	int waits = jiffies_to_msecs(PMCRAID_RESET_HOST_TIMEOUT) / interval;
>   	struct pmcraid_instance *pinstance =
> -		(struct pmcraid_instance *)(scmd->device->host->hostdata);
> +		(struct pmcraid_instance *)(shost->hostdata);
>   
>   
>   	/* wait for an additional 150 seconds just in case firmware could come
> diff --git a/drivers/scsi/ppa.c b/drivers/scsi/ppa.c
> index c6c1bc608224..14a4b582fa9e 100644
> --- a/drivers/scsi/ppa.c
> +++ b/drivers/scsi/ppa.c
> @@ -867,9 +867,9 @@ static void ppa_reset_pulse(unsigned int base)
>   	w_ctr(base, 0xc);
>   }
>   
> -static int ppa_reset(struct scsi_cmnd *cmd)
> +static int ppa_reset(struct Scsi_Host *host)
>   {
> -	ppa_struct *dev = ppa_dev(cmd->device->host);
> +	ppa_struct *dev = ppa_dev(host);
>   
>   	if (ppa_scsi_pointer(cmd)->phase)
>   		ppa_disconnect(dev);
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index 85ccfbc5cd26..c12fb3465946 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -952,12 +952,12 @@ void qedf_ctx_soft_reset(struct fc_lport *lport)
>   }
>   
>   /* Reset the host by gracefully logging out and then logging back in */
> -static int qedf_eh_host_reset(struct scsi_cmnd *sc_cmd)
> +static int qedf_eh_host_reset(struct Scsi_Host *shost)
>   {
>   	struct fc_lport *lport;
>   	struct qedf_ctx *qedf;
>   
> -	lport = shost_priv(sc_cmd->device->host);
> +	lport = shost_priv(shost);
>   	qedf = lport_priv(lport);
>   
>   	if (atomic_read(&qedf->link_state) == QEDF_LINK_DOWN ||
> diff --git a/drivers/scsi/qedi/qedi_iscsi.c b/drivers/scsi/qedi/qedi_iscsi.c
> index 31ec429104e2..dfb12f80fd9f 100644
> --- a/drivers/scsi/qedi/qedi_iscsi.c
> +++ b/drivers/scsi/qedi/qedi_iscsi.c
> @@ -30,9 +30,8 @@ int qedi_recover_all_conns(struct qedi_ctx *qedi)
>   	return SUCCESS;
>   }
>   
> -static int qedi_eh_host_reset(struct scsi_cmnd *cmd)
> +static int qedi_eh_host_reset(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = cmd->device->host;
>   	struct qedi_ctx *qedi;
>   
>   	qedi = iscsi_host_priv(shost);
> diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
> index c4466e4e692f..cd4c7126c1c9 100644
> --- a/drivers/scsi/qla1280.c
> +++ b/drivers/scsi/qla1280.c
> @@ -995,10 +995,9 @@ qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
>    *     Reset the specified adapter (both channels)
>    **************************************************************************/
>   static int
> -qla1280_eh_adapter_reset(struct scsi_cmnd *cmd)
> +qla1280_eh_adapter_reset(struct Scsi_Host *shost)
>   {
>   	int rc;
> -	struct Scsi_Host *shost = cmd->device->host;
>   	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
>   
>   	spin_lock_irq(shost->host_lock);
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 762229d495a8..5f86e7bd5a0e 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -1604,8 +1604,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>   *    The reset function will reset the Adapter.
>   *
>   * Input:
> -*      cmd = Linux SCSI command packet of the command that cause the
> -*            adapter reset.
> +*      shost = Linux SCSI host to be reset
>   *
>   * Returns:
>   *      Either SUCCESS or FAILED.
> @@ -1613,13 +1612,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>   * Note:
>   **************************************************************************/
>   static int
> -qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
> +qla2xxx_eh_host_reset(struct Scsi_Host *shost)
>   {
> -	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
> +	scsi_qla_host_t *vha = shost_priv(shost);
>   	struct qla_hw_data *ha = vha->hw;
>   	int ret = FAILED;
> -	unsigned int id;
> -	uint64_t lun;
>   	scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
>   
>   	if (qla2x00_isp_reg_stat(ha)) {
> @@ -1629,11 +1626,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
>   		return SUCCESS;
>   	}
>   
> -	id = cmd->device->id;
> -	lun = cmd->device->lun;
> -
>   	ql_log(ql_log_info, vha, 0x8018,
> -	    "ADAPTER RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
> +	    "ADAPTER RESET ISSUED host=%ld.\n", vha->host_no);
>   
>   	/*
>   	 * No point in issuing another reset if one is active.  Also do not
> @@ -1679,8 +1673,8 @@ qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
>   
>   eh_host_reset_lock:
>   	ql_log(ql_log_info, vha, 0x8017,
> -	    "ADAPTER RESET %s nexus=%ld:%d:%llu.\n",
> -	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
> +	    "ADAPTER RESET %s host=%ld.\n",
> +	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no);
>   
>   	return ret;
>   }
> diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
> index f4969b99c07f..8f89080e2580 100644
> --- a/drivers/scsi/qla4xxx/ql4_os.c
> +++ b/drivers/scsi/qla4xxx/ql4_os.c
> @@ -159,7 +159,7 @@ static int qla4xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd);
>   static int qla4xxx_eh_abort(struct scsi_cmnd *cmd);
>   static int qla4xxx_eh_device_reset(struct scsi_cmnd *cmd);
>   static int qla4xxx_eh_target_reset(struct scsi_cmnd *cmd);
> -static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd);
> +static int qla4xxx_eh_host_reset(struct Scsi_Host *shost);
>   static int qla4xxx_slave_alloc(struct scsi_device *device);
>   static umode_t qla4_attr_is_visible(int param_type, int param);
>   static int qla4xxx_host_reset(struct Scsi_Host *shost, int reset_type);
> @@ -9411,18 +9411,18 @@ static int qla4xxx_is_eh_active(struct Scsi_Host *shost)
>   
>   /**
>    * qla4xxx_eh_host_reset - kernel callback
> - * @cmd: Pointer to Linux's SCSI command structure
> + * @host: Pointer to Linux's SCSI host structure
>    *
>    * This routine is invoked by the Linux kernel to perform fatal error
>    * recovery on the specified adapter.
>    **/
> -static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
> +static int qla4xxx_eh_host_reset(struct Scsi_Host *host)
>   {
>   	int return_status = FAILED;
>   	struct scsi_qla_host *ha;
>   	int rval;
>   
> -	ha = to_qla_host(cmd->device->host);
> +	ha = to_qla_host(host);
>   
>   	rval = qla4xxx_isp_check_reg(ha);
>   	if (rval != QLA_SUCCESS) {
> @@ -9444,20 +9444,18 @@ static int qla4xxx_eh_host_reset(struct scsi_cmnd *cmd)
>   		     ha->host_no, __func__));
>   
>   		/* Clear outstanding srb in queues */
> -		if (qla4xxx_is_eh_active(cmd->device->host))
> +		if (qla4xxx_is_eh_active(host))
>   			qla4xxx_abort_active_cmds(ha, DID_ABORT << 16);
>   
>   		return FAILED;
>   	}
>   
>   	ql4_printk(KERN_INFO, ha,
> -		   "scsi(%ld:%d:%d:%llu): HOST RESET ISSUED.\n", ha->host_no,
> -		   cmd->device->channel, cmd->device->id, cmd->device->lun);
> +		   "scsi%ld: HOST RESET ISSUED.\n", ha->host_no);
>   
>   	if (qla4xxx_wait_for_hba_online(ha) != QLA_SUCCESS) {
> -		DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host.  Adapter "
> -			      "DEAD.\n", ha->host_no, cmd->device->channel,
> -			      __func__));
> +		DEBUG2(printk("scsi%ld: %s: Unable to reset host.  Adapter "
> +			      "DEAD.\n", ha->host_no, __func__));
>   
>   		return FAILED;
>   	}
> diff --git a/drivers/scsi/qlogicfas408.c b/drivers/scsi/qlogicfas408.c
> index 3e065d5fc80c..008e908e3aff 100644
> --- a/drivers/scsi/qlogicfas408.c
> +++ b/drivers/scsi/qlogicfas408.c
> @@ -525,20 +525,18 @@ int qlogicfas408_abort(struct scsi_cmnd *cmd)
>   
>   /*
>    *	Reset SCSI bus
> - *	FIXME: This function is invoked with cmd = NULL directly by
> - *	the PCMCIA qlogic_stub code. This wants fixing
>    */
>   
> -int qlogicfas408_host_reset(struct scsi_cmnd *cmd)
> +int qlogicfas408_host_reset(struct Scsi_Host *host)
>   {
> -	struct qlogicfas408_priv *priv = get_priv_by_cmd(cmd);
> +	struct qlogicfas408_priv *priv = get_priv_by_host(host);
>   	unsigned long flags;
>   
>   	priv->qabort = 2;
>   
> -	spin_lock_irqsave(cmd->device->host->host_lock, flags);
> +	spin_lock_irqsave(host->host_lock, flags);
>   	ql_zap(priv);
> -	spin_unlock_irqrestore(cmd->device->host->host_lock, flags);
> +	spin_unlock_irqrestore(host->host_lock, flags);
>   
>   	return SUCCESS;
>   }
> diff --git a/drivers/scsi/qlogicfas408.h b/drivers/scsi/qlogicfas408.h
> index a971db11d293..c1b6e9fea9ce 100644
> --- a/drivers/scsi/qlogicfas408.h
> +++ b/drivers/scsi/qlogicfas408.h
> @@ -109,7 +109,7 @@ int qlogicfas408_biosparam(struct scsi_device * disk,
>   			   struct block_device *dev,
>   			   sector_t capacity, int ip[]);
>   int qlogicfas408_abort(struct scsi_cmnd * cmd);
> -extern int qlogicfas408_host_reset(struct scsi_cmnd *cmd);
> +extern int qlogicfas408_host_reset(struct Scsi_Host *host);
>   const char *qlogicfas408_info(struct Scsi_Host *host);
>   int qlogicfas408_get_chip_type(int qbase, int int_type);
>   void qlogicfas408_setup(int qbase, int id, int int_type);
> diff --git a/drivers/scsi/qlogicpti.c b/drivers/scsi/qlogicpti.c
> index 57f2f4135a06..bd3defa15933 100644
> --- a/drivers/scsi/qlogicpti.c
> +++ b/drivers/scsi/qlogicpti.c
> @@ -1260,10 +1260,9 @@ static int qlogicpti_abort(struct scsi_cmnd *Cmnd)
>   	return return_status;
>   }
>   
> -static int qlogicpti_reset(struct scsi_cmnd *Cmnd)
> +static int qlogicpti_reset(struct Scsi_Host *host)
>   {
>   	u_short param[6];
> -	struct Scsi_Host *host = Cmnd->device->host;
>   	struct qlogicpti *qpti = (struct qlogicpti *) host->hostdata;
>   	int return_status = SUCCESS;
>   
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 592a290e6cfa..6292ac7aef7a 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5357,15 +5357,15 @@ static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
>   	return SUCCESS;
>   }
>   
> -static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt)
> +static int scsi_debug_host_reset(struct Scsi_Host *shost)
>   {
>   	struct sdebug_host_info *sdbg_host;
>   	struct sdebug_dev_info *devip;
>   	int k = 0;
>   
>   	++num_host_resets;
> -	if ((SCpnt->device) && (SDEBUG_OPT_ALL_NOISE & sdebug_opts))
> -		sdev_printk(KERN_INFO, SCpnt->device, "%s\n", __func__);
> +	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
> +		shost_printk(KERN_INFO, shost, "%s\n", __func__);
>   	spin_lock(&sdebug_host_list_lock);
>   	list_for_each_entry(sdbg_host, &sdebug_host_list, host_list) {
>   		list_for_each_entry(devip, &sdbg_host->dev_info_list,
> @@ -5377,7 +5377,7 @@ static int scsi_debug_host_reset(struct scsi_cmnd *SCpnt)
>   	spin_unlock(&sdebug_host_list_lock);
>   	stop_all_queued();
>   	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
> -		sdev_printk(KERN_INFO, SCpnt->device,
> +		shost_printk(KERN_INFO, shost,
>   			    "%s: %d device(s) found\n", __func__, k);
>   	return SUCCESS;
>   }
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index cdaca13ac1f1..747131ca8970 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -841,7 +841,7 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
>   	if (!hostt->eh_host_reset_handler)
>   		return FAILED;
>   
> -	rtn = hostt->eh_host_reset_handler(scmd);
> +	rtn = hostt->eh_host_reset_handler(host);
>   
>   	if (rtn == SUCCESS) {
>   		if (!hostt->skip_settle_delay)
> diff --git a/drivers/scsi/snic/snic.h b/drivers/scsi/snic/snic.h
> index e40492d36031..79916e803b26 100644
> --- a/drivers/scsi/snic/snic.h
> +++ b/drivers/scsi/snic/snic.h
> @@ -380,8 +380,7 @@ extern const struct attribute_group *snic_host_groups[];
>   int snic_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
>   int snic_abort_cmd(struct scsi_cmnd *);
>   int snic_device_reset(struct scsi_cmnd *);
> -int snic_host_reset(struct scsi_cmnd *);
> -int snic_reset(struct Scsi_Host *);
> +int snic_host_reset(struct Scsi_Host *);
>   void snic_shutdown_scsi_cleanup(struct snic *);
>   
>   
> diff --git a/drivers/scsi/snic/snic_scsi.c b/drivers/scsi/snic/snic_scsi.c
> index 635656ccf30a..3722383fb529 100644
> --- a/drivers/scsi/snic/snic_scsi.c
> +++ b/drivers/scsi/snic/snic_scsi.c
> @@ -2295,8 +2295,15 @@ snic_issue_hba_reset(struct snic *snic, struct scsi_cmnd *sc)
>   	return ret;
>   } /* end of snic_issue_hba_reset */
>   
> +/*
> + * SCSI Error handling calls driver's eh_host_reset if all prior
> + * error handling levels return FAILED.
> + *
> + * Host Reset is the highest level of error recovery. If this fails, then
> + * host is offlined by SCSI.
> + */
>   int
> -snic_reset(struct Scsi_Host *shost)
> +snic_host_reset(struct Scsi_Host *shost)
>   {
>   	struct snic *snic = shost_priv(shost);
>   	struct scsi_cmnd *sc = NULL;
> @@ -2360,34 +2367,6 @@ snic_reset(struct Scsi_Host *shost)
>   		 (ulong) sc, jiffies_to_msecs(jiffies - start_time),
>   		 0, 0, 0);
>   
> -	return ret;
> -} /* end of snic_reset */
> -
> -/*
> - * SCSI Error handling calls driver's eh_host_reset if all prior
> - * error handling levels return FAILED.
> - *
> - * Host Reset is the highest level of error recovery. If this fails, then
> - * host is offlined by SCSI.
> - */
> -int
> -snic_host_reset(struct scsi_cmnd *sc)
> -{
> -	struct Scsi_Host *shost = sc->device->host;
> -	u32 start_time  = jiffies;
> -	int ret;
> -
> -	SNIC_SCSI_DBG(shost,
> -		      "host reset:sc %p sc_cmd 0x%x req %p tag %d flags 0x%llx\n",
> -		      sc, sc->cmnd[0], scsi_cmd_to_rq(sc),
> -		      snic_cmd_tag(sc), CMD_FLAGS(sc));
> -
> -	ret = snic_reset(shost);
> -
> -	SNIC_TRC(shost->host_no, snic_cmd_tag(sc), (ulong) sc,
> -		 jiffies_to_msecs(jiffies - start_time),
> -		 0, SNIC_TRC_CMD(sc), SNIC_TRC_CMD_STATE_FLAGS(sc));
> -
>   	return ret;
>   } /* end of snic_host_reset */
>   
> diff --git a/drivers/scsi/stex.c b/drivers/scsi/stex.c
> index e6420f2127ce..d6f7e3f541e2 100644
> --- a/drivers/scsi/stex.c
> +++ b/drivers/scsi/stex.c
> @@ -1433,14 +1433,13 @@ static int stex_do_reset(struct st_hba *hba)
>   	return -1;
>   }
>   
> -static int stex_reset(struct scsi_cmnd *cmd)
> +static int stex_reset(struct Scsi_Host *shost)
>   {
>   	struct st_hba *hba;
>   
> -	hba = (struct st_hba *) &cmd->device->host->hostdata[0];
> +	hba = (struct st_hba *) &shost->hostdata[0];
>   
> -	shost_printk(KERN_INFO, cmd->device->host,
> -		     "resetting host\n");
> +	shost_printk(KERN_INFO, shost, "resetting host\n");
>   
>   	return stex_do_reset(hba) ? FAILED : SUCCESS;
>   }
> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
> index 9a0bba5a51a7..70bc095c6e78 100644
> --- a/drivers/scsi/storvsc_drv.c
> +++ b/drivers/scsi/storvsc_drv.c
> @@ -1659,9 +1659,9 @@ static int storvsc_get_chs(struct scsi_device *sdev, struct block_device * bdev,
>   	return 0;
>   }
>   
> -static int storvsc_host_reset_handler(struct scsi_cmnd *scmnd)
> +static int storvsc_host_reset_handler(struct Scsi_Host *shost)
>   {
> -	struct hv_host_device *host_dev = shost_priv(scmnd->device->host);
> +	struct hv_host_device *host_dev = shost_priv(shost);
>   	struct hv_device *device = host_dev->dev;
>   
>   	struct storvsc_device *stor_device;
> diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
> index cb8885eb5a5b..a573baa5bdf2 100644
> --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
> +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
> @@ -693,9 +693,8 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
>   	return SCSI_SUCCESS;
>   }
>   
> -static int sym53c8xx_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +static int sym53c8xx_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
> -	struct Scsi_Host *shost = cmd->device->host;
>   	struct sym_data *sym_data = shost_priv(shost);
>   	struct pci_dev *pdev = sym_data->pdev;
>   	struct sym_hcb *np = sym_data->ncb;
> diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
> index 3f9caafa91bf..d1f065d4bcce 100644
> --- a/drivers/scsi/ufs/ufshcd.c
> +++ b/drivers/scsi/ufs/ufshcd.c
> @@ -229,7 +229,7 @@ static struct ufs_dev_fix ufs_fixups[] = {
>   static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba);
>   static void ufshcd_async_scan(void *data, async_cookie_t cookie);
>   static int ufshcd_reset_and_restore(struct ufs_hba *hba);
> -static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd);
> +static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost);
>   static int ufshcd_clear_tm_cmd(struct ufs_hba *hba, int tag);
>   static void ufshcd_hba_exit(struct ufs_hba *hba);
>   static int ufshcd_probe_hba(struct ufs_hba *hba, bool init_dev_params);
> @@ -7311,13 +7311,13 @@ static int ufshcd_reset_and_restore(struct ufs_hba *hba)
>    *
>    * Returns SUCCESS/FAILED
>    */
> -static int ufshcd_eh_host_reset_handler(struct scsi_cmnd *cmd)
> +static int ufshcd_eh_host_reset_handler(struct Scsi_Host *shost)
>   {
>   	int err = SUCCESS;
>   	unsigned long flags;
>   	struct ufs_hba *hba;
>   
> -	hba = shost_priv(cmd->device->host);
> +	hba = shost_priv(shost);
>   
>   	spin_lock_irqsave(hba->host->host_lock, flags);
>   	hba->force_reset = true;
> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
> index f88ecdb93a8a..ddf1837babc0 100644
> --- a/drivers/scsi/vmw_pvscsi.c
> +++ b/drivers/scsi/vmw_pvscsi.c
> @@ -894,14 +894,13 @@ static void pvscsi_reset_all(struct pvscsi_adapter *adapter)
>   	}
>   }
>   
> -static int pvscsi_host_reset(struct scsi_cmnd *cmd)
> +static int pvscsi_host_reset(struct Scsi_Host *host)
>   {
> -	struct Scsi_Host *host = cmd->device->host;
>   	struct pvscsi_adapter *adapter = shost_priv(host);
>   	unsigned long flags;
>   	bool use_msg;
>   
> -	scmd_printk(KERN_INFO, cmd, "SCSI Host reset\n");
> +	shost_printk(KERN_INFO, host, "SCSI Host reset\n");
>   
>   	spin_lock_irqsave(&adapter->hw_lock, flags);
>   
> diff --git a/drivers/scsi/wd33c93.c b/drivers/scsi/wd33c93.c
> index 3fe562047d85..7cfe736ed6c2 100644
> --- a/drivers/scsi/wd33c93.c
> +++ b/drivers/scsi/wd33c93.c
> @@ -1568,13 +1568,11 @@ reset_wd33c93(struct Scsi_Host *instance)
>   }
>   
>   int
> -wd33c93_host_reset(struct scsi_cmnd * SCpnt)
> +wd33c93_host_reset(struct Scsi_Host * instance)
>   {
> -	struct Scsi_Host *instance;
>   	struct WD33C93_hostdata *hostdata;
>   	int i;
>   
> -	instance = SCpnt->device->host;
>   	spin_lock_irq(instance->host_lock);
>   	hostdata = (struct WD33C93_hostdata *) instance->hostdata;
>   
> @@ -1599,7 +1597,6 @@ wd33c93_host_reset(struct scsi_cmnd * SCpnt)
>   	hostdata->outgoing_len = 0;
>   
>   	reset_wd33c93(instance);
> -	SCpnt->result = DID_RESET << 16;
>   	enable_irq(instance->irq);
>   	spin_unlock_irq(instance->host_lock);
>   	return SUCCESS;
> diff --git a/drivers/scsi/wd33c93.h b/drivers/scsi/wd33c93.h
> index b3800baccd2c..87119e47836a 100644
> --- a/drivers/scsi/wd33c93.h
> +++ b/drivers/scsi/wd33c93.h
> @@ -341,6 +341,6 @@ int wd33c93_queuecommand (struct Scsi_Host *h, struct scsi_cmnd *cmd);
>   void wd33c93_intr (struct Scsi_Host *instance);
>   int wd33c93_show_info(struct seq_file *, struct Scsi_Host *);
>   int wd33c93_write_info(struct Scsi_Host *, char *, int);
> -int wd33c93_host_reset (struct scsi_cmnd *);
> +int wd33c93_host_reset (struct Scsi_Host *);
>   
>   #endif /* WD33C93_H */
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index ff1b22077251..02b8eb153944 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -520,9 +520,9 @@ static int wd719x_bus_reset(struct scsi_cmnd *cmd)
>   	return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
>   }
>   
> -static int wd719x_host_reset(struct scsi_cmnd *cmd)
> +static int wd719x_host_reset(struct Scsi_Host *host)
>   {
> -	struct wd719x *wd = shost_priv(cmd->device->host);
> +	struct wd719x *wd = shost_priv(host);
>   	struct wd719x_scb *scb, *tmp;
>   	unsigned long flags;
>   
> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
> index 48aa18f8b984..0de0dd09cf9d 100644
> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
> @@ -390,11 +390,11 @@ static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd)
>   
>   /*
>    * visorhba_host_reset_handler - Not supported
> - * @scsicmd: The scsicmd that needs to be aborted
> + * @shost: The scsi host that needs resetting
>    *
>    * Return: Not supported, return SUCCESS
>    */
> -static int visorhba_host_reset_handler(struct scsi_cmnd *scsicmd)
> +static int visorhba_host_reset_handler(struct Scsi_Host *shost)
>   {
>   	/* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */
>   	return SUCCESS;
> diff --git a/drivers/usb/image/microtek.c b/drivers/usb/image/microtek.c
> index 874ea4b54ced..8b560772c49a 100644
> --- a/drivers/usb/image/microtek.c
> +++ b/drivers/usb/image/microtek.c
> @@ -345,9 +345,9 @@ static int mts_scsi_abort(struct scsi_cmnd *srb)
>   	return FAILED;
>   }
>   
> -static int mts_scsi_host_reset(struct scsi_cmnd *srb)
> +static int mts_scsi_host_reset(struct Scsi_Host *shost)
>   {
> -	struct mts_desc* desc = (struct mts_desc*)(srb->device->host->hostdata[0]);
> +	struct mts_desc* desc = (struct mts_desc*)(shost->hostdata[0]);
>   	int result;
>   
>   	MTS_DEBUG_GOT_HERE();
> diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
> index 6e29e1719db1..31f60d2ad318 100644
> --- a/include/scsi/libfc.h
> +++ b/include/scsi/libfc.h
> @@ -950,7 +950,7 @@ void fc_fcp_destroy(struct fc_lport *);
>   int fc_queuecommand(struct Scsi_Host *, struct scsi_cmnd *);
>   int fc_eh_abort(struct scsi_cmnd *);
>   int fc_eh_device_reset(struct scsi_cmnd *);
> -int fc_eh_host_reset(struct scsi_cmnd *);
> +int fc_eh_host_reset(struct Scsi_Host *);
>   int fc_slave_alloc(struct scsi_device *);
>   
>   /*
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 667d889b92b5..3b8d9e65ea57 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -141,7 +141,7 @@ struct scsi_host_template {
>   	int (* eh_device_reset_handler)(struct scsi_cmnd *);
>   	int (* eh_target_reset_handler)(struct scsi_cmnd *);
>   	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> -	int (* eh_host_reset_handler)(struct scsi_cmnd *);
> +	int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   	/*
>   	 * Before the mid layer attempts to scan for a new device where none

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
@ 2022-05-03 21:12   ` Lee Duncan
  2022-05-06 11:20   ` Steffen Maier
  2022-05-06 15:29   ` Sathya Prakash Veerichetty
  2 siblings, 0 replies; 31+ messages in thread
From: Lee Duncan @ 2022-05-03 21:12 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

On 5/2/22 14:59, Hannes Reinecke wrote:
> The bus reset should not depend on any command, but rather only
> use the SCSI Host and the channel/bus number as argument.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>   Documentation/scsi/scsi_eh.rst                |  2 +-
>   Documentation/scsi/scsi_mid_low_api.rst       |  5 ++-
>   drivers/message/fusion/mptfc.c                | 13 +++----
>   drivers/message/fusion/mptscsih.c             | 21 ++++-------
>   drivers/message/fusion/mptscsih.h             |  2 +-
>   drivers/scsi/a100u2w.c                        |  4 +-
>   drivers/scsi/aacraid/linit.c                  | 11 +++---
>   drivers/scsi/aha152x.c                        |  4 +-
>   drivers/scsi/aha1542.c                        |  4 +-
>   drivers/scsi/aic7xxx/aic79xx_osm.c            | 10 ++---
>   drivers/scsi/aic7xxx/aic7xxx_osm.c            |  6 +--
>   drivers/scsi/arcmsr/arcmsr_hba.c              |  6 +--
>   drivers/scsi/arm/fas216.c                     |  9 +++--
>   drivers/scsi/arm/fas216.h                     |  5 ++-
>   drivers/scsi/dc395x.c                         | 25 ++++++-------
>   drivers/scsi/dpt_i2o.c                        |  9 +++--
>   drivers/scsi/dpti.h                           |  2 +-
>   drivers/scsi/esas2r/esas2r.h                  |  2 +-
>   drivers/scsi/esas2r/esas2r_main.c             |  4 +-
>   drivers/scsi/esp_scsi.c                       |  4 +-
>   drivers/scsi/initio.c                         | 11 +++---
>   drivers/scsi/mpi3mr/mpi3mr_os.c               | 37 +++++++++++--------
>   drivers/scsi/ncr53c8xx.c                      |  4 +-
>   drivers/scsi/pcmcia/nsp_cs.c                  |  6 +--
>   drivers/scsi/pcmcia/nsp_cs.h                  |  2 +-
>   drivers/scsi/pmcraid.c                        |  7 ++--
>   drivers/scsi/qla1280.c                        | 12 +++---
>   drivers/scsi/qla2xxx/qla_os.c                 | 17 +++------
>   drivers/scsi/scsi_debug.c                     | 31 ++++++----------
>   drivers/scsi/scsi_error.c                     |  2 +-
>   drivers/scsi/sym53c8xx_2/sym_glue.c           |  7 ++--
>   drivers/scsi/vmw_pvscsi.c                     |  5 +--
>   drivers/scsi/wd719x.c                         | 11 +++---
>   .../staging/unisys/visorhba/visorhba_main.c   |  7 ++--
>   drivers/usb/storage/scsiglue.c                |  4 +-
>   include/scsi/scsi_host.h                      |  2 +-
>   36 files changed, 150 insertions(+), 163 deletions(-)
> 
> diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
> index 12113cca5ad9..5e2d04e64005 100644
> --- a/Documentation/scsi/scsi_eh.rst
> +++ b/Documentation/scsi/scsi_eh.rst
> @@ -214,7 +214,7 @@ considered to fail always.
>   
>       int (* eh_abort_handler)(struct scsi_cmnd *);
>       int (* eh_device_reset_handler)(struct scsi_cmnd *);
> -    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
>       int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   Higher-severity actions are taken only when lower-severity actions
> diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
> index 784587ea7eee..1b1c37445580 100644
> --- a/Documentation/scsi/scsi_mid_low_api.rst
> +++ b/Documentation/scsi/scsi_mid_low_api.rst
> @@ -741,7 +741,8 @@ Details::
>   
>       /**
>       *      eh_bus_reset_handler - issue SCSI bus reset
> -    *      @scp: SCSI bus that contains this device should be reset
> +    *      @host: SCSI Host that contains the channel which should be reset
> +    *      @channel: channel to be reset
>       *
>       *      Returns SUCCESS if command aborted else FAILED
>       *
> @@ -754,7 +755,7 @@ Details::
>       *
>       *      Optionally defined in: LLD
>       **/
> -	int eh_bus_reset_handler(struct scsi_cmnd * scp)
> +	int eh_bus_reset_handler(struct Scsi_Host * host, int channel)
>   
>   
>       /**
> diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
> index 4a621380a4eb..bc62f0cc0cbd 100644
> --- a/drivers/message/fusion/mptfc.c
> +++ b/drivers/message/fusion/mptfc.c
> @@ -103,7 +103,7 @@ static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
>   static void mptfc_remove(struct pci_dev *pdev);
>   static int mptfc_abort(struct scsi_cmnd *SCpnt);
>   static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
> -static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
> +static int mptfc_bus_reset(struct Scsi_Host *shost, int channel);
>   
>   static struct scsi_host_template mptfc_driver_template = {
>   	.module				= THIS_MODULE,
> @@ -259,11 +259,9 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt)
>   }
>   
>   static int
> -mptfc_bus_reset(struct scsi_cmnd *SCpnt)
> +mptfc_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct Scsi_Host *shost = SCpnt->device->host;
>   	MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost);
> -	int channel = SCpnt->device->channel;
>   	struct mptfc_rport_info *ri;
>   	int rtn;
>   
> @@ -280,10 +278,9 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt)
>   	}
>   	if (rtn == 0) {
>   		dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
> -			"%s.%d: %d:%llu, executing recovery.\n", __func__,
> -			hd->ioc->name, shost->host_no,
> -			SCpnt->device->id, SCpnt->device->lun));
> -		rtn = mptscsih_bus_reset(SCpnt);
> +			"%s.%d: 0:0, executing recovery.\n", __func__,
> +			hd->ioc->name, shost->host_no));
> +		rtn = mptscsih_bus_reset(shost, channel);
>   	}
>   	return rtn;
>   }
> diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
> index 3df07e024026..afdbc8138346 100644
> --- a/drivers/message/fusion/mptscsih.c
> +++ b/drivers/message/fusion/mptscsih.c
> @@ -1914,39 +1914,34 @@ mptscsih_target_reset(struct scsi_cmnd * SCpnt)
>    *	Returns SUCCESS or FAILED.
>    **/
>   int
> -mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
> +mptscsih_bus_reset(struct Scsi_Host * shost, int channel)
>   {
>   	MPT_SCSI_HOST	*hd;
>   	int		 retval;
> -	VirtDevice	 *vdevice;
>   	MPT_ADAPTER	*ioc;
>   
>   	/* If we can't locate our host adapter structure, return FAILED status.
>   	 */
> -	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
> +	if ((hd = shost_priv(shost)) == NULL){
>   		printk(KERN_ERR MYNAM ": bus reset: "
> -		   "Can't locate host! (sc=%p)\n", SCpnt);
> +		   "Can't locate host!\n");
>   		return FAILED;
>   	}
>   
>   	ioc = hd->ioc;
> -	printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n",
> -	       ioc->name, SCpnt);
> -	scsi_print_command(SCpnt);
> +	printk(MYIOC_s_INFO_FMT "attempting bus reset!\n",
> +	       ioc->name);
>   
>   	if (ioc->timeouts < -1)
>   		ioc->timeouts++;
>   
> -	vdevice = SCpnt->device->hostdata;
> -	if (!vdevice || !vdevice->vtarget)
> -		return SUCCESS;
>   	retval = mptscsih_IssueTaskMgmt(hd,
>   					MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
> -					vdevice->vtarget->channel, 0, 0, 0,
> +					channel, 0, 0, 0,
>   					mptscsih_get_tm_timeout(ioc));
>   
> -	printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
> -	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
> +	printk(MYIOC_s_INFO_FMT "bus reset: %s\n",
> +	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
>   
>   	if (retval == 0)
>   		return SUCCESS;
> diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
> index 0faefe9c7541..9f3756bd25eb 100644
> --- a/drivers/message/fusion/mptscsih.h
> +++ b/drivers/message/fusion/mptscsih.h
> @@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device);
>   extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
>   extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
>   extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
> -extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
> +extern int mptscsih_bus_reset(struct Scsi_Host *, int);
>   extern int mptscsih_host_reset(struct Scsi_Host *sh);
>   extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
>   extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
> diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
> index bf552c818958..dab79824e2f6 100644
> --- a/drivers/scsi/a100u2w.c
> +++ b/drivers/scsi/a100u2w.c
> @@ -934,10 +934,10 @@ static int inia100_abort(struct scsi_cmnd * cmd)
>    Output         : None.
>    Return         : pSRB  -       Pointer to SCSI request block.
>   *****************************************************************************/
> -static int inia100_bus_reset(struct scsi_cmnd * cmd)
> +static int inia100_bus_reset(struct Scsi_Host * shost, int channel)
>   {				/* I need Host Control Block Information */
>   	struct orc_host *host;
> -	host = (struct orc_host *) cmd->device->host->hostdata;
> +	host = (struct orc_host *) shost->hostdata;
>   	return orc_reset_scsi_bus(host);
>   }
>   
> diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
> index 19a012c9a3c9..de7e0985ac2b 100644
> --- a/drivers/scsi/aacraid/linit.c
> +++ b/drivers/scsi/aacraid/linit.c
> @@ -1025,20 +1025,18 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
>   
>   /*
>    *	aac_eh_bus_reset	- Bus reset command handling
> - *	@scsi_cmd:	SCSI command block causing the reset
> + *	@host:	SCSI host causing the reset
> + *	@channel:	Number of the bus to be reset
>    *
>    */
> -static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
> +static int aac_eh_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	struct scsi_device * dev = cmd->device;
> -	struct Scsi_Host * host = dev->host;
>   	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
>   	int count;
>   	u32 cmd_bus;
>   	int status = 0;
>   
> -
> -	cmd_bus = aac_logical_to_phys(scmd_channel(cmd));
> +	cmd_bus = aac_logical_to_phys(channel);
>   	/* Mark the assoc. FIB to not complete, eh handler does this */
>   	for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
>   		struct fib *fib = &aac->fibs[count];
> @@ -1046,6 +1044,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
>   		if (fib->hw_fib_va->header.XferState &&
>   		    (fib->flags & FIB_CONTEXT_FLAG) &&
>   		    (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) {
> +			struct scsi_cmnd *cmd;
>   			struct aac_hba_map_info *info;
>   			u32 bus, cid;
>   
> diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
> index 7e58f25c599b..1312dc5ef6d2 100644
> --- a/drivers/scsi/aha152x.c
> +++ b/drivers/scsi/aha152x.c
> @@ -1192,9 +1192,9 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
>    * Reset the bus
>    *
>    */
> -static int aha152x_bus_reset(struct scsi_cmnd *SCpnt)
> +static int aha152x_bus_reset(struct Scsi_Host *shpnt, int channel)
>   {
> -	return aha152x_bus_reset_host(SCpnt->device->host);
> +	return aha152x_bus_reset_host(shpnt);
>   }
>   
>   /*
> diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
> index 69063fe4aab8..797a49f927dd 100644
> --- a/drivers/scsi/aha1542.c
> +++ b/drivers/scsi/aha1542.c
> @@ -980,9 +980,9 @@ static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
>   	return SUCCESS;
>   }
>   
> -static int aha1542_bus_reset(struct scsi_cmnd *cmd)
> +static int aha1542_bus_reset(struct Scsi_Host *sh, int channel)
>   {
> -	return aha1542_reset(cmd->device->host, SCRST);
> +	return aha1542_reset(sh, SCRST);
>   }
>   
>   static int aha1542_host_reset(struct Scsi_Host *sh)
> diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
> index c46e8152af28..00786c37f39f 100644
> --- a/drivers/scsi/aic7xxx/aic79xx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
> @@ -866,21 +866,21 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
>    * Reset the SCSI bus.
>    */
>   static int
> -ahd_linux_bus_reset(struct scsi_cmnd *cmd)
> +ahd_linux_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	struct ahd_softc *ahd;
>   	int    found;
>   	unsigned long flags;
>   
> -	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
> +	ahd = *(struct ahd_softc **)shost->hostdata;
>   #ifdef AHD_DEBUG
>   	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
> -		printk("%s: Bus reset called for cmd %p\n",
> -		       ahd_name(ahd), cmd);
> +		printk("%s: Bus reset called for channel %d\n",
> +		       ahd_name(ahd), channel);
>   #endif
>   	ahd_lock(ahd, &flags);
>   
> -	found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
> +	found = ahd_reset_channel(ahd, channel + 'A',
>   				  /*initiate reset*/TRUE);
>   	ahd_unlock(ahd, &flags);
>   
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> index 0ad429b7ebcf..f6c547cef26c 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> @@ -753,16 +753,16 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
>    * Reset the SCSI bus.
>    */
>   static int
> -ahc_linux_bus_reset(struct scsi_cmnd *cmd)
> +ahc_linux_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	struct ahc_softc *ahc;
>   	int    found;
>   	unsigned long flags;
>   
> -	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
> +	ahc = *(struct ahc_softc **)shost->hostdata;
>   
>   	ahc_lock(ahc, &flags);
> -	found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
> +	found = ahc_reset_channel(ahc, channel + 'A',
>   				  /*initiate reset*/TRUE);
>   	ahc_unlock(ahc, &flags);
>   
> diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> index d3fb8a9c1c39..baa03ead75d9 100644
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c
> @@ -111,7 +111,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
>   					struct scsi_cmnd *cmd);
>   static int arcmsr_iop_confirm(struct AdapterControlBlock *acb);
>   static int arcmsr_abort(struct scsi_cmnd *);
> -static int arcmsr_bus_reset(struct scsi_cmnd *);
> +static int arcmsr_bus_reset(struct Scsi_Host *, int);
>   static int arcmsr_bios_param(struct scsi_device *sdev,
>   		struct block_device *bdev, sector_t capacity, int *info);
>   static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
> @@ -4573,12 +4573,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
>   	return rtnval;
>   }
>   
> -static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
> +static int arcmsr_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	struct AdapterControlBlock *acb;
>   	int retry_count = 0;
>   	int rtn = FAILED;
> -	acb = (struct AdapterControlBlock *) cmd->device->host->hostdata;
> +	acb = (struct AdapterControlBlock *) shost->hostdata;
>   	if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
>   		return SUCCESS;
>   	pr_notice("arcmsr: executing bus reset eh.....num_resets = %d,"
> diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
> index 38eec967155d..c27b49c42c4f 100644
> --- a/drivers/scsi/arm/fas216.c
> +++ b/drivers/scsi/arm/fas216.c
> @@ -2550,15 +2550,16 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
>   
>   /**
>    * fas216_eh_bus_reset - Reset the bus associated with the command
> - * @SCpnt: command specifing bus to reset
> + * @shost: host to be reset
> + * @channel: bus number to reset
>    *
> - * Reset the bus associated with the command.
> + * Reset the bus.
>    * Returns: FAILED if unable to reset.
>    * Notes: Further commands are blocked.
>    */
> -int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
> +int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
> +	FAS216_Info *info = (FAS216_Info *)shost->hostdata;
>   	unsigned long flags;
>   	struct scsi_device *SDpnt;
>   
> diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
> index f17583f143b3..27a4b564f054 100644
> --- a/drivers/scsi/arm/fas216.h
> +++ b/drivers/scsi/arm/fas216.h
> @@ -389,10 +389,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
>   
>   /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
>    * Purpose : Reset the complete bus associated with this command
> - * Params  : SCpnt - command specifing bus to reset
> + * Params  : shost - host to be reset
> + *           channel - bus to be reset
>    * Returns : FAILED if unable to reset
>    */
> -extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
> +extern int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel);
>   
>   /* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
>    * Purpose : Reset the host associated with this command
> diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
> index 67a89715c863..7374eda8cffa 100644
> --- a/drivers/scsi/dc395x.c
> +++ b/drivers/scsi/dc395x.c
> @@ -1144,19 +1144,18 @@ static void reset_dev_param(struct AdapterCtlBlk *acb)
>    * @cmd - some command for this host (for fetching hooks)
>    * Returns: SUCCESS (0x2002) on success, else FAILED (0x2003).
>    */
> -static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
> +static int __dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	struct AdapterCtlBlk *acb =
> -		(struct AdapterCtlBlk *)cmd->device->host->hostdata;
> +		(struct AdapterCtlBlk *)shost->hostdata;
>   	dprintkl(KERN_INFO,
> -		"eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
> -		cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
> +		 "eh_bus_reset: bus=<%02i>\n", channel);
>   
>   	if (timer_pending(&acb->waiting_timer))
>   		del_timer(&acb->waiting_timer);
>   
>   	/*
> -	 * disable interrupt
> +	 * disable interrupt
>   	 */
>   	DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00);
>   	DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00);
> @@ -1172,7 +1171,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>   	    HZ * acb->eeprom.delay_time;
>   
>   	/*
> -	 * re-enable interrupt
> +	 * re-enable interrupt
>   	 */
>   	/* Clear SCSI FIFO          */
>   	DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
> @@ -1182,7 +1181,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>   	set_basic_config(acb);
>   
>   	reset_dev_param(acb);
> -	doing_srb_done(acb, DID_RESET, cmd, 0);
> +	doing_srb_done(acb, DID_RESET, NULL, 0);
>   	acb->active_dcb = NULL;
>   	acb->acb_flag = 0;	/* RESET_DETECT, RESET_DONE ,RESET_DEV */
>   	waiting_process_next(acb);
> @@ -1190,13 +1189,13 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>   	return SUCCESS;
>   }
>   
> -static int dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
> +static int dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	int rc;
>   
> -	spin_lock_irq(cmd->device->host->host_lock);
> -	rc = __dc395x_eh_bus_reset(cmd);
> -	spin_unlock_irq(cmd->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
> +	rc = __dc395x_eh_bus_reset(shost, channel);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return rc;
>   }
> @@ -3338,7 +3337,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
>   
>   /* abort all cmds in our queues */
>   static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
> -		struct scsi_cmnd *cmd, u8 force)
> +			   struct scsi_cmnd *cmd, u8 force)
>   {
>   	struct DeviceCtlBlk *dcb;
>   	dprintkl(KERN_INFO, "doing_srb_done: pids ");
> @@ -3386,7 +3385,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
>   			set_status_byte(p, SAM_STAT_GOOD);
>   			pci_unmap_srb_sense(acb, srb);
>   			pci_unmap_srb(acb, srb);
> -			if (force) {
> +			if (force && cmd) {
>   				/* For new EH, we normally don't need to give commands back,
>   				 * as they all complete or all time out */
>   				scsi_done(cmd);
> diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
> index 6e3ad0e5b533..b1ab772aff0e 100644
> --- a/drivers/scsi/dpt_i2o.c
> +++ b/drivers/scsi/dpt_i2o.c
> @@ -718,17 +718,18 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
>   
>   #define I2O_HBA_BUS_RESET 0x87
>   // This version of bus reset is called by the eh_error handler
> -static int adpt_bus_reset(struct scsi_cmnd* cmd)
> +static int adpt_bus_reset(struct Scsi_Host *shost, int channel)
>   {
>   	adpt_hba* pHba;
>   	u32 msg[4];
>   	u32 rcode;
>   
> -	pHba = (adpt_hba*)cmd->device->host->hostdata[0];
> +	pHba = (adpt_hba*)shost->hostdata[0];
>   	memset(msg, 0, sizeof(msg));
> -	printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid );
> +	printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",
> +	       pHba->name, channel, pHba->channel[channel].tid );
>   	msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
> -	msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
> +	msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[channel].tid);
>   	msg[2] = 0;
>   	msg[3] = 0;
>   	if (pHba->host)
> diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
> index b77a3625fa6f..48878e69ab2c 100644
> --- a/drivers/scsi/dpti.h
> +++ b/drivers/scsi/dpti.h
> @@ -35,7 +35,7 @@ static const char *adpt_info(struct Scsi_Host *pSHost);
>   static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
>   		sector_t, int geom[]);
>   
> -static int adpt_bus_reset(struct scsi_cmnd* cmd);
> +static int adpt_bus_reset(struct Scsi_Host* shost, int channel);
>   static int adpt_device_reset(struct scsi_cmnd* cmd);
>   
>   
> diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
> index a104d1a3a9da..5c1eeaffc090 100644
> --- a/drivers/scsi/esas2r/esas2r.h
> +++ b/drivers/scsi/esas2r/esas2r.h
> @@ -977,7 +977,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
>   int esas2r_eh_abort(struct scsi_cmnd *cmd);
>   int esas2r_device_reset(struct scsi_cmnd *cmd);
>   int esas2r_host_reset(struct Scsi_Host *shost);
> -int esas2r_bus_reset(struct scsi_cmnd *cmd);
> +int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
>   int esas2r_target_reset(struct scsi_cmnd *cmd);
>   
>   /* Internal functions */
> diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
> index 52494c8bb656..315b8a61d0d7 100644
> --- a/drivers/scsi/esas2r/esas2r_main.c
> +++ b/drivers/scsi/esas2r/esas2r_main.c
> @@ -1094,10 +1094,8 @@ int esas2r_host_reset(struct Scsi_Host *shost)
>   	return esas2r_host_bus_reset(shost, true);
>   }
>   
> -int esas2r_bus_reset(struct scsi_cmnd *cmd)
> +int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct Scsi_Host *shost = cmd->device->host;
> -
>   	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
>   
>   	return esas2r_host_bus_reset(shost, false);
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index b41eac8b5e0f..2fa53100df24 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2604,9 +2604,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
>   	return FAILED;
>   }
>   
> -static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
> +static int esp_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
>   {
> -	struct esp *esp = shost_priv(cmd->device->host);
> +	struct esp *esp = shost_priv(shost);
>   	struct completion eh_reset;
>   	unsigned long flags;
>   
> diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
> index f585d6e5fab9..adddedfdbcc7 100644
> --- a/drivers/scsi/initio.c
> +++ b/drivers/scsi/initio.c
> @@ -2625,20 +2625,21 @@ static DEF_SCSI_QCMD(i91u_queuecommand)
>   
>   /**
>    *	i91u_bus_reset		-	reset the SCSI bus
> - *	@cmnd: Command block we want to trigger the reset for
> + *	@shost: SCSI host to be reset
> + *	@channel: Bus number to be reset
>    *
>    *	Initiate a SCSI bus reset sequence
>    */
>   
> -static int i91u_bus_reset(struct scsi_cmnd * cmnd)
> +static int i91u_bus_reset(struct Scsi_Host * shost, int channel)
>   {
>   	struct initio_host *host;
>   
> -	host = (struct initio_host *) cmnd->device->host->hostdata;
> +	host = (struct initio_host *) shost->hostdata;
>   
> -	spin_lock_irq(cmnd->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
>   	initio_reset_scsi(host, 0);
> -	spin_unlock_irq(cmnd->device->host->host_lock);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return SUCCESS;
>   }
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index bd42d3a56590..88fbd01c05d0 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -3362,39 +3362,46 @@ static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
>   
>   /**
>    * mpi3mr_eh_bus_reset - Bus reset error handling callback
> - * @scmd: SCSI command reference
> + * @shost: SCSI host reference
> + * @channel: bus number
>    *
>    * Checks whether pending I/Os are present for the RAID volume;
>    * if not there's no need to reset the adapter.
>    *
>    * Return: SUCCESS of successful reset else FAILED
>    */
> -static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd)
> +static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
> +	struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +	struct mpi3mr_tgt_dev *tgtdev;
>   	struct mpi3mr_stgt_priv_data *stgt_priv_data;
> -	struct mpi3mr_sdev_priv_data *sdev_priv_data;
> -	u8 dev_type = MPI3_DEVICE_DEVFORM_VD;
>   	int retval = FAILED;
>   
> -	sdev_priv_data = scmd->device->hostdata;
> -	if (sdev_priv_data && sdev_priv_data->tgt_priv_data) {
> -		stgt_priv_data = sdev_priv_data->tgt_priv_data;
> -		dev_type = stgt_priv_data->dev_type;
> +	spin_lock(&mrioc->tgtdev_lock);
> +	list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
> +		if (!tgtdev->starget || !tgtdev->starget->hostdata)
> +			continue;
> +		stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
> +			tgtdev->starget->hostdata;
> +		if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_VD) {
> +			retval = SUCCESS;
> +			break;
> +		}
>   	}
> +	spin_unlock(&mrioc->tgtdev_lock);
>   
> -	if (dev_type == MPI3_DEVICE_DEVFORM_VD) {
> +	if (retval == SUCCESS) {
>   		mpi3mr_wait_for_host_io(mrioc,
>   			MPI3MR_RAID_ERRREC_RESET_TIMEOUT);
> -		if (!mpi3mr_get_fw_pending_ios(mrioc))
> -			retval = SUCCESS;
> +		if (mpi3mr_get_fw_pending_ios(mrioc))
> +			retval = FAILED;
>   	}
>   	if (retval == FAILED)
>   		mpi3mr_print_pending_host_io(mrioc);
>   
> -	sdev_printk(KERN_INFO, scmd->device,
> -		"Bus reset is %s for scmd(%p)\n",
> -		((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
> +	shost_printk(KERN_INFO, shost,
> +		"Bus reset is %s\n",
> +		((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
>   	return retval;
>   }
>   
> diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
> index 4458449c960b..2d4470686a4b 100644
> --- a/drivers/scsi/ncr53c8xx.c
> +++ b/drivers/scsi/ncr53c8xx.c
> @@ -7936,9 +7936,9 @@ static void ncr53c8xx_timeout(struct timer_list *t)
>   		ncr_flush_done_cmds(done_list);
>   }
>   
> -static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
> +static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
> +	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
>   	int sts;
>   	unsigned long flags;
>   	struct scsi_cmnd *done_list;
> diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
> index 4aa9737fa711..b1bce76c83b9 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.c
> +++ b/drivers/scsi/pcmcia/nsp_cs.c
> @@ -1488,11 +1488,11 @@ static int nsp_bus_reset(nsp_hw_data *data)
>   	return SUCCESS;
>   }
>   
> -static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
> +static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
> +	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
>   
> -	nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
> +	nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel);
>   
>   	return nsp_bus_reset(data);
>   }
> diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
> index f532adb5f166..8636f0053c02 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.h
> +++ b/drivers/scsi/pcmcia/nsp_cs.h
> @@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
>   /* Error handler */
>   /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
>   /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
> -static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
> +static int nsp_eh_bus_reset    (struct Scsi_Host *host, int channel);
>   static int nsp_eh_host_reset   (struct Scsi_Host *host);
>   static int nsp_bus_reset       (nsp_hw_data *data);
>   
> diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
> index 79ca737ac75b..14e90807d38c 100644
> --- a/drivers/scsi/pmcraid.c
> +++ b/drivers/scsi/pmcraid.c
> @@ -3023,9 +3023,8 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
>   				    RESET_DEVICE_LUN);
>   }
>   
> -static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
> +static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel)
>   {
> -	struct Scsi_Host *host = scmd->device->host;
>   	struct pmcraid_instance *pinstance =
>   		(struct pmcraid_instance *)host->hostdata;
>   	struct pmcraid_resource_entry *res = NULL;
> @@ -3039,11 +3038,11 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
>   	 */
>   	spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
>   	list_for_each_entry(temp, &pinstance->used_res_q, queue) {
> -		if (scmd->device->channel == PMCRAID_VSET_BUS_ID &&
> +		if (channel == PMCRAID_VSET_BUS_ID &&
>   		    RES_IS_VSET(temp->cfg_entry)) {
>   			res = temp;
>   			break;
> -		} else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID &&
> +		} else if (channel == PMCRAID_PHYS_BUS_ID &&
>   			   RES_IS_GSCSI(temp->cfg_entry)) {
>   			res = temp;
>   			break;
> diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
> index cd4c7126c1c9..f32f00c7a390 100644
> --- a/drivers/scsi/qla1280.c
> +++ b/drivers/scsi/qla1280.c
> @@ -979,13 +979,15 @@ qla1280_eh_device_reset(struct scsi_cmnd *cmd)
>    *     Reset the specified bus.
>    **************************************************************************/
>   static int
> -qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
> +qla1280_eh_bus_reset(struct Scsi_Host *shost, int bus)
>   {
> -	int rc;
> +	int rc = FAILED;
> +	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
>   
> -	spin_lock_irq(cmd->device->host->host_lock);
> -	rc = qla1280_error_action(cmd, BUS_RESET);
> -	spin_unlock_irq(cmd->device->host->host_lock);
> +	spin_lock_irq(shost->host_lock);
> +	if (qla1280_bus_reset(ha, bus) == 0)
> +		rc = qla1280_wait_for_pending_commands(ha, 1, 0);
> +	spin_unlock_irq(shost->host_lock);
>   
>   	return rc;
>   }
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 5f86e7bd5a0e..11e7dc22b94d 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -1537,7 +1537,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>   *    commands.
>   *
>   * Input:
> -*    cmd = Linux SCSI command packet of the command that cause the
> +*    host = Linux SCSI command packet of the command that cause the
>   *          bus reset.
>   *
>   * Returns:
> @@ -1545,12 +1545,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>   *
>   **************************************************************************/
>   static int
> -qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
> +qla2xxx_eh_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
> +	scsi_qla_host_t *vha = shost_priv(shost);
>   	int ret = FAILED;
> -	unsigned int id;
> -	uint64_t lun;
>   	struct qla_hw_data *ha = vha->hw;
>   
>   	if (qla2x00_isp_reg_stat(ha)) {
> @@ -1560,14 +1558,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>   		return FAILED;
>   	}
>   
> -	id = cmd->device->id;
> -	lun = cmd->device->lun;
> -
>   	if (qla2x00_chip_is_down(vha))
>   		return ret;
>   
>   	ql_log(ql_log_info, vha, 0x8012,
> -	    "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
> +	    "BUS RESET ISSUED nexus=%ld:%d.\n", vha->host_no, channel);
>   
>   	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
>   		ql_log(ql_log_fatal, vha, 0x8013,
> @@ -1591,8 +1586,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>   
>   eh_bus_reset_done:
>   	ql_log(ql_log_warn, vha, 0x802b,
> -	    "BUS RESET %s nexus=%ld:%d:%llu.\n",
> -	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
> +	    "BUS RESET %s nexus=%ld:%d.\n",
> +	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, channel);
>   
>   	return ret;
>   }
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 6292ac7aef7a..f2d3271bc80b 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5324,36 +5324,27 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
>   	return SUCCESS;
>   }
>   
> -static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
> +static int scsi_debug_bus_reset(struct Scsi_Host * hp, int channel)
>   {
> -	struct sdebug_host_info *sdbg_host;
> +	struct sdebug_host_info *sdbg_host =
> +		*(struct sdebug_host_info **)shost_priv(hp);
>   	struct sdebug_dev_info *devip;
> -	struct scsi_device *sdp;
> -	struct Scsi_Host *hp;
>   	int k = 0;
>   
>   	++num_bus_resets;
> -	if (!(SCpnt && SCpnt->device))
> -		goto lie;
> -	sdp = SCpnt->device;
>   	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
> -		sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
> -	hp = sdp->host;
> -	if (hp) {
> -		sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
> -		if (sdbg_host) {
> -			list_for_each_entry(devip,
> -					    &sdbg_host->dev_info_list,
> -					    dev_list) {
> -				set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
> -				++k;
> -			}
> +		shost_printk(KERN_INFO, hp, "%s\n", __func__);
> +	if (sdbg_host) {
> +		list_for_each_entry(devip,
> +				    &sdbg_host->dev_info_list,
> +				    dev_list) {
> +			set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
> +			++k;
>   		}
>   	}
>   	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
> -		sdev_printk(KERN_INFO, sdp,
> +		shost_printk(KERN_INFO, hp,
>   			    "%s: %d device(s) found in host\n", __func__, k);
> -lie:
>   	return SUCCESS;
>   }
>   
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 747131ca8970..148cab3e61c0 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -871,7 +871,7 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
>   	if (!hostt->eh_bus_reset_handler)
>   		return FAILED;
>   
> -	rtn = hostt->eh_bus_reset_handler(scmd);
> +	rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
>   
>   	if (rtn == SUCCESS) {
>   		if (!hostt->skip_settle_delay)
> diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
> index a573baa5bdf2..aef828731995 100644
> --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
> +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
> @@ -670,14 +670,13 @@ static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
>   	return SCSI_SUCCESS;
>   }
>   
> -static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
> +static int sym53c8xx_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
>   {
> -	struct Scsi_Host *shost = cmd->device->host;
>   	struct sym_data *sym_data = shost_priv(shost);
>   	struct pci_dev *pdev = sym_data->pdev;
>   	struct sym_hcb *np = sym_data->ncb;
>   
> -	scmd_printk(KERN_WARNING, cmd, "BUS RESET operation started\n");
> +	shost_printk(KERN_WARNING, shost, "BUS RESET operation started\n");
>   
>   	/*
>   	 * Escalate to host reset if the PCI bus went down
> @@ -689,7 +688,7 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
>   	sym_reset_scsi_bus(np, 1);
>   	spin_unlock_irq(shost->host_lock);
>   
> -	dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n");
> +	shost_printk(KERN_WARNING, shost, "BUS RESET operation complete.\n");
>   	return SCSI_SUCCESS;
>   }
>   
> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
> index ddf1837babc0..9c62d446ea9e 100644
> --- a/drivers/scsi/vmw_pvscsi.c
> +++ b/drivers/scsi/vmw_pvscsi.c
> @@ -947,13 +947,12 @@ static int pvscsi_host_reset(struct Scsi_Host *host)
>   	return SUCCESS;
>   }
>   
> -static int pvscsi_bus_reset(struct scsi_cmnd *cmd)
> +static int pvscsi_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	struct Scsi_Host *host = cmd->device->host;
>   	struct pvscsi_adapter *adapter = shost_priv(host);
>   	unsigned long flags;
>   
> -	scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n");
> +	shost_printk(KERN_INFO, host, "SCSI Bus reset\n");
>   
>   	/*
>   	 * We don't want to queue new requests for this bus after
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index 02b8eb153944..fd297c7517cd 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -484,11 +484,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd)
>   	return SUCCESS;
>   }
>   
> -static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
> +static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device)
>   {
>   	int result;
>   	unsigned long flags;
> -	struct wd719x *wd = shost_priv(cmd->device->host);
> +	struct wd719x *wd = shost_priv(shost);
>   	struct wd719x_scb *scb, *tmp;
>   
>   	dev_info(&wd->pdev->dev, "%s reset requested\n",
> @@ -512,12 +512,13 @@ static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
>   
>   static int wd719x_dev_reset(struct scsi_cmnd *cmd)
>   {
> -	return wd719x_reset(cmd, WD719X_CMD_RESET, cmd->device->id);
> +	return wd719x_reset(cmd->device->host, WD719X_CMD_RESET,
> +			    cmd->device->id);
>   }
>   
> -static int wd719x_bus_reset(struct scsi_cmnd *cmd)
> +static int wd719x_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
> +	return wd719x_reset(host, WD719X_CMD_BUSRESET, 0);
>   }
>   
>   static int wd719x_host_reset(struct Scsi_Host *host)
> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
> index 0de0dd09cf9d..28c59218077d 100644
> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
> @@ -366,14 +366,15 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd)
>    *
>    * Return: SUCCESS if inserted, FAILED otherwise
>    */
> -static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd)
> +static int visorhba_bus_reset_handler(struct Scsi_Host *scsihost, int channel)
>   {
>   	struct scsi_device *scsidev;
>   	struct visordisk_info *vdisk;
>   	int rtn;
>   
> -	scsidev = scsicmd->device;
> -	shost_for_each_device(scsidev, scsidev->host) {
> +	shost_for_each_device(scsidev, scsihost) {
> +		if (scsidev->channel != channel)
> +			continue;
>   		vdisk = scsidev->hostdata;
>   		if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT)
>   			atomic_inc(&vdisk->error_count);
> diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
> index 8931df5a85fd..17dabfba6b2b 100644
> --- a/drivers/usb/storage/scsiglue.c
> +++ b/drivers/usb/storage/scsiglue.c
> @@ -464,9 +464,9 @@ static int device_reset(struct scsi_cmnd *srb)
>   }
>   
>   /* Simulate a SCSI bus reset by resetting the device's USB port. */
> -static int bus_reset(struct scsi_cmnd *srb)
> +static int bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct us_data *us = host_to_us(srb->device->host);
> +	struct us_data *us = host_to_us(shost);
>   	int result;
>   
>   	usb_stor_dbg(us, "%s called\n", __func__);
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 3b8d9e65ea57..73c9971e7334 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -140,7 +140,7 @@ struct scsi_host_template {
>   	int (* eh_abort_handler)(struct scsi_cmnd *);
>   	int (* eh_device_reset_handler)(struct scsi_cmnd *);
>   	int (* eh_target_reset_handler)(struct scsi_cmnd *);
> -	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
>   	int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   	/*

Reviewed-by: Lee Duncan <lduncan@suse.com>


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 0/7] scsi: EH rework main part
  2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
                   ` (17 preceding siblings ...)
  2022-05-02 21:59 ` [PATCH 11/11] csiostor: use separate TMF command Hannes Reinecke
@ 2022-05-05  2:27 ` chenxiang (M)
  2022-05-05 16:19   ` Hannes Reinecke
  18 siblings, 1 reply; 31+ messages in thread
From: chenxiang (M) @ 2022-05-05  2:27 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi

Hi Hannes and other guys,

For SCSI EH, i have a question (sorry, it is not related to this 
patchset): for current flow of SCSI EH, if IOs of one disk is failed

(if there are many disks under the same scsi host), it will block all 
the IOs of total scsi host.

So during SCSI EH, all IOs are blocked even if some disks are normal. 
That's the place product line sometimes complain about

as it blocks IO bussiness of some normal disks because of just one bad 
disk during SCSI EH.

Is it possible to split the SCSI EH into two parts, the process of 
recovering the disk and the process of recovering scsi host, at the 
beginning

it just blocks the IOs of the disk and not need to block all the IOs,  
do some recovery related to the disk (such as abort IO/lun reset), and 
if failed,

then block all the IOs and do some recoverys related to scsi host (such 
as host reset) ?


Best regards,

chenxiang


在 2022/5/3 5:59, Hannes Reinecke 写道:
> Hi all,
>
> now that the prep is done we can convert the call sequence
> of the SCSI EH callbacks to use the respective object
> (ie struct Scsi_Host or struct scsi_device) and the Scsi command.
> With that we don't have to allocate a 'fake' command for
> ioctl reset anymore.
>
> As usual, comments and reviews are welcome.
>
> Hannes Reinecke (7):
>    scsi: Use Scsi_Host as argument for eh_host_reset_handler
>    scsi: Use Scsi_Host and channel number as argument for
>      eh_bus_reset_handler()
>    scsi: Use scsi_target as argument for eh_target_reset_handler()
>    scsi: Use scsi_device as argument to eh_device_reset_handler()
>    scsi: Do not allocate scsi command in scsi_ioctl_reset()
>    scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL
>    scsi_error: streamline scsi_eh_bus_device_reset()
>
>   Documentation/scsi/scsi_eh.rst                |  16 +-
>   Documentation/scsi/scsi_mid_low_api.rst       |  31 +++-
>   drivers/infiniband/ulp/srp/ib_srp.c           |  12 +-
>   drivers/message/fusion/mptfc.c                |  25 ++-
>   drivers/message/fusion/mptsas.c               |  10 +-
>   drivers/message/fusion/mptscsih.c             |  86 ++++-----
>   drivers/message/fusion/mptscsih.h             |   8 +-
>   drivers/message/fusion/mptspi.c               |   8 +-
>   drivers/s390/scsi/zfcp_scsi.c                 |  14 +-
>   drivers/scsi/3w-9xxx.c                        |  11 +-
>   drivers/scsi/3w-sas.c                         |  11 +-
>   drivers/scsi/3w-xxxx.c                        |  11 +-
>   drivers/scsi/53c700.c                         |  39 ++--
>   drivers/scsi/BusLogic.c                       |  14 +-
>   drivers/scsi/NCR5380.c                        |   3 +-
>   drivers/scsi/a100u2w.c                        |  11 +-
>   drivers/scsi/aacraid/linit.c                  |  35 ++--
>   drivers/scsi/advansys.c                       |  26 +--
>   drivers/scsi/aha152x.c                        |  10 +-
>   drivers/scsi/aha1542.c                        |  30 +--
>   drivers/scsi/aic7xxx/aic79xx_osm.c            |  37 ++--
>   drivers/scsi/aic7xxx/aic7xxx_osm.c            |  10 +-
>   drivers/scsi/arcmsr/arcmsr_hba.c              |   6 +-
>   drivers/scsi/arm/acornscsi.c                  |   8 +-
>   drivers/scsi/arm/fas216.c                     |  18 +-
>   drivers/scsi/arm/fas216.h                     |  17 +-
>   drivers/scsi/atari_scsi.c                     |   4 +-
>   drivers/scsi/be2iscsi/be_main.c               |  12 +-
>   drivers/scsi/bfa/bfad_im.c                    |   8 +-
>   drivers/scsi/bnx2fc/bnx2fc.h                  |   4 +-
>   drivers/scsi/bnx2fc/bnx2fc_io.c               |  10 +-
>   drivers/scsi/csiostor/csio_scsi.c             |   3 +-
>   drivers/scsi/cxlflash/main.c                  |  10 +-
>   drivers/scsi/dc395x.c                         |  25 ++-
>   drivers/scsi/dpt_i2o.c                        |  43 +++--
>   drivers/scsi/dpti.h                           |   6 +-
>   drivers/scsi/esas2r/esas2r.h                  |   8 +-
>   drivers/scsi/esas2r/esas2r_main.c             |  55 +++---
>   drivers/scsi/esp_scsi.c                       |   8 +-
>   drivers/scsi/fdomain.c                        |   3 +-
>   drivers/scsi/fnic/fnic.h                      |   4 +-
>   drivers/scsi/fnic/fnic_scsi.c                 |   9 +-
>   drivers/scsi/hpsa.c                           |  14 +-
>   drivers/scsi/hptiop.c                         |   6 +-
>   drivers/scsi/ibmvscsi/ibmvfc.c                |  12 +-
>   drivers/scsi/ibmvscsi/ibmvscsi.c              |  23 +--
>   drivers/scsi/imm.c                            |   4 +-
>   drivers/scsi/initio.c                         |  11 +-
>   drivers/scsi/ipr.c                            |  35 ++--
>   drivers/scsi/ips.c                            |  22 +--
>   drivers/scsi/libfc/fc_fcp.c                   |  16 +-
>   drivers/scsi/libiscsi.c                       |  19 +-
>   drivers/scsi/libsas/sas_scsi_host.c           |  21 ++-
>   drivers/scsi/lpfc/lpfc_scsi.c                 |  23 ++-
>   drivers/scsi/mac53c94.c                       |   8 +-
>   drivers/scsi/megaraid.c                       |   4 +-
>   drivers/scsi/megaraid.h                       |   2 +-
>   drivers/scsi/megaraid/megaraid_mbox.c         |  14 +-
>   drivers/scsi/megaraid/megaraid_sas.h          |   3 +-
>   drivers/scsi/megaraid/megaraid_sas_base.c     |  44 ++---
>   drivers/scsi/megaraid/megaraid_sas_fusion.c   |  56 +++---
>   drivers/scsi/mesh.c                           |  10 +-
>   drivers/scsi/mpi3mr/mpi3mr_os.c               | 123 ++++++------
>   drivers/scsi/mpt3sas/mpt3sas_scsih.c          |  72 +++----
>   drivers/scsi/mvumi.c                          |   7 +-
>   drivers/scsi/myrb.c                           |   3 +-
>   drivers/scsi/myrs.c                           |   3 +-
>   drivers/scsi/ncr53c8xx.c                      |   4 +-
>   drivers/scsi/nsp32.c                          |  12 +-
>   drivers/scsi/pcmcia/nsp_cs.c                  |  10 +-
>   drivers/scsi/pcmcia/nsp_cs.h                  |   6 +-
>   drivers/scsi/pcmcia/qlogic_stub.c             |   4 +-
>   drivers/scsi/pcmcia/sym53c500_cs.c            |   8 +-
>   drivers/scsi/pmcraid.c                        |  27 ++-
>   drivers/scsi/ppa.c                            |   4 +-
>   drivers/scsi/qedf/qedf_main.c                 |  13 +-
>   drivers/scsi/qedi/qedi_iscsi.c                |   3 +-
>   drivers/scsi/qla1280.c                        |  36 ++--
>   drivers/scsi/qla2xxx/qla_os.c                 |  83 ++++-----
>   drivers/scsi/qla4xxx/ql4_os.c                 |  54 +++---
>   drivers/scsi/qlogicfas408.c                   |  10 +-
>   drivers/scsi/qlogicfas408.h                   |   2 +-
>   drivers/scsi/qlogicpti.c                      |   3 +-
>   drivers/scsi/scsi_debug.c                     |  78 +++-----
>   drivers/scsi/scsi_error.c                     | 175 +++++++++---------
>   drivers/scsi/scsi_lib.c                       |   2 -
>   drivers/scsi/smartpqi/smartpqi_init.c         |  11 +-
>   drivers/scsi/snic/snic.h                      |   5 +-
>   drivers/scsi/snic/snic_scsi.c                 |  41 +---
>   drivers/scsi/stex.c                           |   7 +-
>   drivers/scsi/storvsc_drv.c                    |   4 +-
>   drivers/scsi/sym53c8xx_2/sym_glue.c           |  13 +-
>   drivers/scsi/ufs/ufshcd.c                     |  14 +-
>   drivers/scsi/virtio_scsi.c                    |  12 +-
>   drivers/scsi/vmw_pvscsi.c                     |  20 +-
>   drivers/scsi/wd33c93.c                        |   5 +-
>   drivers/scsi/wd33c93.h                        |   2 +-
>   drivers/scsi/wd719x.c                         |  17 +-
>   drivers/scsi/xen-scsifront.c                  |  23 ++-
>   drivers/staging/rts5208/rtsx.c                |   6 +-
>   .../staging/unisys/visorhba/visorhba_main.c   |  24 +--
>   drivers/target/loopback/tcm_loop.c            |  17 +-
>   drivers/usb/image/microtek.c                  |   4 +-
>   drivers/usb/storage/scsiglue.c                |   8 +-
>   drivers/usb/storage/uas.c                     |   3 +-
>   include/scsi/libfc.h                          |   4 +-
>   include/scsi/libiscsi.h                       |   4 +-
>   include/scsi/libsas.h                         |   4 +-
>   include/scsi/scsi_cmnd.h                      |   1 -
>   include/scsi/scsi_host.h                      |   8 +-
>   110 files changed, 989 insertions(+), 1076 deletions(-)
>


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 0/7] scsi: EH rework main part
  2022-05-05  2:27 ` [PATCH 0/7] scsi: EH rework main part chenxiang (M)
@ 2022-05-05 16:19   ` Hannes Reinecke
  2022-05-06  3:24     ` chenxiang (M)
  0 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2022-05-05 16:19 UTC (permalink / raw)
  To: chenxiang (M), Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi

On 5/4/22 19:27, chenxiang (M) wrote:
> Hi Hannes and other guys,
> 
> For SCSI EH, i have a question (sorry, it is not related to this 
> patchset): for current flow of SCSI EH, if IOs of one disk is failed
> 
> (if there are many disks under the same scsi host), it will block all 
> the IOs of total scsi host.
> 
> So during SCSI EH, all IOs are blocked even if some disks are normal. 
> That's the place product line sometimes complain about
> 
> as it blocks IO bussiness of some normal disks because of just one bad 
> disk during SCSI EH.
> 
> Is it possible to split the SCSI EH into two parts, the process of 
> recovering the disk and the process of recovering scsi host, at the 
> beginning
> 
If it were so easy.
The biggest problem we're facing in SCSI EH is that basically _all_ 
instances I've seen where EH got engaged were due to a command timeout.

Which means that we've sent a command to the HBA, and never heard from 
it again. Now, it were easy if it would just be the command which has 
vanished, but the problem is that we don't know what happened.
It might be the command being ln transit, the drive might be 
unresponsive, or the HBA has gone off the rails altogether.
So until we've established where the command got lost, we have to assume 
the worst and _have_ to treat the HBA as unreliable.
So initially we shouldn't isolate the device, and hope the failure is 
restricted to the device.
Instead we have to stop I/O to the HBA, establish communication 
(typically by sending a TMF), and only restart operations once we get a 
response back from the HBA.

This is especially true for old SCSI parallel HBA, where quite some 
state is being kept in the HBA structure itself. So if we were to send 
another command we would loas the state of the failed command, and 
wouldn't be able to figure out the root cause on why the command had failed.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 0/7] scsi: EH rework main part
  2022-05-05 16:19   ` Hannes Reinecke
@ 2022-05-06  3:24     ` chenxiang (M)
  0 siblings, 0 replies; 31+ messages in thread
From: chenxiang (M) @ 2022-05-06  3:24 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi

Hi Hannes,


Thanks your detailed comments.

在 2022/5/6 0:19, Hannes Reinecke 写道:
> On 5/4/22 19:27, chenxiang (M) wrote:
>> Hi Hannes and other guys,
>>
>> For SCSI EH, i have a question (sorry, it is not related to this 
>> patchset): for current flow of SCSI EH, if IOs of one disk is failed
>>
>> (if there are many disks under the same scsi host), it will block all 
>> the IOs of total scsi host.
>>
>> So during SCSI EH, all IOs are blocked even if some disks are normal. 
>> That's the place product line sometimes complain about
>>
>> as it blocks IO bussiness of some normal disks because of just one 
>> bad disk during SCSI EH.
>>
>> Is it possible to split the SCSI EH into two parts, the process of 
>> recovering the disk and the process of recovering scsi host, at the 
>> beginning
>>
> If it were so easy.
> The biggest problem we're facing in SCSI EH is that basically _all_ 
> instances I've seen where EH got engaged were due to a command timeout.

Right, currently it is always a command timeout which makes EH got 
engaged. The worse situation is that some IOs are failed with response 
while other IOs
are timeout. Then when the first IO with response complete, it tries to 
enter EH (just mark host SHOST_RECOVERY), then it begins to block IOs. 
Normally maybe
after almost 30s, all those IOs are completed (timeout or failed),then 
it enters EH. So the blocking time of this situation is waiting for EH 
(max 30s) + EH (serval seconds ~ 10+seconds).

>
> Which means that we've sent a command to the HBA, and never heard from 
> it again. Now, it were easy if it would just be the command which has 
> vanished, but the problem is that we don't know what happened.
> It might be the command being ln transit, the drive might be 
> unresponsive, or the HBA has gone off the rails altogether.
> So until we've established where the command got lost, we have to 
> assume the worst and _have_ to treat the HBA as unreliable.
> So initially we shouldn't isolate the device, and hope the failure is 
> restricted to the device.
> Instead we have to stop I/O to the HBA, establish communication 
> (typically by sending a TMF), and only restart operations once we get 
> a response back from the HBA.

Ok, but what we see is that hard disk is more easily broken than HBA, 
and usually error handling is due to a bad disk though the other disks 
are normal.
Current SCSI EH is based on scsi host (there is a EH thread for every 
scsi host), I think if SCSI EH is based on scsi device (there is a EH 
thread for every scsi device),
when one IO of one disk is failed or timeout, we just mark the disk as 
RECOVERY and trigger EH of the disk. Only when recovery operation of the 
device also is failed, then
trigger EH of scsi host.  Maybe it can alleviate the issue.
Even if there is something wrong with HBA, once IO of a disk is fialed 
or timeout, it will also stop IOs of the disk immediately and 
separately, and i think maybe it doesn't make much difference.
(In current SCSI EH, i think it also the situation that many IOs are 
still sent to broken HBA, if previous IOs are all timeout).


>
> This is especially true for old SCSI parallel HBA, where quite some 
> state is being kept in the HBA structure itself. So if we were to send 
> another command we would loas the state of the failed command, and 
> wouldn't be able to figure out the root cause on why the command had 
> failed.
>
> Cheers,
>
> Hannes


^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler()
  2022-05-02 21:59 ` [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
@ 2022-05-06 10:18   ` Steffen Maier
  0 siblings, 0 replies; 31+ messages in thread
From: Steffen Maier @ 2022-05-06 10:18 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen, Benjamin Block
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke,
	James Smart

On 5/2/22 23:59, Hannes Reinecke wrote:
> The target reset function should only depend on the scsi target,
> not the scsi command.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> Reviewed-by: James Smart <jsmart2021@gmail.com>
> ---
>   Documentation/scsi/scsi_eh.rst              | 10 ++++
>   Documentation/scsi/scsi_mid_low_api.rst     | 18 +++++++

>   drivers/s390/scsi/zfcp_scsi.c               |  7 ++-

>   drivers/scsi/scsi_debug.c                   | 21 +++-----
>   drivers/scsi/scsi_error.c                   |  5 +-

>   include/scsi/scsi_host.h                    |  2 +-
>   34 files changed, 216 insertions(+), 190 deletions(-)

> diff --git a/drivers/s390/scsi/zfcp_scsi.c b/drivers/s390/scsi/zfcp_scsi.c
> index 873ccc60e4d6..10bbe56189b3 100644
> --- a/drivers/s390/scsi/zfcp_scsi.c
> +++ b/drivers/s390/scsi/zfcp_scsi.c
> @@ -340,9 +340,12 @@ static int zfcp_scsi_eh_device_reset_handler(struct scsi_cmnd *scpnt)
>   	return zfcp_scsi_task_mgmt_function(sdev, FCP_TMF_LUN_RESET);
>   }
> 
> -static int zfcp_scsi_eh_target_reset_handler(struct scsi_cmnd *scpnt)

> +/*
> + * Note: We need to select a LUN as the storage array doesn't
> + * necessarily supports LUN 0 and might refuse the target reset.
> + */

That's not the reason and this patch does not change anything regarding LUN 
handling within target reset handler, so I wonder if we should just drop this 
new comment.

The reason was given in the description of:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/s390/scsi?id=674595d8519fdf4f78e1a4cceb2130ffa46bcdeb
"zfcp_scsi_eh_target_reset_handler() is special: The FCP channel requires a
valid LUN handle so we try to find ourselves a stand-in scsi_device"

I think that's sufficient. If you think we also need a copy in the code, you 
can copy&paste the description.

> +static int zfcp_scsi_eh_target_reset_handler(struct scsi_target *starget)
>   {
> -	struct scsi_target *starget = scsi_target(scpnt->device);
>   	struct fc_rport *rport = starget_to_rport(starget);
>   	struct Scsi_Host *shost = rport_to_shost(rport);
>   	struct scsi_device *sdev = NULL, *tmp_sdev;

the other change to zfcp looks good


-- 
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z and LinuxONE

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschaeftsfuehrung: David Faller
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
  2022-05-03 21:12   ` Lee Duncan
@ 2022-05-06 11:20   ` Steffen Maier
  2022-05-06 15:29   ` Sathya Prakash Veerichetty
  2 siblings, 0 replies; 31+ messages in thread
From: Steffen Maier @ 2022-05-06 11:20 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke

On 5/2/22 23:59, Hannes Reinecke wrote:
> The bus reset should not depend on any command, but rather only
> use the SCSI Host and the channel/bus number as argument.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>   Documentation/scsi/scsi_eh.rst                |  2 +-
>   Documentation/scsi/scsi_mid_low_api.rst       |  5 ++-

>   include/scsi/scsi_host.h                      |  2 +-
>   36 files changed, 150 insertions(+), 163 deletions(-)
> 
> diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
> index 12113cca5ad9..5e2d04e64005 100644
> --- a/Documentation/scsi/scsi_eh.rst
> +++ b/Documentation/scsi/scsi_eh.rst
> @@ -214,7 +214,7 @@ considered to fail always.
> 
>       int (* eh_abort_handler)(struct scsi_cmnd *);
>       int (* eh_device_reset_handler)(struct scsi_cmnd *);
> -    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);

IIRC, checkpatch prefers using variable names with prototypes. I also like it 
because it would explain the semantics of e.g. the "int". Is it possible to do 
so in function pointer definitions? [method seemed to work for me with gcc 11.3.0]:

+    int (* eh_bus_reset_handler)(struct Scsi_Host *host, int channel);

>       int (* eh_host_reset_handler)(struct Scsi_Host *);
> 
>   Higher-severity actions are taken only when lower-severity actions
> diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
> index 784587ea7eee..1b1c37445580 100644
> --- a/Documentation/scsi/scsi_mid_low_api.rst
> +++ b/Documentation/scsi/scsi_mid_low_api.rst
> @@ -741,7 +741,8 @@ Details::
> 
>       /**
>       *      eh_bus_reset_handler - issue SCSI bus reset
> -    *      @scp: SCSI bus that contains this device should be reset
> +    *      @host: SCSI Host that contains the channel which should be reset
> +    *      @channel: channel to be reset
>       *
>       *      Returns SUCCESS if command aborted else FAILED
>       *
> @@ -754,7 +755,7 @@ Details::
>       *
>       *      Optionally defined in: LLD
>       **/
> -	int eh_bus_reset_handler(struct scsi_cmnd * scp)
> +	int eh_bus_reset_handler(struct Scsi_Host * host, int channel)

exactly like that

> 
> 
>       /**

> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 3b8d9e65ea57..73c9971e7334 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -140,7 +140,7 @@ struct scsi_host_template {
>   	int (* eh_abort_handler)(struct scsi_cmnd *);
>   	int (* eh_device_reset_handler)(struct scsi_cmnd *);
>   	int (* eh_target_reset_handler)(struct scsi_cmnd *);
> -	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);

dito

>   	int (* eh_host_reset_handler)(struct Scsi_Host *);
> 
>   	/*


-- 
Mit freundlichen Gruessen / Kind regards
Steffen Maier

Linux on IBM Z and LinuxONE

https://www.ibm.com/privacy/us/en/
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Gregor Pillen
Geschaeftsfuehrung: David Faller
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
  2022-05-03 21:12   ` Lee Duncan
  2022-05-06 11:20   ` Steffen Maier
@ 2022-05-06 15:29   ` Sathya Prakash Veerichetty
  2 siblings, 0 replies; 31+ messages in thread
From: Sathya Prakash Veerichetty @ 2022-05-06 15:29 UTC (permalink / raw)
  To: Hannes Reinecke
  Cc: Martin K. Petersen, Christoph Hellwig, James Bottomley,
	linux-scsi, Hannes Reinecke

[-- Attachment #1: Type: text/plain, Size: 46184 bytes --]

On Mon, May 2, 2022 at 4:01 PM Hannes Reinecke <hare@suse.de> wrote:
>
> The bus reset should not depend on any command, but rather only
> use the SCSI Host and the channel/bus number as argument.
>
> Signed-off-by: Hannes Reinecke <hare@suse.com>
> ---
>  Documentation/scsi/scsi_eh.rst                |  2 +-
>  Documentation/scsi/scsi_mid_low_api.rst       |  5 ++-
>  drivers/message/fusion/mptfc.c                | 13 +++----
>  drivers/message/fusion/mptscsih.c             | 21 ++++-------
>  drivers/message/fusion/mptscsih.h             |  2 +-
>  drivers/scsi/a100u2w.c                        |  4 +-
>  drivers/scsi/aacraid/linit.c                  | 11 +++---
>  drivers/scsi/aha152x.c                        |  4 +-
>  drivers/scsi/aha1542.c                        |  4 +-
>  drivers/scsi/aic7xxx/aic79xx_osm.c            | 10 ++---
>  drivers/scsi/aic7xxx/aic7xxx_osm.c            |  6 +--
>  drivers/scsi/arcmsr/arcmsr_hba.c              |  6 +--
>  drivers/scsi/arm/fas216.c                     |  9 +++--
>  drivers/scsi/arm/fas216.h                     |  5 ++-
>  drivers/scsi/dc395x.c                         | 25 ++++++-------
>  drivers/scsi/dpt_i2o.c                        |  9 +++--
>  drivers/scsi/dpti.h                           |  2 +-
>  drivers/scsi/esas2r/esas2r.h                  |  2 +-
>  drivers/scsi/esas2r/esas2r_main.c             |  4 +-
>  drivers/scsi/esp_scsi.c                       |  4 +-
>  drivers/scsi/initio.c                         | 11 +++---
>  drivers/scsi/mpi3mr/mpi3mr_os.c               | 37 +++++++++++--------
>  drivers/scsi/ncr53c8xx.c                      |  4 +-
>  drivers/scsi/pcmcia/nsp_cs.c                  |  6 +--
>  drivers/scsi/pcmcia/nsp_cs.h                  |  2 +-
>  drivers/scsi/pmcraid.c                        |  7 ++--
>  drivers/scsi/qla1280.c                        | 12 +++---
>  drivers/scsi/qla2xxx/qla_os.c                 | 17 +++------
>  drivers/scsi/scsi_debug.c                     | 31 ++++++----------
>  drivers/scsi/scsi_error.c                     |  2 +-
>  drivers/scsi/sym53c8xx_2/sym_glue.c           |  7 ++--
>  drivers/scsi/vmw_pvscsi.c                     |  5 +--
>  drivers/scsi/wd719x.c                         | 11 +++---
>  .../staging/unisys/visorhba/visorhba_main.c   |  7 ++--
>  drivers/usb/storage/scsiglue.c                |  4 +-
>  include/scsi/scsi_host.h                      |  2 +-
>  36 files changed, 150 insertions(+), 163 deletions(-)
>
> diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
> index 12113cca5ad9..5e2d04e64005 100644
> --- a/Documentation/scsi/scsi_eh.rst
> +++ b/Documentation/scsi/scsi_eh.rst
> @@ -214,7 +214,7 @@ considered to fail always.
>
>      int (* eh_abort_handler)(struct scsi_cmnd *);
>      int (* eh_device_reset_handler)(struct scsi_cmnd *);
> -    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
>      int (* eh_host_reset_handler)(struct Scsi_Host *);
>
>  Higher-severity actions are taken only when lower-severity actions
> diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
> index 784587ea7eee..1b1c37445580 100644
> --- a/Documentation/scsi/scsi_mid_low_api.rst
> +++ b/Documentation/scsi/scsi_mid_low_api.rst
> @@ -741,7 +741,8 @@ Details::
>
>      /**
>      *      eh_bus_reset_handler - issue SCSI bus reset
> -    *      @scp: SCSI bus that contains this device should be reset
> +    *      @host: SCSI Host that contains the channel which should be reset
> +    *      @channel: channel to be reset
>      *
>      *      Returns SUCCESS if command aborted else FAILED
>      *
> @@ -754,7 +755,7 @@ Details::
>      *
>      *      Optionally defined in: LLD
>      **/
> -       int eh_bus_reset_handler(struct scsi_cmnd * scp)
> +       int eh_bus_reset_handler(struct Scsi_Host * host, int channel)
>
>
>      /**
> diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
> index 4a621380a4eb..bc62f0cc0cbd 100644
> --- a/drivers/message/fusion/mptfc.c
> +++ b/drivers/message/fusion/mptfc.c
> @@ -103,7 +103,7 @@ static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
>  static void mptfc_remove(struct pci_dev *pdev);
>  static int mptfc_abort(struct scsi_cmnd *SCpnt);
>  static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
> -static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
> +static int mptfc_bus_reset(struct Scsi_Host *shost, int channel);
>
>  static struct scsi_host_template mptfc_driver_template = {
>         .module                         = THIS_MODULE,
> @@ -259,11 +259,9 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt)
>  }
>
>  static int
> -mptfc_bus_reset(struct scsi_cmnd *SCpnt)
> +mptfc_bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       struct Scsi_Host *shost = SCpnt->device->host;
>         MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost);
> -       int channel = SCpnt->device->channel;
>         struct mptfc_rport_info *ri;
>         int rtn;
>
> @@ -280,10 +278,9 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt)
>         }
>         if (rtn == 0) {
>                 dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
> -                       "%s.%d: %d:%llu, executing recovery.\n", __func__,
> -                       hd->ioc->name, shost->host_no,
> -                       SCpnt->device->id, SCpnt->device->lun));
> -               rtn = mptscsih_bus_reset(SCpnt);
> +                       "%s.%d: 0:0, executing recovery.\n", __func__,
> +                       hd->ioc->name, shost->host_no));
> +               rtn = mptscsih_bus_reset(shost, channel);
>         }
>         return rtn;
>  }
> diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
> index 3df07e024026..afdbc8138346 100644
> --- a/drivers/message/fusion/mptscsih.c
> +++ b/drivers/message/fusion/mptscsih.c
> @@ -1914,39 +1914,34 @@ mptscsih_target_reset(struct scsi_cmnd * SCpnt)
>   *     Returns SUCCESS or FAILED.
>   **/
>  int
> -mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
> +mptscsih_bus_reset(struct Scsi_Host * shost, int channel)
>  {
>         MPT_SCSI_HOST   *hd;
>         int              retval;
> -       VirtDevice       *vdevice;
>         MPT_ADAPTER     *ioc;
>
>         /* If we can't locate our host adapter structure, return FAILED status.
>          */
> -       if ((hd = shost_priv(SCpnt->device->host)) == NULL){
> +       if ((hd = shost_priv(shost)) == NULL){
>                 printk(KERN_ERR MYNAM ": bus reset: "
> -                  "Can't locate host! (sc=%p)\n", SCpnt);
> +                  "Can't locate host!\n");
>                 return FAILED;
>         }
>
>         ioc = hd->ioc;
> -       printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n",
> -              ioc->name, SCpnt);
> -       scsi_print_command(SCpnt);
> +       printk(MYIOC_s_INFO_FMT "attempting bus reset!\n",
> +              ioc->name);
>
>         if (ioc->timeouts < -1)
>                 ioc->timeouts++;
>
> -       vdevice = SCpnt->device->hostdata;
> -       if (!vdevice || !vdevice->vtarget)
> -               return SUCCESS;
>         retval = mptscsih_IssueTaskMgmt(hd,
>                                         MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
> -                                       vdevice->vtarget->channel, 0, 0, 0,
> +                                       channel, 0, 0, 0,
>                                         mptscsih_get_tm_timeout(ioc));
>
> -       printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
> -           ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
> +       printk(MYIOC_s_INFO_FMT "bus reset: %s\n",
> +           ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
>
>         if (retval == 0)
>                 return SUCCESS;
> diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
> index 0faefe9c7541..9f3756bd25eb 100644
> --- a/drivers/message/fusion/mptscsih.h
> +++ b/drivers/message/fusion/mptscsih.h
> @@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device);
>  extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
>  extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
>  extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
> -extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
> +extern int mptscsih_bus_reset(struct Scsi_Host *, int);
>  extern int mptscsih_host_reset(struct Scsi_Host *sh);
>  extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
>  extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
> diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
> index bf552c818958..dab79824e2f6 100644
> --- a/drivers/scsi/a100u2w.c
> +++ b/drivers/scsi/a100u2w.c
> @@ -934,10 +934,10 @@ static int inia100_abort(struct scsi_cmnd * cmd)
>   Output         : None.
>   Return         : pSRB  -       Pointer to SCSI request block.
>  *****************************************************************************/
> -static int inia100_bus_reset(struct scsi_cmnd * cmd)
> +static int inia100_bus_reset(struct Scsi_Host * shost, int channel)
>  {                              /* I need Host Control Block Information */
>         struct orc_host *host;
> -       host = (struct orc_host *) cmd->device->host->hostdata;
> +       host = (struct orc_host *) shost->hostdata;
>         return orc_reset_scsi_bus(host);
>  }
>
> diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
> index 19a012c9a3c9..de7e0985ac2b 100644
> --- a/drivers/scsi/aacraid/linit.c
> +++ b/drivers/scsi/aacraid/linit.c
> @@ -1025,20 +1025,18 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
>
>  /*
>   *     aac_eh_bus_reset        - Bus reset command handling
> - *     @scsi_cmd:      SCSI command block causing the reset
> + *     @host:  SCSI host causing the reset
> + *     @channel:       Number of the bus to be reset
>   *
>   */
> -static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
> +static int aac_eh_bus_reset(struct Scsi_Host *host, int channel)
>  {
> -       struct scsi_device * dev = cmd->device;
> -       struct Scsi_Host * host = dev->host;
>         struct aac_dev * aac = (struct aac_dev *)host->hostdata;
>         int count;
>         u32 cmd_bus;
>         int status = 0;
>
> -
> -       cmd_bus = aac_logical_to_phys(scmd_channel(cmd));
> +       cmd_bus = aac_logical_to_phys(channel);
>         /* Mark the assoc. FIB to not complete, eh handler does this */
>         for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
>                 struct fib *fib = &aac->fibs[count];
> @@ -1046,6 +1044,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
>                 if (fib->hw_fib_va->header.XferState &&
>                     (fib->flags & FIB_CONTEXT_FLAG) &&
>                     (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) {
> +                       struct scsi_cmnd *cmd;
>                         struct aac_hba_map_info *info;
>                         u32 bus, cid;
>
> diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
> index 7e58f25c599b..1312dc5ef6d2 100644
> --- a/drivers/scsi/aha152x.c
> +++ b/drivers/scsi/aha152x.c
> @@ -1192,9 +1192,9 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
>   * Reset the bus
>   *
>   */
> -static int aha152x_bus_reset(struct scsi_cmnd *SCpnt)
> +static int aha152x_bus_reset(struct Scsi_Host *shpnt, int channel)
>  {
> -       return aha152x_bus_reset_host(SCpnt->device->host);
> +       return aha152x_bus_reset_host(shpnt);
>  }
>
>  /*
> diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
> index 69063fe4aab8..797a49f927dd 100644
> --- a/drivers/scsi/aha1542.c
> +++ b/drivers/scsi/aha1542.c
> @@ -980,9 +980,9 @@ static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
>         return SUCCESS;
>  }
>
> -static int aha1542_bus_reset(struct scsi_cmnd *cmd)
> +static int aha1542_bus_reset(struct Scsi_Host *sh, int channel)
>  {
> -       return aha1542_reset(cmd->device->host, SCRST);
> +       return aha1542_reset(sh, SCRST);
>  }
>
>  static int aha1542_host_reset(struct Scsi_Host *sh)
> diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
> index c46e8152af28..00786c37f39f 100644
> --- a/drivers/scsi/aic7xxx/aic79xx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
> @@ -866,21 +866,21 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
>   * Reset the SCSI bus.
>   */
>  static int
> -ahd_linux_bus_reset(struct scsi_cmnd *cmd)
> +ahd_linux_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         struct ahd_softc *ahd;
>         int    found;
>         unsigned long flags;
>
> -       ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
> +       ahd = *(struct ahd_softc **)shost->hostdata;
>  #ifdef AHD_DEBUG
>         if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
> -               printk("%s: Bus reset called for cmd %p\n",
> -                      ahd_name(ahd), cmd);
> +               printk("%s: Bus reset called for channel %d\n",
> +                      ahd_name(ahd), channel);
>  #endif
>         ahd_lock(ahd, &flags);
>
> -       found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
> +       found = ahd_reset_channel(ahd, channel + 'A',
>                                   /*initiate reset*/TRUE);
>         ahd_unlock(ahd, &flags);
>
> diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> index 0ad429b7ebcf..f6c547cef26c 100644
> --- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
> +++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
> @@ -753,16 +753,16 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
>   * Reset the SCSI bus.
>   */
>  static int
> -ahc_linux_bus_reset(struct scsi_cmnd *cmd)
> +ahc_linux_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         struct ahc_softc *ahc;
>         int    found;
>         unsigned long flags;
>
> -       ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
> +       ahc = *(struct ahc_softc **)shost->hostdata;
>
>         ahc_lock(ahc, &flags);
> -       found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
> +       found = ahc_reset_channel(ahc, channel + 'A',
>                                   /*initiate reset*/TRUE);
>         ahc_unlock(ahc, &flags);
>
> diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
> index d3fb8a9c1c39..baa03ead75d9 100644
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c
> @@ -111,7 +111,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
>                                         struct scsi_cmnd *cmd);
>  static int arcmsr_iop_confirm(struct AdapterControlBlock *acb);
>  static int arcmsr_abort(struct scsi_cmnd *);
> -static int arcmsr_bus_reset(struct scsi_cmnd *);
> +static int arcmsr_bus_reset(struct Scsi_Host *, int);
>  static int arcmsr_bios_param(struct scsi_device *sdev,
>                 struct block_device *bdev, sector_t capacity, int *info);
>  static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
> @@ -4573,12 +4573,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
>         return rtnval;
>  }
>
> -static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
> +static int arcmsr_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         struct AdapterControlBlock *acb;
>         int retry_count = 0;
>         int rtn = FAILED;
> -       acb = (struct AdapterControlBlock *) cmd->device->host->hostdata;
> +       acb = (struct AdapterControlBlock *) shost->hostdata;
>         if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
>                 return SUCCESS;
>         pr_notice("arcmsr: executing bus reset eh.....num_resets = %d,"
> diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
> index 38eec967155d..c27b49c42c4f 100644
> --- a/drivers/scsi/arm/fas216.c
> +++ b/drivers/scsi/arm/fas216.c
> @@ -2550,15 +2550,16 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
>
>  /**
>   * fas216_eh_bus_reset - Reset the bus associated with the command
> - * @SCpnt: command specifing bus to reset
> + * @shost: host to be reset
> + * @channel: bus number to reset
>   *
> - * Reset the bus associated with the command.
> + * Reset the bus.
>   * Returns: FAILED if unable to reset.
>   * Notes: Further commands are blocked.
>   */
> -int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
> +int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
> +       FAS216_Info *info = (FAS216_Info *)shost->hostdata;
>         unsigned long flags;
>         struct scsi_device *SDpnt;
>
> diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
> index f17583f143b3..27a4b564f054 100644
> --- a/drivers/scsi/arm/fas216.h
> +++ b/drivers/scsi/arm/fas216.h
> @@ -389,10 +389,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
>
>  /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
>   * Purpose : Reset the complete bus associated with this command
> - * Params  : SCpnt - command specifing bus to reset
> + * Params  : shost - host to be reset
> + *           channel - bus to be reset
>   * Returns : FAILED if unable to reset
>   */
> -extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
> +extern int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel);
>
>  /* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
>   * Purpose : Reset the host associated with this command
> diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
> index 67a89715c863..7374eda8cffa 100644
> --- a/drivers/scsi/dc395x.c
> +++ b/drivers/scsi/dc395x.c
> @@ -1144,19 +1144,18 @@ static void reset_dev_param(struct AdapterCtlBlk *acb)
>   * @cmd - some command for this host (for fetching hooks)
>   * Returns: SUCCESS (0x2002) on success, else FAILED (0x2003).
>   */
> -static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
> +static int __dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         struct AdapterCtlBlk *acb =
> -               (struct AdapterCtlBlk *)cmd->device->host->hostdata;
> +               (struct AdapterCtlBlk *)shost->hostdata;
>         dprintkl(KERN_INFO,
> -               "eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
> -               cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
> +                "eh_bus_reset: bus=<%02i>\n", channel);
>
>         if (timer_pending(&acb->waiting_timer))
>                 del_timer(&acb->waiting_timer);
>
>         /*
> -        * disable interrupt
> +        * disable interrupt
>          */
>         DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00);
>         DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00);
> @@ -1172,7 +1171,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>             HZ * acb->eeprom.delay_time;
>
>         /*
> -        * re-enable interrupt
> +        * re-enable interrupt
>          */
>         /* Clear SCSI FIFO          */
>         DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
> @@ -1182,7 +1181,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>         set_basic_config(acb);
>
>         reset_dev_param(acb);
> -       doing_srb_done(acb, DID_RESET, cmd, 0);
> +       doing_srb_done(acb, DID_RESET, NULL, 0);
>         acb->active_dcb = NULL;
>         acb->acb_flag = 0;      /* RESET_DETECT, RESET_DONE ,RESET_DEV */
>         waiting_process_next(acb);
> @@ -1190,13 +1189,13 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>         return SUCCESS;
>  }
>
> -static int dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
> +static int dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         int rc;
>
> -       spin_lock_irq(cmd->device->host->host_lock);
> -       rc = __dc395x_eh_bus_reset(cmd);
> -       spin_unlock_irq(cmd->device->host->host_lock);
> +       spin_lock_irq(shost->host_lock);
> +       rc = __dc395x_eh_bus_reset(shost, channel);
> +       spin_unlock_irq(shost->host_lock);
>
>         return rc;
>  }
> @@ -3338,7 +3337,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
>
>  /* abort all cmds in our queues */
>  static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
> -               struct scsi_cmnd *cmd, u8 force)
> +                          struct scsi_cmnd *cmd, u8 force)
>  {
>         struct DeviceCtlBlk *dcb;
>         dprintkl(KERN_INFO, "doing_srb_done: pids ");
> @@ -3386,7 +3385,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
>                         set_status_byte(p, SAM_STAT_GOOD);
>                         pci_unmap_srb_sense(acb, srb);
>                         pci_unmap_srb(acb, srb);
> -                       if (force) {
> +                       if (force && cmd) {
>                                 /* For new EH, we normally don't need to give commands back,
>                                  * as they all complete or all time out */
>                                 scsi_done(cmd);
> diff --git a/drivers/scsi/dpt_i2o.c b/drivers/scsi/dpt_i2o.c
> index 6e3ad0e5b533..b1ab772aff0e 100644
> --- a/drivers/scsi/dpt_i2o.c
> +++ b/drivers/scsi/dpt_i2o.c
> @@ -718,17 +718,18 @@ static int adpt_device_reset(struct scsi_cmnd* cmd)
>
>  #define I2O_HBA_BUS_RESET 0x87
>  // This version of bus reset is called by the eh_error handler
> -static int adpt_bus_reset(struct scsi_cmnd* cmd)
> +static int adpt_bus_reset(struct Scsi_Host *shost, int channel)
>  {
>         adpt_hba* pHba;
>         u32 msg[4];
>         u32 rcode;
>
> -       pHba = (adpt_hba*)cmd->device->host->hostdata[0];
> +       pHba = (adpt_hba*)shost->hostdata[0];
>         memset(msg, 0, sizeof(msg));
> -       printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",pHba->name, cmd->device->channel,pHba->channel[cmd->device->channel].tid );
> +       printk(KERN_WARNING"%s: Bus reset: SCSI Bus %d: tid: %d\n",
> +              pHba->name, channel, pHba->channel[channel].tid );
>         msg[0] = FOUR_WORD_MSG_SIZE|SGL_OFFSET_0;
> -       msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[cmd->device->channel].tid);
> +       msg[1] = (I2O_HBA_BUS_RESET<<24|HOST_TID<<12|pHba->channel[channel].tid);
>         msg[2] = 0;
>         msg[3] = 0;
>         if (pHba->host)
> diff --git a/drivers/scsi/dpti.h b/drivers/scsi/dpti.h
> index b77a3625fa6f..48878e69ab2c 100644
> --- a/drivers/scsi/dpti.h
> +++ b/drivers/scsi/dpti.h
> @@ -35,7 +35,7 @@ static const char *adpt_info(struct Scsi_Host *pSHost);
>  static int adpt_bios_param(struct scsi_device * sdev, struct block_device *dev,
>                 sector_t, int geom[]);
>
> -static int adpt_bus_reset(struct scsi_cmnd* cmd);
> +static int adpt_bus_reset(struct Scsi_Host* shost, int channel);
>  static int adpt_device_reset(struct scsi_cmnd* cmd);
>
>
> diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
> index a104d1a3a9da..5c1eeaffc090 100644
> --- a/drivers/scsi/esas2r/esas2r.h
> +++ b/drivers/scsi/esas2r/esas2r.h
> @@ -977,7 +977,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
>  int esas2r_eh_abort(struct scsi_cmnd *cmd);
>  int esas2r_device_reset(struct scsi_cmnd *cmd);
>  int esas2r_host_reset(struct Scsi_Host *shost);
> -int esas2r_bus_reset(struct scsi_cmnd *cmd);
> +int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
>  int esas2r_target_reset(struct scsi_cmnd *cmd);
>
>  /* Internal functions */
> diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
> index 52494c8bb656..315b8a61d0d7 100644
> --- a/drivers/scsi/esas2r/esas2r_main.c
> +++ b/drivers/scsi/esas2r/esas2r_main.c
> @@ -1094,10 +1094,8 @@ int esas2r_host_reset(struct Scsi_Host *shost)
>         return esas2r_host_bus_reset(shost, true);
>  }
>
> -int esas2r_bus_reset(struct scsi_cmnd *cmd)
> +int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       struct Scsi_Host *shost = cmd->device->host;
> -
>         esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
>
>         return esas2r_host_bus_reset(shost, false);
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index b41eac8b5e0f..2fa53100df24 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2604,9 +2604,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
>         return FAILED;
>  }
>
> -static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
> +static int esp_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
>  {
> -       struct esp *esp = shost_priv(cmd->device->host);
> +       struct esp *esp = shost_priv(shost);
>         struct completion eh_reset;
>         unsigned long flags;
>
> diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
> index f585d6e5fab9..adddedfdbcc7 100644
> --- a/drivers/scsi/initio.c
> +++ b/drivers/scsi/initio.c
> @@ -2625,20 +2625,21 @@ static DEF_SCSI_QCMD(i91u_queuecommand)
>
>  /**
>   *     i91u_bus_reset          -       reset the SCSI bus
> - *     @cmnd: Command block we want to trigger the reset for
> + *     @shost: SCSI host to be reset
> + *     @channel: Bus number to be reset
>   *
>   *     Initiate a SCSI bus reset sequence
>   */
>
> -static int i91u_bus_reset(struct scsi_cmnd * cmnd)
> +static int i91u_bus_reset(struct Scsi_Host * shost, int channel)
>  {
>         struct initio_host *host;
>
> -       host = (struct initio_host *) cmnd->device->host->hostdata;
> +       host = (struct initio_host *) shost->hostdata;
>
> -       spin_lock_irq(cmnd->device->host->host_lock);
> +       spin_lock_irq(shost->host_lock);
>         initio_reset_scsi(host, 0);
> -       spin_unlock_irq(cmnd->device->host->host_lock);
> +       spin_unlock_irq(shost->host_lock);
>
>         return SUCCESS;
>  }
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index bd42d3a56590..88fbd01c05d0 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -3362,39 +3362,46 @@ static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
>
>  /**
>   * mpi3mr_eh_bus_reset - Bus reset error handling callback
> - * @scmd: SCSI command reference
> + * @shost: SCSI host reference
> + * @channel: bus number
>   *
>   * Checks whether pending I/Os are present for the RAID volume;
>   * if not there's no need to reset the adapter.
>   *
>   * Return: SUCCESS of successful reset else FAILED
>   */
> -static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd)
> +static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
> +       struct mpi3mr_ioc *mrioc = shost_priv(shost);
> +       struct mpi3mr_tgt_dev *tgtdev;
>         struct mpi3mr_stgt_priv_data *stgt_priv_data;
> -       struct mpi3mr_sdev_priv_data *sdev_priv_data;
> -       u8 dev_type = MPI3_DEVICE_DEVFORM_VD;
>         int retval = FAILED;
>
> -       sdev_priv_data = scmd->device->hostdata;
> -       if (sdev_priv_data && sdev_priv_data->tgt_priv_data) {
> -               stgt_priv_data = sdev_priv_data->tgt_priv_data;
> -               dev_type = stgt_priv_data->dev_type;
> +       spin_lock(&mrioc->tgtdev_lock);
> +       list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
> +               if (!tgtdev->starget || !tgtdev->starget->hostdata)
> +                       continue;
> +               stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
> +                       tgtdev->starget->hostdata;
> +               if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_VD) {
> +                       retval = SUCCESS;
> +                       break;
> +               }
>         }
> +       spin_unlock(&mrioc->tgtdev_lock);
>
>>Hannes, This is changing the purpose of the function.  As per our original driver code, the driver was checking pending I/O (with a timeout of three minutes) only if I/Os that timed out were issued for RAID volumes, if an I/O which got timedout was issued to a normal bare drive then the controller is reset without checking pending I/O.  That is changed here to wait even if there is a RAID volume in the channel. So even if the problematic drive is a PD, the driver will wait for three minutes.  The driver doesn't expose PDs and VDs in different channels.  I need more discussions with our controller architecture team prior to ACKing this change.
> -       if (dev_type == MPI3_DEVICE_DEVFORM_VD) {
> +       if (retval == SUCCESS) {
>                 mpi3mr_wait_for_host_io(mrioc,
>                         MPI3MR_RAID_ERRREC_RESET_TIMEOUT);
> -               if (!mpi3mr_get_fw_pending_ios(mrioc))
> -                       retval = SUCCESS;
> +               if (mpi3mr_get_fw_pending_ios(mrioc))
> +                       retval = FAILED;
>         }
>         if (retval == FAILED)
>                 mpi3mr_print_pending_host_io(mrioc);
>
> -       sdev_printk(KERN_INFO, scmd->device,
> -               "Bus reset is %s for scmd(%p)\n",
> -               ((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
> +       shost_printk(KERN_INFO, shost,
> +               "Bus reset is %s\n",
> +               ((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
>         return retval;
>  }
>
> diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
> index 4458449c960b..2d4470686a4b 100644
> --- a/drivers/scsi/ncr53c8xx.c
> +++ b/drivers/scsi/ncr53c8xx.c
> @@ -7936,9 +7936,9 @@ static void ncr53c8xx_timeout(struct timer_list *t)
>                 ncr_flush_done_cmds(done_list);
>  }
>
> -static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
> +static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel)
>  {
> -       struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
> +       struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
>         int sts;
>         unsigned long flags;
>         struct scsi_cmnd *done_list;
> diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
> index 4aa9737fa711..b1bce76c83b9 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.c
> +++ b/drivers/scsi/pcmcia/nsp_cs.c
> @@ -1488,11 +1488,11 @@ static int nsp_bus_reset(nsp_hw_data *data)
>         return SUCCESS;
>  }
>
> -static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
> +static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel)
>  {
> -       nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
> +       nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
>
> -       nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
> +       nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel);
>
>         return nsp_bus_reset(data);
>  }
> diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
> index f532adb5f166..8636f0053c02 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.h
> +++ b/drivers/scsi/pcmcia/nsp_cs.h
> @@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
>  /* Error handler */
>  /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
>  /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
> -static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
> +static int nsp_eh_bus_reset    (struct Scsi_Host *host, int channel);
>  static int nsp_eh_host_reset   (struct Scsi_Host *host);
>  static int nsp_bus_reset       (nsp_hw_data *data);
>
> diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
> index 79ca737ac75b..14e90807d38c 100644
> --- a/drivers/scsi/pmcraid.c
> +++ b/drivers/scsi/pmcraid.c
> @@ -3023,9 +3023,8 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
>                                     RESET_DEVICE_LUN);
>  }
>
> -static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
> +static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel)
>  {
> -       struct Scsi_Host *host = scmd->device->host;
>         struct pmcraid_instance *pinstance =
>                 (struct pmcraid_instance *)host->hostdata;
>         struct pmcraid_resource_entry *res = NULL;
> @@ -3039,11 +3038,11 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
>          */
>         spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
>         list_for_each_entry(temp, &pinstance->used_res_q, queue) {
> -               if (scmd->device->channel == PMCRAID_VSET_BUS_ID &&
> +               if (channel == PMCRAID_VSET_BUS_ID &&
>                     RES_IS_VSET(temp->cfg_entry)) {
>                         res = temp;
>                         break;
> -               } else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID &&
> +               } else if (channel == PMCRAID_PHYS_BUS_ID &&
>                            RES_IS_GSCSI(temp->cfg_entry)) {
>                         res = temp;
>                         break;
> diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
> index cd4c7126c1c9..f32f00c7a390 100644
> --- a/drivers/scsi/qla1280.c
> +++ b/drivers/scsi/qla1280.c
> @@ -979,13 +979,15 @@ qla1280_eh_device_reset(struct scsi_cmnd *cmd)
>   *     Reset the specified bus.
>   **************************************************************************/
>  static int
> -qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
> +qla1280_eh_bus_reset(struct Scsi_Host *shost, int bus)
>  {
> -       int rc;
> +       int rc = FAILED;
> +       struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
>
> -       spin_lock_irq(cmd->device->host->host_lock);
> -       rc = qla1280_error_action(cmd, BUS_RESET);
> -       spin_unlock_irq(cmd->device->host->host_lock);
> +       spin_lock_irq(shost->host_lock);
> +       if (qla1280_bus_reset(ha, bus) == 0)
> +               rc = qla1280_wait_for_pending_commands(ha, 1, 0);
> +       spin_unlock_irq(shost->host_lock);
>
>         return rc;
>  }
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 5f86e7bd5a0e..11e7dc22b94d 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -1537,7 +1537,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>  *    commands.
>  *
>  * Input:
> -*    cmd = Linux SCSI command packet of the command that cause the
> +*    host = Linux SCSI command packet of the command that cause the
>  *          bus reset.
>  *
>  * Returns:
> @@ -1545,12 +1545,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>  *
>  **************************************************************************/
>  static int
> -qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
> +qla2xxx_eh_bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       scsi_qla_host_t *vha = shost_priv(cmd->device->host);
> +       scsi_qla_host_t *vha = shost_priv(shost);
>         int ret = FAILED;
> -       unsigned int id;
> -       uint64_t lun;
>         struct qla_hw_data *ha = vha->hw;
>
>         if (qla2x00_isp_reg_stat(ha)) {
> @@ -1560,14 +1558,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>                 return FAILED;
>         }
>
> -       id = cmd->device->id;
> -       lun = cmd->device->lun;
> -
>         if (qla2x00_chip_is_down(vha))
>                 return ret;
>
>         ql_log(ql_log_info, vha, 0x8012,
> -           "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
> +           "BUS RESET ISSUED nexus=%ld:%d.\n", vha->host_no, channel);
>
>         if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
>                 ql_log(ql_log_fatal, vha, 0x8013,
> @@ -1591,8 +1586,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
>
>  eh_bus_reset_done:
>         ql_log(ql_log_warn, vha, 0x802b,
> -           "BUS RESET %s nexus=%ld:%d:%llu.\n",
> -           (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
> +           "BUS RESET %s nexus=%ld:%d.\n",
> +           (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, channel);
>
>         return ret;
>  }
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 6292ac7aef7a..f2d3271bc80b 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5324,36 +5324,27 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
>         return SUCCESS;
>  }
>
> -static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
> +static int scsi_debug_bus_reset(struct Scsi_Host * hp, int channel)
>  {
> -       struct sdebug_host_info *sdbg_host;
> +       struct sdebug_host_info *sdbg_host =
> +               *(struct sdebug_host_info **)shost_priv(hp);
>         struct sdebug_dev_info *devip;
> -       struct scsi_device *sdp;
> -       struct Scsi_Host *hp;
>         int k = 0;
>
>         ++num_bus_resets;
> -       if (!(SCpnt && SCpnt->device))
> -               goto lie;
> -       sdp = SCpnt->device;
>         if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
> -               sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
> -       hp = sdp->host;
> -       if (hp) {
> -               sdbg_host = *(struct sdebug_host_info **)shost_priv(hp);
> -               if (sdbg_host) {
> -                       list_for_each_entry(devip,
> -                                           &sdbg_host->dev_info_list,
> -                                           dev_list) {
> -                               set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
> -                               ++k;
> -                       }
> +               shost_printk(KERN_INFO, hp, "%s\n", __func__);
> +       if (sdbg_host) {
> +               list_for_each_entry(devip,
> +                                   &sdbg_host->dev_info_list,
> +                                   dev_list) {
> +                       set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
> +                       ++k;
>                 }
>         }
>         if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
> -               sdev_printk(KERN_INFO, sdp,
> +               shost_printk(KERN_INFO, hp,
>                             "%s: %d device(s) found in host\n", __func__, k);
> -lie:
>         return SUCCESS;
>  }
>
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 747131ca8970..148cab3e61c0 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -871,7 +871,7 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
>         if (!hostt->eh_bus_reset_handler)
>                 return FAILED;
>
> -       rtn = hostt->eh_bus_reset_handler(scmd);
> +       rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
>
>         if (rtn == SUCCESS) {
>                 if (!hostt->skip_settle_delay)
> diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
> index a573baa5bdf2..aef828731995 100644
> --- a/drivers/scsi/sym53c8xx_2/sym_glue.c
> +++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
> @@ -670,14 +670,13 @@ static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
>         return SCSI_SUCCESS;
>  }
>
> -static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
> +static int sym53c8xx_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
>  {
> -       struct Scsi_Host *shost = cmd->device->host;
>         struct sym_data *sym_data = shost_priv(shost);
>         struct pci_dev *pdev = sym_data->pdev;
>         struct sym_hcb *np = sym_data->ncb;
>
> -       scmd_printk(KERN_WARNING, cmd, "BUS RESET operation started\n");
> +       shost_printk(KERN_WARNING, shost, "BUS RESET operation started\n");
>
>         /*
>          * Escalate to host reset if the PCI bus went down
> @@ -689,7 +688,7 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
>         sym_reset_scsi_bus(np, 1);
>         spin_unlock_irq(shost->host_lock);
>
> -       dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n");
> +       shost_printk(KERN_WARNING, shost, "BUS RESET operation complete.\n");
>         return SCSI_SUCCESS;
>  }
>
> diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
> index ddf1837babc0..9c62d446ea9e 100644
> --- a/drivers/scsi/vmw_pvscsi.c
> +++ b/drivers/scsi/vmw_pvscsi.c
> @@ -947,13 +947,12 @@ static int pvscsi_host_reset(struct Scsi_Host *host)
>         return SUCCESS;
>  }
>
> -static int pvscsi_bus_reset(struct scsi_cmnd *cmd)
> +static int pvscsi_bus_reset(struct Scsi_Host *host, int channel)
>  {
> -       struct Scsi_Host *host = cmd->device->host;
>         struct pvscsi_adapter *adapter = shost_priv(host);
>         unsigned long flags;
>
> -       scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n");
> +       shost_printk(KERN_INFO, host, "SCSI Bus reset\n");
>
>         /*
>          * We don't want to queue new requests for this bus after
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index 02b8eb153944..fd297c7517cd 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -484,11 +484,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd)
>         return SUCCESS;
>  }
>
> -static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
> +static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device)
>  {
>         int result;
>         unsigned long flags;
> -       struct wd719x *wd = shost_priv(cmd->device->host);
> +       struct wd719x *wd = shost_priv(shost);
>         struct wd719x_scb *scb, *tmp;
>
>         dev_info(&wd->pdev->dev, "%s reset requested\n",
> @@ -512,12 +512,13 @@ static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
>
>  static int wd719x_dev_reset(struct scsi_cmnd *cmd)
>  {
> -       return wd719x_reset(cmd, WD719X_CMD_RESET, cmd->device->id);
> +       return wd719x_reset(cmd->device->host, WD719X_CMD_RESET,
> +                           cmd->device->id);
>  }
>
> -static int wd719x_bus_reset(struct scsi_cmnd *cmd)
> +static int wd719x_bus_reset(struct Scsi_Host *host, int channel)
>  {
> -       return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
> +       return wd719x_reset(host, WD719X_CMD_BUSRESET, 0);
>  }
>
>  static int wd719x_host_reset(struct Scsi_Host *host)
> diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c
> index 0de0dd09cf9d..28c59218077d 100644
> --- a/drivers/staging/unisys/visorhba/visorhba_main.c
> +++ b/drivers/staging/unisys/visorhba/visorhba_main.c
> @@ -366,14 +366,15 @@ static int visorhba_device_reset_handler(struct scsi_cmnd *scsicmd)
>   *
>   * Return: SUCCESS if inserted, FAILED otherwise
>   */
> -static int visorhba_bus_reset_handler(struct scsi_cmnd *scsicmd)
> +static int visorhba_bus_reset_handler(struct Scsi_Host *scsihost, int channel)
>  {
>         struct scsi_device *scsidev;
>         struct visordisk_info *vdisk;
>         int rtn;
>
> -       scsidev = scsicmd->device;
> -       shost_for_each_device(scsidev, scsidev->host) {
> +       shost_for_each_device(scsidev, scsihost) {
> +               if (scsidev->channel != channel)
> +                       continue;
>                 vdisk = scsidev->hostdata;
>                 if (atomic_read(&vdisk->error_count) < VISORHBA_ERROR_COUNT)
>                         atomic_inc(&vdisk->error_count);
> diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
> index 8931df5a85fd..17dabfba6b2b 100644
> --- a/drivers/usb/storage/scsiglue.c
> +++ b/drivers/usb/storage/scsiglue.c
> @@ -464,9 +464,9 @@ static int device_reset(struct scsi_cmnd *srb)
>  }
>
>  /* Simulate a SCSI bus reset by resetting the device's USB port. */
> -static int bus_reset(struct scsi_cmnd *srb)
> +static int bus_reset(struct Scsi_Host *shost, int channel)
>  {
> -       struct us_data *us = host_to_us(srb->device->host);
> +       struct us_data *us = host_to_us(shost);
>         int result;
>
>         usb_stor_dbg(us, "%s called\n", __func__);
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 3b8d9e65ea57..73c9971e7334 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -140,7 +140,7 @@ struct scsi_host_template {
>         int (* eh_abort_handler)(struct scsi_cmnd *);
>         int (* eh_device_reset_handler)(struct scsi_cmnd *);
>         int (* eh_target_reset_handler)(struct scsi_cmnd *);
> -       int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +       int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
>         int (* eh_host_reset_handler)(struct Scsi_Host *);
>
>         /*
> --
> 2.29.2
>

-- 
This electronic communication and the information and any files transmitted 
with it, or attached to it, are confidential and are intended solely for 
the use of the individual or entity to whom it is addressed and may contain 
information that is confidential, legally privileged, protected by privacy 
laws, or otherwise restricted from disclosure to anyone else. If you are 
not the intended recipient or the person responsible for delivering the 
e-mail to the intended recipient, you are hereby notified that any use, 
copying, distributing, dissemination, forwarding, printing, or copying of 
this e-mail is strictly prohibited. If you received this e-mail in error, 
please return the e-mail to the sender, delete it from your computer, and 
destroy any printed copy of it.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4227 bytes --]

^ permalink raw reply	[flat|nested] 31+ messages in thread

* Re: [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2023-10-02 15:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
@ 2023-10-05 11:54   ` John Garry
  0 siblings, 0 replies; 31+ messages in thread
From: John Garry @ 2023-10-05 11:54 UTC (permalink / raw)
  To: Hannes Reinecke, Martin K. Petersen
  Cc: James Bottomley, linux-scsi, Christoph Hellwig


> diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
> index da95971b4f44..dbbfd754a928 100644
> --- a/Documentation/scsi/scsi_eh.rst
> +++ b/Documentation/scsi/scsi_eh.rst
> @@ -216,7 +216,7 @@ considered to fail always.
>   
>       int (* eh_abort_handler)(struct scsi_cmnd *);
>       int (* eh_device_reset_handler)(struct scsi_cmnd *);
> -    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);

scsi_device.channel and scsi_target.channel are both unsigned int, so 
could this also be unsigned int?

>       int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   Higher-severity actions are taken only when lower-severity actions
> diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
> index 85b1384ba4fd..88bb3b7578ba 100644
> --- a/Documentation/scsi/scsi_mid_low_api.rst
> +++ b/Documentation/scsi/scsi_mid_low_api.rst
> @@ -741,7 +741,8 @@ Details::

...

>   
>   	/* If we can't locate our host adapter structure, return FAILED status.
>   	 */
> -	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
> +	if ((hd = shost_priv(shost)) == NULL){
>   		printk(KERN_ERR MYNAM ": bus reset: "
> -		   "Can't locate host! (sc=%p)\n", SCpnt);
> +		   "Can't locate host!\n");
>   		return FAILED;
>   	}
>   
>   	ioc = hd->ioc;
> -	printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n",
> -	       ioc->name, SCpnt);
> -	scsi_print_command(SCpnt);
> +	printk(MYIOC_s_INFO_FMT "attempting bus reset!\n",

maybe printing the channel number may be helpful

> +	       ioc->name);
>   
>   	if (ioc->timeouts < -1)
>   		ioc->timeouts++;
>   
> -	vdevice = SCpnt->device->hostdata;
> -	if (!vdevice || !vdevice->vtarget)
> -		return SUCCESS;
>   	retval = mptscsih_IssueTaskMgmt(hd,
>   					MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
> -					vdevice->vtarget->channel, 0, 0, 0,
> +					channel, 0, 0, 0,
>   					mptscsih_get_tm_timeout(ioc));
>   
> -	printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
> -	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
> +	printk(MYIOC_s_INFO_FMT "bus reset: %s\n",
> +	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));

Outer () can be removed

>   
>   	if (retval == 0)
>   		return SUCCESS;
> diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h

...

>   	struct AdapterCtlBlk *acb =
> -		(struct AdapterCtlBlk *)cmd->device->host->hostdata;
> +		(struct AdapterCtlBlk *)shost->hostdata;
>   	dprintkl(KERN_INFO,
> -		"eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
> -		cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
> +		 "eh_bus_reset: bus=<%02i>\n", channel);
>   
>   	if (timer_pending(&acb->waiting_timer))
>   		del_timer(&acb->waiting_timer);
>   
>   	/*
> -	 * disable interrupt
> +	 * disable interrupt

what changed here?

>   	 */
>   	DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00);
>   	DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00);
> @@ -1172,7 +1171,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
>   	    HZ * acb->eeprom.delay_time;
>   
>   	/*
> -	 * re-enable interrupt
> +	 * re-enable interrupt
>   	 */

...

>   
>   /* Internal functions */
> diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
> index 168f01a34acc..ae647e2586d0 100644
> --- a/drivers/scsi/esas2r/esas2r_main.c
> +++ b/drivers/scsi/esas2r/esas2r_main.c
> @@ -1097,10 +1097,8 @@ int esas2r_host_reset(struct Scsi_Host *shost)
>   	return esas2r_host_bus_reset(shost, true);
>   }
>   
> -int esas2r_bus_reset(struct scsi_cmnd *cmd)
> +int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct Scsi_Host *shost = cmd->device->host;
> -
>   	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);

surely printing the channel would be better than the shost pointer

>   
>   	return esas2r_host_bus_reset(shost, false);
> diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
> index 355fec046220..c6a5721aef23 100644
> --- a/drivers/scsi/esp_scsi.c
> +++ b/drivers/scsi/esp_scsi.c
> @@ -2604,9 +2604,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
>   	return FAILED;
>   }
>   

...

>   
> -	sdev_printk(KERN_INFO, scmd->device,
> -		"Bus reset is %s for scmd(%p)\n",
> -		((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
> +	shost_printk(KERN_INFO, shost,
> +		"Bus reset is %s\n",
> +		((retval == SUCCESS) ? "SUCCESS" : "FAILED"));

again, () can be removed

>   	return retval;
>   }
>   
> diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
> index 35869b4f9329..59efe064b304 100644
> --- a/drivers/scsi/ncr53c8xx.c
> +++ b/drivers/scsi/ncr53c8xx.c
> @@ -7936,9 +7936,9 @@ static void ncr53c8xx_timeout(struct timer_list *t)
>   		ncr_flush_done_cmds(done_list);
>   }
>   
> -static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
> +static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
> +	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
>   	int sts;
>   	unsigned long flags;
>   	struct scsi_cmnd *done_list;
> diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
> index 104647a6170e..c709bb955d05 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.c
> +++ b/drivers/scsi/pcmcia/nsp_cs.c
> @@ -1486,11 +1486,11 @@ static int nsp_bus_reset(nsp_hw_data *data)
>   	return SUCCESS;
>   }
>   
> -static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
> +static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel)
>   {
> -	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
> +	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
>   
> -	nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
> +	nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel);

0x%x, and I am not sure that is even better than printing in decimal

>   
>   	return nsp_bus_reset(data);
>   }
> diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
> index f532adb5f166..8636f0053c02 100644
> --- a/drivers/scsi/pcmcia/nsp_cs.h
> +++ b/drivers/scsi/pcmcia/nsp_cs.h
> @@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);

...
>   	return rc;
>   }
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index bb0323d05640..a9d9d0a9abd7 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -1588,7 +1588,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>   *    commands.
>   *
>   * Input:
> -*    cmd = Linux SCSI command packet of the command that cause the
> +*    host = Linux SCSI command packet of the command that cause the
>   *          bus reset.

"Linux SCSI command packet " - really?

>   *
>   * Returns:
> @@ -1596,12 +1596,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
>   *
>   **************************************************************************/
...

>   
> -	scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n");
> +	shost_printk(KERN_INFO, host, "SCSI Bus reset\n");

how about this the channel #?

>   
>   	/*
>   	 * We don't want to queue new requests for this bus after
> diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
> index 42134f9510d5..bc48152e74b8 100644
> --- a/drivers/scsi/wd719x.c
> +++ b/drivers/scsi/wd719x.c
> @@ -484,11 +484,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd)
>   	return SUCCESS;
>   }



>   /* Simulate a SCSI bus reset by resetting the device's USB port. */
> -static int bus_reset(struct scsi_cmnd *srb)
> +static int bus_reset(struct Scsi_Host *shost, int channel)
>   {
> -	struct us_data *us = host_to_us(srb->device->host);
> +	struct us_data *us = host_to_us(shost);

Incidentally host_to_us() seems a copy of shost_priv()

>   	int result;
>   
>   	usb_stor_dbg(us, "%s called\n", __func__);
> diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
> index 9e3ec411cdc6..32ef595db028 100644
> --- a/include/scsi/scsi_host.h
> +++ b/include/scsi/scsi_host.h
> @@ -152,7 +152,7 @@ struct scsi_host_template {
>   	int (* eh_abort_handler)(struct scsi_cmnd *);
>   	int (* eh_device_reset_handler)(struct scsi_cmnd *);
>   	int (* eh_target_reset_handler)(struct scsi_cmnd *);
> -	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
> +	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
>   	int (* eh_host_reset_handler)(struct Scsi_Host *);
>   
>   	/*


^ permalink raw reply	[flat|nested] 31+ messages in thread

* [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler()
  2023-10-02 15:59 [PATCHv5 0/7] scsi: EH rework, " Hannes Reinecke
@ 2023-10-02 15:59 ` Hannes Reinecke
  2023-10-05 11:54   ` John Garry
  0 siblings, 1 reply; 31+ messages in thread
From: Hannes Reinecke @ 2023-10-02 15:59 UTC (permalink / raw)
  To: Martin K. Petersen
  Cc: James Bottomley, linux-scsi, Christoph Hellwig, Hannes Reinecke

The bus reset should not depend on any command, but rather only
use the SCSI Host and the channel/bus number as argument.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 Documentation/scsi/scsi_eh.rst          |  2 +-
 Documentation/scsi/scsi_mid_low_api.rst |  5 ++--
 drivers/message/fusion/mptfc.c          | 13 ++++-----
 drivers/message/fusion/mptscsih.c       | 21 ++++++--------
 drivers/message/fusion/mptscsih.h       |  2 +-
 drivers/scsi/a100u2w.c                  |  4 +--
 drivers/scsi/aacraid/linit.c            | 11 ++++----
 drivers/scsi/aha152x.c                  |  4 +--
 drivers/scsi/aha1542.c                  |  4 +--
 drivers/scsi/aic7xxx/aic79xx_osm.c      | 10 +++----
 drivers/scsi/aic7xxx/aic7xxx_osm.c      |  6 ++--
 drivers/scsi/arcmsr/arcmsr_hba.c        |  6 ++--
 drivers/scsi/arm/fas216.c               |  9 +++---
 drivers/scsi/arm/fas216.h               |  5 ++--
 drivers/scsi/dc395x.c                   | 25 ++++++++---------
 drivers/scsi/esas2r/esas2r.h            |  2 +-
 drivers/scsi/esas2r/esas2r_main.c       |  4 +--
 drivers/scsi/esp_scsi.c                 |  4 +--
 drivers/scsi/initio.c                   | 11 ++++----
 drivers/scsi/mpi3mr/mpi3mr_os.c         | 37 +++++++++++++++----------
 drivers/scsi/ncr53c8xx.c                |  4 +--
 drivers/scsi/pcmcia/nsp_cs.c            |  6 ++--
 drivers/scsi/pcmcia/nsp_cs.h            |  2 +-
 drivers/scsi/pmcraid.c                  |  7 ++---
 drivers/scsi/qla1280.c                  | 12 ++++----
 drivers/scsi/qla2xxx/qla_os.c           | 17 ++++--------
 drivers/scsi/scsi_debug.c               |  9 +++---
 drivers/scsi/scsi_error.c               |  2 +-
 drivers/scsi/sym53c8xx_2/sym_glue.c     |  7 ++---
 drivers/scsi/vmw_pvscsi.c               |  5 ++--
 drivers/scsi/wd719x.c                   | 11 ++++----
 drivers/usb/storage/scsiglue.c          |  4 +--
 include/scsi/scsi_host.h                |  2 +-
 33 files changed, 133 insertions(+), 140 deletions(-)

diff --git a/Documentation/scsi/scsi_eh.rst b/Documentation/scsi/scsi_eh.rst
index da95971b4f44..dbbfd754a928 100644
--- a/Documentation/scsi/scsi_eh.rst
+++ b/Documentation/scsi/scsi_eh.rst
@@ -216,7 +216,7 @@ considered to fail always.
 
     int (* eh_abort_handler)(struct scsi_cmnd *);
     int (* eh_device_reset_handler)(struct scsi_cmnd *);
-    int (* eh_bus_reset_handler)(struct scsi_cmnd *);
+    int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
     int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 Higher-severity actions are taken only when lower-severity actions
diff --git a/Documentation/scsi/scsi_mid_low_api.rst b/Documentation/scsi/scsi_mid_low_api.rst
index 85b1384ba4fd..88bb3b7578ba 100644
--- a/Documentation/scsi/scsi_mid_low_api.rst
+++ b/Documentation/scsi/scsi_mid_low_api.rst
@@ -741,7 +741,8 @@ Details::
 
     /**
     *      eh_bus_reset_handler - issue SCSI bus reset
-    *      @scp: SCSI bus that contains this device should be reset
+    *      @host: SCSI Host that contains the channel which should be reset
+    *      @channel: channel to be reset
     *
     *      Returns SUCCESS if command aborted else FAILED
     *
@@ -754,7 +755,7 @@ Details::
     *
     *      Optionally defined in: LLD
     **/
-	int eh_bus_reset_handler(struct scsi_cmnd * scp)
+	int eh_bus_reset_handler(struct Scsi_Host * host, int channel)
 
 
     /**
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index aa6bb764df3e..83718602c1c4 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -103,7 +103,7 @@ static void mptfc_set_rport_loss_tmo(struct fc_rport *rport, uint32_t timeout);
 static void mptfc_remove(struct pci_dev *pdev);
 static int mptfc_abort(struct scsi_cmnd *SCpnt);
 static int mptfc_dev_reset(struct scsi_cmnd *SCpnt);
-static int mptfc_bus_reset(struct scsi_cmnd *SCpnt);
+static int mptfc_bus_reset(struct Scsi_Host *shost, int channel);
 
 static const struct scsi_host_template mptfc_driver_template = {
 	.module				= THIS_MODULE,
@@ -259,11 +259,9 @@ mptfc_dev_reset(struct scsi_cmnd *SCpnt)
 }
 
 static int
-mptfc_bus_reset(struct scsi_cmnd *SCpnt)
+mptfc_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = SCpnt->device->host;
 	MPT_SCSI_HOST __maybe_unused *hd = shost_priv(shost);
-	int channel = SCpnt->device->channel;
 	struct mptfc_rport_info *ri;
 	int rtn;
 
@@ -280,10 +278,9 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt)
 	}
 	if (rtn == 0) {
 		dfcprintk (hd->ioc, printk(MYIOC_s_DEBUG_FMT
-			"%s.%d: %d:%llu, executing recovery.\n", __func__,
-			hd->ioc->name, shost->host_no,
-			SCpnt->device->id, SCpnt->device->lun));
-		rtn = mptscsih_bus_reset(SCpnt);
+			"%s.%d: 0:0, executing recovery.\n", __func__,
+			hd->ioc->name, shost->host_no));
+		rtn = mptscsih_bus_reset(shost, channel);
 	}
 	return rtn;
 }
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index caf045cfea0e..591b2858f823 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1913,39 +1913,34 @@ mptscsih_target_reset(struct scsi_cmnd * SCpnt)
  *	Returns SUCCESS or FAILED.
  **/
 int
-mptscsih_bus_reset(struct scsi_cmnd * SCpnt)
+mptscsih_bus_reset(struct Scsi_Host * shost, int channel)
 {
 	MPT_SCSI_HOST	*hd;
 	int		 retval;
-	VirtDevice	 *vdevice;
 	MPT_ADAPTER	*ioc;
 
 	/* If we can't locate our host adapter structure, return FAILED status.
 	 */
-	if ((hd = shost_priv(SCpnt->device->host)) == NULL){
+	if ((hd = shost_priv(shost)) == NULL){
 		printk(KERN_ERR MYNAM ": bus reset: "
-		   "Can't locate host! (sc=%p)\n", SCpnt);
+		   "Can't locate host!\n");
 		return FAILED;
 	}
 
 	ioc = hd->ioc;
-	printk(MYIOC_s_INFO_FMT "attempting bus reset! (sc=%p)\n",
-	       ioc->name, SCpnt);
-	scsi_print_command(SCpnt);
+	printk(MYIOC_s_INFO_FMT "attempting bus reset!\n",
+	       ioc->name);
 
 	if (ioc->timeouts < -1)
 		ioc->timeouts++;
 
-	vdevice = SCpnt->device->hostdata;
-	if (!vdevice || !vdevice->vtarget)
-		return SUCCESS;
 	retval = mptscsih_IssueTaskMgmt(hd,
 					MPI_SCSITASKMGMT_TASKTYPE_RESET_BUS,
-					vdevice->vtarget->channel, 0, 0, 0,
+					channel, 0, 0, 0,
 					mptscsih_get_tm_timeout(ioc));
 
-	printk(MYIOC_s_INFO_FMT "bus reset: %s (sc=%p)\n",
-	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+	printk(MYIOC_s_INFO_FMT "bus reset: %s\n",
+	    ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ));
 
 	if (retval == 0)
 		return SUCCESS;
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 0faefe9c7541..9f3756bd25eb 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -121,7 +121,7 @@ extern int mptscsih_slave_configure(struct scsi_device *device);
 extern int mptscsih_abort(struct scsi_cmnd * SCpnt);
 extern int mptscsih_dev_reset(struct scsi_cmnd * SCpnt);
 extern int mptscsih_target_reset(struct scsi_cmnd * SCpnt);
-extern int mptscsih_bus_reset(struct scsi_cmnd * SCpnt);
+extern int mptscsih_bus_reset(struct Scsi_Host *, int);
 extern int mptscsih_host_reset(struct Scsi_Host *sh);
 extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
 extern int mptscsih_io_done(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, MPT_FRAME_HDR *r);
diff --git a/drivers/scsi/a100u2w.c b/drivers/scsi/a100u2w.c
index 43b119add2b9..a1f5f8d65e6b 100644
--- a/drivers/scsi/a100u2w.c
+++ b/drivers/scsi/a100u2w.c
@@ -934,10 +934,10 @@ static int inia100_abort(struct scsi_cmnd * cmd)
  Output         : None.
  Return         : pSRB  -       Pointer to SCSI request block.
 *****************************************************************************/
-static int inia100_bus_reset(struct scsi_cmnd * cmd)
+static int inia100_bus_reset(struct Scsi_Host * shost, int channel)
 {				/* I need Host Control Block Information */
 	struct orc_host *host;
-	host = (struct orc_host *) cmd->device->host->hostdata;
+	host = (struct orc_host *) shost->hostdata;
 	return orc_reset_scsi_bus(host);
 }
 
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c
index 121b6447baa6..f865f8a8f88d 100644
--- a/drivers/scsi/aacraid/linit.c
+++ b/drivers/scsi/aacraid/linit.c
@@ -1034,20 +1034,18 @@ static int aac_eh_target_reset(struct scsi_cmnd *cmd)
 
 /*
  *	aac_eh_bus_reset	- Bus reset command handling
- *	@scsi_cmd:	SCSI command block causing the reset
+ *	@host:	SCSI host causing the reset
+ *	@channel:	Number of the bus to be reset
  *
  */
-static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
+static int aac_eh_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct scsi_device * dev = cmd->device;
-	struct Scsi_Host * host = dev->host;
 	struct aac_dev * aac = (struct aac_dev *)host->hostdata;
 	int count;
 	u32 cmd_bus;
 	int status = 0;
 
-
-	cmd_bus = aac_logical_to_phys(scmd_channel(cmd));
+	cmd_bus = aac_logical_to_phys(channel);
 	/* Mark the assoc. FIB to not complete, eh handler does this */
 	for (count = 0; count < (host->can_queue + AAC_NUM_MGT_FIB); ++count) {
 		struct fib *fib = &aac->fibs[count];
@@ -1055,6 +1053,7 @@ static int aac_eh_bus_reset(struct scsi_cmnd* cmd)
 		if (fib->hw_fib_va->header.XferState &&
 		    (fib->flags & FIB_CONTEXT_FLAG) &&
 		    (fib->flags & FIB_CONTEXT_FLAG_SCSI_CMD)) {
+			struct scsi_cmnd *cmd;
 			struct aac_hba_map_info *info;
 			u32 bus, cid;
 
diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index 936c9f5c6f23..d8ace084b5a7 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -1192,9 +1192,9 @@ static int aha152x_bus_reset_host(struct Scsi_Host *shpnt)
  * Reset the bus
  *
  */
-static int aha152x_bus_reset(struct scsi_cmnd *SCpnt)
+static int aha152x_bus_reset(struct Scsi_Host *shpnt, int channel)
 {
-	return aha152x_bus_reset_host(SCpnt->device->host);
+	return aha152x_bus_reset_host(shpnt);
 }
 
 /*
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c
index 2a88e1c6ffda..89c0e2c7d9da 100644
--- a/drivers/scsi/aha1542.c
+++ b/drivers/scsi/aha1542.c
@@ -981,9 +981,9 @@ static int aha1542_reset(struct Scsi_Host *sh, u8 reset_cmd)
 	return SUCCESS;
 }
 
-static int aha1542_bus_reset(struct scsi_cmnd *cmd)
+static int aha1542_bus_reset(struct Scsi_Host *sh, int channel)
 {
-	return aha1542_reset(cmd->device->host, SCRST);
+	return aha1542_reset(sh, SCRST);
 }
 
 static int aha1542_host_reset(struct Scsi_Host *sh)
diff --git a/drivers/scsi/aic7xxx/aic79xx_osm.c b/drivers/scsi/aic7xxx/aic79xx_osm.c
index b3075a022d99..a43f643622a9 100644
--- a/drivers/scsi/aic7xxx/aic79xx_osm.c
+++ b/drivers/scsi/aic7xxx/aic79xx_osm.c
@@ -863,21 +863,21 @@ ahd_linux_dev_reset(struct scsi_cmnd *cmd)
  * Reset the SCSI bus.
  */
 static int
-ahd_linux_bus_reset(struct scsi_cmnd *cmd)
+ahd_linux_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct ahd_softc *ahd;
 	int    found;
 	unsigned long flags;
 
-	ahd = *(struct ahd_softc **)cmd->device->host->hostdata;
+	ahd = *(struct ahd_softc **)shost->hostdata;
 #ifdef AHD_DEBUG
 	if ((ahd_debug & AHD_SHOW_RECOVERY) != 0)
-		printk("%s: Bus reset called for cmd %p\n",
-		       ahd_name(ahd), cmd);
+		printk("%s: Bus reset called for channel %d\n",
+		       ahd_name(ahd), channel);
 #endif
 	ahd_lock(ahd, &flags);
 
-	found = ahd_reset_channel(ahd, scmd_channel(cmd) + 'A',
+	found = ahd_reset_channel(ahd, channel + 'A',
 				  /*initiate reset*/TRUE);
 	ahd_unlock(ahd, &flags);
 
diff --git a/drivers/scsi/aic7xxx/aic7xxx_osm.c b/drivers/scsi/aic7xxx/aic7xxx_osm.c
index 4ae0a1c4d374..6d42d39806a0 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_osm.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_osm.c
@@ -753,16 +753,16 @@ ahc_linux_dev_reset(struct scsi_cmnd *cmd)
  * Reset the SCSI bus.
  */
 static int
-ahc_linux_bus_reset(struct scsi_cmnd *cmd)
+ahc_linux_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct ahc_softc *ahc;
 	int    found;
 	unsigned long flags;
 
-	ahc = *(struct ahc_softc **)cmd->device->host->hostdata;
+	ahc = *(struct ahc_softc **)shost->hostdata;
 
 	ahc_lock(ahc, &flags);
-	found = ahc_reset_channel(ahc, scmd_channel(cmd) + 'A',
+	found = ahc_reset_channel(ahc, channel + 'A',
 				  /*initiate reset*/TRUE);
 	ahc_unlock(ahc, &flags);
 
diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index a66221c3b72f..6c9d3a427636 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -110,7 +110,7 @@ static int arcmsr_iop_message_xfer(struct AdapterControlBlock *acb,
 					struct scsi_cmnd *cmd);
 static int arcmsr_iop_confirm(struct AdapterControlBlock *acb);
 static int arcmsr_abort(struct scsi_cmnd *);
-static int arcmsr_bus_reset(struct scsi_cmnd *);
+static int arcmsr_bus_reset(struct Scsi_Host *, int);
 static int arcmsr_bios_param(struct scsi_device *sdev,
 		struct block_device *bdev, sector_t capacity, int *info);
 static int arcmsr_queue_command(struct Scsi_Host *h, struct scsi_cmnd *cmd);
@@ -4571,12 +4571,12 @@ static uint8_t arcmsr_iop_reset(struct AdapterControlBlock *acb)
 	return rtnval;
 }
 
-static int arcmsr_bus_reset(struct scsi_cmnd *cmd)
+static int arcmsr_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct AdapterControlBlock *acb;
 	int retry_count = 0;
 	int rtn = FAILED;
-	acb = (struct AdapterControlBlock *) cmd->device->host->hostdata;
+	acb = (struct AdapterControlBlock *) shost->hostdata;
 	if (acb->acb_flags & ACB_F_ADAPTER_REMOVED)
 		return SUCCESS;
 	pr_notice("arcmsr: executing bus reset eh.....num_resets = %d,"
diff --git a/drivers/scsi/arm/fas216.c b/drivers/scsi/arm/fas216.c
index 38eec967155d..c27b49c42c4f 100644
--- a/drivers/scsi/arm/fas216.c
+++ b/drivers/scsi/arm/fas216.c
@@ -2550,15 +2550,16 @@ int fas216_eh_device_reset(struct scsi_cmnd *SCpnt)
 
 /**
  * fas216_eh_bus_reset - Reset the bus associated with the command
- * @SCpnt: command specifing bus to reset
+ * @shost: host to be reset
+ * @channel: bus number to reset
  *
- * Reset the bus associated with the command.
+ * Reset the bus.
  * Returns: FAILED if unable to reset.
  * Notes: Further commands are blocked.
  */
-int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
+int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	FAS216_Info *info = (FAS216_Info *)SCpnt->device->host->hostdata;
+	FAS216_Info *info = (FAS216_Info *)shost->hostdata;
 	unsigned long flags;
 	struct scsi_device *SDpnt;
 
diff --git a/drivers/scsi/arm/fas216.h b/drivers/scsi/arm/fas216.h
index f17583f143b3..27a4b564f054 100644
--- a/drivers/scsi/arm/fas216.h
+++ b/drivers/scsi/arm/fas216.h
@@ -389,10 +389,11 @@ extern int fas216_eh_device_reset(struct scsi_cmnd *SCpnt);
 
 /* Function: int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt)
  * Purpose : Reset the complete bus associated with this command
- * Params  : SCpnt - command specifing bus to reset
+ * Params  : shost - host to be reset
+ *           channel - bus to be reset
  * Returns : FAILED if unable to reset
  */
-extern int fas216_eh_bus_reset(struct scsi_cmnd *SCpnt);
+extern int fas216_eh_bus_reset(struct Scsi_Host *shost, int channel);
 
 /* Function: int fas216_eh_host_reset(struct Scsi_Host *shost)
  * Purpose : Reset the host associated with this command
diff --git a/drivers/scsi/dc395x.c b/drivers/scsi/dc395x.c
index c8e86f8a631e..b4586cb22d1e 100644
--- a/drivers/scsi/dc395x.c
+++ b/drivers/scsi/dc395x.c
@@ -1144,19 +1144,18 @@ static void reset_dev_param(struct AdapterCtlBlk *acb)
  * @cmd - some command for this host (for fetching hooks)
  * Returns: SUCCESS (0x2002) on success, else FAILED (0x2003).
  */
-static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
+static int __dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	struct AdapterCtlBlk *acb =
-		(struct AdapterCtlBlk *)cmd->device->host->hostdata;
+		(struct AdapterCtlBlk *)shost->hostdata;
 	dprintkl(KERN_INFO,
-		"eh_bus_reset: (0%p) target=<%02i-%i> cmd=%p\n",
-		cmd, cmd->device->id, (u8)cmd->device->lun, cmd);
+		 "eh_bus_reset: bus=<%02i>\n", channel);
 
 	if (timer_pending(&acb->waiting_timer))
 		del_timer(&acb->waiting_timer);
 
 	/*
-	 * disable interrupt    
+	 * disable interrupt
 	 */
 	DC395x_write8(acb, TRM_S1040_DMA_INTEN, 0x00);
 	DC395x_write8(acb, TRM_S1040_SCSI_INTEN, 0x00);
@@ -1172,7 +1171,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	    HZ * acb->eeprom.delay_time;
 
 	/*
-	 * re-enable interrupt      
+	 * re-enable interrupt
 	 */
 	/* Clear SCSI FIFO          */
 	DC395x_write8(acb, TRM_S1040_DMA_CONTROL, CLRXFIFO);
@@ -1182,7 +1181,7 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	set_basic_config(acb);
 
 	reset_dev_param(acb);
-	doing_srb_done(acb, DID_RESET, cmd, 0);
+	doing_srb_done(acb, DID_RESET, NULL, 0);
 	acb->active_dcb = NULL;
 	acb->acb_flag = 0;	/* RESET_DETECT, RESET_DONE ,RESET_DEV */
 	waiting_process_next(acb);
@@ -1190,13 +1189,13 @@ static int __dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int dc395x_eh_bus_reset(struct scsi_cmnd *cmd)
+static int dc395x_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
 	int rc;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = __dc395x_eh_bus_reset(cmd);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	rc = __dc395x_eh_bus_reset(shost, channel);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
@@ -3338,7 +3337,7 @@ static void srb_done(struct AdapterCtlBlk *acb, struct DeviceCtlBlk *dcb,
 
 /* abort all cmds in our queues */
 static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
-		struct scsi_cmnd *cmd, u8 force)
+			   struct scsi_cmnd *cmd, u8 force)
 {
 	struct DeviceCtlBlk *dcb;
 	dprintkl(KERN_INFO, "doing_srb_done: pids ");
@@ -3386,7 +3385,7 @@ static void doing_srb_done(struct AdapterCtlBlk *acb, u8 did_flag,
 			set_status_byte(p, SAM_STAT_GOOD);
 			pci_unmap_srb_sense(acb, srb);
 			pci_unmap_srb(acb, srb);
-			if (force) {
+			if (force && cmd) {
 				/* For new EH, we normally don't need to give commands back,
 				 * as they all complete or all time out */
 				scsi_done(cmd);
diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index a104d1a3a9da..5c1eeaffc090 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -977,7 +977,7 @@ long esas2r_proc_ioctl(struct file *fp, unsigned int cmd, unsigned long arg);
 int esas2r_eh_abort(struct scsi_cmnd *cmd);
 int esas2r_device_reset(struct scsi_cmnd *cmd);
 int esas2r_host_reset(struct Scsi_Host *shost);
-int esas2r_bus_reset(struct scsi_cmnd *cmd);
+int esas2r_bus_reset(struct Scsi_Host *shost, int channel);
 int esas2r_target_reset(struct scsi_cmnd *cmd);
 
 /* Internal functions */
diff --git a/drivers/scsi/esas2r/esas2r_main.c b/drivers/scsi/esas2r/esas2r_main.c
index 168f01a34acc..ae647e2586d0 100644
--- a/drivers/scsi/esas2r/esas2r_main.c
+++ b/drivers/scsi/esas2r/esas2r_main.c
@@ -1097,10 +1097,8 @@ int esas2r_host_reset(struct Scsi_Host *shost)
 	return esas2r_host_bus_reset(shost, true);
 }
 
-int esas2r_bus_reset(struct scsi_cmnd *cmd)
+int esas2r_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = cmd->device->host;
-
 	esas2r_log(ESAS2R_LOG_INFO, "bus_reset (%p)", shost);
 
 	return esas2r_host_bus_reset(shost, false);
diff --git a/drivers/scsi/esp_scsi.c b/drivers/scsi/esp_scsi.c
index 355fec046220..c6a5721aef23 100644
--- a/drivers/scsi/esp_scsi.c
+++ b/drivers/scsi/esp_scsi.c
@@ -2604,9 +2604,9 @@ static int esp_eh_abort_handler(struct scsi_cmnd *cmd)
 	return FAILED;
 }
 
-static int esp_eh_bus_reset_handler(struct scsi_cmnd *cmd)
+static int esp_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
 {
-	struct esp *esp = shost_priv(cmd->device->host);
+	struct esp *esp = shost_priv(shost);
 	struct completion eh_reset;
 	unsigned long flags;
 
diff --git a/drivers/scsi/initio.c b/drivers/scsi/initio.c
index 2a50fda3a628..863efc80a3b4 100644
--- a/drivers/scsi/initio.c
+++ b/drivers/scsi/initio.c
@@ -2625,20 +2625,21 @@ static DEF_SCSI_QCMD(i91u_queuecommand)
 
 /**
  *	i91u_bus_reset		-	reset the SCSI bus
- *	@cmnd: Command block we want to trigger the reset for
+ *	@shost: SCSI host to be reset
+ *	@channel: Bus number to be reset
  *
  *	Initiate a SCSI bus reset sequence
  */
 
-static int i91u_bus_reset(struct scsi_cmnd * cmnd)
+static int i91u_bus_reset(struct Scsi_Host * shost, int channel)
 {
 	struct initio_host *host;
 
-	host = (struct initio_host *) cmnd->device->host->hostdata;
+	host = (struct initio_host *) shost->hostdata;
 
-	spin_lock_irq(cmnd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
 	initio_reset_scsi(host, 0);
-	spin_unlock_irq(cmnd->device->host->host_lock);
+	spin_unlock_irq(shost->host_lock);
 
 	return SUCCESS;
 }
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index d52412870b54..63b6ed19e9d1 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -4037,39 +4037,46 @@ static int mpi3mr_eh_host_reset(struct Scsi_Host *shost)
 
 /**
  * mpi3mr_eh_bus_reset - Bus reset error handling callback
- * @scmd: SCSI command reference
+ * @shost: SCSI host reference
+ * @channel: bus number
  *
  * Checks whether pending I/Os are present for the RAID volume;
  * if not there's no need to reset the adapter.
  *
  * Return: SUCCESS of successful reset else FAILED
  */
-static int mpi3mr_eh_bus_reset(struct scsi_cmnd *scmd)
+static int mpi3mr_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct mpi3mr_ioc *mrioc = shost_priv(scmd->device->host);
+	struct mpi3mr_ioc *mrioc = shost_priv(shost);
+	struct mpi3mr_tgt_dev *tgtdev;
 	struct mpi3mr_stgt_priv_data *stgt_priv_data;
-	struct mpi3mr_sdev_priv_data *sdev_priv_data;
-	u8 dev_type = MPI3_DEVICE_DEVFORM_VD;
 	int retval = FAILED;
 
-	sdev_priv_data = scmd->device->hostdata;
-	if (sdev_priv_data && sdev_priv_data->tgt_priv_data) {
-		stgt_priv_data = sdev_priv_data->tgt_priv_data;
-		dev_type = stgt_priv_data->dev_type;
+	spin_lock(&mrioc->tgtdev_lock);
+	list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
+		if (!tgtdev->starget || !tgtdev->starget->hostdata)
+			continue;
+		stgt_priv_data = (struct mpi3mr_stgt_priv_data *)
+			tgtdev->starget->hostdata;
+		if (stgt_priv_data->dev_type == MPI3_DEVICE_DEVFORM_VD) {
+			retval = SUCCESS;
+			break;
+		}
 	}
+	spin_unlock(&mrioc->tgtdev_lock);
 
-	if (dev_type == MPI3_DEVICE_DEVFORM_VD) {
+	if (retval == SUCCESS) {
 		mpi3mr_wait_for_host_io(mrioc,
 			MPI3MR_RAID_ERRREC_RESET_TIMEOUT);
-		if (!mpi3mr_get_fw_pending_ios(mrioc))
-			retval = SUCCESS;
+		if (mpi3mr_get_fw_pending_ios(mrioc))
+			retval = FAILED;
 	}
 	if (retval == FAILED)
 		mpi3mr_print_pending_host_io(mrioc);
 
-	sdev_printk(KERN_INFO, scmd->device,
-		"Bus reset is %s for scmd(%p)\n",
-		((retval == SUCCESS) ? "SUCCESS" : "FAILED"), scmd);
+	shost_printk(KERN_INFO, shost,
+		"Bus reset is %s\n",
+		((retval == SUCCESS) ? "SUCCESS" : "FAILED"));
 	return retval;
 }
 
diff --git a/drivers/scsi/ncr53c8xx.c b/drivers/scsi/ncr53c8xx.c
index 35869b4f9329..59efe064b304 100644
--- a/drivers/scsi/ncr53c8xx.c
+++ b/drivers/scsi/ncr53c8xx.c
@@ -7936,9 +7936,9 @@ static void ncr53c8xx_timeout(struct timer_list *t)
 		ncr_flush_done_cmds(done_list);
 }
 
-static int ncr53c8xx_bus_reset(struct scsi_cmnd *cmd)
+static int ncr53c8xx_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct ncb *np = ((struct host_data *) cmd->device->host->hostdata)->ncb;
+	struct ncb *np = ((struct host_data *) host->hostdata)->ncb;
 	int sts;
 	unsigned long flags;
 	struct scsi_cmnd *done_list;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 104647a6170e..c709bb955d05 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1486,11 +1486,11 @@ static int nsp_bus_reset(nsp_hw_data *data)
 	return SUCCESS;
 }
 
-static int nsp_eh_bus_reset(struct scsi_cmnd *SCpnt)
+static int nsp_eh_bus_reset(struct Scsi_Host *host, int channel)
 {
-	nsp_hw_data *data = (nsp_hw_data *)SCpnt->device->host->hostdata;
+	nsp_hw_data *data = (nsp_hw_data *)host->hostdata;
 
-	nsp_dbg(NSP_DEBUG_BUSRESET, "SCpnt=0x%p", SCpnt);
+	nsp_dbg(NSP_DEBUG_BUSRESET, "channel=0x%d", channel);
 
 	return nsp_bus_reset(data);
 }
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index f532adb5f166..8636f0053c02 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -299,7 +299,7 @@ static int nsp_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *SCpnt);
 /* Error handler */
 /*static int nsp_eh_abort       (struct scsi_cmnd *SCpnt);*/
 /*static int nsp_eh_device_reset(struct scsi_cmnd *SCpnt);*/
-static int nsp_eh_bus_reset    (struct scsi_cmnd *SCpnt);
+static int nsp_eh_bus_reset    (struct Scsi_Host *host, int channel);
 static int nsp_eh_host_reset   (struct Scsi_Host *host);
 static int nsp_bus_reset       (nsp_hw_data *data);
 
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
index 4cf7a0b1c39f..f25598a50368 100644
--- a/drivers/scsi/pmcraid.c
+++ b/drivers/scsi/pmcraid.c
@@ -3023,9 +3023,8 @@ static int pmcraid_eh_device_reset_handler(struct scsi_cmnd *scmd)
 				    RESET_DEVICE_LUN);
 }
 
-static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
+static int pmcraid_eh_bus_reset_handler(struct Scsi_Host *host, int channel)
 {
-	struct Scsi_Host *host = scmd->device->host;
 	struct pmcraid_instance *pinstance =
 		(struct pmcraid_instance *)host->hostdata;
 	struct pmcraid_resource_entry *res = NULL;
@@ -3039,11 +3038,11 @@ static int pmcraid_eh_bus_reset_handler(struct scsi_cmnd *scmd)
 	 */
 	spin_lock_irqsave(&pinstance->resource_lock, lock_flags);
 	list_for_each_entry(temp, &pinstance->used_res_q, queue) {
-		if (scmd->device->channel == PMCRAID_VSET_BUS_ID &&
+		if (channel == PMCRAID_VSET_BUS_ID &&
 		    RES_IS_VSET(temp->cfg_entry)) {
 			res = temp;
 			break;
-		} else if (scmd->device->channel == PMCRAID_PHYS_BUS_ID &&
+		} else if (channel == PMCRAID_PHYS_BUS_ID &&
 			   RES_IS_GSCSI(temp->cfg_entry)) {
 			res = temp;
 			break;
diff --git a/drivers/scsi/qla1280.c b/drivers/scsi/qla1280.c
index 178f249057e7..1df3deb618e4 100644
--- a/drivers/scsi/qla1280.c
+++ b/drivers/scsi/qla1280.c
@@ -979,13 +979,15 @@ qla1280_eh_device_reset(struct scsi_cmnd *cmd)
  *     Reset the specified bus.
  **************************************************************************/
 static int
-qla1280_eh_bus_reset(struct scsi_cmnd *cmd)
+qla1280_eh_bus_reset(struct Scsi_Host *shost, int bus)
 {
-	int rc;
+	int rc = FAILED;
+	struct scsi_qla_host *ha = (struct scsi_qla_host *)shost->hostdata;
 
-	spin_lock_irq(cmd->device->host->host_lock);
-	rc = qla1280_error_action(cmd, BUS_RESET);
-	spin_unlock_irq(cmd->device->host->host_lock);
+	spin_lock_irq(shost->host_lock);
+	if (qla1280_bus_reset(ha, bus) == 0)
+		rc = qla1280_wait_for_pending_commands(ha, 1, 0);
+	spin_unlock_irq(shost->host_lock);
 
 	return rc;
 }
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index bb0323d05640..a9d9d0a9abd7 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -1588,7 +1588,7 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
 *    commands.
 *
 * Input:
-*    cmd = Linux SCSI command packet of the command that cause the
+*    host = Linux SCSI command packet of the command that cause the
 *          bus reset.
 *
 * Returns:
@@ -1596,12 +1596,10 @@ qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
 *
 **************************************************************************/
 static int
-qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
+qla2xxx_eh_bus_reset(struct Scsi_Host *shost, int channel)
 {
-	scsi_qla_host_t *vha = shost_priv(cmd->device->host);
+	scsi_qla_host_t *vha = shost_priv(shost);
 	int ret = FAILED;
-	unsigned int id;
-	uint64_t lun;
 	struct qla_hw_data *ha = vha->hw;
 
 	if (qla2x00_isp_reg_stat(ha)) {
@@ -1611,14 +1609,11 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 		return FAILED;
 	}
 
-	id = cmd->device->id;
-	lun = cmd->device->lun;
-
 	if (qla2x00_chip_is_down(vha))
 		return ret;
 
 	ql_log(ql_log_info, vha, 0x8012,
-	    "BUS RESET ISSUED nexus=%ld:%d:%llu.\n", vha->host_no, id, lun);
+	    "BUS RESET ISSUED nexus=%ld:%d.\n", vha->host_no, channel);
 
 	if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
 		ql_log(ql_log_fatal, vha, 0x8013,
@@ -1642,8 +1637,8 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
 
 eh_bus_reset_done:
 	ql_log(ql_log_warn, vha, 0x802b,
-	    "BUS RESET %s nexus=%ld:%d:%llu.\n",
-	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
+	    "BUS RESET %s nexus=%ld:%d.\n",
+	    (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, channel);
 
 	return ret;
 }
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index fff18af80068..217c65a6b9c6 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5348,17 +5348,16 @@ static int scsi_debug_target_reset(struct scsi_cmnd *SCpnt)
 	return SUCCESS;
 }
 
-static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
+static int scsi_debug_bus_reset(struct Scsi_Host * hp, int channel)
 {
-	struct scsi_device *sdp = SCpnt->device;
-	struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(sdp->host);
+	struct sdebug_host_info *sdbg_host = shost_to_sdebug_host(hp);
 	struct sdebug_dev_info *devip;
 	int k = 0;
 
 	++num_bus_resets;
 
 	if (SDEBUG_OPT_ALL_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp, "%s\n", __func__);
+		shost_printk(KERN_INFO, hp, "%s\n", __func__);
 
 	list_for_each_entry(devip, &sdbg_host->dev_info_list, dev_list) {
 		set_bit(SDEBUG_UA_BUS_RESET, devip->uas_bm);
@@ -5366,7 +5365,7 @@ static int scsi_debug_bus_reset(struct scsi_cmnd *SCpnt)
 	}
 
 	if (SDEBUG_OPT_RESET_NOISE & sdebug_opts)
-		sdev_printk(KERN_INFO, sdp,
+		shost_printk(KERN_INFO, hp,
 			    "%s: %d device(s) found in host\n", __func__, k);
 	return SUCCESS;
 }
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index f022bb1c3e4a..e3a36a1b57df 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -911,7 +911,7 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
 	if (!hostt->eh_bus_reset_handler)
 		return FAILED;
 
-	rtn = hostt->eh_bus_reset_handler(scmd);
+	rtn = hostt->eh_bus_reset_handler(host, scmd_channel(scmd));
 
 	if (rtn == SUCCESS) {
 		if (!hostt->skip_settle_delay)
diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 2ecc0ed60084..78c5c654023f 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -670,14 +670,13 @@ static int sym53c8xx_eh_target_reset_handler(struct scsi_cmnd *cmd)
 	return SCSI_SUCCESS;
 }
 
-static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
+static int sym53c8xx_eh_bus_reset_handler(struct Scsi_Host *shost, int channel)
 {
-	struct Scsi_Host *shost = cmd->device->host;
 	struct sym_data *sym_data = shost_priv(shost);
 	struct pci_dev *pdev = sym_data->pdev;
 	struct sym_hcb *np = sym_data->ncb;
 
-	scmd_printk(KERN_WARNING, cmd, "BUS RESET operation started\n");
+	shost_printk(KERN_WARNING, shost, "BUS RESET operation started\n");
 
 	/*
 	 * Escalate to host reset if the PCI bus went down
@@ -689,7 +688,7 @@ static int sym53c8xx_eh_bus_reset_handler(struct scsi_cmnd *cmd)
 	sym_reset_scsi_bus(np, 1);
 	spin_unlock_irq(shost->host_lock);
 
-	dev_warn(&cmd->device->sdev_gendev, "BUS RESET operation complete.\n");
+	shost_printk(KERN_WARNING, shost, "BUS RESET operation complete.\n");
 	return SCSI_SUCCESS;
 }
 
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index ddf1837babc0..9c62d446ea9e 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -947,13 +947,12 @@ static int pvscsi_host_reset(struct Scsi_Host *host)
 	return SUCCESS;
 }
 
-static int pvscsi_bus_reset(struct scsi_cmnd *cmd)
+static int pvscsi_bus_reset(struct Scsi_Host *host, int channel)
 {
-	struct Scsi_Host *host = cmd->device->host;
 	struct pvscsi_adapter *adapter = shost_priv(host);
 	unsigned long flags;
 
-	scmd_printk(KERN_INFO, cmd, "SCSI Bus reset\n");
+	shost_printk(KERN_INFO, host, "SCSI Bus reset\n");
 
 	/*
 	 * We don't want to queue new requests for this bus after
diff --git a/drivers/scsi/wd719x.c b/drivers/scsi/wd719x.c
index 42134f9510d5..bc48152e74b8 100644
--- a/drivers/scsi/wd719x.c
+++ b/drivers/scsi/wd719x.c
@@ -484,11 +484,11 @@ static int wd719x_abort(struct scsi_cmnd *cmd)
 	return SUCCESS;
 }
 
-static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
+static int wd719x_reset(struct Scsi_Host *shost, u8 opcode, u8 device)
 {
 	int result;
 	unsigned long flags;
-	struct wd719x *wd = shost_priv(cmd->device->host);
+	struct wd719x *wd = shost_priv(shost);
 	struct wd719x_scb *scb, *tmp;
 
 	dev_info(&wd->pdev->dev, "%s reset requested\n",
@@ -512,12 +512,13 @@ static int wd719x_reset(struct scsi_cmnd *cmd, u8 opcode, u8 device)
 
 static int wd719x_dev_reset(struct scsi_cmnd *cmd)
 {
-	return wd719x_reset(cmd, WD719X_CMD_RESET, cmd->device->id);
+	return wd719x_reset(cmd->device->host, WD719X_CMD_RESET,
+			    cmd->device->id);
 }
 
-static int wd719x_bus_reset(struct scsi_cmnd *cmd)
+static int wd719x_bus_reset(struct Scsi_Host *host, int channel)
 {
-	return wd719x_reset(cmd, WD719X_CMD_BUSRESET, 0);
+	return wd719x_reset(host, WD719X_CMD_BUSRESET, 0);
 }
 
 static int wd719x_host_reset(struct Scsi_Host *host)
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index c54e9805da53..4b5b10d64931 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -478,9 +478,9 @@ static int device_reset(struct scsi_cmnd *srb)
 }
 
 /* Simulate a SCSI bus reset by resetting the device's USB port. */
-static int bus_reset(struct scsi_cmnd *srb)
+static int bus_reset(struct Scsi_Host *shost, int channel)
 {
-	struct us_data *us = host_to_us(srb->device->host);
+	struct us_data *us = host_to_us(shost);
 	int result;
 
 	usb_stor_dbg(us, "%s called\n", __func__);
diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h
index 9e3ec411cdc6..32ef595db028 100644
--- a/include/scsi/scsi_host.h
+++ b/include/scsi/scsi_host.h
@@ -152,7 +152,7 @@ struct scsi_host_template {
 	int (* eh_abort_handler)(struct scsi_cmnd *);
 	int (* eh_device_reset_handler)(struct scsi_cmnd *);
 	int (* eh_target_reset_handler)(struct scsi_cmnd *);
-	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
+	int (* eh_bus_reset_handler)(struct Scsi_Host *, int);
 	int (* eh_host_reset_handler)(struct Scsi_Host *);
 
 	/*
-- 
2.35.3


^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2023-10-05 14:43 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02 21:59 [PATCH 0/7] scsi: EH rework main part Hannes Reinecke
2022-05-02 21:59 ` [PATCH 01/11] pmcraid: Select device in pmcraid_eh_bus_reset_handler() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 1/7] scsi: Use Scsi_Host as argument for eh_host_reset_handler Hannes Reinecke
2022-05-03 21:02   ` Lee Duncan
2022-05-02 21:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
2022-05-03 21:12   ` Lee Duncan
2022-05-06 11:20   ` Steffen Maier
2022-05-06 15:29   ` Sathya Prakash Veerichetty
2022-05-02 21:59 ` [PATCH 02/11] sym53c8xx_2: rework reset handling Hannes Reinecke
2022-05-02 21:59 ` [PATCH 03/11] libiscsi: use cls_session as argument for target and session reset Hannes Reinecke
2022-05-03 20:04   ` michael.christie
2022-05-02 21:59 ` [PATCH 3/7] scsi: Use scsi_target as argument for eh_target_reset_handler() Hannes Reinecke
2022-05-06 10:18   ` Steffen Maier
2022-05-02 21:59 ` [PATCH 04/11] scsi_transport_iscsi: use session as argument for iscsi_block_scsi_eh() Hannes Reinecke
2022-05-03 20:32   ` michael.christie
2022-05-02 21:59 ` [PATCH 4/7] scsi: Use scsi_device as argument to eh_device_reset_handler() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 05/11] pmcraid: select first available device for target reset Hannes Reinecke
2022-05-02 21:59 ` [PATCH 5/7] scsi: Do not allocate scsi command in scsi_ioctl_reset() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 06/11] bfa: Do not use scsi command to signal TMF status Hannes Reinecke
2022-05-02 21:59 ` [PATCH 6/7] scsi: remove SUBMITTED_BY_SCSI_RESET_IOCTL Hannes Reinecke
2022-05-02 21:59 ` [PATCH 07/11] aha152x: look for stuck command when resetting device Hannes Reinecke
2022-05-02 21:59 ` [PATCH 7/7] scsi_error: streamline scsi_eh_bus_device_reset() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 08/11] a1000u2w: do not rely on the command for inia100_device_reset() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 09/11] xen-scsifront: add scsi device as argument to scsifront_do_request() Hannes Reinecke
2022-05-02 21:59 ` [PATCH 10/11] fas216: Rework device reset to not rely on SCSI command pointer Hannes Reinecke
2022-05-02 21:59 ` [PATCH 11/11] csiostor: use separate TMF command Hannes Reinecke
2022-05-05  2:27 ` [PATCH 0/7] scsi: EH rework main part chenxiang (M)
2022-05-05 16:19   ` Hannes Reinecke
2022-05-06  3:24     ` chenxiang (M)
2023-10-02 15:59 [PATCHv5 0/7] scsi: EH rework, " Hannes Reinecke
2023-10-02 15:59 ` [PATCH 2/7] scsi: Use Scsi_Host and channel number as argument for eh_bus_reset_handler() Hannes Reinecke
2023-10-05 11:54   ` John Garry

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.