From 54e179ddadd2e56add9ed4e5ca5b44cb811e6b7a Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Wed, 15 May 2019 11:25:27 -0700 Subject: [PATCH] gpu: nvgpu: fix MISRA 13.5 nvgpu.hal.nvlink MISRA rule 13.5 doesn't allow right-hand operand of logical && or || operator to have persistent side effects. The reason is right-hand operand is executed or checked depending on the left-hand operand value. That means side effects in the right-hand operand may or may not occur, contrary to programmer's expectation. Hence, this rule is implemented to avoid unexpected behavior. This patch divides if condition with logical && operator to nested if conditions to resolve this violation. Jira NVGPU-3277 Change-Id: I9f4387d71427821278db6bbda2eb53bd4d8ea543 Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/2119684 Reviewed-by: Philip Elcan Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/hal/nvlink/minion_gv100.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/nvgpu/hal/nvlink/minion_gv100.c b/drivers/gpu/nvgpu/hal/nvlink/minion_gv100.c index b0f5f38a0..9036df151 100644 --- a/drivers/gpu/nvgpu/hal/nvlink/minion_gv100.c +++ b/drivers/gpu/nvgpu/hal/nvlink/minion_gv100.c @@ -60,11 +60,12 @@ u32 gv100_nvlink_minion_base_addr(struct gk20a *g) bool gv100_nvlink_minion_is_running(struct gk20a *g) { /* if minion is booted and not halted, it is running */ - if (((MINION_REG_RD32(g, minion_minion_status_r()) & - minion_minion_status_status_f(1)) != 0U) && - ((minion_falcon_irqstat_halt_v( - MINION_REG_RD32(g, minion_falcon_irqstat_r()))) == 0U)) { - return true; + if ((MINION_REG_RD32(g, minion_minion_status_r()) & + minion_minion_status_status_f(1)) != 0U) { + if (minion_falcon_irqstat_halt_v( + MINION_REG_RD32(g, minion_falcon_irqstat_r())) == 0U) { + return true; + } } return false;