From 04adc7130461e89778335a75d7d2f5b5890442bb Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Mon, 25 Nov 2019 19:31:16 +0530 Subject: [PATCH] gpu: nvgpu: add assert on number of SMs HAL gops.gr.config.init_sm_id_table() initializes SM count in struct nvgpu_gr_config. It is almost impossible that SM count is detected as zero. Hence remove the error check and add an assert instead. This also helps with code coverage tests since it is difficult to simulate error condition of having zero SMs detected. Also, HAL gops.gr.config.init_sm_id_table() should always be defined for each platform. Hence remove unnecessary check. Jira NVGPU-4373 Change-Id: Ibd9b301b28d5bd2952367346a8f12fabcee2abd9 Signed-off-by: Deepak Nibade Reviewed-on: https://git-master.nvidia.com/r/2247845 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Alex Waterman Reviewed-by: Seshendra Gadagottu GVS: Gerrit_Virtual_Submit Reviewed-by: Vinod Gopalakrishnakurup Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/fs_state.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/fs_state.c b/drivers/gpu/nvgpu/common/gr/fs_state.c index b67f6436d..e0b469a3f 100644 --- a/drivers/gpu/nvgpu/common/gr/fs_state.c +++ b/drivers/gpu/nvgpu/common/gr/fs_state.c @@ -105,18 +105,13 @@ int nvgpu_gr_fs_state_init(struct gk20a *g, struct nvgpu_gr_config *config) g->ops.gr.init.fs_state(g); - if (g->ops.gr.config.init_sm_id_table != NULL) { - err = g->ops.gr.config.init_sm_id_table(g, config); - if (err != 0) { - return err; - } - - /* Is table empty ? */ - if (g->ops.gr.init.get_no_of_sm(g) == 0U) { - return -EINVAL; - } + err = g->ops.gr.config.init_sm_id_table(g, config); + if (err != 0) { + return err; } + nvgpu_assert(g->ops.gr.init.get_no_of_sm(g) > 0U); + for (sm_id = 0; sm_id < g->ops.gr.init.get_no_of_sm(g); sm_id++) { struct nvgpu_sm_info *sm_info =