From d35997f97e5bca6ac7e1dffebc4f7bc0bf4a168e Mon Sep 17 00:00:00 2001 From: mav Date: Wed, 1 Aug 2012 17:31:31 +0000 Subject: Several fixes to allow firmware/BIOS flash access from user-level: - remove special handling of zero length transfers in mpi_pre_fw_upload(); - add missing MPS_CM_FLAGS_DATAIN flag in mpi_pre_fw_upload(); - move mps_user_setup_request() call into proper place; - increase user command timeout from 30 to 60 seconds; - avoid NULL dereference panic in case of firmware crash. Set max DMA segment size to 24bit, as MPI SGE supports it. Use mps_add_dmaseg() to add empty SGE instead of custom code. Tune endianness safety. Reviewed by: Desai, Kashyap Sponsored by: iXsystems, Inc. --- sys/dev/mps/mps_user.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'sys/dev/mps/mps_user.c') diff --git a/sys/dev/mps/mps_user.c b/sys/dev/mps/mps_user.c index 98dc511..ee03573 100644 --- a/sys/dev/mps/mps_user.c +++ b/sys/dev/mps/mps_user.c @@ -534,11 +534,6 @@ mpi_pre_fw_upload(struct mps_command *cm, struct mps_usr_command *cmd) return (EINVAL); mpi_init_sge(cm, req, &req->SGL); - if (cmd->len == 0) { - /* Perhaps just asking what the size of the fw is? */ - return (0); - } - bzero(&tc, sizeof tc); /* @@ -554,6 +549,8 @@ mpi_pre_fw_upload(struct mps_command *cm, struct mps_usr_command *cmd) tc.ImageOffset = 0; tc.ImageSize = cmd->len; + cm->cm_flags |= MPS_CM_FLAGS_DATAIN; + return (mps_push_sge(cm, &tc, sizeof tc, 0)); } @@ -692,13 +689,6 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd) mps_dprint(sc, MPS_INFO, "mps_user_command: Function %02X " "MsgFlags %02X\n", hdr->Function, hdr->MsgFlags ); - err = mps_user_setup_request(cm, cmd); - if (err != 0) { - mps_printf(sc, "mps_user_command: unsupported function 0x%X\n", - hdr->Function ); - goto RetFreeUnlocked; - } - if (cmd->len > 0) { buf = malloc(cmd->len, M_MPSUSER, M_WAITOK|M_ZERO); if(!buf) { @@ -716,8 +706,15 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd) cm->cm_flags = MPS_CM_FLAGS_SGE_SIMPLE; cm->cm_desc.Default.RequestFlags = MPI2_REQ_DESCRIPT_FLAGS_DEFAULT_TYPE; + err = mps_user_setup_request(cm, cmd); + if (err != 0) { + mps_printf(sc, "mps_user_command: unsupported function 0x%X\n", + hdr->Function ); + goto RetFreeUnlocked; + } + mps_lock(sc); - err = mps_wait_command(sc, cm, 30); + err = mps_wait_command(sc, cm, 60); if (err) { mps_printf(sc, "%s: invalid request: error %d\n", @@ -726,7 +723,10 @@ mps_user_command(struct mps_softc *sc, struct mps_usr_command *cmd) } rpl = (MPI2_DEFAULT_REPLY *)cm->cm_reply; - sz = rpl->MsgLength * 4; + if (rpl != NULL) + sz = rpl->MsgLength * 4; + else + sz = 0; if (sz > cmd->rpl_len) { mps_printf(sc, -- cgit v1.1