aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/mps
diff options
context:
space:
mode:
authorKenneth D. Merry <ken@FreeBSD.org>2017-08-10 14:59:17 +0000
committerKenneth D. Merry <ken@FreeBSD.org>2017-08-10 14:59:17 +0000
commit6d4ffcb4acd13b34175df069e09e8d7920188bd4 (patch)
treeb8e5b776c8447892158af9f2df0622274e4e442d /sys/dev/mps
parent5f593927a84cb8e4632cfc8fb88883853967e38b (diff)
Notes
Diffstat (limited to 'sys/dev/mps')
-rw-r--r--sys/dev/mps/mps.c30
-rw-r--r--sys/dev/mps/mps_config.c108
-rw-r--r--sys/dev/mps/mps_sas.c7
-rw-r--r--sys/dev/mps/mps_sas_lsi.c13
-rw-r--r--sys/dev/mps/mps_user.c38
-rw-r--r--sys/dev/mps/mpsvar.h3
6 files changed, 118 insertions, 81 deletions
diff --git a/sys/dev/mps/mps.c b/sys/dev/mps/mps.c
index 378cb044e66a..56cb61d8483a 100644
--- a/sys/dev/mps/mps.c
+++ b/sys/dev/mps/mps.c
@@ -427,6 +427,8 @@ mps_iocfacts_allocate(struct mps_softc *sc, uint8_t attaching)
/* Only deallocate and reallocate if relevant IOC Facts have changed */
reallocating = FALSE;
+ sc->mps_flags &= ~MPS_FLAGS_REALLOCATED;
+
if ((!attaching) &&
((saved_facts.MsgVersion != sc->facts->MsgVersion) ||
(saved_facts.HeaderVersion != sc->facts->HeaderVersion) ||
@@ -447,6 +449,9 @@ mps_iocfacts_allocate(struct mps_softc *sc, uint8_t attaching)
(saved_facts.MaxPersistentEntries !=
sc->facts->MaxPersistentEntries))) {
reallocating = TRUE;
+
+ /* Record that we reallocated everything */
+ sc->mps_flags |= MPS_FLAGS_REALLOCATED;
}
/*
@@ -2075,7 +2080,7 @@ mps_update_events(struct mps_softc *sc, struct mps_event_handle *handle,
u32 *mask)
{
MPI2_EVENT_NOTIFICATION_REQUEST *evtreq;
- MPI2_EVENT_NOTIFICATION_REPLY *reply;
+ MPI2_EVENT_NOTIFICATION_REPLY *reply = NULL;
struct mps_command *cm;
int error, i;
@@ -2113,8 +2118,9 @@ mps_update_events(struct mps_softc *sc, struct mps_event_handle *handle,
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_EVENT_NOTIFICATION_REPLY *)cm->cm_reply;
if ((reply == NULL) ||
(reply->IOCStatus & MPI2_IOCSTATUS_MASK) != MPI2_IOCSTATUS_SUCCESS)
error = ENXIO;
@@ -2124,7 +2130,8 @@ mps_update_events(struct mps_softc *sc, struct mps_event_handle *handle,
mps_dprint(sc, MPS_TRACE, "%s finished error %d\n", __func__, error);
- mps_free_command(sc, cm);
+ if (cm != NULL)
+ mps_free_command(sc, cm);
return (error);
}
@@ -2530,11 +2537,12 @@ mps_map_command(struct mps_softc *sc, struct mps_command *cm)
* be executed and enqueued automatically. Other errors come from msleep().
*/
int
-mps_wait_command(struct mps_softc *sc, struct mps_command *cm, int timeout,
+mps_wait_command(struct mps_softc *sc, struct mps_command **cmp, int timeout,
int sleep_flag)
{
int error, rc;
struct timeval cur_time, start_time;
+ struct mps_command *cm = *cmp;
if (sc->mps_flags & MPS_FLAGS_DIAGRESET)
return EBUSY;
@@ -2588,6 +2596,13 @@ mps_wait_command(struct mps_softc *sc, struct mps_command *cm, int timeout,
rc = mps_reinit(sc);
mps_dprint(sc, MPS_FAULT, "Reinit %s\n", (rc == 0) ? "success" :
"failed");
+ if (sc->mps_flags & MPS_FLAGS_REALLOCATED) {
+ /*
+ * Tell the caller that we freed the command in a
+ * reinit.
+ */
+ *cmp = NULL;
+ }
error = ETIMEDOUT;
}
return (error);
@@ -2654,11 +2669,12 @@ mps_read_config_page(struct mps_softc *sc, struct mps_config_params *params)
cm->cm_complete = mps_config_complete;
return (mps_map_command(sc, cm));
} else {
- error = mps_wait_command(sc, cm, 0, CAN_SLEEP);
+ error = mps_wait_command(sc, &cm, 0, CAN_SLEEP);
if (error) {
mps_dprint(sc, MPS_FAULT,
"Error %d reading config page\n", error);
- mps_free_command(sc, cm);
+ if (cm != NULL)
+ mps_free_command(sc, cm);
return (error);
}
mps_config_complete(sc, cm);
diff --git a/sys/dev/mps/mps_config.c b/sys/dev/mps/mps_config.c
index e435d4f83d67..cfaf0a472f6a 100644
--- a/sys/dev/mps/mps_config.c
+++ b/sys/dev/mps/mps_config.c
@@ -71,7 +71,7 @@ mps_config_get_ioc_pg8(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
Mpi2IOCPage8_t *config_page)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
MPI2_CONFIG_PAGE_IOC_8 *page = NULL;
int error = 0;
@@ -94,8 +94,9 @@ mps_config_get_ioc_pg8(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
request->Header.PageVersion = MPI2_IOCPAGE8_PAGEVERSION;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -152,8 +153,9 @@ mps_config_get_ioc_pg8(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
}
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -200,7 +202,7 @@ int
mps_config_get_man_pg10(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
pMpi2ManufacturingPagePS_t page = NULL;
uint32_t *pPS_info;
@@ -230,8 +232,9 @@ mps_config_get_man_pg10(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply)
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
@@ -286,8 +289,9 @@ mps_config_get_man_pg10(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply)
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
@@ -559,7 +563,7 @@ mps_config_get_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
Mpi2DriverMappingPage0_t *config_page, u16 sz)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2DriverMappingPage0_t *page = NULL;
int error = 0;
@@ -586,8 +590,9 @@ mps_config_get_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
MPI2_DPM_PGAD_ENTRY_COUNT_SHIFT;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -646,8 +651,9 @@ mps_config_get_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
goto out;
}
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -695,7 +701,7 @@ int mps_config_set_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
Mpi2DriverMappingPage0_t *config_page, u16 entry_idx)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
MPI2_CONFIG_PAGE_DRIVER_MAPPING_0 *page = NULL;
int error = 0;
@@ -722,8 +728,9 @@ int mps_config_set_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
request->PageAddress |= htole16(entry_idx);
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -784,8 +791,9 @@ int mps_config_set_dpm_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
bcopy(config_page, page, MIN(cm->cm_length,
(sizeof(Mpi2DriverMappingPage0_t))));
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -833,7 +841,7 @@ mps_config_get_sas_device_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
*mpi_reply, Mpi2SasDevicePage0_t *config_page, u32 form, u16 handle)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2SasDevicePage0_t *page = NULL;
int error = 0;
@@ -857,8 +865,9 @@ mps_config_get_sas_device_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
request->Header.PageVersion = MPI2_SASDEVICE0_PAGEVERSION;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -917,8 +926,9 @@ mps_config_get_sas_device_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
}
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -966,7 +976,7 @@ mps_config_get_bios_pg3(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
Mpi2BiosPage3_t *config_page)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2BiosPage3_t *page = NULL;
int error = 0;
@@ -989,8 +999,9 @@ mps_config_get_bios_pg3(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
request->Header.PageVersion = MPI2_BIOSPAGE3_PAGEVERSION;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -1047,8 +1058,9 @@ mps_config_get_bios_pg3(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
}
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -1096,7 +1108,7 @@ mps_config_get_raid_volume_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
*mpi_reply, Mpi2RaidVolPage0_t *config_page, u32 page_address)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2RaidVolPage0_t *page = NULL;
int error = 0;
@@ -1124,8 +1136,9 @@ mps_config_get_raid_volume_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
@@ -1181,8 +1194,9 @@ mps_config_get_raid_volume_pg0(struct mps_softc *sc, Mpi2ConfigReply_t
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
@@ -1225,7 +1239,7 @@ mps_config_get_raid_volume_pg1(struct mps_softc *sc, Mpi2ConfigReply_t
*mpi_reply, Mpi2RaidVolPage1_t *config_page, u32 form, u16 handle)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2RaidVolPage1_t *page = NULL;
int error = 0;
@@ -1248,8 +1262,9 @@ mps_config_get_raid_volume_pg1(struct mps_softc *sc, Mpi2ConfigReply_t
request->Header.PageVersion = MPI2_RAIDVOLPAGE1_PAGEVERSION;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
cm->cm_data = NULL;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -1307,8 +1322,9 @@ mps_config_get_raid_volume_pg1(struct mps_softc *sc, Mpi2ConfigReply_t
}
cm->cm_data = page;
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -1382,7 +1398,7 @@ mps_config_get_raid_pd_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
Mpi2RaidPhysDiskPage0_t *config_page, u32 page_address)
{
MPI2_CONFIG_REQUEST *request;
- MPI2_CONFIG_REPLY *reply;
+ MPI2_CONFIG_REPLY *reply = NULL;
struct mps_command *cm;
Mpi2RaidPhysDiskPage0_t *page = NULL;
int error = 0;
@@ -1410,8 +1426,9 @@ mps_config_get_raid_pd_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
@@ -1467,8 +1484,9 @@ mps_config_get_raid_pd_pg0(struct mps_softc *sc, Mpi2ConfigReply_t *mpi_reply,
* This page must be polled because the IOC isn't ready yet when this
* page is needed.
*/
- error = mps_wait_command(sc, cm, 60, 0);
- reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
+ error = mps_wait_command(sc, &cm, 60, 0);
+ if (cm != NULL)
+ reply = (MPI2_CONFIG_REPLY *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/* If the poll returns error then we need to do diag reset */
diff --git a/sys/dev/mps/mps_sas.c b/sys/dev/mps/mps_sas.c
index be864effc69f..c09df175425d 100644
--- a/sys/dev/mps/mps_sas.c
+++ b/sys/dev/mps/mps_sas.c
@@ -1131,13 +1131,8 @@ mpssas_complete_all_commands(struct mps_softc *sc)
completed = 1;
}
- if (cm->cm_sc->io_cmds_active != 0) {
+ if (cm->cm_sc->io_cmds_active != 0)
cm->cm_sc->io_cmds_active--;
- } else {
- mps_dprint(cm->cm_sc, MPS_INFO, "Warning: "
- "io_cmds_active is out of sync - resynching to "
- "0\n");
- }
if ((completed == 0) && (cm->cm_state != MPS_CM_STATE_FREE)) {
/* this should never happen, but if it does, log */
diff --git a/sys/dev/mps/mps_sas_lsi.c b/sys/dev/mps/mps_sas_lsi.c
index 618d193bfedf..3d62a9a4bff5 100644
--- a/sys/dev/mps/mps_sas_lsi.c
+++ b/sys/dev/mps/mps_sas_lsi.c
@@ -915,7 +915,7 @@ mpssas_get_sata_identify(struct mps_softc *sc, u16 handle,
Mpi2SataPassthroughReply_t *mpi_reply, char *id_buffer, int sz, u32 devinfo)
{
Mpi2SataPassthroughRequest_t *mpi_request;
- Mpi2SataPassthroughReply_t *reply;
+ Mpi2SataPassthroughReply_t *reply = NULL;
struct mps_command *cm;
char *buffer;
int error = 0;
@@ -957,12 +957,14 @@ mpssas_get_sata_identify(struct mps_softc *sc, u16 handle,
"command\n", __func__);
callout_reset(&cm->cm_callout, MPS_ATA_ID_TIMEOUT * hz,
mpssas_ata_id_timeout, cm);
- error = mps_wait_command(sc, cm, 60, CAN_SLEEP);
+ error = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
mps_dprint(sc, MPS_XINFO, "%s stop timeout counter for SATA ID "
"command\n", __func__);
+ /* XXX KDM need to fix the case where this command is destroyed */
callout_stop(&cm->cm_callout);
- reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply;
+ if (cm != NULL)
+ reply = (Mpi2SataPassthroughReply_t *)cm->cm_reply;
if (error || (reply == NULL)) {
/* FIXME */
/*
@@ -989,7 +991,8 @@ out:
* it. The command will be freed after sending a target reset TM. If
* the command did timeout, use EWOULDBLOCK.
*/
- if ((cm->cm_flags & MPS_CM_FLAGS_SATA_ID_TIMEOUT) == 0)
+ if ((cm != NULL)
+ && (cm->cm_flags & MPS_CM_FLAGS_SATA_ID_TIMEOUT) == 0)
mps_free_command(sc, cm);
else if (error == 0)
error = EWOULDBLOCK;
@@ -1285,7 +1288,7 @@ mpssas_ir_shutdown(struct mps_softc *sc)
action->Action = MPI2_RAID_ACTION_SYSTEM_SHUTDOWN_INITIATED;
cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE;
mps_lock(sc);
- mps_wait_command(sc, cm, 5, CAN_SLEEP);
+ mps_wait_command(sc, &cm, 5, CAN_SLEEP);
mps_unlock(sc);
/*
diff --git a/sys/dev/mps/mps_user.c b/sys/dev/mps/mps_user.c
index dc1ced14840f..c245efa969e9 100644
--- a/sys/dev/mps/mps_user.c
+++ b/sys/dev/mps/mps_user.c
@@ -677,7 +677,7 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
if (cm == NULL) {
mps_printf(sc, "%s: no mps requests\n", __func__);
err = ENOMEM;
- goto Ret;
+ goto RetFree;
}
mps_unlock(sc);
@@ -719,12 +719,12 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
goto RetFreeUnlocked;
mps_lock(sc);
- err = mps_wait_command(sc, cm, 60, CAN_SLEEP);
+ err = mps_wait_command(sc, &cm, 60, CAN_SLEEP);
- if (err) {
+ if (err || (cm == NULL)) {
mps_printf(sc, "%s: invalid request: error %d\n",
__func__, err);
- goto Ret;
+ goto RetFree;
}
rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply;
@@ -747,9 +747,9 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd)
RetFreeUnlocked:
mps_lock(sc);
+RetFree:
if (cm != NULL)
mps_free_command(sc, cm);
-Ret:
mps_unlock(sc);
if (buf != NULL)
free(buf, M_MPSUSER);
@@ -760,7 +760,7 @@ static int
mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
{
MPI2_REQUEST_HEADER *hdr, tmphdr;
- MPI2_DEFAULT_REPLY *rpl;
+ MPI2_DEFAULT_REPLY *rpl = NULL;
struct mps_command *cm = NULL;
int err = 0, dir = 0, sz;
uint8_t function = 0;
@@ -861,7 +861,7 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
err = 1;
} else {
mpssas_prepare_for_tm(sc, cm, targ, CAM_LUN_WILDCARD);
- err = mps_wait_command(sc, cm, 30, CAN_SLEEP);
+ err = mps_wait_command(sc, &cm, 30, CAN_SLEEP);
}
if (err != 0) {
@@ -872,7 +872,7 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
/*
* Copy the reply data and sense data to user space.
*/
- if (cm->cm_reply != NULL) {
+ if ((cm != NULL) && (cm->cm_reply != NULL)) {
rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply;
sz = rpl->MsgLength * 4;
@@ -993,9 +993,9 @@ mps_user_pass_thru(struct mps_softc *sc, mps_pass_thru_t *data)
mps_lock(sc);
- err = mps_wait_command(sc, cm, 30, CAN_SLEEP);
+ err = mps_wait_command(sc, &cm, 30, CAN_SLEEP);
- if (err) {
+ if (err || (cm == NULL)) {
mps_printf(sc, "%s: invalid request: error %d\n", __func__,
err);
mps_unlock(sc);
@@ -1161,7 +1161,7 @@ mps_post_fw_diag_buffer(struct mps_softc *sc,
mps_fw_diagnostic_buffer_t *pBuffer, uint32_t *return_code)
{
MPI2_DIAG_BUFFER_POST_REQUEST *req;
- MPI2_DIAG_BUFFER_POST_REPLY *reply;
+ MPI2_DIAG_BUFFER_POST_REPLY *reply = NULL;
struct mps_command *cm = NULL;
int i, status;
@@ -1208,8 +1208,8 @@ mps_post_fw_diag_buffer(struct mps_softc *sc,
/*
* Send command synchronously.
*/
- status = mps_wait_command(sc, cm, 30, CAN_SLEEP);
- if (status) {
+ status = mps_wait_command(sc, &cm, 30, CAN_SLEEP);
+ if (status || (cm == NULL)) {
mps_printf(sc, "%s: invalid request: error %d\n", __func__,
status);
status = MPS_DIAG_FAILURE;
@@ -1240,7 +1240,8 @@ mps_post_fw_diag_buffer(struct mps_softc *sc,
status = MPS_DIAG_SUCCESS;
done:
- mps_free_command(sc, cm);
+ if (cm != NULL)
+ mps_free_command(sc, cm);
return (status);
}
@@ -1250,7 +1251,7 @@ mps_release_fw_diag_buffer(struct mps_softc *sc,
uint32_t diag_type)
{
MPI2_DIAG_RELEASE_REQUEST *req;
- MPI2_DIAG_RELEASE_REPLY *reply;
+ MPI2_DIAG_RELEASE_REPLY *reply = NULL;
struct mps_command *cm = NULL;
int status;
@@ -1294,8 +1295,8 @@ mps_release_fw_diag_buffer(struct mps_softc *sc,
/*
* Send command synchronously.
*/
- status = mps_wait_command(sc, cm, 30, CAN_SLEEP);
- if (status) {
+ status = mps_wait_command(sc, &cm, 30, CAN_SLEEP);
+ if (status || (cm == NULL)) {
mps_printf(sc, "%s: invalid request: error %d\n", __func__,
status);
status = MPS_DIAG_FAILURE;
@@ -1330,6 +1331,9 @@ mps_release_fw_diag_buffer(struct mps_softc *sc,
}
done:
+ if (cm != NULL)
+ mps_free_command(sc, cm);
+
return (status);
}
diff --git a/sys/dev/mps/mpsvar.h b/sys/dev/mps/mpsvar.h
index b7cc549d3a96..b8d074a8e2bb 100644
--- a/sys/dev/mps/mpsvar.h
+++ b/sys/dev/mps/mpsvar.h
@@ -271,6 +271,7 @@ struct mps_softc {
#define MPS_FLAGS_DIAGRESET (1 << 4)
#define MPS_FLAGS_ATTACH_DONE (1 << 5)
#define MPS_FLAGS_WD_AVAILABLE (1 << 6)
+#define MPS_FLAGS_REALLOCATED (1 << 7)
u_int mps_debug;
u_int disable_msix;
u_int disable_msi;
@@ -697,7 +698,7 @@ void mpssas_record_event(struct mps_softc *sc,
MPI2_EVENT_NOTIFICATION_REPLY *event_reply);
int mps_map_command(struct mps_softc *sc, struct mps_command *cm);
-int mps_wait_command(struct mps_softc *sc, struct mps_command *cm, int timeout,
+int mps_wait_command(struct mps_softc *sc, struct mps_command **cm, int timeout,
int sleep_flag);
int mps_config_get_bios_pg3(struct mps_softc *sc, Mpi2ConfigReply_t