From bf70449ba2d1ffd20b01741c491dc0f565009b3d Mon Sep 17 00:00:00 2001 From: Venkatesh Yadav Abbarapu Date: Mon, 19 Apr 2021 07:49:57 -0600 Subject: [PATCH 1/2] feat(versal): add support to reset SGI Add "reset" parameter in pm_register_sgi() to reset SGI number. This will be required if OS wants to reset SGI number to default state. Caller can reset param to 1 to reset SGI in ATF. Change-Id: If485ff275df884f74eb67671cac7fa953458afe9 Signed-off-by: Rajan Vaja Signed-off-by: Tanmay Shah --- plat/xilinx/versal/pm_service/pm_api_sys.c | 3 ++- plat/xilinx/versal/pm_service/pm_svc_main.c | 10 ++++++++-- plat/xilinx/versal/pm_service/pm_svc_main.h | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/plat/xilinx/versal/pm_service/pm_api_sys.c b/plat/xilinx/versal/pm_service/pm_api_sys.c index c7b60476f..04258cc0a 100644 --- a/plat/xilinx/versal/pm_service/pm_api_sys.c +++ b/plat/xilinx/versal/pm_service/pm_api_sys.c @@ -496,7 +496,8 @@ enum pm_ret_status pm_api_ioctl(uint32_t device_id, uint32_t ioctl_id, break; case IOCTL_SET_SGI: /* Get the sgi number */ - if (pm_register_sgi(arg1) != 0) { + ret = pm_register_sgi(arg1, arg2); + if (ret != 0) { return PM_RET_ERROR_ARGS; } gicd_write_irouter(gicv3_driver_data->gicd_base, diff --git a/plat/xilinx/versal/pm_service/pm_svc_main.c b/plat/xilinx/versal/pm_service/pm_svc_main.c index 75c12684a..f779ad78b 100644 --- a/plat/xilinx/versal/pm_service/pm_svc_main.c +++ b/plat/xilinx/versal/pm_service/pm_svc_main.c @@ -51,6 +51,7 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle, * pm_register_sgi() - PM register the IPI interrupt * * @sgi - SGI number to be used for communication. + * @reset - Reset to invalid SGI when reset=1. * @return On success, the initialization function must return 0. * Any other return value will cause the framework to ignore * the service @@ -58,9 +59,14 @@ static uint64_t ipi_fiq_handler(uint32_t id, uint32_t flags, void *handle, * Update the SGI number to be used. * */ -int pm_register_sgi(unsigned int sgi_num) +int pm_register_sgi(unsigned int sgi_num, unsigned int reset) { - if ((unsigned int)sgi != (unsigned int)INVALID_SGI) { + if (reset == 1U) { + sgi = INVALID_SGI; + return 0; + } + + if (sgi != INVALID_SGI) { return -EBUSY; } diff --git a/plat/xilinx/versal/pm_service/pm_svc_main.h b/plat/xilinx/versal/pm_service/pm_svc_main.h index 4f8dc2b7f..2dff5b296 100644 --- a/plat/xilinx/versal/pm_service/pm_svc_main.h +++ b/plat/xilinx/versal/pm_service/pm_svc_main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Xilinx, Inc. All rights reserved. + * Copyright (c) 2019-2022, Xilinx, Inc. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,5 +14,5 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3, uint64_t x4, void *cookie, void *handle, uint64_t flags); -int pm_register_sgi(unsigned int sgi_num); +int pm_register_sgi(unsigned int sgi_num, unsigned int reset); #endif /* PM_SVC_MAIN_H */ From fcf6f469318d693a024d42ae2d0f4afb26c1e85d Mon Sep 17 00:00:00 2001 From: Tanmay Shah Date: Tue, 14 Dec 2021 04:53:40 -0800 Subject: [PATCH 2/2] feat(versal): add SMCCC call TF_A_PM_REGISTER_SGI This call is used to register and reset SGI interrupt. Before this functionality was performed using IOCTL_REGISTER_SGI pm_ioctl EEMI call. It's not correct use of PM_IOCTL as it is not EEMI functionality. Instead this new SMCCC call will be handled by TF-A specific handler. Change-Id: If2408af38b889d29a5c584e8eec5f1672eab4fb5 Signed-off-by: Tanmay Shah --- plat/xilinx/versal/pm_service/pm_defs.h | 1 + plat/xilinx/versal/pm_service/pm_svc_main.c | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/plat/xilinx/versal/pm_service/pm_defs.h b/plat/xilinx/versal/pm_service/pm_defs.h index 378565049..92061208b 100644 --- a/plat/xilinx/versal/pm_service/pm_defs.h +++ b/plat/xilinx/versal/pm_service/pm_defs.h @@ -35,6 +35,7 @@ #define PM_GET_CALLBACK_DATA 0xa01U #define PM_GET_TRUSTZONE_VERSION 0xa03U +#define TF_A_PM_REGISTER_SGI 0xa04U /* PM API Versions */ #define PM_API_BASE_VERSION 1U diff --git a/plat/xilinx/versal/pm_service/pm_svc_main.c b/plat/xilinx/versal/pm_service/pm_svc_main.c index f779ad78b..24b68e7ef 100644 --- a/plat/xilinx/versal/pm_service/pm_svc_main.c +++ b/plat/xilinx/versal/pm_service/pm_svc_main.c @@ -237,6 +237,18 @@ static uintptr_t TF_A_specific_handler(uint32_t api_id, uint32_t *pm_arg, { switch (api_id) { + case TF_A_PM_REGISTER_SGI: + { + int ret; + + ret = pm_register_sgi(pm_arg[0], pm_arg[1]); + if (ret != 0) { + SMC_RET1(handle, (uint32_t)PM_RET_ERROR_ARGS); + } + + SMC_RET1(handle, (uint32_t)PM_RET_SUCCESS); + } + case PM_GET_CALLBACK_DATA: { uint32_t result[4] = {0};