Commit c7a35705 authored by Bart Van Assche's avatar Bart Van Assche Committed by Martin K. Petersen

scsi: mpt3sas: Split _base_reset_handler(), mpt3sas_scsih_reset_handler() and...

scsi: mpt3sas: Split _base_reset_handler(), mpt3sas_scsih_reset_handler() and mpt3sas_ctl_reset_handler()

Split each of these functions in three functions - one function per reset
phase. This patch does not change any functionality but makes the code
easier to read.

Note: it is much easier to review the git diff -w output after having
applied this patch than by reviewing the patch itself.
Signed-off-by: default avatarBart Van Assche <bart.vanassche@wdc.com>
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Chaitra P B <chaitra.basappa@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 982ea6f9
...@@ -6840,65 +6840,69 @@ mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc) ...@@ -6840,65 +6840,69 @@ mpt3sas_base_detach(struct MPT3SAS_ADAPTER *ioc)
} }
/** /**
* _base_reset_handler - reset callback handler (for base) * _base_pre_reset_handler - pre reset handler
* @ioc: per adapter object * @ioc: per adapter object
* @reset_phase: phase
*
* The handler for doing any required cleanup or initialization.
*
* The reset phase can be MPT3_IOC_PRE_RESET, MPT3_IOC_AFTER_RESET,
* MPT3_IOC_DONE_RESET
*
* Return nothing.
*/ */
static void static void _base_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc)
_base_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase)
{ {
mpt3sas_scsih_reset_handler(ioc, reset_phase); mpt3sas_scsih_pre_reset_handler(ioc);
mpt3sas_ctl_reset_handler(ioc, reset_phase); mpt3sas_ctl_pre_reset_handler(ioc);
switch (reset_phase) { dtmprintk(ioc, pr_info(MPT3SAS_FMT
case MPT3_IOC_PRE_RESET: "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
dtmprintk(ioc, pr_info(MPT3SAS_FMT }
"%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
break; /**
case MPT3_IOC_AFTER_RESET: * _base_after_reset_handler - after reset handler
dtmprintk(ioc, pr_info(MPT3SAS_FMT * @ioc: per adapter object
"%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__)); */
if (ioc->transport_cmds.status & MPT3_CMD_PENDING) { static void _base_after_reset_handler(struct MPT3SAS_ADAPTER *ioc)
ioc->transport_cmds.status |= MPT3_CMD_RESET; {
mpt3sas_base_free_smid(ioc, ioc->transport_cmds.smid); mpt3sas_scsih_after_reset_handler(ioc);
complete(&ioc->transport_cmds.done); mpt3sas_ctl_after_reset_handler(ioc);
} dtmprintk(ioc, pr_info(MPT3SAS_FMT
if (ioc->base_cmds.status & MPT3_CMD_PENDING) { "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__));
ioc->base_cmds.status |= MPT3_CMD_RESET; if (ioc->transport_cmds.status & MPT3_CMD_PENDING) {
mpt3sas_base_free_smid(ioc, ioc->base_cmds.smid); ioc->transport_cmds.status |= MPT3_CMD_RESET;
complete(&ioc->base_cmds.done); mpt3sas_base_free_smid(ioc, ioc->transport_cmds.smid);
} complete(&ioc->transport_cmds.done);
if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) { }
ioc->port_enable_failed = 1; if (ioc->base_cmds.status & MPT3_CMD_PENDING) {
ioc->port_enable_cmds.status |= MPT3_CMD_RESET; ioc->base_cmds.status |= MPT3_CMD_RESET;
mpt3sas_base_free_smid(ioc, ioc->port_enable_cmds.smid); mpt3sas_base_free_smid(ioc, ioc->base_cmds.smid);
if (ioc->is_driver_loading) { complete(&ioc->base_cmds.done);
ioc->start_scan_failed = }
MPI2_IOCSTATUS_INTERNAL_ERROR; if (ioc->port_enable_cmds.status & MPT3_CMD_PENDING) {
ioc->start_scan = 0; ioc->port_enable_failed = 1;
ioc->port_enable_cmds.status = ioc->port_enable_cmds.status |= MPT3_CMD_RESET;
MPT3_CMD_NOT_USED; mpt3sas_base_free_smid(ioc, ioc->port_enable_cmds.smid);
} else if (ioc->is_driver_loading) {
complete(&ioc->port_enable_cmds.done); ioc->start_scan_failed =
} MPI2_IOCSTATUS_INTERNAL_ERROR;
if (ioc->config_cmds.status & MPT3_CMD_PENDING) { ioc->start_scan = 0;
ioc->config_cmds.status |= MPT3_CMD_RESET; ioc->port_enable_cmds.status =
mpt3sas_base_free_smid(ioc, ioc->config_cmds.smid); MPT3_CMD_NOT_USED;
ioc->config_cmds.smid = USHRT_MAX; } else {
complete(&ioc->config_cmds.done); complete(&ioc->port_enable_cmds.done);
} }
break;
case MPT3_IOC_DONE_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
break;
} }
if (ioc->config_cmds.status & MPT3_CMD_PENDING) {
ioc->config_cmds.status |= MPT3_CMD_RESET;
mpt3sas_base_free_smid(ioc, ioc->config_cmds.smid);
ioc->config_cmds.smid = USHRT_MAX;
complete(&ioc->config_cmds.done);
}
}
/**
* _base_reset_done_handler - reset done handler
* @ioc: per adapter object
*/
static void _base_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
{
mpt3sas_scsih_reset_done_handler(ioc);
mpt3sas_ctl_reset_done_handler(ioc);
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
} }
/** /**
...@@ -6974,13 +6978,13 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, ...@@ -6974,13 +6978,13 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT) if ((ioc_state & MPI2_IOC_STATE_MASK) == MPI2_IOC_STATE_FAULT)
is_fault = 1; is_fault = 1;
} }
_base_reset_handler(ioc, MPT3_IOC_PRE_RESET); _base_pre_reset_handler(ioc);
mpt3sas_wait_for_commands_to_complete(ioc); mpt3sas_wait_for_commands_to_complete(ioc);
_base_mask_interrupts(ioc); _base_mask_interrupts(ioc);
r = _base_make_ioc_ready(ioc, type); r = _base_make_ioc_ready(ioc, type);
if (r) if (r)
goto out; goto out;
_base_reset_handler(ioc, MPT3_IOC_AFTER_RESET); _base_after_reset_handler(ioc);
/* If this hard reset is called while port enable is active, then /* If this hard reset is called while port enable is active, then
* there is no reason to call make_ioc_operational * there is no reason to call make_ioc_operational
...@@ -7001,7 +7005,7 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc, ...@@ -7001,7 +7005,7 @@ mpt3sas_base_hard_reset_handler(struct MPT3SAS_ADAPTER *ioc,
r = _base_make_ioc_operational(ioc); r = _base_make_ioc_operational(ioc);
if (!r) if (!r)
_base_reset_handler(ioc, MPT3_IOC_DONE_RESET); _base_reset_done_handler(ioc);
out: out:
dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: %s\n", dtmprintk(ioc, pr_info(MPT3SAS_FMT "%s: %s\n",
......
...@@ -155,13 +155,6 @@ struct mpt3sas_nvme_cmd { ...@@ -155,13 +155,6 @@ struct mpt3sas_nvme_cmd {
__le64 prp2; __le64 prp2;
}; };
/*
* reset phases
*/
#define MPT3_IOC_PRE_RESET 1 /* prior to host reset */
#define MPT3_IOC_AFTER_RESET 2 /* just after host reset */
#define MPT3_IOC_DONE_RESET 3 /* links re-initialized */
/* /*
* logging format * logging format
*/ */
...@@ -1493,7 +1486,9 @@ struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc, ...@@ -1493,7 +1486,9 @@ struct scsi_cmnd *mpt3sas_scsih_scsi_lookup_get(struct MPT3SAS_ADAPTER *ioc,
u16 smid); u16 smid);
u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index, u8 mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
u32 reply); u32 reply);
void mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase); void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_scsih_after_reset_handler(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, u64 lun, int mpt3sas_scsih_issue_tm(struct MPT3SAS_ADAPTER *ioc, u16 handle, u64 lun,
u8 type, u16 smid_task, u16 msix_task, u8 timeout, u8 tr_method); u8 type, u16 smid_task, u16 msix_task, u8 timeout, u8 tr_method);
...@@ -1620,7 +1615,9 @@ void mpt3sas_ctl_init(ushort hbas_to_enumerate); ...@@ -1620,7 +1615,9 @@ void mpt3sas_ctl_init(ushort hbas_to_enumerate);
void mpt3sas_ctl_exit(ushort hbas_to_enumerate); void mpt3sas_ctl_exit(ushort hbas_to_enumerate);
u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index, u8 mpt3sas_ctl_done(struct MPT3SAS_ADAPTER *ioc, u16 smid, u8 msix_index,
u32 reply); u32 reply);
void mpt3sas_ctl_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase); void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_ctl_after_reset_handler(struct MPT3SAS_ADAPTER *ioc);
void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc);
u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 mpt3sas_ctl_event_callback(struct MPT3SAS_ADAPTER *ioc,
u8 msix_index, u32 reply); u8 msix_index, u32 reply);
void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc, void mpt3sas_ctl_add_to_event_log(struct MPT3SAS_ADAPTER *ioc,
......
...@@ -460,57 +460,66 @@ _ctl_verify_adapter(int ioc_number, struct MPT3SAS_ADAPTER **iocpp, ...@@ -460,57 +460,66 @@ _ctl_verify_adapter(int ioc_number, struct MPT3SAS_ADAPTER **iocpp,
/** /**
* mpt3sas_ctl_reset_handler - reset callback handler (for ctl) * mpt3sas_ctl_reset_handler - reset callback handler (for ctl)
* @ioc: per adapter object * @ioc: per adapter object
* @reset_phase: phase
* *
* The handler for doing any required cleanup or initialization. * The handler for doing any required cleanup or initialization.
*
* The reset phase can be MPT3_IOC_PRE_RESET, MPT3_IOC_AFTER_RESET,
* MPT3_IOC_DONE_RESET
*/ */
void void mpt3sas_ctl_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc)
mpt3sas_ctl_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase)
{ {
int i; int i;
u8 issue_reset; u8 issue_reset;
switch (reset_phase) { dtmprintk(ioc, pr_info(MPT3SAS_FMT
case MPT3_IOC_PRE_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__)); "%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
if (!(ioc->diag_buffer_status[i] & if (!(ioc->diag_buffer_status[i] &
MPT3_DIAG_BUFFER_IS_REGISTERED)) MPT3_DIAG_BUFFER_IS_REGISTERED))
continue; continue;
if ((ioc->diag_buffer_status[i] & if ((ioc->diag_buffer_status[i] &
MPT3_DIAG_BUFFER_IS_RELEASED)) MPT3_DIAG_BUFFER_IS_RELEASED))
continue; continue;
mpt3sas_send_diag_release(ioc, i, &issue_reset); mpt3sas_send_diag_release(ioc, i, &issue_reset);
} }
break; }
case MPT3_IOC_AFTER_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT /**
* mpt3sas_ctl_reset_handler - reset callback handler (for ctl)
* @ioc: per adapter object
*
* The handler for doing any required cleanup or initialization.
*/
void mpt3sas_ctl_after_reset_handler(struct MPT3SAS_ADAPTER *ioc)
{
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__)); "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__));
if (ioc->ctl_cmds.status & MPT3_CMD_PENDING) { if (ioc->ctl_cmds.status & MPT3_CMD_PENDING) {
ioc->ctl_cmds.status |= MPT3_CMD_RESET; ioc->ctl_cmds.status |= MPT3_CMD_RESET;
mpt3sas_base_free_smid(ioc, ioc->ctl_cmds.smid); mpt3sas_base_free_smid(ioc, ioc->ctl_cmds.smid);
complete(&ioc->ctl_cmds.done); complete(&ioc->ctl_cmds.done);
} }
break; }
case MPT3_IOC_DONE_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT /**
* mpt3sas_ctl_reset_handler - reset callback handler (for ctl)
* @ioc: per adapter object
*
* The handler for doing any required cleanup or initialization.
*/
void mpt3sas_ctl_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
{
int i;
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__)); "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) { for (i = 0; i < MPI2_DIAG_BUF_TYPE_COUNT; i++) {
if (!(ioc->diag_buffer_status[i] & if (!(ioc->diag_buffer_status[i] &
MPT3_DIAG_BUFFER_IS_REGISTERED)) MPT3_DIAG_BUFFER_IS_REGISTERED))
continue; continue;
if ((ioc->diag_buffer_status[i] & if ((ioc->diag_buffer_status[i] &
MPT3_DIAG_BUFFER_IS_RELEASED)) MPT3_DIAG_BUFFER_IS_RELEASED))
continue; continue;
ioc->diag_buffer_status[i] |= ioc->diag_buffer_status[i] |=
MPT3_DIAG_BUFFER_IS_DIAG_RESET; MPT3_DIAG_BUFFER_IS_DIAG_RESET;
}
break;
} }
} }
......
...@@ -9422,60 +9422,68 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc) ...@@ -9422,60 +9422,68 @@ _scsih_scan_for_devices_after_reset(struct MPT3SAS_ADAPTER *ioc)
ioc->name); ioc->name);
pr_info(MPT3SAS_FMT "scan devices: complete\n", ioc->name); pr_info(MPT3SAS_FMT "scan devices: complete\n", ioc->name);
} }
/** /**
* mpt3sas_scsih_reset_handler - reset callback handler (for scsih) * mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
* @ioc: per adapter object * @ioc: per adapter object
* @reset_phase: phase
* *
* The handler for doing any required cleanup or initialization. * The handler for doing any required cleanup or initialization.
*/
void mpt3sas_scsih_pre_reset_handler(struct MPT3SAS_ADAPTER *ioc)
{
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
}
/**
* mpt3sas_scsih_after_reset_handler - reset callback handler (for scsih)
* @ioc: per adapter object
* *
* The reset phase can be MPT3_IOC_PRE_RESET, MPT3_IOC_AFTER_RESET, * The handler for doing any required cleanup or initialization.
* MPT3_IOC_DONE_RESET
*
* Return nothing.
*/ */
void void
mpt3sas_scsih_reset_handler(struct MPT3SAS_ADAPTER *ioc, int reset_phase) mpt3sas_scsih_after_reset_handler(struct MPT3SAS_ADAPTER *ioc)
{ {
switch (reset_phase) { dtmprintk(ioc, pr_info(MPT3SAS_FMT
case MPT3_IOC_PRE_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_PRE_RESET\n", ioc->name, __func__));
break;
case MPT3_IOC_AFTER_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__)); "%s: MPT3_IOC_AFTER_RESET\n", ioc->name, __func__));
if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) { if (ioc->scsih_cmds.status & MPT3_CMD_PENDING) {
ioc->scsih_cmds.status |= MPT3_CMD_RESET; ioc->scsih_cmds.status |= MPT3_CMD_RESET;
mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid); mpt3sas_base_free_smid(ioc, ioc->scsih_cmds.smid);
complete(&ioc->scsih_cmds.done); complete(&ioc->scsih_cmds.done);
} }
if (ioc->tm_cmds.status & MPT3_CMD_PENDING) { if (ioc->tm_cmds.status & MPT3_CMD_PENDING) {
ioc->tm_cmds.status |= MPT3_CMD_RESET; ioc->tm_cmds.status |= MPT3_CMD_RESET;
mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid); mpt3sas_base_free_smid(ioc, ioc->tm_cmds.smid);
complete(&ioc->tm_cmds.done); complete(&ioc->tm_cmds.done);
} }
memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz); memset(ioc->pend_os_device_add, 0, ioc->pend_os_device_add_sz);
memset(ioc->device_remove_in_progress, 0, memset(ioc->device_remove_in_progress, 0,
ioc->device_remove_in_progress_sz); ioc->device_remove_in_progress_sz);
_scsih_fw_event_cleanup_queue(ioc); _scsih_fw_event_cleanup_queue(ioc);
_scsih_flush_running_cmds(ioc); _scsih_flush_running_cmds(ioc);
break; }
case MPT3_IOC_DONE_RESET:
dtmprintk(ioc, pr_info(MPT3SAS_FMT /**
* mpt3sas_scsih_reset_handler - reset callback handler (for scsih)
* @ioc: per adapter object
*
* The handler for doing any required cleanup or initialization.
*/
void
mpt3sas_scsih_reset_done_handler(struct MPT3SAS_ADAPTER *ioc)
{
dtmprintk(ioc, pr_info(MPT3SAS_FMT
"%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__)); "%s: MPT3_IOC_DONE_RESET\n", ioc->name, __func__));
if ((!ioc->is_driver_loading) && !(disable_discovery > 0 && if ((!ioc->is_driver_loading) && !(disable_discovery > 0 &&
!ioc->sas_hba.num_phys)) { !ioc->sas_hba.num_phys)) {
_scsih_prep_device_scan(ioc); _scsih_prep_device_scan(ioc);
_scsih_create_enclosure_list_after_reset(ioc); _scsih_create_enclosure_list_after_reset(ioc);
_scsih_search_responding_sas_devices(ioc); _scsih_search_responding_sas_devices(ioc);
_scsih_search_responding_pcie_devices(ioc); _scsih_search_responding_pcie_devices(ioc);
_scsih_search_responding_raid_devices(ioc); _scsih_search_responding_raid_devices(ioc);
_scsih_search_responding_expanders(ioc); _scsih_search_responding_expanders(ioc);
_scsih_error_recovery_delete_devices(ioc); _scsih_error_recovery_delete_devices(ioc);
}
break;
} }
} }
......
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