FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_wait_for_outstanding:	Wait for outstanding commands
 * input:						Adapter Context.
 *
 * This function will wait for 180 seconds for outstanding commands to be
 * completed.
 */
Wait for outstanding commands
input:                                               Adapter Context.

This function will wait for 180 seconds for outstanding commands to be
completed.
Wait for outstanding commands input : Adapter Context . This function will wait for 180 seconds for outstanding commands to be completed .
int
mrsas_wait_for_outstanding(struct mrsas_softc *sc, u_int8_t check_reason)
{
	int i, outstanding, retval = 0;
	u_int32_t fw_state, count, MSIxIndex;
	for (i = 0; i < MRSAS_RESET_WAIT_TIME; i++) {
		if (sc->remove_in_progress) {
			mrsas_dprint(sc, MRSAS_OCR,
			    "Driver remove or shutdown called.\n");
			retval = 1;
			goto out;
		}
		fw_state = mrsas_read_reg(sc, offsetof(mrsas_reg_set,
		    outbound_scratch_pad)) & MFI_STATE_MASK;
		if (fw_state == MFI_STATE_FAULT) {
			mrsas_dprint(sc, MRSAS_OCR,
			    "Found FW in FAULT state, will reset adapter.\n");
			retval = 1;
			goto out;
		}
		if (check_reason == MFI_DCMD_TIMEOUT_OCR) {
			mrsas_dprint(sc, MRSAS_OCR,
			    "DCMD IO TIMEOUT detected, will reset adapter.\n");
			retval = 1;
			goto out;
		}
		outstanding = mrsas_atomic_read(&sc->fw_outstanding);
		if (!outstanding)
			goto out;
		if (!(i % MRSAS_RESET_NOTICE_INTERVAL)) {
			mrsas_dprint(sc, MRSAS_OCR, "[%2d]waiting for %d "
			    "commands to complete\n", i, outstanding);
			count = sc->msix_vectors > 0 ? sc->msix_vectors : 1;
			for (MSIxIndex = 0; MSIxIndex < count; MSIxIndex++)
				mrsas_complete_cmd(sc, MSIxIndex);
		}
		DELAY(1000 * 1000);
	}
	if (mrsas_atomic_read(&sc->fw_outstanding)) {
		mrsas_dprint(sc, MRSAS_OCR,
		    " pending commands remain after waiting,"
		    " will reset adapter.\n");
		retval = 1;
	}
out:
	return retval;
}
int mrsas_wait_for_outstanding ( struct mrsas_softc * sc , u_int8_t check_reason ) { int i , outstanding , retval = 0 ; u_int32_t fw_state , count , MSIxIndex ; for ( i = 0 ; i < MRSAS_RESET_WAIT_TIME ; i ++ ) { if ( sc -> remove_in_progress ) { mrsas_dprint ( sc , MRSAS_OCR , " \n " ) ; retval = 1 ; goto out ; } fw_state = mrsas_read_reg ( sc , offsetof ( mrsas_reg_set , outbound_scratch_pad ) ) & MFI_STATE_MASK ; if ( fw_state == MFI_STATE_FAULT ) { mrsas_dprint ( sc , MRSAS_OCR , " \n " ) ; retval = 1 ; goto out ; } if ( check_reason == MFI_DCMD_TIMEOUT_OCR ) { mrsas_dprint ( sc , MRSAS_OCR , " \n " ) ; retval = 1 ; goto out ; } outstanding = mrsas_atomic_read ( & sc -> fw_outstanding ) ; if ( ! outstanding ) goto out ; if ( ! ( i % MRSAS_RESET_NOTICE_INTERVAL ) ) { mrsas_dprint ( sc , MRSAS_OCR , " " " \n " , i , outstanding ) ; count = sc -> msix_vectors > 0 ? sc -> msix_vectors : 1 ; for ( MSIxIndex = 0 ; MSIxIndex < count ; MSIxIndex ++ ) mrsas_complete_cmd ( sc , MSIxIndex ) ; } DELAY ( 1000 * 1000 ) ; } if ( mrsas_atomic_read ( & sc -> fw_outstanding ) ) { mrsas_dprint ( sc , MRSAS_OCR , " " " \n " ) ; retval = 1 ; } out : return retval ; }
mrsas_wait_for_outstanding:  Wait for outstanding commands
 input:                                               Adapter Context.
mrsas_wait_for_outstanding : Wait for outstanding commands input : Adapter Context .
/* Check if firmware is in fault state */