FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_issue_blocked_cmd:	Synchronous wrapper around regular FW cmds
 * input:					Adapter soft state Command to be issued
 *
 * This function waits on an event for the command to be returned from the ISR.
 * Max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME secs. Used for issuing
 * internal and ioctl commands.
 */
Synchronous wrapper around regular FW cmds
input:                                       Adapter soft state Command to be issued

This function waits on an event for the command to be returned from the ISR.
Max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME secs. Used for issuing
internal and ioctl commands.
Synchronous wrapper around regular FW cmds input : Adapter soft state Command to be issued This function waits on an event for the command to be returned from the ISR . Max wait time is MRSAS_INTERNAL_CMD_WAIT_TIME secs . Used for issuing internal and ioctl commands .
int
mrsas_issue_blocked_cmd(struct mrsas_softc *sc, struct mrsas_mfi_cmd *cmd)
{
	u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME;
	unsigned long total_time = 0;
	int retcode = SUCCESS;
	cmd->cmd_status = 0xFF;
	if (mrsas_issue_dcmd(sc, cmd)) {
		device_printf(sc->mrsas_dev, "Cannot issue DCMD internal 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;
		if (!cmd->sync_cmd) {	
			total_time++;
			if (total_time >= max_wait) {
				device_printf(sc->mrsas_dev,
				    "Internal command timed out after %d seconds.\n", max_wait);
				retcode = 1;
				break;
			}
		}
	}
	if (cmd->cmd_status == 0xFF) {
		device_printf(sc->mrsas_dev, "DCMD timed out after %d "
		    "seconds from %s\n", max_wait, __func__);
		device_printf(sc->mrsas_dev, "DCMD opcode 0x%X\n",
		    cmd->frame->dcmd.opcode);
		retcode = ETIMEDOUT;
	}
	return (retcode);
}
int mrsas_issue_blocked_cmd ( struct mrsas_softc * sc , struct mrsas_mfi_cmd * cmd ) { u_int8_t max_wait = MRSAS_INTERNAL_CMD_WAIT_TIME ; unsigned long total_time = 0 ; int retcode = SUCCESS ; 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 ; if ( ! cmd -> sync_cmd ) { total_time ++ ; if ( total_time >= max_wait ) { device_printf ( sc -> mrsas_dev , " \n " , max_wait ) ; retcode = 1 ; break ; } } } if ( cmd -> cmd_status == 0xFF ) { device_printf ( sc -> mrsas_dev , " " " \n " , max_wait , __func__ ) ; device_printf ( sc -> mrsas_dev , " \n " , cmd -> frame -> dcmd . opcode ) ; retcode = ETIMEDOUT ; } return ( retcode ) ; }
mrsas_issue_blocked_cmd:     Synchronous wrapper around regular FW cmds
 input:                                       Adapter soft state Command to be issued
mrsas_issue_blocked_cmd : Synchronous wrapper around regular FW cmds input : Adapter soft state Command to be issued
/* Initialize cmd_status */ /* Build MPT-MFI command for issue to FW */ /* cmd->sync will be set for an IOCTL
					 * command */