Skip to content

Commit

Permalink
Revert "sw_services: xilplmi: Added support for handling PSM to PLM I…
Browse files Browse the repository at this point in the history
…PI events"

This reverts commit acde630.

With this commit observing RCU stalls and kernal panic during CPU
hot plug stress testing. Also observing issues in RPU suspend resume due
to wakeup interrupt is missed in PLM. So revert this commit as temporary
solution.

Signed-off-by: Jay Buddhabhatti <[email protected]>

Acked-for-series: Arun Balaji Kannan <[email protected]>
  • Loading branch information
jbuddhab authored and Siva Addepalli committed Oct 28, 2024
1 parent e6b4ea9 commit 5f03a57
Show file tree
Hide file tree
Showing 11 changed files with 34 additions and 154 deletions.
3 changes: 1 addition & 2 deletions lib/sw_apps/versal_plm/src/versal_aiepg2/xplm_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* XPLMI_IPI_DEVICE_ID
* 1.01 ng 11/11/2022 Fixed doxygen file name error
* 1.11 ng 04/30/2024 Fixed doxygen grouping
* ma 09/23/2024 Added support for PSM-PLM IPI events
*
* </pre>
*
Expand Down Expand Up @@ -90,7 +89,7 @@ int XPlm_HookAfterPmcCdo(void *Arg)
/* In-Place PLM Update is applicable only for versalnet */
if (XPlmi_IsPlmUpdateDone() == (u8)TRUE) {
#ifdef XPLMI_IPI_DEVICE_ID
XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask, NULL);
XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask);
#endif /* XPLMI_IPI_DEVICE_ID */
XPlmi_LpdInit();
/* Call LibPM hook */
Expand Down
3 changes: 1 addition & 2 deletions lib/sw_apps/versal_plm/src/versal_net/xplm_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* XPLMI_IPI_DEVICE_ID
* 1.01 ng 11/11/2022 Fixed doxygen file name error
* 1.11 ng 04/30/2024 Fixed doxygen grouping
* ma 09/23/2024 Added support for PSM-PLM IPI events
*
* </pre>
*
Expand Down Expand Up @@ -90,7 +89,7 @@ int XPlm_HookAfterPmcCdo(void *Arg)
/* In-Place PLM Update is applicable only for versalnet */
if (XPlmi_IsPlmUpdateDone() == (u8)TRUE) {
#ifdef XPLMI_IPI_DEVICE_ID
XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask, XPm_ProcessPsmCmd);
XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask);
#endif /* XPLMI_IPI_DEVICE_ID */
XPlmi_LpdInit();
/* Call LibPM hook */
Expand Down
151 changes: 28 additions & 123 deletions lib/sw_services/xilplmi/src/common/server/xplmi_ipi.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
* pre 09/18/2024 Throwing error if SlrIndex is not valid
* pre 10/07/2024 Executing invalid command handler registered for SEM module
* irrespective of SLR index field
* ma 09/23/2024 Added support for PSM to PLM IPI event handler
*
* </pre>
*
Expand Down Expand Up @@ -123,28 +122,19 @@
#define XPLMI_ACCESS_PERM_MASK (0x3U)
#define XPLMI_ACCESS_PERM_SHIFT (0x2U)

#ifdef PLM_ENABLE_STL
#define XPLMI_PSM_TO_STL_EVENTS_CMD_ID (0x6U)
#endif /* PLM_ENABLE_STL */

/************************** Function Prototypes ******************************/
static u32 XPlmi_GetIpiReqType(u32 CmdId, u32 SrcIndex);
static XPlmi_SubsystemHandler XPlmi_GetPmSubsystemHandler(
XPlmi_SubsystemHandler SubsystemHandler);
static int XPlmi_IpiDispatchHandler(void *Data);
static int XPlmi_IpiCmdExecute(XPlmi_Cmd * CmdPtr, u32 * Payload);
static XStatus (*XPlmi_PsmIpiHandler)(void);
#ifndef VERSAL_AIEPG2
static int XPlmi_PsmIpiDispatchHandler(void *Data);
#endif /* VERSAL_AIEPG2 */

/************************** Variable Definitions *****************************/

/*****************************************************************************/
/* Instance of IPI Driver */
static XIpiPsu IpiInst;
static XIpiPsu_Config *IpiCfgPtr;
static volatile PsmToPlmEventInfo_t *PsmToPlmEventInfo = NULL;

/*****************************************************************************/
/**
Expand Down Expand Up @@ -204,15 +194,13 @@ int XPlmi_IpiDrvInit(void)
*
* @param SubsystemHandler is handler to XilPm API called to retrieve
* Subsystem Id using Ipi mask
* @param PsmIpiHandler is the handler for PSM IPI interrupts
*
* @return
* - XST_SUCCESS on success.
* - XPLM_ERR_TASK_CREATE if failed to create task.
*
*****************************************************************************/
int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler,
XPlmi_PsmIpiHandler_t PsmIpiHandler)
int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler)
{
int Status = XST_FAILURE;
u32 Index;
Expand Down Expand Up @@ -241,21 +229,9 @@ int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler,
IpiIntrId = XPlmi_GetIpiIntrId(IpiCfgPtr->TargetList[Index].BufferIndex);
Task = XPlmi_GetTaskInstance(NULL, NULL, IpiIntrId);
if (Task == NULL) {
#ifndef VERSAL_AIEPG2
if (IpiCfgPtr->TargetList[Index].BufferIndex ==
IPI_PSM_BUFFER_INDEX) {
Task = XPlmi_TaskCreate(XPLM_TASK_PRIORITY_1,
XPlmi_PsmIpiDispatchHandler,
(void *)IpiCfgPtr->TargetList[Index].BufferIndex);
}
else
#endif
{
Task = XPlmi_TaskCreate(XPLM_TASK_PRIORITY_1,
XPlmi_IpiDispatchHandler,
(void *)IpiCfgPtr->TargetList[Index].BufferIndex);
}

Task = XPlmi_TaskCreate(XPLM_TASK_PRIORITY_1,
XPlmi_IpiDispatchHandler,
(void *)IpiCfgPtr->TargetList[Index].BufferIndex);
if (Task == NULL) {
Status = XPlmi_UpdateStatus(XPLM_ERR_TASK_CREATE, 0);
XPlmi_Printf(DEBUG_INFO, "IPI Interrupt task creation "
Expand All @@ -270,7 +246,6 @@ int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler,
XPlmi_Out32(XIPIPSU_BASE_ADDR, XPLMI_SLAVE_ERROR_ENABLE_MASK);

(void) XPlmi_GetPmSubsystemHandler(SubsystemHandler);
XPlmi_PsmIpiHandler = PsmIpiHandler;

/** - Register and Enable the IPI IRQ. */
Status = XPlmi_RegisterNEnableIpi();
Expand Down Expand Up @@ -306,100 +281,6 @@ int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler,
return Status;
}

/*****************************************************************************/
/**
* @brief This function assigns PsmToPlmEventInfo structure address.
*
* @param EventInfo is the pointer to PsmToPlmEventInfo structure
*
*****************************************************************************/
void XPlmi_SetPsmToPlmEventInfo(volatile PsmToPlmEventInfo_t *EventInfo)
{
PsmToPlmEventInfo = EventInfo;
}

#ifndef VERSAL_AIEPG2
/*****************************************************************************/
/**
* @brief This is the handler for PSM IPI interrupts.
*
* @param Data is the buffer index of the PSM IPI channel.
*
* @return
* - XST_SUCCESS on success
* - XPlMI_INVALID_BUFFER_INDEX_FOR_PSM_IPI_TASK if input IPI index
* does not match with PSM IPI channel.
* - XPLMI_IPI_PSM_TO_PLM_EVENT_INFO_INVALID if PSM to PLM structure
* is not valid
* - Other error codes returned through the called functions.
*
*****************************************************************************/
static int XPlmi_PsmIpiDispatchHandler(void *Data)
{
int Status = XST_FAILURE;
#ifdef PLM_ENABLE_STL
const XPlmi_Module *Module = NULL;
static const XPlmi_ModuleCmd *PsmStlModuleCmd = NULL;
#endif

if ((u32)Data != IPI_PSM_BUFFER_INDEX) {
Status = (int)XPlMI_INVALID_BUFFER_INDEX_FOR_PSM_IPI_TASK;
goto END;
}

if (PsmToPlmEventInfo == NULL) {
Status = (int)XPLMI_IPI_PSM_TO_PLM_EVENT_INFO_INVALID;
goto END;
}

if ((XPlmi_IsLpdInitialized() == (u8)TRUE) &&
(PsmToPlmEventInfo->PmEvent == (u32)TRUE) &&
(XPlmi_PsmIpiHandler != NULL)) {
Status = (int)XPlmi_PsmIpiHandler();
if (Status != XST_SUCCESS) {
XPlmi_Printf(DEBUG_GENERAL, "Error: PSM-PLM event status: 0x%x\r\n",
Status);
}
} else {
Status = XST_SUCCESS;
}

#ifdef PLM_ENABLE_STL
if (PsmStlModuleCmd == NULL) {
Module = XPlmi_GetModule(XPLMI_MODULE_STL_ID);
if (Module != NULL) {
PsmStlModuleCmd = &Module->CmdAry[XPLMI_PSM_TO_STL_EVENTS_CMD_ID];
} else {
Status = XPlmi_UpdateStatus(XPLMI_ERR_MODULE_NOT_REGISTERED, 0);
goto END;
}
}

if ((XPlmi_IsLpdInitialized() == (u8)TRUE) &&
(PsmToPlmEventInfo->StlEvent == (u32)TRUE)) {
if (PsmStlModuleCmd->Handler(NULL) != XST_SUCCESS) {
XPlmi_Printf(DEBUG_GENERAL, "Error: PSM-STL event failed\r\n");
}
}
#endif

END:
if (XPlmi_IsLpdInitialized() == (u8)TRUE) {
/* Clear and enable PSM IPI interrupt */
XPlmi_Out32(IPI_PMC_ISR, IPI_PMC_ISR_PSM_BIT_MASK);
XPlmi_Out32(IPI_PMC_IER, IPI_PMC_ISR_PSM_BIT_MASK);
}

/**
* Clear and enable the IPI interrupt
*/
XPlmi_ClearIpiIntr();
XPlmi_EnableIpiIntr();

return Status;
}
#endif

/*****************************************************************************/
/**
* @brief This is the handler for IPI interrupts.
Expand All @@ -420,6 +301,9 @@ static int XPlmi_IpiDispatchHandler(void *Data)
u32 Payload[XPLMI_IPI_MAX_MSG_LEN] = {0U};
u32 MaskIndex;
XPlmi_Cmd Cmd = {0U};
#ifndef VERSAL_AIEPG2
u32 PendingPsmIpi = (u32)FALSE;
#endif

for (MaskIndex = 0U; MaskIndex < XPLMI_IPI_MASK_COUNT; MaskIndex++) {
if (IpiInst.Config.TargetList[MaskIndex].BufferIndex == (u32)Data) {
Expand All @@ -435,6 +319,11 @@ static int XPlmi_IpiDispatchHandler(void *Data)
Cmd.AckInPLM = (u8)TRUE;
Cmd.IpiReqType = XPLMI_CMD_NON_SECURE;
Cmd.IpiMask = IpiInst.Config.TargetList[MaskIndex].Mask;
#ifndef VERSAL_AIEPG2
if (IPI_PMC_ISR_PSM_BIT_MASK == Cmd.IpiMask) {
PendingPsmIpi = (u32)TRUE;
}
#endif

/**
* Read the IPI command and arguments
Expand Down Expand Up @@ -482,6 +371,15 @@ static int XPlmi_IpiDispatchHandler(void *Data)
}
Cmd.Payload = (u32 *)&Payload[1U];

#ifndef VERSAL_AIEPG2
/* Ack PSM IPIs before running handlers */
if (IPI_PMC_ISR_PSM_BIT_MASK == Cmd.IpiMask) {
PendingPsmIpi = (u32)FALSE;
XPlmi_Out32(IPI_PMC_ISR,
IPI_PMC_ISR_PSM_BIT_MASK);
}
#endif

/**
* Execute the IPI command
*/
Expand All @@ -503,7 +401,14 @@ static int XPlmi_IpiDispatchHandler(void *Data)
* Ack all IPIs
*/
if (XPlmi_IsLpdInitialized() == (u8)TRUE) {
#ifndef VERSAL_AIEPG2
if ((IPI_PMC_ISR_PSM_BIT_MASK != Cmd.IpiMask) ||
(PendingPsmIpi == (u32)TRUE)) {
XPlmi_Out32(IPI_PMC_ISR, Cmd.IpiMask);
}
#else
XPlmi_Out32(IPI_PMC_ISR, Cmd.IpiMask);
#endif
XPlmi_Out32(IPI_PMC_IER, Cmd.IpiMask);
}
}
Expand Down
13 changes: 1 addition & 12 deletions lib/sw_services/xilplmi/src/common/server/xplmi_ipi.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
* 1.08 bm 06/23/2023 Added IPI access permissions validation
* 1.09 bm 02/23/2024 Ack In-Place PLM Update request after complete restore
* 1.10 sk 05/07/2024 Added declaration for get ipi instance function
* ma 09/23/2024 Added support for PSM to PLM IPI event handler
*
* </pre>
*
Expand Down Expand Up @@ -80,26 +79,17 @@ extern "C" {
#define IPI_PMC_ISR_IPI5_BIT_MASK (0x80U)
#define IPI_NO_BUF_CHANNEL_INDEX (0xFFFFU)

/* PSM IPI defines */
#define IPI_PSM_BUFFER_INDEX (0U)

/* Command header secure bit defines */
#define IPI_CMD_HDR_SECURE_BIT_MASK (0x1000000U)
#define IPI_CMD_HDR_SECURE_BIT_SHIFT (24U)

/**************************** Type Definitions *******************************/
typedef struct {
u32 PmEvent;
u32 StlEvent;
} PsmToPlmEventInfo_t;

/***************** Macros (Inline Functions) Definitions *********************/
typedef u32 (*XPlmi_SubsystemHandler)(u32 IpiMask);
typedef XStatus (*XPlmi_PsmIpiHandler_t)(void);

/************************** Function Prototypes ******************************/
int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler,
XPlmi_PsmIpiHandler_t PsmIpiHandler);
int XPlmi_IpiInit(XPlmi_SubsystemHandler SubsystemHandler);
int XPlmi_IpiWrite(u32 DestCpuMask, const u32 *MsgPtr, u32 MsgLen, u8 Type);
int XPlmi_IpiRead(u32 SrcCpuMask, u32 *MsgPtr, u32 MsgLen, u8 Type);
int XPlmi_IpiTrigger(u32 DestCpuMask);
Expand All @@ -108,7 +98,6 @@ int XPlmi_IpiDrvInit(void);
int XPlmi_ValidateIpiCmd(XPlmi_Cmd *Cmd, u32 SrcIndex);
void XPlmi_IpiEnable(u32 IpiMask);
XIpiPsu *XPlmi_GetIpiInstance(void);
void XPlmi_SetPsmToPlmEventInfo(volatile PsmToPlmEventInfo_t *EventInfo);

/************************** Variable Definitions *****************************/

Expand Down
5 changes: 0 additions & 5 deletions lib/sw_services/xilplmi/src/versal/server/xplmi_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@
* rama 09/05/2024 Added XPLM_ERR_STL_DIAG_TASK_CREATE, XPLM_ERR_STL_DIAG_TASK_REMOVE
* error codes for STL diagnostic task scheduling
* pre 10/07/2024 Removed XPLMI_SSIT_NO_PENDING_EVENTS error code
* ma 09/23/2024 Added error codes related to PSM to PLM IPI events
*
* </pre>
*
Expand Down Expand Up @@ -368,10 +367,6 @@ typedef enum {
XPLMI_IPI_MAX_BUF_SIZE_EXCEEDS, /**< 0x1B3 - Error when IPI request size exceeds */
XPLMI_SSIT_SECURE_COMM_KEYWRITE_FAILURE, /**< 0x1B4 - Error if key write fails during
secure plm to plm communication establishment */
XPlMI_INVALID_BUFFER_INDEX_FOR_PSM_IPI_TASK, /**< 0x1B6 PSM IPI handler task received
invalid buffer index*/
XPLMI_IPI_PSM_TO_PLM_EVENT_INFO_INVALID, /**< 0x1B7 PSM IPI event structure not initialized */

/** Status codes used in PLM */
/* PLM error codes common for all platforms are from 0x200 to 0x29F */
XPLM_ERR_TASK_CREATE = 0x200, /**< 0x200 - Error when task create
Expand Down
4 changes: 0 additions & 4 deletions lib/sw_services/xilplmi/src/versal_net/server/xplmi_status.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
* mss 03/13/2024 MISRA-C violatiom Rule 17.8 fixed
* 2.1 mb 06/21/2024 Added error code for AES initialization fail
* pre 07/14/2024 Added error code for exceeding IPI buffer size
* ma 09/23/2024 Added error codes related to PSM to PLM IPI events
*
* </pre>
*
Expand Down Expand Up @@ -301,9 +300,6 @@ typedef enum {
retry later */
XPLMI_ERR_STORE_DATA_BACKUP, /**< 0x1BC - Error when data structure storing fails */
XPLMI_IPI_MAX_BUF_SIZE_EXCEEDS, /**< 0x1BD - Error when IPI request size exceeds */
XPlMI_INVALID_BUFFER_INDEX_FOR_PSM_IPI_TASK, /**< 0x1BE PSM IPI handler task received
invalid buffer index*/
XPLMI_IPI_PSM_TO_PLM_EVENT_INFO_INVALID, /**< 0x1BF PSM IPI event structure not initialized */

/** Status codes used in PLM */
/* PLM error codes common for all platforms are from 0x200 to 0x29F */
Expand Down
2 changes: 1 addition & 1 deletion lib/sw_services/xilpm/src/versal/server/xpm_api_plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ static XStatus PwrDomainInitNode(u32 NodeId, u32 Function, const u32 *Args, u32
}
XPlmi_LpdInit();
#ifdef XPLMI_IPI_DEVICE_ID
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask, XPm_ProcessPsmCmd);
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask);
if (XST_SUCCESS != Status) {
PmErr("Error %u in IPI initialization\r\n", Status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ static XStatus PwrDomainInitNode(u32 NodeId, u32 Function, const u32 *Args, u32
}
XPlmi_LpdInit();
#ifdef XPLMI_IPI_DEVICE_ID
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask, NULL);
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask);
if (XST_SUCCESS != Status) {
PmErr("Error %u in IPI initialization\r\n", Status);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/sw_services/xilpm/src/versal_common/server/xpm_psm_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,6 @@ XStatus XPm_GetPsmToPlmEventAddr(void)
Status = XPm_IpiRead(PSM_IPI_INT_MASK, &Response);
if (XST_SUCCESS == Status) {
PsmToPlmEvent = (struct PsmToPlmEvent_t *)Response[1];
/* Update PsmToPlmEventInfo in xilplmi */
XPlmi_SetPsmToPlmEventInfo(&PsmToPlmEvent->EventInfo);
} else if (XST_INVALID_PARAM == Status) {
PmErr("PSM-PLM versions may be out of sync. "
"PSM_TO_PLM_EVENT_ADDR unsupported.\n\r");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ extern "C" {

struct PsmToPlmEvent_t {
u32 Version; /* Version of the event structure */
PsmToPlmEventInfo_t EventInfo;
u32 Event[PROC_DEV_MAX];
u32 CpuIdleFlag[PROC_DEV_MAX];
u64 ResumeAddress[PROC_DEV_MAX];
Expand Down
2 changes: 1 addition & 1 deletion lib/sw_services/xilpm/src/versal_net/server/xpm_api_plat.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ static XStatus PwrDomainInitNode(u32 NodeId, u32 Function, const u32 *Args, u32
}
XPlmi_LpdInit();
#ifdef XPLMI_IPI_DEVICE_ID
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask, XPm_ProcessPsmCmd);
Status = XPlmi_IpiInit(XPmSubsystem_GetSubSysIdByIpiMask);
if (XST_SUCCESS != Status) {
PmErr("Error %u in IPI initialization\r\n", Status);
}
Expand Down

0 comments on commit 5f03a57

Please sign in to comment.