From 2f3314fb9eaf0c1ac1ed5671e3fea464809c3422 Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Sun, 21 Apr 2019 09:34:56 +0530 Subject: [PATCH] gpu: nvgpu: address CCM deviations for pmu_cmd_post and rpc_execute nvgpu_pmu_cmd_post and nvgpu_pmu_rpc_execute CCM values were higher than 10. Address the same by moving cmd checks to pmu_validate_cmd and right cleanup in nvgpu_pmu_rpc_execute. JIRA NVGPU-3194 Change-Id: I5357a2469b256d4540881ad23f592dcee725511b Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/2101942 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/pmu/ipc/pmu_cmd.c | 27 ++++++++++------------ 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/nvgpu/common/pmu/ipc/pmu_cmd.c b/drivers/gpu/nvgpu/common/pmu/ipc/pmu_cmd.c index 2ed7cde0b..78105b1a2 100644 --- a/drivers/gpu/nvgpu/common/pmu/ipc/pmu_cmd.c +++ b/drivers/gpu/nvgpu/common/pmu/ipc/pmu_cmd.c @@ -88,6 +88,11 @@ static bool pmu_validate_cmd(struct nvgpu_pmu *pmu, struct pmu_cmd *cmd, struct gk20a *g = gk20a_from_pmu(pmu); u32 queue_size; + if (cmd == NULL) { + nvgpu_err(g, "PMU cmd buffer is NULL"); + return false; + } + if (!PMU_IS_SW_COMMAND_QUEUE(queue_id)) { goto invalid_cmd; } @@ -586,14 +591,8 @@ int nvgpu_pmu_cmd_post(struct gk20a *g, struct pmu_cmd *cmd, nvgpu_log_fn(g, " "); - if (cmd == NULL || !nvgpu_pmu_get_fw_ready(g, pmu)) { - if (cmd == NULL) { - nvgpu_warn(g, "%s(): PMU cmd buffer is NULL", __func__); - } else { - nvgpu_warn(g, "%s(): PMU is not ready", __func__); - } - - WARN_ON(true); + if (!nvgpu_pmu_get_fw_ready(g, pmu)) { + nvgpu_warn(g, "PMU is not ready"); return -EINVAL; } @@ -748,7 +747,7 @@ int nvgpu_pmu_rpc_execute(struct nvgpu_pmu *pmu, struct nv_pmu_rpc_header *rpc, if (status != 0) { nvgpu_err(g, "Failed to execute RPC status=0x%x, func=0x%x", status, rpc->function); - goto exit; + goto cleanup; } /* @@ -766,12 +765,10 @@ int nvgpu_pmu_rpc_execute(struct nvgpu_pmu *pmu, struct nv_pmu_rpc_header *rpc, nvgpu_kfree(g, rpc_payload); } -exit: - if (status != 0) { - if (rpc_payload != NULL) { - nvgpu_kfree(g, rpc_payload); - } - } + return 0; +cleanup: + nvgpu_kfree(g, rpc_payload); +exit: return status; }