Commit 1d3324c3 authored by Matthew R. Ochs's avatar Matthew R. Ochs Committed by Martin K. Petersen

scsi: cxlflash: Fix to avoid EEH and host reset collisions

The EEH reset handler is ignorant to the current state of the driver
when processing a frozen event and initiating a device reset. This can
be an issue if an EEH event occurs while a user or stack initiated reset
is executing. More specifically, if an EEH occurs while the SCSI host
reset handler is active, the reset initiated by the EEH thread will
likely collide with the host reset thread. This can leave the device in
an inconsistent state, or worse, cause a system crash.

As a remedy, the EEH handler is updated to evaluate the device state and
take appropriate action (proceed, wait, or disconnect host). The host
reset handler is also updated to handle situations where an EEH occurred
during a host reset. In such situations, the host reset handler will
delay reporting back a success to give the EEH reset an opportunity to
complete.
Signed-off-by: default avatarMatthew R. Ochs <mrochs@linux.vnet.ibm.com>
Acked-by: default avatarUma Krishnan <ukrishn@linux.vnet.ibm.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent babf985d
...@@ -2042,6 +2042,11 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp) ...@@ -2042,6 +2042,11 @@ static int cxlflash_eh_device_reset_handler(struct scsi_cmnd *scp)
* cxlflash_eh_host_reset_handler() - reset the host adapter * cxlflash_eh_host_reset_handler() - reset the host adapter
* @scp: SCSI command from stack identifying host. * @scp: SCSI command from stack identifying host.
* *
* 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
* until the EEH recovery is complete or return success or failure based
* upon the current device state.
*
* Return: * Return:
* SUCCESS as defined in scsi/scsi.h * SUCCESS as defined in scsi/scsi.h
* FAILED as defined in scsi/scsi.h * FAILED as defined in scsi/scsi.h
...@@ -2074,7 +2079,8 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp) ...@@ -2074,7 +2079,8 @@ static int cxlflash_eh_host_reset_handler(struct scsi_cmnd *scp)
} else } else
cfg->state = STATE_NORMAL; cfg->state = STATE_NORMAL;
wake_up_all(&cfg->reset_waitq); wake_up_all(&cfg->reset_waitq);
break; ssleep(1);
/* fall through */
case STATE_RESET: case STATE_RESET:
wait_event(cfg->reset_waitq, cfg->state != STATE_RESET); wait_event(cfg->reset_waitq, cfg->state != STATE_RESET);
if (cfg->state == STATE_NORMAL) if (cfg->state == STATE_NORMAL)
...@@ -2590,6 +2596,9 @@ static int cxlflash_probe(struct pci_dev *pdev, ...@@ -2590,6 +2596,9 @@ static int cxlflash_probe(struct pci_dev *pdev,
* @pdev: PCI device struct. * @pdev: PCI device struct.
* @state: PCI channel state. * @state: PCI channel state.
* *
* When an EEH occurs during an active reset, wait until the reset is
* complete and then take action based upon the device state.
*
* Return: PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT * Return: PCI_ERS_RESULT_NEED_RESET or PCI_ERS_RESULT_DISCONNECT
*/ */
static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev,
...@@ -2603,6 +2612,10 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev, ...@@ -2603,6 +2612,10 @@ static pci_ers_result_t cxlflash_pci_error_detected(struct pci_dev *pdev,
switch (state) { switch (state) {
case pci_channel_io_frozen: case pci_channel_io_frozen:
wait_event(cfg->reset_waitq, cfg->state != STATE_RESET);
if (cfg->state == STATE_FAILTERM)
return PCI_ERS_RESULT_DISCONNECT;
cfg->state = STATE_RESET; cfg->state = STATE_RESET;
scsi_block_requests(cfg->host); scsi_block_requests(cfg->host);
drain_ioctls(cfg); drain_ioctls(cfg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment