fix(zynqmp): resolve coverity warnings

Fix for coverity issues in pm_service component.
Fixed compilation error for versal platform.

Change-Id: I948f01807e67ad1e41021557e040dcbfb7b3a39e
Signed-off-by: HariBabu Gattem <haribabu.gattem@amd.com>
Signed-off-by: Naman Patel <naman.patel@amd.com>
This commit is contained in:
HariBabu Gattem 2022-10-07 00:07:49 -07:00 committed by Bipin Ravi
parent baddcf497f
commit 590519a8a5
6 changed files with 25 additions and 32 deletions

View file

@ -16,7 +16,7 @@
#define IPI_BLOCKING 1
#define IPI_NON_BLOCKING 0
int32_t pm_ipi_init(const struct pm_proc *proc);
void pm_ipi_init(const struct pm_proc *proc);
enum pm_ret_status pm_ipi_send(const struct pm_proc *proc,
uint32_t payload[PAYLOAD_ARG_CNT]);

View file

@ -19,6 +19,7 @@
#include "pm_ipi.h"
#define ERROR_CODE_MASK (0xFFFFU)
#define PM_OFFSET (0U)
DEFINE_BAKERY_LOCK(pm_secure_lock);
@ -33,12 +34,10 @@ DEFINE_BAKERY_LOCK(pm_secure_lock);
*
* Called from pm_setup initialization function
*/
int32_t pm_ipi_init(const struct pm_proc *proc)
void pm_ipi_init(const struct pm_proc *proc)
{
bakery_lock_init(&pm_secure_lock);
ipi_mb_open(proc->ipi->local_ipi_id, proc->ipi->remote_ipi_id);
return 0;
}
/**
@ -55,7 +54,7 @@ static enum pm_ret_status pm_ipi_send_common(const struct pm_proc *proc,
uint32_t payload[PAYLOAD_ARG_CNT],
uint32_t is_blocking)
{
unsigned int offset = 0;
uint32_t offset = PM_OFFSET;
uintptr_t buffer_base = proc->ipi->buffer_base +
IPI_BUFFER_TARGET_REMOTE_OFFSET +
IPI_BUFFER_REQ_OFFSET;
@ -185,7 +184,7 @@ void pm_ipi_buff_read_callb(uint32_t *value, size_t count)
size_t i;
#if IPI_CRC_CHECK
size_t j;
unsigned int response_payload[PAYLOAD_ARG_CNT];
unsigned int response_payload[PAYLOAD_ARG_CNT] = {0};
#endif
uintptr_t buffer_base = IPI_BUFFER_REMOTE_BASE +
IPI_BUFFER_TARGET_LOCAL_OFFSET +

View file

@ -119,16 +119,10 @@ int32_t pm_register_sgi(uint32_t sgi_num, uint32_t reset)
*/
int32_t pm_setup(void)
{
int32_t status, ret = 0;
int32_t ret = 0;
status = pm_ipi_init(primary_proc);
if (status < 0) {
INFO("BL31: PM Service Init Failed, Error Code %d!\n", status);
ret = status;
} else {
pm_up = true;
}
pm_ipi_init(primary_proc);
pm_up = true;
/*
* Enable IPI IRQ

View file

@ -41,7 +41,7 @@
#define IPI_BUFFER_TARGET_LOCAL_OFFSET 0x80U
#define IPI_BUFFER_TARGET_REMOTE_OFFSET 0x1C0U
#define IPI_BUFFER_MAX_WORDS 8
#define IPI_BUFFER_MAX_WORDS 8U
#define IPI_BUFFER_REQ_OFFSET 0x0U
#define IPI_BUFFER_RESP_OFFSET 0x20U

View file

@ -176,7 +176,7 @@ static enum pm_node_id irq_to_pm_node(uint32_t irq)
static void pm_client_set_wakeup_sources(void)
{
uint32_t reg_num;
uint8_t pm_wakeup_nodes_set[NODE_MAX];
uint8_t pm_wakeup_nodes_set[NODE_MAX] = { 0 };
uintptr_t isenabler1 = BASE_GICD_BASE + GICD_ISENABLER + 4U;
/* In case of power-off suspend, only NODE_EXTERN must be set */

View file

@ -207,11 +207,10 @@ err:
*/
int32_t pm_setup(void)
{
int32_t status, ret;
status = pm_ipi_init(primary_proc);
pm_ipi_init(primary_proc);
ret = pm_get_api_version(&pm_ctx.api_version);
pm_get_api_version(&pm_ctx.api_version);
if (pm_ctx.api_version < PM_VERSION) {
ERROR("BL31: Platform Management API version error. Expected: "
"v%d.%d - Found: v%d.%d\n", PM_VERSION_MAJOR,
@ -220,6 +219,7 @@ int32_t pm_setup(void)
return -EINVAL;
}
int32_t status = 0, ret = 0;
#if ZYNQMP_WDT_RESTART
status = pm_wdt_restart_setup();
if (status)
@ -263,7 +263,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
uint32_t payload[PAYLOAD_ARG_CNT];
uint32_t pm_arg[5];
uint32_t result[PAYLOAD_ARG_CNT];
uint32_t result[PAYLOAD_ARG_CNT] = {0};
uint32_t api_id;
/* Handle case where PM wasn't initialized properly */
@ -350,7 +350,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_FPGA_GET_STATUS:
{
uint32_t value;
uint32_t value = 0;
ret = pm_fpga_get_status(&value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@ -368,7 +368,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
(uint64_t)result[2] | ((uint64_t)result[3] << 32));
case PM_IOCTL:
{
uint32_t value;
uint32_t value = 0;
ret = pm_ioctl(pm_arg[0], pm_arg[1], pm_arg[2],
pm_arg[3], &value);
@ -395,7 +395,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_CLOCK_GETSTATE:
{
uint32_t value;
uint32_t value = 0;
ret = pm_clock_getstate(pm_arg[0], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@ -407,7 +407,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_CLOCK_GETDIVIDER:
{
uint32_t value;
uint32_t value = 0;
ret = pm_clock_getdivider(pm_arg[0], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
@ -436,7 +436,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_CLOCK_GETPARENT:
{
uint32_t value;
uint32_t value = 0;
ret = pm_clock_getparent(pm_arg[0], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
@ -470,7 +470,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_FPGA_READ:
{
uint32_t value;
uint32_t value = 0;
ret = pm_fpga_read(pm_arg[0], pm_arg[1], pm_arg[2], pm_arg[3],
&value);
@ -479,7 +479,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_SECURE_AES:
{
uint32_t value;
uint32_t value = 0;
ret = pm_aes_engine(pm_arg[0], pm_arg[1], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32U);
@ -491,7 +491,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_PLL_GET_PARAMETER:
{
uint32_t value;
uint32_t value = 0;
ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32U));
@ -503,7 +503,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_PLL_GET_MODE:
{
uint32_t mode;
uint32_t mode = 0;
ret = pm_pll_get_mode(pm_arg[0], &mode);
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32U));
@ -511,7 +511,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_REGISTER_ACCESS:
{
uint32_t value;
uint32_t value = 0;
ret = pm_register_access(pm_arg[0], pm_arg[1], pm_arg[2],
pm_arg[3], &value);
@ -520,7 +520,7 @@ uint64_t pm_smc_handler(uint32_t smc_fid, uint64_t x1, uint64_t x2, uint64_t x3,
case PM_EFUSE_ACCESS:
{
uint32_t value;
uint32_t value = 0;
#if defined(ZYNQMP_SECURE_EFUSES)
if (is_caller_non_secure(flags)) {