From 2eface802a4aea417206bcdda689a65cf47d300b Mon Sep 17 00:00:00 2001 From: Nicolas Benech Date: Thu, 23 Aug 2018 16:23:52 -0400 Subject: gpu: nvgpu: Fix mutex MISRA 17.7 violations MISRA Rule-17.7 requires the return value of all functions to be used. Fix is either to use the return value or change the function to return void. This patch contains fix for calls to nvgpu_mutex_init and improves related error handling. JIRA NVGPU-677 Change-Id: I609fa138520cc7ccfdd5aa0e7fd28c8ca0b3a21c Signed-off-by: Nicolas Benech Reviewed-on: https://git-master.nvidia.com/r/1805598 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/fifo_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index f06bf1c5..9dfe3083 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -696,6 +696,7 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f) u32 active_engine_id, pbdma_id, engine_id; int flags = nvgpu_is_enabled(g, NVGPU_MM_USE_PHYSICAL_SG) ? NVGPU_DMA_FORCE_CONTIGUOUS : 0; + int err = 0; nvgpu_log_fn(g, " "); @@ -733,7 +734,7 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f) f->num_runlist_entries, runlist_size); for (i = 0; i < MAX_RUNLIST_BUFFERS; i++) { - int err = nvgpu_dma_alloc_flags_sys(g, flags, + err = nvgpu_dma_alloc_flags_sys(g, flags, runlist_size, &runlist->mem[i]); if (err) { @@ -741,7 +742,13 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f) goto clean_up_runlist; } } - nvgpu_mutex_init(&runlist->runlist_lock); + + err = nvgpu_mutex_init(&runlist->runlist_lock); + if (err != 0) { + nvgpu_err(g, + "Error in runlist_lock mutex initialization"); + goto clean_up_runlist; + } /* None of buffers is pinned if this value doesn't change. Otherwise, one of them (cur_buffer) must have been pinned. */ @@ -773,7 +780,7 @@ static int init_runlist(struct gk20a *g, struct fifo_gk20a *f) clean_up_runlist: gk20a_fifo_delete_runlist(f); nvgpu_log_fn(g, "fail"); - return -ENOMEM; + return err; } u32 gk20a_fifo_intr_0_error_mask(struct gk20a *g) -- cgit v1.2.2