FreeBSD/sys/dev/mrsas/mrsas.c
/*
 * mrsas_ocr_thread:	Thread to handle OCR/Kill Adapter.
 * input:				Adapter Context.
 *
 * This function will check FW status register and flag do_timeout_reset flag.
 * It will do OCR/Kill adapter if FW is in fault state or IO timed out has
 * trigger reset.
 */
Thread to handle OCR/Kill Adapter.
input:                               Adapter Context.

This function will check FW status register and flag do_timeout_reset flag.
It will do OCR/Kill adapter if FW is in fault state or IO timed out has
trigger reset.
Thread to handle OCR / Kill Adapter . input : Adapter Context . This function will check FW status register and flag do_timeout_reset flag . It will do OCR / Kill adapter if FW is in fault state or IO timed out has trigger reset .
static void
mrsas_ocr_thread(void *arg)
{
	struct mrsas_softc *sc;
	u_int32_t fw_status, fw_state;
	sc = (struct mrsas_softc *)arg;
	mrsas_dprint(sc, MRSAS_TRACE, "%s\n", __func__);
	sc->ocr_thread_active = 1;
	mtx_lock(&sc->sim_lock);
	for (;;) {
		msleep(&sc->ocr_chan, &sc->sim_lock, PRIBIO,
		    "mrsas_ocr", sc->mrsas_fw_fault_check_delay * hz);
		if (sc->remove_in_progress ||
		    sc->adprecovery == MRSAS_HW_CRITICAL_ERROR) {
			mrsas_dprint(sc, MRSAS_OCR,
			    "Exit due to %s from %s\n",
			    sc->remove_in_progress ? "Shutdown" :
			    "Hardware critical error", __func__);
			break;
		}
		fw_status = mrsas_read_reg(sc,
		    offsetof(mrsas_reg_set, outbound_scratch_pad));
		fw_state = fw_status & MFI_STATE_MASK;
		if (fw_state == MFI_STATE_FAULT || sc->do_timedout_reset) {
			device_printf(sc->mrsas_dev, "%s started due to %s!\n",
			    sc->disableOnlineCtrlReset ? "Kill Adapter" : "OCR",
			    sc->do_timedout_reset ? "IO Timeout" :
			    "FW fault detected");
			mtx_lock_spin(&sc->ioctl_lock);
			sc->reset_in_progress = 1;
			sc->reset_count++;
			mtx_unlock_spin(&sc->ioctl_lock);
			mrsas_xpt_freeze(sc);
			mrsas_reset_ctrl(sc, sc->do_timedout_reset);
			mrsas_xpt_release(sc);
			sc->reset_in_progress = 0;
			sc->do_timedout_reset = 0;
		}
	}
	mtx_unlock(&sc->sim_lock);
	sc->ocr_thread_active = 0;
	mrsas_kproc_exit(0);
}
static void mrsas_ocr_thread ( void * arg ) { struct mrsas_softc * sc ; u_int32_t fw_status , fw_state ; sc = ( struct mrsas_softc * ) arg ; mrsas_dprint ( sc , MRSAS_TRACE , " \n " , __func__ ) ; sc -> ocr_thread_active = 1 ; mtx_lock ( & sc -> sim_lock ) ; for ( ; ; ) { msleep ( & sc -> ocr_chan , & sc -> sim_lock , PRIBIO , " " , sc -> mrsas_fw_fault_check_delay * hz ) ; if ( sc -> remove_in_progress || sc -> adprecovery == MRSAS_HW_CRITICAL_ERROR ) { mrsas_dprint ( sc , MRSAS_OCR , " \n " , sc -> remove_in_progress ? " " : " " , __func__ ) ; break ; } fw_status = mrsas_read_reg ( sc , offsetof ( mrsas_reg_set , outbound_scratch_pad ) ) ; fw_state = fw_status & MFI_STATE_MASK ; if ( fw_state == MFI_STATE_FAULT || sc -> do_timedout_reset ) { device_printf ( sc -> mrsas_dev , " \n " , sc -> disableOnlineCtrlReset ? " " : " " , sc -> do_timedout_reset ? " " : " " ) ; mtx_lock_spin ( & sc -> ioctl_lock ) ; sc -> reset_in_progress = 1 ; sc -> reset_count ++ ; mtx_unlock_spin ( & sc -> ioctl_lock ) ; mrsas_xpt_freeze ( sc ) ; mrsas_reset_ctrl ( sc , sc -> do_timedout_reset ) ; mrsas_xpt_release ( sc ) ; sc -> reset_in_progress = 0 ; sc -> do_timedout_reset = 0 ; } } mtx_unlock ( & sc -> sim_lock ) ; sc -> ocr_thread_active = 0 ; mrsas_kproc_exit ( 0 ) ; }
mrsas_ocr_thread:    Thread to handle OCR/Kill Adapter.
mrsas_ocr_thread : Thread to handle OCR / Kill Adapter .
/* Sleep for 1 second and check the queue status */