From 6c08d1df0ccb14fb66ba081bbe57ea17b8b3bb1c Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Fri, 19 Apr 2024 14:35:27 +0530 Subject: [PATCH 1/7] fix(zynqmp): add external declaration This corrects the MISRA violation C2012-8.4: A compatible declaration shall be visible when an object or function with external linkage is defined. Change-Id: I0e554972c24b70abd5b563639482f267cd4e1b5e Signed-off-by: Nithin G <nithing@amd.com> Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/xilinx/zynqmp/aarch64/zynqmp_common.c | 1 + plat/xilinx/zynqmp/custom_sip_svc.c | 2 ++ plat/xilinx/zynqmp/plat_topology.c | 2 ++ plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c | 1 + 4 files changed, 6 insertions(+) diff --git a/plat/xilinx/zynqmp/aarch64/zynqmp_common.c b/plat/xilinx/zynqmp/aarch64/zynqmp_common.c index 8b902c828..0e698f733 100644 --- a/plat/xilinx/zynqmp/aarch64/zynqmp_common.c +++ b/plat/xilinx/zynqmp/aarch64/zynqmp_common.c @@ -14,6 +14,7 @@ #include <lib/smccc.h> #include <lib/xlat_tables/xlat_tables_v2.h> #include <plat/common/platform.h> +#include <plat_arm.h> #include <services/arm_arch_svc.h> #include <plat_ipi.h> diff --git a/plat/xilinx/zynqmp/custom_sip_svc.c b/plat/xilinx/zynqmp/custom_sip_svc.c index c61c92cdd..c39e4bef2 100644 --- a/plat/xilinx/zynqmp/custom_sip_svc.c +++ b/plat/xilinx/zynqmp/custom_sip_svc.c @@ -8,6 +8,8 @@ #include <common/debug.h> #include <smccc_helpers.h> +#include <custom_svc.h> + uint64_t custom_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) diff --git a/plat/xilinx/zynqmp/plat_topology.c b/plat/xilinx/zynqmp/plat_topology.c index 25966508c..3755513ce 100644 --- a/plat/xilinx/zynqmp/plat_topology.c +++ b/plat/xilinx/zynqmp/plat_topology.c @@ -5,6 +5,8 @@ */ #include <stdint.h> +#include <plat/common/platform.h> + static const uint8_t plat_power_domain_tree_desc[] = {1, 4}; const uint8_t *plat_get_power_domain_tree_desc(void) diff --git a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c index b3215f81d..c3a9e5197 100644 --- a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c +++ b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c @@ -22,6 +22,7 @@ #include <plat_private.h> #include "pm_client.h" #include "pm_ipi.h" +#include "pm_svc_main.h" #include "zynqmp_pm_api_sys.h" #include "zynqmp_pm_defs.h" From 16c611f8a6f6a6669265fda95115a0ade56078e7 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Mon, 7 Oct 2024 09:27:58 +0000 Subject: [PATCH 2/7] fix(versal): add external declaration This corrects the MISRA violation C2012-8.4: A compatible declaration shall be visible when an object or function with external linkage is defined. Change-Id: I91817596c5de84b259a5dffcc01a7b1106a5b7a4 Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/xilinx/common/plat_clkfunc.c | 1 + plat/xilinx/common/versal.c | 1 + plat/xilinx/versal/include/plat_private.h | 2 ++ plat/xilinx/versal/plat_psci.c | 2 +- plat/xilinx/versal/sip_svc_setup.c | 16 ++++++++-------- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/plat/xilinx/common/plat_clkfunc.c b/plat/xilinx/common/plat_clkfunc.c index 8a8ea7e8e..f7910de6c 100644 --- a/plat/xilinx/common/plat_clkfunc.c +++ b/plat/xilinx/common/plat_clkfunc.c @@ -8,6 +8,7 @@ #include <plat/common/platform.h> #include <platform_def.h> +#include <plat_clkfunc.h> #include <plat_private.h> uint32_t plat_get_syscnt_freq2(void) diff --git a/plat/xilinx/common/versal.c b/plat/xilinx/common/versal.c index 3ea022cf3..b37dc76c2 100644 --- a/plat/xilinx/common/versal.c +++ b/plat/xilinx/common/versal.c @@ -7,6 +7,7 @@ #include <common/debug.h> #include <lib/mmio.h> #include <lib/smccc.h> +#include <plat/common/platform.h> #include <services/arm_arch_svc.h> #include <plat_private.h> diff --git a/plat/xilinx/versal/include/plat_private.h b/plat/xilinx/versal/include/plat_private.h index 4b2b6cf46..658dc9eb1 100644 --- a/plat/xilinx/versal/include/plat_private.h +++ b/plat/xilinx/versal/include/plat_private.h @@ -34,6 +34,8 @@ void plat_versal_gic_cpuif_disable(void); void plat_versal_gic_pcpu_init(void); void plat_versal_gic_save(void); void plat_versal_gic_resume(void); +void plat_versal_gic_redistif_on(void); +void plat_versal_gic_redistif_off(void); uint32_t versal_calc_core_pos(u_register_t mpidr); /* diff --git a/plat/xilinx/versal/plat_psci.c b/plat/xilinx/versal/plat_psci.c index 7571e9d44..9acf24e2b 100644 --- a/plat/xilinx/versal/plat_psci.c +++ b/plat/xilinx/versal/plat_psci.c @@ -126,7 +126,7 @@ static void versal_pwr_domain_suspend_finish( plat_versal_gic_cpuif_enable(); } -void versal_pwr_domain_on_finish(const psci_power_state_t *target_state) +static void versal_pwr_domain_on_finish(const psci_power_state_t *target_state) { /* Enable the gic cpu interface */ plat_versal_gic_pcpu_init(); diff --git a/plat/xilinx/versal/sip_svc_setup.c b/plat/xilinx/versal/sip_svc_setup.c index d449f746c..3027946b1 100644 --- a/plat/xilinx/versal/sip_svc_setup.c +++ b/plat/xilinx/versal/sip_svc_setup.c @@ -68,14 +68,14 @@ static int32_t sip_svc_setup(void) * * Return: Unused. */ -uintptr_t sip_svc_smc_handler(uint32_t smc_fid, - u_register_t x1, - u_register_t x2, - u_register_t x3, - u_register_t x4, - void *cookie, - void *handle, - u_register_t flags) +static uintptr_t sip_svc_smc_handler(uint32_t smc_fid, + u_register_t x1, + u_register_t x2, + u_register_t x3, + u_register_t x4, + void *cookie, + void *handle, + u_register_t flags) { VERBOSE("SMCID: 0x%08x, x1: 0x%016" PRIx64 ", x2: 0x%016" PRIx64 ", x3: 0x%016" PRIx64 ", x4: 0x%016" PRIx64 "\n", smc_fid, x1, x2, x3, x4); From 17a8f41e458e662c878fc8549d7a04a49e88abac Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Mon, 7 Oct 2024 10:55:26 +0000 Subject: [PATCH 3/7] fix(versal2): add external declaration This corrects the MISRA violation C2012-8.4: A compatible declaration shall be visible when an object or function with external linkage is defined. Change-Id: I75c8e6a23ec192417f0e09c226f53c922a43f33c Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/amd/versal2/include/scmi.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plat/amd/versal2/include/scmi.h b/plat/amd/versal2/include/scmi.h index 0ab8b34a7..761535bd5 100644 --- a/plat/amd/versal2/include/scmi.h +++ b/plat/amd/versal2/include/scmi.h @@ -14,6 +14,14 @@ void init_scmi_server(void); +size_t plat_scmi_pd_count(unsigned int agent_id); +const char *plat_scmi_pd_get_name(unsigned int agent_id, unsigned int pd_id); +unsigned int plat_scmi_pd_statistics(unsigned int agent_id, unsigned long *pd_id); +unsigned int plat_scmi_pd_get_attributes(unsigned int agent_id, unsigned int pd_id); +unsigned int plat_scmi_pd_get_state(unsigned int agent_id, unsigned int pd_id); +int32_t plat_scmi_pd_set_state(unsigned int agent_id, unsigned int flags, unsigned int pd_id, + unsigned int state); + #define SCMI_VENDOR "AMD" #define SCMI_PRODUCT "Versal Gen 2" From eda23fa5aa065216d9cf86176fbb916b4841c874 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Tue, 8 Oct 2024 05:34:11 +0000 Subject: [PATCH 4/7] fix(zynqmp): variable conflicting with external linkage This corrects the MISRA violation C2012-5.8: Identifiers that define objects or functions with external linkage shall be unique. Modify the variable name to prevent conflict with external object linkage. Change-Id: I32bed542c4810508174029ab0aaec18bcdf849a5 Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/xilinx/zynqmp/pm_service/zynqmp_pm_api_sys.c | 6 +++--- plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_api_sys.c b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_api_sys.c index 079f89e50..719ab6f84 100644 --- a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_api_sys.c +++ b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_api_sys.c @@ -769,7 +769,7 @@ static enum pm_ret_status fw_api_version(uint32_t id, uint32_t *version, enum pm_ret_status check_api_dependency(uint8_t id) { uint8_t i; - uint32_t version; + uint32_t version_type; int ret; for (i = 0U; i < ARRAY_SIZE(api_dep_table); i++) { @@ -779,13 +779,13 @@ enum pm_ret_status check_api_dependency(uint8_t id) } ret = fw_api_version(api_dep_table[i].api_id, - &version, 1); + &version_type, 1); if (ret != PM_RET_SUCCESS) { return ret; } /* Check if fw version matches TF-A expected version */ - if (version != tfa_expected_ver_id[api_dep_table[i].api_id]) { + if (version_type != tfa_expected_ver_id[api_dep_table[i].api_id]) { return PM_RET_ERROR_NOTSUPPORTED; } } diff --git a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c index c3a9e5197..738699eac 100644 --- a/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c +++ b/plat/xilinx/zynqmp/pm_service/zynqmp_pm_svc_main.c @@ -556,12 +556,12 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3, case PM_FEATURE_CHECK: { - uint32_t version = 0; + uint32_t version_type = 0; uint32_t bit_mask[2] = {0}; - ret = pm_feature_check(pm_arg[0], &version, bit_mask, + ret = pm_feature_check(pm_arg[0], &version_type, bit_mask, ARRAY_SIZE(bit_mask)); - SMC_RET2(handle, ((uint64_t)ret | ((uint64_t)version << 32U)), + SMC_RET2(handle, ((uint64_t)ret | ((uint64_t)version_type << 32U)), ((uint64_t)bit_mask[0] | ((uint64_t)bit_mask[1] << 32U))); } From e452826ad3aa595f720be2c2500ada2f27d3eaea Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Tue, 8 Oct 2024 05:42:28 +0000 Subject: [PATCH 5/7] fix(versal): variable conflicting with external linkage This corrects the MISRA violation C2012-5.8: Identifiers that define objects or functions with external linkage shall be unique. Modify the variable name to prevent conflict with external object linkage. Change-Id: I118fc302e6c37ba589a2871a7c59a694314910c2 Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/xilinx/versal/plat_psci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plat/xilinx/versal/plat_psci.c b/plat/xilinx/versal/plat_psci.c index 9acf24e2b..3fc6dbd3b 100644 --- a/plat/xilinx/versal/plat_psci.c +++ b/plat/xilinx/versal/plat_psci.c @@ -197,7 +197,7 @@ static void __dead2 versal_system_reset(void) */ static void versal_pwr_domain_off(const psci_power_state_t *target_state) { - uint32_t ret, fw_api_version, version[RET_PAYLOAD_ARG_CNT] = {0U}; + uint32_t ret, fw_api_version, version_type[RET_PAYLOAD_ARG_CNT] = {0U}; uint32_t cpu_id = plat_my_core_pos(); const struct pm_proc *proc = pm_get_proc(cpu_id); @@ -221,9 +221,9 @@ static void versal_pwr_domain_off(const psci_power_state_t *target_state) * invoking CPU_on function, during which resume address will * be set. */ - ret = pm_feature_check((uint32_t)PM_SELF_SUSPEND, &version[0], SECURE_FLAG); + ret = pm_feature_check((uint32_t)PM_SELF_SUSPEND, &version_type[0], SECURE_FLAG); if (ret == PM_RET_SUCCESS) { - fw_api_version = version[0] & 0xFFFFU; + fw_api_version = version_type[0] & 0xFFFFU; if (fw_api_version >= 3U) { (void)pm_self_suspend(proc->node_id, MAX_LATENCY, PM_STATE_CPU_OFF, 0, SECURE_FLAG); From 4d2b4e4dd7ed22a41c0569f9b2b2fd5c419a8261 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Tue, 8 Oct 2024 05:50:05 +0000 Subject: [PATCH 6/7] fix(versal-net): variable conflicting with external linkage This corrects the MISRA violation C2012-5.8: Identifiers that define objects or functions with external linkage shall be unique. Modify the variable name to prevent conflict with external object linkage. Change-Id: Icba1860d789d3826a58b3d83b65ca86a7b364c46 Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/xilinx/versal_net/aarch64/versal_net_common.c | 8 ++++---- plat/xilinx/versal_net/plat_psci_pm.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plat/xilinx/versal_net/aarch64/versal_net_common.c b/plat/xilinx/versal_net/aarch64/versal_net_common.c index 55c419831..0dd019461 100644 --- a/plat/xilinx/versal_net/aarch64/versal_net_common.c +++ b/plat/xilinx/versal_net/aarch64/versal_net_common.c @@ -60,11 +60,11 @@ char *board_name_decode(void) void board_detection(void) { - uint32_t version; + uint32_t version_type; - version = mmio_read_32(PMC_TAP_VERSION); - platform_id = FIELD_GET(PLATFORM_MASK, version); - platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version); + version_type = mmio_read_32(PMC_TAP_VERSION); + platform_id = FIELD_GET(PLATFORM_MASK, version_type); + platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version_type); if (platform_id == VERSAL_NET_QEMU_COSIM) { platform_id = VERSAL_NET_QEMU; diff --git a/plat/xilinx/versal_net/plat_psci_pm.c b/plat/xilinx/versal_net/plat_psci_pm.c index a2bf0d945..1c32879b5 100644 --- a/plat/xilinx/versal_net/plat_psci_pm.c +++ b/plat/xilinx/versal_net/plat_psci_pm.c @@ -59,7 +59,7 @@ static int32_t versal_net_pwr_domain_on(u_register_t mpidr) */ static void versal_net_pwr_domain_off(const psci_power_state_t *target_state) { - uint32_t ret, fw_api_version, version[RET_PAYLOAD_ARG_CNT] = {0U}; + uint32_t ret, fw_api_version, version_type[RET_PAYLOAD_ARG_CNT] = {0U}; uint32_t cpu_id = plat_my_core_pos(); const struct pm_proc *proc = pm_get_proc(cpu_id); @@ -83,9 +83,9 @@ static void versal_net_pwr_domain_off(const psci_power_state_t *target_state) * invoking CPU_on function, during which resume address will * be set. */ - ret = pm_feature_check((uint32_t)PM_SELF_SUSPEND, &version[0], SECURE_FLAG); + ret = pm_feature_check((uint32_t)PM_SELF_SUSPEND, &version_type[0], SECURE_FLAG); if (ret == PM_RET_SUCCESS) { - fw_api_version = version[0] & 0xFFFFU; + fw_api_version = version_type[0] & 0xFFFFU; if (fw_api_version >= 3U) { (void)pm_self_suspend(proc->node_id, MAX_LATENCY, PM_STATE_CPU_OFF, 0, SECURE_FLAG); From ca39fd46c1ce0203df7f797fa6bd8a4fc5336c38 Mon Sep 17 00:00:00 2001 From: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> Date: Tue, 8 Oct 2024 06:09:19 +0000 Subject: [PATCH 7/7] fix(versal2): variable conflicting with external linkage This corrects the MISRA violation C2012-5.8: Identifiers that define objects or functions with external linkage shall be unique. Modify the variable name to prevent conflict with external object linkage. Change-Id: I2448e4ad0660e654ceb40940e0046d2f2899b41b Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com> --- plat/amd/versal2/aarch64/common.c | 8 ++++---- plat/amd/versal2/plat_psci.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/plat/amd/versal2/aarch64/common.c b/plat/amd/versal2/aarch64/common.c index 5fce01ec1..0e46edc9c 100644 --- a/plat/amd/versal2/aarch64/common.c +++ b/plat/amd/versal2/aarch64/common.c @@ -72,11 +72,11 @@ const char *board_name_decode(void) void board_detection(void) { - uint32_t version; + uint32_t version_type; - version = mmio_read_32(PMC_TAP_VERSION); - platform_id = FIELD_GET(PLATFORM_MASK, version); - platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version); + version_type = mmio_read_32(PMC_TAP_VERSION); + platform_id = FIELD_GET(PLATFORM_MASK, version_type); + platform_version = FIELD_GET(PLATFORM_VERSION_MASK, version_type); if (platform_id == QEMU_COSIM) { platform_id = QEMU; diff --git a/plat/amd/versal2/plat_psci.c b/plat/amd/versal2/plat_psci.c index 688b17736..eab032ddc 100644 --- a/plat/amd/versal2/plat_psci.c +++ b/plat/amd/versal2/plat_psci.c @@ -222,11 +222,11 @@ static uint64_t no_pm_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64 } case PM_GET_CHIPID: { - uint32_t idcode, version; + uint32_t idcode, version_type; idcode = mmio_read_32(PMC_TAP); - version = mmio_read_32(PMC_TAP_VERSION); - SMC_RET2(handle, ((uint64_t)idcode << 32), version); + version_type = mmio_read_32(PMC_TAP_VERSION); + SMC_RET2(handle, ((uint64_t)idcode << 32), version_type); } default: WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);