XilinxProcessorIPLib/drivers/aiengine/src/tile/xaietile_error.c
static int _XAieTile_ErrorRegisterNotification(XAieGbl *AieInst, u8 Module,
					       u8 Error,
					       XAieTile_ErrorCallBack Cb,
					       void *Arg)
{
	XAieGbl_ErrorHandler *Handler;
	XAieGbl_EventHandler *EvtHandler;
	u32 *ErrsDefaultTrap, *ErrsPollOnly;
	u8 ErrOff, ErrsStart, ErrsEnd;

	/* Setup the handler */
	XAie_AssertNonvoid(AieInst != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->Config != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->Tiles != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->IsReady == XAIE_COMPONENT_IS_READY);
	XAie_AssertNonvoid(Module == XAIEGBL_MODULE_CORE ||
			   Module == XAIEGBL_MODULE_MEM ||
			   Module == XAIEGBL_MODULE_PL);

	if (Module == XAIEGBL_MODULE_CORE) {
		ErrsDefaultTrap = &(AieInst->CoreErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->CoreErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_CORE_SRS_SATURATE;
		ErrsEnd = XAIETILE_EVENT_CORE_INSTR_ERROR;
		EvtHandler = AieInst->CoreEvtHandlers;
		Handler = AieInst->CoreErrHandlers;
	} else if (Module == XAIEGBL_MODULE_MEM) {
		ErrsDefaultTrap = &(AieInst->MemErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->MemErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_MEM_DM_ECC_ERROR_SCRUB_CORRECTED;
		ErrsEnd = XAIETILE_EVENT_MEM_DMA_MM2S_1_ERROR;
		Handler = AieInst->MemErrHandlers;
		EvtHandler = AieInst->MemEvtHandlers;
	} else {
		ErrsDefaultTrap = &(AieInst->ShimErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->ShimErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_SHIM_AXI_MM_SLAVE_TILE_ERROR;
		ErrsEnd = XAIETILE_EVENT_SHIM_DMA_MM2S_1_ERROR_NOC;
		Handler = AieInst->ShimErrHandlers;
		EvtHandler = AieInst->ShimEvtHandlers;
	}
	XAie_AssertNonvoid((Error >= ErrsStart) && (Error <= ErrsEnd));
	ErrOff = Error - ErrsStart;
	if (Handler[ErrOff].Cb != XAIE_NULL) {
		if ((Cb != XAIE_NULL && Cb != Handler[ErrOff].Cb) ||
		    (Arg != XAIE_NULL && Arg != Handler[ErrOff].Arg)) {
			XAieLib_IntPrint("%s: failed,"
					 "event(%u) has been registered with"
					 "different callback."
					 "Please unregister first.\n",
					 __func__, Error);
			return XAIE_FAILURE;
		}
	}
	Handler[ErrOff].Cb = Cb;
	Handler[ErrOff].Arg = Arg;
	*ErrsDefaultTrap |= 1 << ErrOff;
	if (EvtHandler[Error].Cb == XAIE_NULL) {
		EvtHandler[Error].Cb = XAieTile_ErrorHandler;
		EvtHandler[Error].Arg = AieInst;
	}
	/* Enable notification if the error was polled only before */
	if ((*ErrsPollOnly & (1 << ErrOff)) != 0) {
		*ErrsPollOnly &= ~(1 << ErrOff);
		u32 NumCols, NumRows, ClockCntrlRegVal;
		XAieGbl_Tile *TilePtr;
		u64 RegAddr;

		NumCols = AieInst->Config->NumCols;
		NumRows = AieInst->Config->NumRows;
		/* Enable notification for the error */
		for(u32 col = 0; col < NumCols; col++){
			TilePtr = AieInst->Tiles;
			TilePtr += col * (NumRows + 1);
			if(Module == XAIEGBL_MODULE_PL){
			   XAieTile_PlGroupEventSet(TilePtr,
			   XAIETILE_GROUP_EVENT_PL_ERRORS,(~(*ErrsPollOnly)));
			}
			RegAddr = TilePtr->TileAddr;
			ClockCntrlRegVal = XAieGbl_Read32(RegAddr +
							XAIEGBL_PL_TILCLOCTRL);

			/* check if any tile in this col is used */
			if(ClockCntrlRegVal & XAIEGBL_PL_TILCLOCTRLMSK){
				for(u32 row = 1; row <= NumRows; row++){
					TilePtr = AieInst->Tiles;
					TilePtr += col * (NumRows + 1) + row;

					if (Module == XAIEGBL_MODULE_CORE) {
					    XAieTile_CoreGroupEventSet(TilePtr,
					    XAIETILE_GROUP_EVENT_CORE_ERROR0,
							   (~(*ErrsPollOnly)));
					}
					else if (Module == XAIEGBL_MODULE_MEM) {
					        XAieTile_MemGroupEventSet(TilePtr,
						XAIETILE_GROUP_EVENT_MEM_ERROR,
							   (~(*ErrsPollOnly)));
					}
					RegAddr = TilePtr->TileAddr;
					ClockCntrlRegVal = XAieGbl_Read32(
					     RegAddr + XAIEGBL_CORE_TILCLOCTRL);
					/* check if the tile above is gated */
					if(!(ClockCntrlRegVal &
					     XAIEGBL_CORE_TILCLOCTRL_NEXTILCLOENA_MASK))
						break;
				}
			}
		}
	}
	return XAIE_SUCCESS;
}
/*****************************************************************************/
/**
 * This API sets user callback to the specified error.
 *
 * @param	AieInst - Pointer to the AIE device instance
 * @param	Module - Module type
 *			XAIEGBL_MODULE_CORE, XAIEGBL_MODULE_PL,
 *			XAIEGBL_MODULE_MEM
 * @param	Error - Error event id
 *			48 - 69 for Core module
 *			87 - 100 for Memory module
 *			62 - 72 for SHIM PL module
 * @param	Cb - User error callback function pointer
 * @param	Arg - Argument which will be passed to callback function,
 *		      it can be NULL.
 *
 * @return	XAIE_SUCCESS if successful, else XAIE_FAILURE
 *
 * @note	Used only within this file.
 *****************************************************************************/
This API sets user callback to the specified error.



@note        Used only within this file.
This API sets user callback to the specified error . @note Used only within this file .
static int _XAieTile_ErrorRegisterNotification(XAieGbl *AieInst, u8 Module,
					       u8 Error,
					       XAieTile_ErrorCallBack Cb,
					       void *Arg)
{
	XAieGbl_ErrorHandler *Handler;
	XAieGbl_EventHandler *EvtHandler;
	u32 *ErrsDefaultTrap, *ErrsPollOnly;
	u8 ErrOff, ErrsStart, ErrsEnd;
	XAie_AssertNonvoid(AieInst != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->Config != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->Tiles != XAIE_NULL);
	XAie_AssertNonvoid(AieInst->IsReady == XAIE_COMPONENT_IS_READY);
	XAie_AssertNonvoid(Module == XAIEGBL_MODULE_CORE ||
			   Module == XAIEGBL_MODULE_MEM ||
			   Module == XAIEGBL_MODULE_PL);
	if (Module == XAIEGBL_MODULE_CORE) {
		ErrsDefaultTrap = &(AieInst->CoreErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->CoreErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_CORE_SRS_SATURATE;
		ErrsEnd = XAIETILE_EVENT_CORE_INSTR_ERROR;
		EvtHandler = AieInst->CoreEvtHandlers;
		Handler = AieInst->CoreErrHandlers;
	} else if (Module == XAIEGBL_MODULE_MEM) {
		ErrsDefaultTrap = &(AieInst->MemErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->MemErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_MEM_DM_ECC_ERROR_SCRUB_CORRECTED;
		ErrsEnd = XAIETILE_EVENT_MEM_DMA_MM2S_1_ERROR;
		Handler = AieInst->MemErrHandlers;
		EvtHandler = AieInst->MemEvtHandlers;
	} else {
		ErrsDefaultTrap = &(AieInst->ShimErrsDefaultTrap);
		ErrsPollOnly = &(AieInst->ShimErrsPollOnly);
		ErrsStart = XAIETILE_EVENT_SHIM_AXI_MM_SLAVE_TILE_ERROR;
		ErrsEnd = XAIETILE_EVENT_SHIM_DMA_MM2S_1_ERROR_NOC;
		Handler = AieInst->ShimErrHandlers;
		EvtHandler = AieInst->ShimEvtHandlers;
	}
	XAie_AssertNonvoid((Error >= ErrsStart) && (Error <= ErrsEnd));
	ErrOff = Error - ErrsStart;
	if (Handler[ErrOff].Cb != XAIE_NULL) {
		if ((Cb != XAIE_NULL && Cb != Handler[ErrOff].Cb) ||
		    (Arg != XAIE_NULL && Arg != Handler[ErrOff].Arg)) {
			XAieLib_IntPrint("%s: failed,"
					 "event(%u) has been registered with"
					 "different callback."
					 "Please unregister first.\n",
					 __func__, Error);
			return XAIE_FAILURE;
		}
	}
	Handler[ErrOff].Cb = Cb;
	Handler[ErrOff].Arg = Arg;
	*ErrsDefaultTrap |= 1 << ErrOff;
	if (EvtHandler[Error].Cb == XAIE_NULL) {
		EvtHandler[Error].Cb = XAieTile_ErrorHandler;
		EvtHandler[Error].Arg = AieInst;
	}
	if ((*ErrsPollOnly & (1 << ErrOff)) != 0) {
		*ErrsPollOnly &= ~(1 << ErrOff);
		u32 NumCols, NumRows, ClockCntrlRegVal;
		XAieGbl_Tile *TilePtr;
		u64 RegAddr;
		NumCols = AieInst->Config->NumCols;
		NumRows = AieInst->Config->NumRows;
		for(u32 col = 0; col < NumCols; col++){
			TilePtr = AieInst->Tiles;
			TilePtr += col * (NumRows + 1);
			if(Module == XAIEGBL_MODULE_PL){
			   XAieTile_PlGroupEventSet(TilePtr,
			   XAIETILE_GROUP_EVENT_PL_ERRORS,(~(*ErrsPollOnly)));
			}
			RegAddr = TilePtr->TileAddr;
			ClockCntrlRegVal = XAieGbl_Read32(RegAddr +
							XAIEGBL_PL_TILCLOCTRL);
			if(ClockCntrlRegVal & XAIEGBL_PL_TILCLOCTRLMSK){
				for(u32 row = 1; row <= NumRows; row++){
					TilePtr = AieInst->Tiles;
					TilePtr += col * (NumRows + 1) + row;
					if (Module == XAIEGBL_MODULE_CORE) {
					    XAieTile_CoreGroupEventSet(TilePtr,
					    XAIETILE_GROUP_EVENT_CORE_ERROR0,
							   (~(*ErrsPollOnly)));
					}
					else if (Module == XAIEGBL_MODULE_MEM) {
					        XAieTile_MemGroupEventSet(TilePtr,
						XAIETILE_GROUP_EVENT_MEM_ERROR,
							   (~(*ErrsPollOnly)));
					}
					RegAddr = TilePtr->TileAddr;
					ClockCntrlRegVal = XAieGbl_Read32(
					     RegAddr + XAIEGBL_CORE_TILCLOCTRL);
					if(!(ClockCntrlRegVal &
					     XAIEGBL_CORE_TILCLOCTRL_NEXTILCLOENA_MASK))
						break;
				}
			}
		}
	}
	return XAIE_SUCCESS;
}
static int _XAieTile_ErrorRegisterNotification ( XAieGbl * AieInst , u8 Module , u8 Error , XAieTile_ErrorCallBack Cb , void * Arg ) { XAieGbl_ErrorHandler * Handler ; XAieGbl_EventHandler * EvtHandler ; u32 * ErrsDefaultTrap , * ErrsPollOnly ; u8 ErrOff , ErrsStart , ErrsEnd ; XAie_AssertNonvoid ( AieInst != XAIE_NULL ) ; XAie_AssertNonvoid ( AieInst -> Config != XAIE_NULL ) ; XAie_AssertNonvoid ( AieInst -> Tiles != XAIE_NULL ) ; XAie_AssertNonvoid ( AieInst -> IsReady == XAIE_COMPONENT_IS_READY ) ; XAie_AssertNonvoid ( Module == XAIEGBL_MODULE_CORE || Module == XAIEGBL_MODULE_MEM || Module == XAIEGBL_MODULE_PL ) ; if ( Module == XAIEGBL_MODULE_CORE ) { ErrsDefaultTrap = & ( AieInst -> CoreErrsDefaultTrap ) ; ErrsPollOnly = & ( AieInst -> CoreErrsPollOnly ) ; ErrsStart = XAIETILE_EVENT_CORE_SRS_SATURATE ; ErrsEnd = XAIETILE_EVENT_CORE_INSTR_ERROR ; EvtHandler = AieInst -> CoreEvtHandlers ; Handler = AieInst -> CoreErrHandlers ; } else if ( Module == XAIEGBL_MODULE_MEM ) { ErrsDefaultTrap = & ( AieInst -> MemErrsDefaultTrap ) ; ErrsPollOnly = & ( AieInst -> MemErrsPollOnly ) ; ErrsStart = XAIETILE_EVENT_MEM_DM_ECC_ERROR_SCRUB_CORRECTED ; ErrsEnd = XAIETILE_EVENT_MEM_DMA_MM2S_1_ERROR ; Handler = AieInst -> MemErrHandlers ; EvtHandler = AieInst -> MemEvtHandlers ; } else { ErrsDefaultTrap = & ( AieInst -> ShimErrsDefaultTrap ) ; ErrsPollOnly = & ( AieInst -> ShimErrsPollOnly ) ; ErrsStart = XAIETILE_EVENT_SHIM_AXI_MM_SLAVE_TILE_ERROR ; ErrsEnd = XAIETILE_EVENT_SHIM_DMA_MM2S_1_ERROR_NOC ; Handler = AieInst -> ShimErrHandlers ; EvtHandler = AieInst -> ShimEvtHandlers ; } XAie_AssertNonvoid ( ( Error >= ErrsStart ) && ( Error <= ErrsEnd ) ) ; ErrOff = Error - ErrsStart ; if ( Handler [ ErrOff ] . Cb != XAIE_NULL ) { if ( ( Cb != XAIE_NULL && Cb != Handler [ ErrOff ] . Cb ) || ( Arg != XAIE_NULL && Arg != Handler [ ErrOff ] . Arg ) ) { XAieLib_IntPrint ( " " " " " " " \n " , __func__ , Error ) ; return XAIE_FAILURE ; } } Handler [ ErrOff ] . Cb = Cb ; Handler [ ErrOff ] . Arg = Arg ; * ErrsDefaultTrap |= 1 << ErrOff ; if ( EvtHandler [ Error ] . Cb == XAIE_NULL ) { EvtHandler [ Error ] . Cb = XAieTile_ErrorHandler ; EvtHandler [ Error ] . Arg = AieInst ; } if ( ( * ErrsPollOnly & ( 1 << ErrOff ) ) != 0 ) { * ErrsPollOnly &= ~ ( 1 << ErrOff ) ; u32 NumCols , NumRows , ClockCntrlRegVal ; XAieGbl_Tile * TilePtr ; u64 RegAddr ; NumCols = AieInst -> Config -> NumCols ; NumRows = AieInst -> Config -> NumRows ; for ( u32 col = 0 ; col < NumCols ; col ++ ) { TilePtr = AieInst -> Tiles ; TilePtr += col * ( NumRows + 1 ) ; if ( Module == XAIEGBL_MODULE_PL ) { XAieTile_PlGroupEventSet ( TilePtr , XAIETILE_GROUP_EVENT_PL_ERRORS , ( ~ ( * ErrsPollOnly ) ) ) ; } RegAddr = TilePtr -> TileAddr ; ClockCntrlRegVal = XAieGbl_Read32 ( RegAddr + XAIEGBL_PL_TILCLOCTRL ) ; if ( ClockCntrlRegVal & XAIEGBL_PL_TILCLOCTRLMSK ) { for ( u32 row = 1 ; row <= NumRows ; row ++ ) { TilePtr = AieInst -> Tiles ; TilePtr += col * ( NumRows + 1 ) + row ; if ( Module == XAIEGBL_MODULE_CORE ) { XAieTile_CoreGroupEventSet ( TilePtr , XAIETILE_GROUP_EVENT_CORE_ERROR0 , ( ~ ( * ErrsPollOnly ) ) ) ; } else if ( Module == XAIEGBL_MODULE_MEM ) { XAieTile_MemGroupEventSet ( TilePtr , XAIETILE_GROUP_EVENT_MEM_ERROR , ( ~ ( * ErrsPollOnly ) ) ) ; } RegAddr = TilePtr -> TileAddr ; ClockCntrlRegVal = XAieGbl_Read32 ( RegAddr + XAIEGBL_CORE_TILCLOCTRL ) ; if ( ! ( ClockCntrlRegVal & XAIEGBL_CORE_TILCLOCTRL_NEXTILCLOENA_MASK ) ) break ; } } } } return XAIE_SUCCESS ; }
This API sets user callback to the specified error.
This API sets user callback to the specified error .
/* Setup the handler */ /* Enable notification if the error was polled only before */ /* Enable notification for the error */ /* check if any tile in this col is used */ /* check if the tile above is gated */