Device and target reset will be using different calling sequences, so there's not point in trying to combine both. Signed-off-by: Hannes Reinecke <hare@xxxxxxxx> Cc: Nilesh Javali <njavali@xxxxxxxxxxx> --- drivers/scsi/qla2xxx/qla_os.c | 91 +++++++++++++++++++++++++---------- 1 file changed, 65 insertions(+), 26 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 97568af82750..64820a3d34dd 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c @@ -1388,13 +1388,20 @@ static char *reset_errors[] = { }; static int -__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, - struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, uint64_t, int)) +qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); + struct qla_hw_data *ha = vha->hw; fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; int err; + if (qla2x00_isp_reg_stat(ha)) { + ql_log(ql_log_info, vha, 0x803e, + "PCI/Register disconnect, exiting.\n"); + qla_pci_set_eeh_busy(vha); + return FAILED; + } + if (!fcport) { return FAILED; } @@ -1407,8 +1414,8 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, return SUCCESS; ql_log(ql_log_info, vha, 0x8009, - "%s RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", name, vha->host_no, - cmd->device->id, cmd->device->lun, cmd); + "DEVICE RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", + vha->host_no, cmd->device->id, cmd->device->lun, cmd); err = 0; if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { @@ -1417,29 +1424,29 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, goto eh_reset_failed; } err = 2; - if (do_reset(fcport, cmd->device->lun, 1) + if (ha->isp_ops->lun_reset(fcport, cmd->device->lun, 1) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800c, - "do_reset failed for cmd=%p.\n", cmd); + "lun_reset failed for cmd=%p.\n", cmd); goto eh_reset_failed; } err = 3; if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, - cmd->device->lun, type) != QLA_SUCCESS) { + cmd->device->lun, WAIT_LUN) != QLA_SUCCESS) { ql_log(ql_log_warn, vha, 0x800d, "wait for pending cmds failed for cmd=%p.\n", cmd); goto eh_reset_failed; } ql_log(ql_log_info, vha, 0x800e, - "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, + "DEVICE RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", vha->host_no, cmd->device->id, cmd->device->lun, cmd); return SUCCESS; eh_reset_failed: ql_log(ql_log_info, vha, 0x800f, - "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, + "DEVICE RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, cmd); vha->reset_cmd_err_cnt++; @@ -1447,37 +1454,69 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, } static int -qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) +qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) { scsi_qla_host_t *vha = shost_priv(cmd->device->host); + fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; struct qla_hw_data *ha = vha->hw; + int err; if (qla2x00_isp_reg_stat(ha)) { - ql_log(ql_log_info, vha, 0x803e, + ql_log(ql_log_info, vha, 0x803f, "PCI/Register disconnect, exiting.\n"); qla_pci_set_eeh_busy(vha); return FAILED; } - return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, - ha->isp_ops->lun_reset); -} + if (!fcport) { + return FAILED; + } -static int -qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) -{ - scsi_qla_host_t *vha = shost_priv(cmd->device->host); - struct qla_hw_data *ha = vha->hw; + err = fc_block_scsi_eh(cmd); + if (err != 0) + return err; - if (qla2x00_isp_reg_stat(ha)) { - ql_log(ql_log_info, vha, 0x803f, - "PCI/Register disconnect, exiting.\n"); - qla_pci_set_eeh_busy(vha); - return FAILED; + if (fcport->deleted) + return SUCCESS; + + ql_log(ql_log_info, vha, 0x8009, + "TARGET RESET ISSUED nexus=%ld:%d:%llu cmd=%p.\n", vha->host_no, + cmd->device->id, cmd->device->lun, cmd); + + 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); + goto eh_reset_failed; + } + err = 2; + if (ha->isp_ops->target_reset(fcport, cmd->device->lun, 1) + != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800c, + "target_reset failed for cmd=%p.\n", cmd); + goto eh_reset_failed; } + err = 3; + if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, + cmd->device->lun, WAIT_TARGET) != QLA_SUCCESS) { + ql_log(ql_log_warn, vha, 0x800d, + "wait for pending cmds failed for cmd=%p.\n", cmd); + goto eh_reset_failed; + } + + ql_log(ql_log_info, vha, 0x800e, + "TARGET RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", + vha->host_no, cmd->device->id, cmd->device->lun, cmd); - return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, - ha->isp_ops->target_reset); + 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); + vha->reset_cmd_err_cnt++; + return FAILED; } /************************************************************************** -- 2.29.2