From 013e1c937ae78bfc5755dba89e5b346bb001afb9 Mon Sep 17 00:00:00 2001 From: Chandrakanth Patil Date: Wed, 29 Jul 2020 16:10:30 +0530 Subject: [PATCH] mfi: remove raid map sync --- mfi.c | 7 --- mfi_tbolt.c | 176 ---------------------------------------------------- mfivar.h | 3 - 3 files changed, 186 deletions(-) diff --git a/mfi.c b/mfi.c index 79a804b..be84583 100644 --- a/mfi.c +++ b/mfi.c @@ -385,7 +385,6 @@ mfi_attach(struct mfi_softc *sc) TAILQ_INIT(&sc->mfi_syspd_pend_tqh); TAILQ_INIT(&sc->mfi_evt_queue); TASK_INIT(&sc->mfi_evt_task, 0, mfi_handle_evt, sc); - TASK_INIT(&sc->mfi_map_sync_task, 0, mfi_handle_map_sync, sc); TAILQ_INIT(&sc->mfi_aen_pids); TAILQ_INIT(&sc->mfi_cam_ccbq); @@ -786,12 +785,6 @@ mfi_attach(struct mfi_softc *sc) callout_reset(&sc->mfi_watchdog_callout, mfi_cmd_timeout * hz, mfi_timeout, sc); - if (sc->mfi_flags & MFI_FLAGS_TBOLT) { - mtx_lock(&sc->mfi_io_lock); - mfi_tbolt_sync_map_info(sc); - mtx_unlock(&sc->mfi_io_lock); - } - return (0); } diff --git a/mfi_tbolt.c b/mfi_tbolt.c index 083c53d..d2c5e3d 100644 --- a/mfi_tbolt.c +++ b/mfi_tbolt.c @@ -79,8 +79,6 @@ map_tbolt_cmd_status(struct mfi_command *mfi_cmd, uint8_t status, static void mfi_issue_pending_cmds_again (struct mfi_softc *sc); static void mfi_kill_hba (struct mfi_softc *sc); static void mfi_process_fw_state_chg_isr(void *arg); -static void mfi_sync_map_complete(struct mfi_command *); -static void mfi_queue_map_sync(struct mfi_softc *sc); #define MFI_FUSION_ENABLE_INTERRUPT_MASK (0x00000008) @@ -1310,7 +1308,6 @@ mfi_process_fw_state_chg_isr(void *arg) * Sync Map */ mfi_aen_setup(sc, sc->last_seq_num); - mfi_tbolt_sync_map_info(sc); sc->issuepend_done = 1; device_printf(sc->mfi_dev, "second stage of reset " @@ -1325,176 +1322,3 @@ mfi_process_fw_state_chg_isr(void *arg) } } -/* - * The ThunderBolt HW has an option for the driver to directly - * access the underlying disks and operate on the RAID. To - * do this there needs to be a capability to keep the RAID controller - * and driver in sync. The FreeBSD driver does not take advantage - * of this feature since it adds a lot of complexity and slows down - * performance. Performance is gained by using the controller's - * cache etc. - * - * Even though this driver doesn't access the disks directly, an - * AEN like command is used to inform the RAID firmware to "sync" - * with all LD's via the MFI_DCMD_LD_MAP_GET_INFO command. This - * command in write mode will return when the RAID firmware has - * detected a change to the RAID state. Examples of this type - * of change are removing a disk. Once the command returns then - * the driver needs to acknowledge this and "sync" all LD's again. - * This repeats until we shutdown. Then we need to cancel this - * pending command. - * - * If this is not done right the RAID firmware will not remove a - * pulled drive and the RAID won't go degraded etc. Effectively, - * stopping any RAID mangement to functions. - * - * Doing another LD sync, requires the use of an event since the - * driver needs to do a mfi_wait_command and can't do that in an - * interrupt thread. - * - * The driver could get the RAID state via the MFI_DCMD_LD_MAP_GET_INFO - * That requires a bunch of structure and it is simpler to just do - * the MFI_DCMD_LD_GET_LIST versus walking the RAID map. - */ - -void -mfi_tbolt_sync_map_info(struct mfi_softc *sc) -{ - int error = 0, i; - struct mfi_command *cmd = NULL; - struct mfi_dcmd_frame *dcmd = NULL; - uint32_t context = 0; - union mfi_ld_ref *ld_sync = NULL; - size_t ld_size; - struct mfi_frame_header *hdr; - struct mfi_command *cm = NULL; - struct mfi_ld_list *list = NULL; - - mtx_assert(&sc->mfi_io_lock, MA_OWNED); - - if (sc->mfi_map_sync_cm != NULL || sc->cm_map_abort) - return; - - error = mfi_dcmd_command(sc, &cm, MFI_DCMD_LD_GET_LIST, - (void **)&list, sizeof(*list)); - if (error) - goto out; - - cm->cm_flags = MFI_CMD_POLLED | MFI_CMD_DATAIN; - - if (mfi_wait_command(sc, cm) != 0) { - device_printf(sc->mfi_dev, "Failed to get device listing\n"); - goto out; - } - - hdr = &cm->cm_frame->header; - if (hdr->cmd_status != MFI_STAT_OK) { - device_printf(sc->mfi_dev, "MFI_DCMD_LD_GET_LIST failed %x\n", - hdr->cmd_status); - goto out; - } - - ld_size = sizeof(*ld_sync) * list->ld_count; - ld_sync = (union mfi_ld_ref *) malloc(ld_size, M_MFIBUF, - M_NOWAIT | M_ZERO); - if (ld_sync == NULL) { - device_printf(sc->mfi_dev, "Failed to allocate sync\n"); - goto out; - } - for (i = 0; i < list->ld_count; i++) - ld_sync[i].ref = list->ld_list[i].ld.ref; - - if ((cmd = mfi_dequeue_free(sc)) == NULL) { - device_printf(sc->mfi_dev, "Failed to get command\n"); - free(ld_sync, M_MFIBUF); - goto out; - } - - context = cmd->cm_frame->header.context; - bzero(cmd->cm_frame, sizeof(union mfi_frame)); - cmd->cm_frame->header.context = context; - - dcmd = &cmd->cm_frame->dcmd; - bzero(dcmd->mbox, MFI_MBOX_SIZE); - dcmd->header.cmd = MFI_CMD_DCMD; - dcmd->header.flags = MFI_FRAME_DIR_WRITE; - dcmd->header.timeout = 0; - dcmd->header.data_len = ld_size; - dcmd->header.scsi_status = 0; - dcmd->opcode = MFI_DCMD_LD_MAP_GET_INFO; - cmd->cm_sg = &dcmd->sgl; - cmd->cm_total_frame_size = MFI_DCMD_FRAME_SIZE; - cmd->cm_data = ld_sync; - cmd->cm_private = ld_sync; - - cmd->cm_len = ld_size; - cmd->cm_complete = mfi_sync_map_complete; - sc->mfi_map_sync_cm = cmd; - - cmd->cm_flags = MFI_CMD_DATAOUT; - cmd->cm_frame->dcmd.mbox[0] = list->ld_count; - cmd->cm_frame->dcmd.mbox[1] = MFI_DCMD_MBOX_PEND_FLAG; - - if ((error = mfi_mapcmd(sc, cmd)) != 0) { - device_printf(sc->mfi_dev, "failed to send map sync\n"); - free(ld_sync, M_MFIBUF); - sc->mfi_map_sync_cm = NULL; - mfi_release_command(cmd); - goto out; - } - -out: - if (list) - free(list, M_MFIBUF); - if (cm) - mfi_release_command(cm); -} - -static void -mfi_sync_map_complete(struct mfi_command *cm) -{ - struct mfi_frame_header *hdr; - struct mfi_softc *sc; - int aborted = 0; - - sc = cm->cm_sc; - mtx_assert(&sc->mfi_io_lock, MA_OWNED); - - hdr = &cm->cm_frame->header; - - if (sc->mfi_map_sync_cm == NULL) - return; - - if (sc->cm_map_abort || - hdr->cmd_status == MFI_STAT_INVALID_STATUS) { - sc->cm_map_abort = 0; - aborted = 1; - } - - free(cm->cm_data, M_MFIBUF); - wakeup(&sc->mfi_map_sync_cm); - sc->mfi_map_sync_cm = NULL; - mfi_release_command(cm); - - /* set it up again so the driver can catch more events */ - if (!aborted) - mfi_queue_map_sync(sc); -} - -static void -mfi_queue_map_sync(struct mfi_softc *sc) -{ - mtx_assert(&sc->mfi_io_lock, MA_OWNED); - taskqueue_enqueue(taskqueue_swi, &sc->mfi_map_sync_task); -} - -void -mfi_handle_map_sync(void *context, int pending) -{ - struct mfi_softc *sc; - - sc = context; - mtx_lock(&sc->mfi_io_lock); - mfi_tbolt_sync_map_info(sc); - mtx_unlock(&sc->mfi_io_lock); -} diff --git a/mfivar.h b/mfivar.h index 9710509..d4766bc 100644 --- a/mfivar.h +++ b/mfivar.h @@ -248,7 +248,6 @@ struct mfi_softc { TAILQ_HEAD(,mfi_evt_queue_elm) mfi_evt_queue; struct task mfi_evt_task; - struct task mfi_map_sync_task; TAILQ_HEAD(,mfi_aen) mfi_aen_pids; struct mfi_command *mfi_aen_cm; struct mfi_command *mfi_skinny_cm; @@ -451,8 +450,6 @@ extern int mfi_tbolt_alloc_cmd(struct mfi_softc *sc); extern int mfi_tbolt_send_frame(struct mfi_softc *sc, struct mfi_command *cm); extern int mfi_tbolt_adp_reset(struct mfi_softc *sc); extern int mfi_tbolt_reset(struct mfi_softc *sc); -extern void mfi_tbolt_sync_map_info(struct mfi_softc *sc); -extern void mfi_handle_map_sync(void *context, int pending); extern int mfi_dcmd_command(struct mfi_softc *, struct mfi_command **, uint32_t, void **, size_t); extern int mfi_build_cdb(int, uint8_t, u_int64_t, u_int32_t, uint8_t *); -- 2.26.2