aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Barnett2021-03-11 14:16:38 -0600
committerMartin K. Petersen2021-04-05 23:02:31 -0400
commit37f3318199ce31122c389bafb092ee72a6123d9d (patch)
treee06eb503f72dd754d52b206eee4290f35e489f7d
parent4ccc354bac14b03e13c1d20131fe6d5a8e2c2c45 (diff)
scsi: smartpqi: Synchronize device resets with mutex
Remove some flags used to check for device resets already in progress. Allow only 1 reset operation at a time for the host. Link: https://lore.kernel.org/r/161549379810.25025.10194117431886743795.stgit@brunhilda Reviewed-by: Scott Benesh <scott.benesh@microchip.com> Reviewed-by: Mike McGowen <mike.mcgowen@microchip.com> Reviewed-by: Scott Teel <scott.teel@microchip.com> Signed-off-by: Kevin Barnett <kevin.barnett@microchip.com> Signed-off-by: Don Brace <don.brace@microchip.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
-rw-r--r--drivers/scsi/smartpqi/smartpqi.h1
-rw-r--r--drivers/scsi/smartpqi/smartpqi_init.c48
2 files changed, 13 insertions, 36 deletions
diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h
index a18c1f9afb37..ba7d26364b84 100644
--- a/drivers/scsi/smartpqi/smartpqi.h
+++ b/drivers/scsi/smartpqi/smartpqi.h
@@ -1295,7 +1295,6 @@ struct pqi_ctrl_info {
struct mutex ofa_mutex; /* serialize ofa */
bool controller_online;
bool block_requests;
- bool block_device_reset;
bool in_ofa;
bool in_shutdown;
u8 inbound_spanning_supported : 1;
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 41aa401e58eb..cc2b29a67ba0 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -247,12 +247,12 @@ static inline void pqi_save_ctrl_mode(struct pqi_ctrl_info *ctrl_info,
static inline void pqi_ctrl_block_device_reset(struct pqi_ctrl_info *ctrl_info)
{
- ctrl_info->block_device_reset = true;
+ mutex_lock(&ctrl_info->lun_reset_mutex);
}
-static inline bool pqi_device_reset_blocked(struct pqi_ctrl_info *ctrl_info)
+static inline void pqi_ctrl_unblock_device_reset(struct pqi_ctrl_info *ctrl_info)
{
- return ctrl_info->block_device_reset;
+ mutex_unlock(&ctrl_info->lun_reset_mutex);
}
static inline bool pqi_ctrl_blocked(struct pqi_ctrl_info *ctrl_info)
@@ -297,16 +297,6 @@ static inline bool pqi_device_offline(struct pqi_scsi_dev *device)
return device->device_offline;
}
-static inline void pqi_device_reset_start(struct pqi_scsi_dev *device)
-{
- device->in_reset = true;
-}
-
-static inline void pqi_device_reset_done(struct pqi_scsi_dev *device)
-{
- device->in_reset = false;
-}
-
static inline bool pqi_device_in_reset(struct pqi_scsi_dev *device)
{
return device->in_reset;
@@ -6098,7 +6088,7 @@ static int pqi_lun_reset(struct pqi_ctrl_info *ctrl_info,
#define PQI_LUN_RESET_RETRY_INTERVAL_MSECS 10000
#define PQI_LUN_RESET_PENDING_IO_TIMEOUT_SECS 120
-static int _pqi_device_reset(struct pqi_ctrl_info *ctrl_info,
+static int pqi_lun_reset_with_retries(struct pqi_ctrl_info *ctrl_info,
struct pqi_scsi_dev *device)
{
int rc;
@@ -6124,23 +6114,15 @@ static int pqi_device_reset(struct pqi_ctrl_info *ctrl_info,
{
int rc;
- mutex_lock(&ctrl_info->lun_reset_mutex);
-
pqi_ctrl_block_requests(ctrl_info);
pqi_ctrl_wait_until_quiesced(ctrl_info);
pqi_fail_io_queued_for_device(ctrl_info, device);
rc = pqi_wait_until_inbound_queues_empty(ctrl_info);
- pqi_device_reset_start(device);
- pqi_ctrl_unblock_requests(ctrl_info);
-
if (rc)
rc = FAILED;
else
- rc = _pqi_device_reset(ctrl_info, device);
-
- pqi_device_reset_done(device);
-
- mutex_unlock(&ctrl_info->lun_reset_mutex);
+ rc = pqi_lun_reset_with_retries(ctrl_info, device);
+ pqi_ctrl_unblock_requests(ctrl_info);
return rc;
}
@@ -6156,29 +6138,25 @@ static int pqi_eh_device_reset_handler(struct scsi_cmnd *scmd)
ctrl_info = shost_to_hba(shost);
device = scmd->device->hostdata;
+ mutex_lock(&ctrl_info->lun_reset_mutex);
+
dev_err(&ctrl_info->pci_dev->dev,
"resetting scsi %d:%d:%d:%d\n",
shost->host_no, device->bus, device->target, device->lun);
pqi_check_ctrl_health(ctrl_info);
- if (pqi_ctrl_offline(ctrl_info) ||
- pqi_device_reset_blocked(ctrl_info)) {
+ if (pqi_ctrl_offline(ctrl_info))
rc = FAILED;
- goto out;
- }
-
- pqi_wait_until_ofa_finished(ctrl_info);
-
- atomic_inc(&ctrl_info->sync_cmds_outstanding);
- rc = pqi_device_reset(ctrl_info, device);
- atomic_dec(&ctrl_info->sync_cmds_outstanding);
+ else
+ rc = pqi_device_reset(ctrl_info, device);
-out:
dev_err(&ctrl_info->pci_dev->dev,
"reset of scsi %d:%d:%d:%d: %s\n",
shost->host_no, device->bus, device->target, device->lun,
rc == SUCCESS ? "SUCCESS" : "FAILED");
+ mutex_unlock(&ctrl_info->lun_reset_mutex);
+
return rc;
}