From 52a4dd74e22bf11042def3db8ef07bdd695d6e79 Mon Sep 17 00:00:00 2001 From: Scott Long Date: Wed, 2 Oct 2019 09:37:27 -0700 Subject: [PATCH] gpu: nvgpu: fix misra 18.4 violations This change eliminates MISRA Advisory Rule 18.4 violations in the following cases: * nvgpu_submit_append_gpfifo_user_direct() * nvgpu_submit_append_gpfifo_common() - use array-indexing to access gpfifo entry lists * gv11b_gr_intr_record_sm_error_state() - use array-indexing to access sm_error_states table Advisory Rule 18.4 states that the +, -, +=, and -= operators should not be applied to an expression of pointer type. JIRA NVGPU-3798 Change-Id: I736930e4ba09a88888b0ef48f62496c4082ea5a1 Signed-off-by: Scott Long Reviewed-on: https://git-master.nvidia.com/r/2210173 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/submit.c | 6 +++--- drivers/gpu/nvgpu/hal/gr/intr/gr_intr_gv11b_fusa.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/submit.c b/drivers/gpu/nvgpu/common/fifo/submit.c index ebb541f03..a4f96a842 100644 --- a/drivers/gpu/nvgpu/common/fifo/submit.c +++ b/drivers/gpu/nvgpu/common/fifo/submit.c @@ -234,7 +234,7 @@ static int nvgpu_submit_append_gpfifo_user_direct(struct nvgpu_channel *c, u32 length1 = len - length0; err = g->os_channel.copy_user_gpfifo( - gpfifo_cpu + start, userdata, + &gpfifo_cpu[start], userdata, 0, length0); if (err != 0) { return err; @@ -248,7 +248,7 @@ static int nvgpu_submit_append_gpfifo_user_direct(struct nvgpu_channel *c, } } else { err = g->os_channel.copy_user_gpfifo( - gpfifo_cpu + start, userdata, + &gpfifo_cpu[start], userdata, 0, len); if (err != 0) { return err; @@ -274,7 +274,7 @@ static void nvgpu_submit_append_gpfifo_common(struct nvgpu_channel *c, /* wrap-around */ u32 length0 = gpfifo_size - start; u32 length1 = len - length0; - struct nvgpu_gpfifo_entry *src2 = src + length0; + struct nvgpu_gpfifo_entry *src2 = &src[length0]; nvgpu_mem_wr_n(g, gpfifo_mem, start, src, length0); nvgpu_mem_wr_n(g, gpfifo_mem, 0, src2, length1); diff --git a/drivers/gpu/nvgpu/hal/gr/intr/gr_intr_gv11b_fusa.c b/drivers/gpu/nvgpu/hal/gr/intr/gr_intr_gv11b_fusa.c index 23e7e39ba..48215f2bb 100644 --- a/drivers/gpu/nvgpu/hal/gr/intr/gr_intr_gv11b_fusa.c +++ b/drivers/gpu/nvgpu/hal/gr/intr/gr_intr_gv11b_fusa.c @@ -1691,7 +1691,7 @@ u32 gv11b_gr_intr_record_sm_error_state(struct gk20a *g, u32 gpc, u32 tpc, u32 s goto record_fail; } - sm_error_states = tsg->sm_error_states + sm_id; + sm_error_states = &tsg->sm_error_states[sm_id]; gv11b_gr_intr_read_sm_error_state(g, offset, sm_error_states); record_fail: