* [PATCH 1/3] mptfusion: correct definitions for mptscsih_dev_reset()
2021-08-19 9:10 [PATCH 0/3] mptfusion: Fixes for SCSI EH rework Hannes Reinecke
@ 2021-08-19 9:10 ` Hannes Reinecke
2021-08-19 9:10 ` [PATCH 2/3] mptfc: use fc_block_rport() instead of open-coding it Hannes Reinecke
2021-08-19 9:10 ` [PATCH 3/3] mptfc: iterate over all rports during bus reset Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2021-08-19 9:10 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke
From: Hannes Reinecke <hare@suse.com>
mptscsih_dev_reset() is _not_ a device reset, but rather a
target reset. Nevertheless it's being used for either purpose.
This patch adds a correct implementation for mptscsih_dev_reset(),
and renames the original function to mptscsih_target_reset().
Signed-off-by: Hannes Reinecke <hare@suse.com>
---
drivers/message/fusion/mptscsih.c | 55 ++++++++++++++++++++++++++++++-
drivers/message/fusion/mptscsih.h | 1 +
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
index ce2e5b21978e..fb4e6b201d55 100644
--- a/drivers/message/fusion/mptscsih.c
+++ b/drivers/message/fusion/mptscsih.c
@@ -1794,7 +1794,7 @@ mptscsih_abort(struct scsi_cmnd * SCpnt)
/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
/**
- * mptscsih_dev_reset - Perform a SCSI TARGET_RESET! new_eh variant
+ * mptscsih_dev_reset - Perform a SCSI LOGICAL_UNIT_RESET!
* @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
*
* (linux scsi_host_template.eh_dev_reset_handler routine)
@@ -1809,6 +1809,58 @@ mptscsih_dev_reset(struct scsi_cmnd * SCpnt)
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){
+ printk(KERN_ERR MYNAM ": lun reset: "
+ "Can't locate host! (sc=%p)\n", SCpnt);
+ return FAILED;
+ }
+
+ ioc = hd->ioc;
+ printk(MYIOC_s_INFO_FMT "attempting lun reset! (sc=%p)\n",
+ ioc->name, SCpnt);
+ scsi_print_command(SCpnt);
+
+ vdevice = SCpnt->device->hostdata;
+ if (!vdevice || !vdevice->vtarget) {
+ retval = 0;
+ goto out;
+ }
+
+ retval = mptscsih_IssueTaskMgmt(hd,
+ MPI_SCSITASKMGMT_TASKTYPE_LOGICAL_UNIT_RESET,
+ vdevice->vtarget->channel,
+ vdevice->vtarget->id, vdevice->lun, 0,
+ mptscsih_get_tm_timeout(ioc));
+
+ out:
+ printk (MYIOC_s_INFO_FMT "lun reset: %s (sc=%p)\n",
+ ioc->name, ((retval == 0) ? "SUCCESS" : "FAILED" ), SCpnt);
+
+ if (retval == 0)
+ return SUCCESS;
+ else
+ return FAILED;
+}
+
+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/**
+ * mptscsih_target_reset - Perform a SCSI TARGET_RESET!
+ * @SCpnt: Pointer to scsi_cmnd structure, IO which reset is due to
+ *
+ * (linux scsi_host_template.eh_target_reset_handler routine)
+ *
+ * Returns SUCCESS or FAILED.
+ **/
+int
+mptscsih_target_reset(struct scsi_cmnd * SCpnt)
+{
+ 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){
@@ -3249,6 +3301,7 @@ EXPORT_SYMBOL(mptscsih_slave_destroy);
EXPORT_SYMBOL(mptscsih_slave_configure);
EXPORT_SYMBOL(mptscsih_abort);
EXPORT_SYMBOL(mptscsih_dev_reset);
+EXPORT_SYMBOL(mptscsih_target_reset);
EXPORT_SYMBOL(mptscsih_bus_reset);
EXPORT_SYMBOL(mptscsih_host_reset);
EXPORT_SYMBOL(mptscsih_bios_param);
diff --git a/drivers/message/fusion/mptscsih.h b/drivers/message/fusion/mptscsih.h
index 2baeefd9be7a..d8c195c48b7b 100644
--- a/drivers/message/fusion/mptscsih.h
+++ b/drivers/message/fusion/mptscsih.h
@@ -120,6 +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_bus_reset(struct scsi_cmnd * SCpnt);
extern int mptscsih_host_reset(struct scsi_cmnd *SCpnt);
extern int mptscsih_bios_param(struct scsi_device * sdev, struct block_device *bdev, sector_t capacity, int geom[]);
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] mptfc: use fc_block_rport() instead of open-coding it
2021-08-19 9:10 [PATCH 0/3] mptfusion: Fixes for SCSI EH rework Hannes Reinecke
2021-08-19 9:10 ` [PATCH 1/3] mptfusion: correct definitions for mptscsih_dev_reset() Hannes Reinecke
@ 2021-08-19 9:10 ` Hannes Reinecke
2021-08-19 9:10 ` [PATCH 3/3] mptfc: iterate over all rports during bus reset Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2021-08-19 9:10 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke
mptfc_block_error_handler() is just an open-coded version of
fc_block_rport().
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/message/fusion/mptfc.c | 92 +++++++++++++++-------------------
1 file changed, 41 insertions(+), 51 deletions(-)
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 572333fadd68..3962951c1e9a 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -183,73 +183,63 @@ static struct fc_function_template mptfc_transport_functions = {
};
static int
-mptfc_block_error_handler(struct scsi_cmnd *SCpnt,
- int (*func)(struct scsi_cmnd *SCpnt),
- const char *caller)
+mptfc_abort(struct scsi_cmnd *SCpnt)
{
- MPT_SCSI_HOST *hd;
struct scsi_device *sdev = SCpnt->device;
struct Scsi_Host *shost = sdev->host;
struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
- unsigned long flags;
- int ready;
- MPT_ADAPTER *ioc;
- int loops = 40; /* seconds */
+ MPT_SCSI_HOST *hd = shost_priv(shost);
+ MPT_ADAPTER *ioc = hd->ioc;
+ int rval;
- hd = shost_priv(SCpnt->device->host);
- ioc = hd->ioc;
- spin_lock_irqsave(shost->host_lock, flags);
- while ((ready = fc_remote_port_chkready(rport) >> 16) == DID_IMM_RETRY
- || (loops > 0 && ioc->active == 0)) {
- spin_unlock_irqrestore(shost->host_lock, flags);
- dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
- "mptfc_block_error_handler.%d: %d:%llu, port status is "
- "%x, active flag %d, deferring %s recovery.\n",
- ioc->name, ioc->sh->host_no,
- SCpnt->device->id, SCpnt->device->lun,
- ready, ioc->active, caller));
- msleep(1000);
- spin_lock_irqsave(shost->host_lock, flags);
- loops --;
- }
- spin_unlock_irqrestore(shost->host_lock, flags);
-
- if (ready == DID_NO_CONNECT || !SCpnt->device->hostdata
- || ioc->active == 0) {
- dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
- "%s.%d: %d:%llu, failing recovery, "
- "port state %x, active %d, vdevice %p.\n", caller,
- ioc->name, ioc->sh->host_no,
- SCpnt->device->id, SCpnt->device->lun, ready,
- ioc->active, SCpnt->device->hostdata));
- return FAILED;
- }
+ rval = fc_block_rport(rport);
+ if (rval)
+ return rval;
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
- "%s.%d: %d:%llu, executing recovery.\n", caller,
- ioc->name, ioc->sh->host_no,
- SCpnt->device->id, SCpnt->device->lun));
- return (*func)(SCpnt);
-}
-
-static int
-mptfc_abort(struct scsi_cmnd *SCpnt)
-{
- return
- mptfc_block_error_handler(SCpnt, mptscsih_abort, __func__);
+ "%s.%d: %d:%llu, executing recovery.\n",
+ ioc->name, __func__, ioc->sh->host_no,
+ sdev->id, sdev->lun));
+ return mptscsih_abort(SCpnt);
}
static int
mptfc_dev_reset(struct scsi_cmnd *SCpnt)
{
- return
- mptfc_block_error_handler(SCpnt, mptscsih_dev_reset, __func__);
+ struct scsi_device *sdev = SCpnt->device;
+ struct Scsi_Host *shost = sdev->host;
+ struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+ MPT_SCSI_HOST *hd = shost_priv(shost);
+ MPT_ADAPTER *ioc = hd->ioc;
+ int rval;
+
+ rval = fc_block_rport(rport);
+ if (rval)
+ return rval;
+ dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
+ "%s.%d: %d:%llu, executing recovery.\n",
+ ioc->name, __func__, ioc->sh->host_no,
+ sdev->id, sdev->lun));
+ return mptscsih_dev_reset(SCpnt);
}
static int
mptfc_bus_reset(struct scsi_cmnd *SCpnt)
{
- return
- mptfc_block_error_handler(SCpnt, mptscsih_bus_reset, __func__);
+ struct scsi_device *sdev = SCpnt->device;
+ struct Scsi_Host *shost = sdev->host;
+ struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
+ MPT_SCSI_HOST *hd = shost_priv(shost);
+ MPT_ADAPTER *ioc = hd->ioc;
+ int rval;
+
+ rval = fc_block_rport(rport);
+ if (rval)
+ return rval;
+ dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
+ "%s.%d: %d:%llu, executing recovery.\n",
+ ioc->name, __func__, ioc->sh->host_no,
+ sdev->id, sdev->lun));
+ return mptscsih_bus_reset(SCpnt);
}
static void
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] mptfc: iterate over all rports during bus reset
2021-08-19 9:10 [PATCH 0/3] mptfusion: Fixes for SCSI EH rework Hannes Reinecke
2021-08-19 9:10 ` [PATCH 1/3] mptfusion: correct definitions for mptscsih_dev_reset() Hannes Reinecke
2021-08-19 9:10 ` [PATCH 2/3] mptfc: use fc_block_rport() instead of open-coding it Hannes Reinecke
@ 2021-08-19 9:10 ` Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2021-08-19 9:10 UTC (permalink / raw)
To: Martin K. Petersen
Cc: Christoph Hellwig, James Bottomley, linux-scsi, Hannes Reinecke
When issuing a bus reset we need to call fc_block_rport() on all
ports, otherwise we might be executing the bus reset call prematurely.
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/message/fusion/mptfc.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 3962951c1e9a..952dc85bba08 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -227,14 +227,18 @@ mptfc_bus_reset(struct scsi_cmnd *SCpnt)
{
struct scsi_device *sdev = SCpnt->device;
struct Scsi_Host *shost = sdev->host;
- struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
MPT_SCSI_HOST *hd = shost_priv(shost);
MPT_ADAPTER *ioc = hd->ioc;
+ struct mptfc_rport_info *ri;
int rval;
- rval = fc_block_rport(rport);
- if (rval)
- return rval;
+ list_for_each_entry(ri, &ioc->fc_rports, list) {
+ rval = fc_block_rport(ri->rport);
+ if (rval)
+ return rval;
+ if (ioc->active == 0)
+ return FAILED;
+ }
dfcprintk (ioc, printk(MYIOC_s_DEBUG_FMT
"%s.%d: %d:%llu, executing recovery.\n",
ioc->name, __func__, ioc->sh->host_no,
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread