Skip to content

Commit 4542c2a

Browse files
slmslm
slm
authored and
slm
committed
MFC r302031
- No log bit in IOCStatus and endian-safe changes. Use MPI2_IOCSTATUS_MASK when checking IOCStatus to mask off the log bit, and make a few more things endian-safe. - Fix possible use of invalid pointer. It was possible to use an invalid pointer to get the target ID value. To fix this, initialize a local Target ID variable to an invalid value and change that variable to a valid value only if the pointer to the Target ID is not NULL. - No need to set the MPSSAS_SHUTDOWN flag because it's never used. - done_ccb pointer can be used if it is NULL. To prevent this, move check for done_ccb == NULL to before done_ccb is used in mpssas_stop_unit_done(). - Disks can go missing until a reboot is done in some cases. This is due to the DevHandle not being released, which causes the Firmware to not allow that disk to be re-added. Approved by: ken, scottl, ambrisko (mentors)
1 parent 7f8dab4 commit 4542c2a

File tree

6 files changed

+35
-29
lines changed

6 files changed

+35
-29
lines changed

sys/dev/mps/mps.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1916,9 +1916,10 @@ mps_intr_locked(void *data)
19161916
*/
19171917
rel_rep =
19181918
(MPI2_DIAG_RELEASE_REPLY *)reply;
1919-
if (le16toh(rel_rep->IOCStatus) ==
1919+
if ((le16toh(rel_rep->IOCStatus) &
1920+
MPI2_IOCSTATUS_MASK) ==
19201921
MPI2_IOCSTATUS_DIAGNOSTIC_RELEASED)
1921-
{
1922+
{
19221923
pBuffer =
19231924
&sc->fw_diag_buffer_list[
19241925
rel_rep->BufferType];

sys/dev/mps/mps_config.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ mps_wd_config_pages(struct mps_softc *sc)
499499
*/
500500
if (mps_config_get_raid_volume_pg0(sc, &mpi_reply,
501501
raid_vol_pg0, (u32)raid_vol_pg0->DevHandle)) {
502-
if (mpi_reply.IOCStatus !=
502+
if ((le16toh(mpi_reply.IOCStatus) &
503+
MPI2_IOCSTATUS_MASK) !=
503504
MPI2_IOCSTATUS_CONFIG_INVALID_PAGE) {
504505
mps_dprint(sc, MPS_FAULT,
505506
"Multiple RAID Volume Page0! Direct Drive "

sys/dev/mps/mps_sas.c

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ mpssas_alloc_tm(struct mps_softc *sc)
241241
void
242242
mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm)
243243
{
244+
int target_id = 0xFFFFFFFF;
245+
244246
if (tm == NULL)
245247
return;
246248

@@ -251,10 +253,11 @@ mpssas_free_tm(struct mps_softc *sc, struct mps_command *tm)
251253
*/
252254
if (tm->cm_targ != NULL) {
253255
tm->cm_targ->flags &= ~MPSSAS_TARGET_INRESET;
256+
target_id = tm->cm_targ->tid;
254257
}
255258
if (tm->cm_ccb) {
256259
mps_dprint(sc, MPS_INFO, "Unfreezing devq for target ID %d\n",
257-
tm->cm_targ->tid);
260+
target_id);
258261
xpt_release_devq(tm->cm_ccb->ccb_h.path, 1, TRUE);
259262
xpt_free_path(tm->cm_ccb->ccb_h.path);
260263
xpt_free_ccb(tm->cm_ccb);
@@ -372,12 +375,11 @@ mpssas_remove_volume(struct mps_softc *sc, struct mps_command *tm)
372375
return;
373376
}
374377

375-
if (reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) {
376-
mps_dprint(sc, MPS_FAULT,
378+
if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) !=
379+
MPI2_IOCSTATUS_SUCCESS) {
380+
mps_dprint(sc, MPS_ERROR,
377381
"IOCStatus = 0x%x while resetting device 0x%x\n",
378-
reply->IOCStatus, handle);
379-
mpssas_free_tm(sc, tm);
380-
return;
382+
le16toh(reply->IOCStatus), handle);
381383
}
382384

383385
mps_dprint(sc, MPS_XINFO,
@@ -394,7 +396,8 @@ mpssas_remove_volume(struct mps_softc *sc, struct mps_command *tm)
394396
* this target id if possible, and so we can assign the same target id
395397
* to this device if it comes back in the future.
396398
*/
397-
if (reply->IOCStatus == MPI2_IOCSTATUS_SUCCESS) {
399+
if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) ==
400+
MPI2_IOCSTATUS_SUCCESS) {
398401
targ = tm->cm_targ;
399402
targ->handle = 0x0;
400403
targ->encl_handle = 0x0;
@@ -567,24 +570,22 @@ mpssas_remove_device(struct mps_softc *sc, struct mps_command *tm)
567570
"%s: cm_flags = %#x for remove of handle %#04x! "
568571
"This should not happen!\n", __func__, tm->cm_flags,
569572
handle);
570-
mpssas_free_tm(sc, tm);
571-
return;
572573
}
573574

574575
if (reply == NULL) {
575576
/* XXX retry the remove after the diag reset completes? */
576577
mps_dprint(sc, MPS_FAULT,
577-
"%s NULL reply reseting device 0x%04x\n", __func__, handle);
578+
"%s NULL reply resetting device 0x%04x\n", __func__,
579+
handle);
578580
mpssas_free_tm(sc, tm);
579581
return;
580582
}
581583

582-
if (le16toh(reply->IOCStatus) != MPI2_IOCSTATUS_SUCCESS) {
583-
mps_dprint(sc, MPS_FAULT,
584+
if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) !=
585+
MPI2_IOCSTATUS_SUCCESS) {
586+
mps_dprint(sc, MPS_ERROR,
584587
"IOCStatus = 0x%x while resetting device 0x%x\n",
585588
le16toh(reply->IOCStatus), handle);
586-
mpssas_free_tm(sc, tm);
587-
return;
588589
}
589590

590591
mps_dprint(sc, MPS_XINFO, "Reset aborted %u commands\n",
@@ -662,7 +663,8 @@ mpssas_remove_complete(struct mps_softc *sc, struct mps_command *tm)
662663
* this target id if possible, and so we can assign the same target id
663664
* to this device if it comes back in the future.
664665
*/
665-
if (le16toh(reply->IOCStatus) == MPI2_IOCSTATUS_SUCCESS) {
666+
if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) ==
667+
MPI2_IOCSTATUS_SUCCESS) {
666668
targ = tm->cm_targ;
667669
targ->handle = 0x0;
668670
targ->encl_handle = 0x0;
@@ -880,7 +882,6 @@ mps_detach_sas(struct mps_softc *sc)
880882
cam_sim_free(sassc->sim, FALSE);
881883
}
882884

883-
sassc->flags |= MPSSAS_SHUTDOWN;
884885
mps_unlock(sc);
885886

886887
if (sassc->devq != NULL)

sys/dev/mps/mps_sas_lsi.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,15 +1161,15 @@ mpssas_stop_unit_done(struct cam_periph *periph, union ccb *done_ccb)
11611161
struct mpssas_softc *sassc;
11621162
char path_str[64];
11631163

1164+
if (done_ccb == NULL)
1165+
return;
1166+
11641167
sassc = (struct mpssas_softc *)done_ccb->ccb_h.ppriv_ptr1;
11651168

11661169
xpt_path_string(done_ccb->ccb_h.path, path_str, sizeof(path_str));
11671170
mps_dprint(sassc->sc, MPS_INFO, "Completing stop unit for %s\n",
11681171
path_str);
11691172

1170-
if (done_ccb == NULL)
1171-
return;
1172-
11731173
/*
11741174
* Nothing more to do except free the CCB and path. If the command
11751175
* timed out, an abort reset, then target reset will be issued during

sys/dev/mps/mps_user.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,12 +1230,14 @@ mps_post_fw_diag_buffer(struct mps_softc *sc,
12301230
* Process POST reply.
12311231
*/
12321232
reply = (MPI2_DIAG_BUFFER_POST_REPLY *)cm->cm_reply;
1233-
if (reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) {
1233+
if ((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) !=
1234+
MPI2_IOCSTATUS_SUCCESS) {
12341235
status = MPS_DIAG_FAILURE;
12351236
mps_dprint(sc, MPS_FAULT, "%s: post of FW Diag Buffer failed "
12361237
"with IOCStatus = 0x%x, IOCLogInfo = 0x%x and "
1237-
"TransferLength = 0x%x\n", __func__, reply->IOCStatus,
1238-
reply->IOCLogInfo, reply->TransferLength);
1238+
"TransferLength = 0x%x\n", __func__,
1239+
le16toh(reply->IOCStatus), le32toh(reply->IOCLogInfo),
1240+
le32toh(reply->TransferLength));
12391241
goto done;
12401242
}
12411243

@@ -1314,12 +1316,13 @@ mps_release_fw_diag_buffer(struct mps_softc *sc,
13141316
* Process RELEASE reply.
13151317
*/
13161318
reply = (MPI2_DIAG_RELEASE_REPLY *)cm->cm_reply;
1317-
if ((reply->IOCStatus != MPI2_IOCSTATUS_SUCCESS) ||
1318-
pBuffer->owned_by_firmware) {
1319+
if (((le16toh(reply->IOCStatus) & MPI2_IOCSTATUS_MASK) !=
1320+
MPI2_IOCSTATUS_SUCCESS) || pBuffer->owned_by_firmware) {
13191321
status = MPS_DIAG_FAILURE;
13201322
mps_dprint(sc, MPS_FAULT, "%s: release of FW Diag Buffer "
13211323
"failed with IOCStatus = 0x%x and IOCLogInfo = 0x%x\n",
1322-
__func__, reply->IOCStatus, reply->IOCLogInfo);
1324+
__func__, le16toh(reply->IOCStatus),
1325+
le32toh(reply->IOCLogInfo));
13231326
goto done;
13241327
}
13251328

sys/dev/mps/mpsvar.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#ifndef _MPSVAR_H
3434
#define _MPSVAR_H
3535

36-
#define MPS_DRIVER_VERSION "20.00.00.00-fbsd"
36+
#define MPS_DRIVER_VERSION "21.00.00.00-fbsd"
3737

3838
#define MPS_DB_MAX_WAIT 2500
3939

0 commit comments

Comments
 (0)