First step in refactoring and fixing the error recovery and task management

code in the mpr and mps drivers.  Eliminate duplicated code and fix some
comments.
This commit is contained in:
Scott Long 2018-12-24 05:05:38 +00:00
parent 4db33e987e
commit b7f1ee7970
6 changed files with 28 additions and 39 deletions

View File

@ -229,9 +229,12 @@ mprsas_startup_decrement(struct mprsas_softc *sassc)
}
}
/* The firmware requires us to stop sending commands when we're doing task
* management, so refcount the TMs and keep the simq frozen when any are in
/*
* The firmware requires us to stop sending commands when we're doing task
* management.
* use.
* XXX The logic for serializing the device has been made lazy and moved to
* mprsas_prepare_for_tm().
*/
struct mpr_command *
mprsas_alloc_tm(struct mpr_softc *sc)
@ -467,8 +470,6 @@ mprsas_prepare_volume_remove(struct mprsas_softc *sassc, uint16_t handle)
cm->cm_targ = targ;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = mprsas_remove_volume;
cm->cm_complete_data = (void *)(uintptr_t)handle;
@ -531,8 +532,6 @@ mprsas_prepare_remove(struct mprsas_softc *sassc, uint16_t handle)
cm->cm_targ = targ;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = mprsas_remove_device;
cm->cm_complete_data = (void *)(uintptr_t)handle;
@ -1494,8 +1493,6 @@ mprsas_send_reset(struct mpr_softc *sc, struct mpr_command *tm, uint8_t type)
}
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete_data = (void *)tm;
callout_reset(&tm->cm_callout, MPR_RESET_TIMEOUT * hz,
@ -1623,8 +1620,6 @@ mprsas_send_abort(struct mpr_softc *sc, struct mpr_command *tm,
req->TaskMID = htole16(cm->cm_desc.Default.SMID);
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete = mprsas_abort_complete;
tm->cm_complete_data = (void *)tm;
tm->cm_targ = cm->cm_targ;
@ -3336,8 +3331,6 @@ mprsas_action_resetdev(struct mprsas_softc *sassc, union ccb *ccb)
req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete = mprsas_resetdev_complete;
tm->cm_complete_data = ccb;
@ -3750,6 +3743,13 @@ mprsas_read_cap_done(struct cam_periph *periph, union ccb *done_ccb)
#endif /* (__FreeBSD_version < 901503) || \
((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006)) */
/*
* Set the INRESET flag for this target so that no I/O will be sent to
* the target until the reset has completed. If an I/O request does
* happen, the devq will be frozen. The CCB holds the path which is
* used to release the devq. The devq is released and the CCB is freed
* when the TM completes.
*/
void
mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm,
struct mprsas_target *target, lun_id_t lun_id)
@ -3757,13 +3757,6 @@ mprsas_prepare_for_tm(struct mpr_softc *sc, struct mpr_command *tm,
union ccb *ccb;
path_id_t path_id;
/*
* Set the INRESET flag for this target so that no I/O will be sent to
* the target until the reset has completed. If an I/O request does
* happen, the devq will be frozen. The CCB holds the path which is
* used to release the devq. The devq is released and the CCB is freed
* when the TM completes.
*/
ccb = xpt_alloc_ccb_nowait();
if (ccb) {
path_id = cam_sim_path(sc->sassc->sim);

View File

@ -835,8 +835,6 @@ mpr_user_pass_thru(struct mpr_softc *sc, mpr_pass_thru_t *data)
task->TaskMID = cm->cm_desc.Default.SMID;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = NULL;
cm->cm_complete_data = NULL;

View File

@ -657,6 +657,8 @@ mpr_alloc_high_priority_command(struct mpr_softc *sc)
TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link);
cm->cm_state = MPR_CM_STATE_BUSY;
cm->cm_timeout_handler = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
return (cm);
}

View File

@ -227,9 +227,11 @@ mpssas_startup_decrement(struct mpssas_softc *sassc)
}
}
/* The firmware requires us to stop sending commands when we're doing task
* management, so refcount the TMs and keep the simq frozen when any are in
* use.
/*
* The firmware requires us to stop sending commands when we're doing task
* management.
* XXX The logic for serializing the device has been made lazy and moved to
* mpssas_prepare_for_tm().
*/
struct mps_command *
mpssas_alloc_tm(struct mps_softc *sc)
@ -472,8 +474,6 @@ mpssas_prepare_volume_remove(struct mpssas_softc *sassc, uint16_t handle)
cm->cm_targ = targ;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = mpssas_remove_volume;
cm->cm_complete_data = (void *)(uintptr_t)handle;
@ -536,7 +536,6 @@ mpssas_prepare_remove(struct mpssas_softc *sassc, uint16_t handle)
cm->cm_targ = targ;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = mpssas_remove_device;
cm->cm_complete_data = (void *)(uintptr_t)handle;
@ -1428,7 +1427,6 @@ mpssas_send_reset(struct mps_softc *sc, struct mps_command *tm, uint8_t type)
}
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete_data = (void *)tm;
callout_reset(&tm->cm_callout, MPS_RESET_TIMEOUT * hz,
@ -1557,7 +1555,6 @@ mpssas_send_abort(struct mps_softc *sc, struct mps_command *tm, struct mps_comma
req->TaskMID = htole16(cm->cm_desc.Default.SMID);
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete = mpssas_abort_complete;
tm->cm_complete_data = (void *)tm;
tm->cm_targ = cm->cm_targ;
@ -3079,7 +3076,6 @@ mpssas_action_resetdev(struct mpssas_softc *sassc, union ccb *ccb)
req->MsgFlags = MPI2_SCSITASKMGMT_MSGFLAGS_LINK_RESET;
tm->cm_data = NULL;
tm->cm_desc.HighPriority.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
tm->cm_complete = mpssas_resetdev_complete;
tm->cm_complete_data = ccb;
tm->cm_targ = targ;
@ -3475,6 +3471,13 @@ mpssas_read_cap_done(struct cam_periph *periph, union ccb *done_ccb)
#endif /* (__FreeBSD_version < 901503) || \
((__FreeBSD_version >= 1000000) && (__FreeBSD_version < 1000006)) */
/*
* Set the INRESET flag for this target so that no I/O will be sent to
* the target until the reset has completed. If an I/O request does
* happen, the devq will be frozen. The CCB holds the path which is
* used to release the devq. The devq is released and the CCB is freed
* when the TM completes.
*/
void
mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm,
struct mpssas_target *target, lun_id_t lun_id)
@ -3482,13 +3485,6 @@ mpssas_prepare_for_tm(struct mps_softc *sc, struct mps_command *tm,
union ccb *ccb;
path_id_t path_id;
/*
* Set the INRESET flag for this target so that no I/O will be sent to
* the target until the reset has completed. If an I/O request does
* happen, the devq will be frozen. The CCB holds the path which is
* used to release the devq. The devq is released and the CCB is freed
* when the TM completes.
*/
ccb = xpt_alloc_ccb_nowait();
if (ccb) {
path_id = cam_sim_path(sc->sassc->sim);

View File

@ -847,8 +847,6 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
task->TaskMID = cm->cm_desc.Default.SMID;
cm->cm_data = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
cm->cm_complete = NULL;
cm->cm_complete_data = NULL;

View File

@ -625,6 +625,8 @@ mps_alloc_high_priority_command(struct mps_softc *sc)
TAILQ_REMOVE(&sc->high_priority_req_list, cm, cm_link);
cm->cm_state = MPS_CM_STATE_BUSY;
cm->cm_timeout_handler = NULL;
cm->cm_desc.HighPriority.RequestFlags =
MPI2_REQ_DESCRIPT_FLAGS_HIGH_PRIORITY;
return (cm);
}