FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_issue_blocked_abort_cmd:       Aborts previously issued cmd input:
 * Adapter soft state Previously issued cmd to be aborted
 *
 * This function is used to abort previously issued commands, such as AEN and
 * RAID map sync map commands.  The abort command is sent as a DCMD internal
 * command and subsequently the driver will wait for a return status.  The
 * max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME seconds.
 */
Aborts previously issued cmd input:
Adapter soft state Previously issued cmd to be aborted

This function is used to abort previously issued commands, such as AEN and
RAID map sync map commands.  The abort command is sent as a DCMD internal
command and subsequently the driver will wait for a return status.  The
max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME seconds.
Aborts previously issued cmd input : Adapter soft state Previously issued cmd to be aborted This function is used to abort previously issued commands such as AEN and RAID map sync map commands . The abort command is sent as a DCMD internal command and subsequently the driver will wait for a return status . The max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME seconds .
static int
mrsas_issue_blocked_abort_cmd(struct mrsas_softc *sc,
    struct mrsas_mfi_cmd *cmd_to_abort)
{
	struct mrsas_mfi_cmd *cmd;
	struct mrsas_abort_frame *abort_fr;
	u_int8_t retcode = 0;
	unsigned long total_time = 0;
	u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME;
	cmd = mrsas_get_mfi_cmd(sc);
	if (!cmd) {
		device_printf(sc->mrsas_dev, "Cannot alloc for abort cmd\n");
		return (1);
	}
	abort_fr = &cmd->frame->abort;
	abort_fr->cmd = MFI_CMD_ABORT;
	abort_fr->cmd_status = 0xFF;
	abort_fr->flags = 0;
	abort_fr->abort_context = cmd_to_abort->index;
	abort_fr->abort_mfi_phys_addr_lo = cmd_to_abort->frame_phys_addr;
	abort_fr->abort_mfi_phys_addr_hi = 0;
	cmd->sync_cmd = 1;
	cmd->cmd_status = 0xFF;
	if (mrsas_issue_dcmd(sc, cmd)) {
		device_printf(sc->mrsas_dev, "Fail to send abort command.\n");
		return (1);
	}
	sc->chan = (void *)&cmd;
	while (1) {
		if (cmd->cmd_status == 0xFF) {
			tsleep((void *)&sc->chan, 0, "mrsas_sleep", hz);
		} else
			break;
		total_time++;
		if (total_time >= max_wait) {
			device_printf(sc->mrsas_dev, "Abort cmd timed out after %d sec.\n", max_wait);
			retcode = 1;
			break;
		}
	}
	cmd->sync_cmd = 0;
	mrsas_release_mfi_cmd(cmd);
	return (retcode);
}
static int mrsas_issue_blocked_abort_cmd ( struct mrsas_softc * sc , struct mrsas_mfi_cmd * cmd_to_abort ) { struct mrsas_mfi_cmd * cmd ; struct mrsas_abort_frame * abort_fr ; u_int8_t retcode = 0 ; unsigned long total_time = 0 ; u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME ; cmd = mrsas_get_mfi_cmd ( sc ) ; if ( ! cmd ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return ( 1 ) ; } abort_fr = & cmd -> frame -> abort ; abort_fr -> cmd = MFI_CMD_ABORT ; abort_fr -> cmd_status = 0xFF ; abort_fr -> flags = 0 ; abort_fr -> abort_context = cmd_to_abort -> index ; abort_fr -> abort_mfi_phys_addr_lo = cmd_to_abort -> frame_phys_addr ; abort_fr -> abort_mfi_phys_addr_hi = 0 ; cmd -> sync_cmd = 1 ; cmd -> cmd_status = 0xFF ; if ( mrsas_issue_dcmd ( sc , cmd ) ) { device_printf ( sc -> mrsas_dev , " \n " ) ; return ( 1 ) ; } sc -> chan = ( void * ) & cmd ; while ( 1 ) { if ( cmd -> cmd_status == 0xFF ) { tsleep ( ( void * ) & sc -> chan , 0 , " " , hz ) ; } else break ; total_time ++ ; if ( total_time >= max_wait ) { device_printf ( sc -> mrsas_dev , " \n " , max_wait ) ; retcode = 1 ; break ; } } cmd -> sync_cmd = 0 ; mrsas_release_mfi_cmd ( cmd ) ; return ( retcode ) ; }
mrsas_issue_blocked_abort_cmd:       Aborts previously issued cmd input:
 Adapter soft state Previously issued cmd to be aborted
mrsas_issue_blocked_abort_cmd : Aborts previously issued cmd input : Adapter soft state Previously issued cmd to be aborted
/* Prepare and issue the abort frame */ /* Wait for this cmd to complete */