gpu: nvgpu: assert gr dev is non-NULL

nvgpu_device_get can return NULL if supplied invalid ID or instance
ID. We expect GR device struct to be non-NULL there hence just
assert that it is indeed non-NULL in gr_reset_engine and
ga10b_grmgr_init_gr_manager.

CID 224133
CID 250232
Bug 3512546

Change-Id: Id09a1c436a8e49b921111b940d3d013bd66bff7a
Signed-off-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2707018
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Sagar Kamble
2022-05-04 12:55:47 +05:30
committed by mobile promotions
parent c1202d7283
commit 9d6269ce7f
2 changed files with 4 additions and 0 deletions

View File

@@ -620,6 +620,8 @@ static int gr_reset_engine(struct gk20a *g)
nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS, nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS,
nvgpu_gr_get_syspipe_id(g, g->mig.cur_gr_instance)); nvgpu_gr_get_syspipe_id(g, g->mig.cur_gr_instance));
nvgpu_assert(dev != NULL);
nvgpu_log(g, gpu_dbg_gr, "Reset GR%u", cur_gr_instance_id); nvgpu_log(g, gpu_dbg_gr, "Reset GR%u", cur_gr_instance_id);
/* Reset GR engine: Disable then enable GR engine */ /* Reset GR engine: Disable then enable GR engine */

View File

@@ -803,6 +803,8 @@ int ga10b_grmgr_init_gr_manager(struct gk20a *g)
gr_dev = nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS, gr_dev = nvgpu_device_get(g, NVGPU_DEVTYPE_GRAPHICS,
gr_syspipe->gr_syspipe_id); gr_syspipe->gr_syspipe_id);
nvgpu_assert(gr_dev != NULL);
/* /*
* HW recommended to put GR engine into reset before programming * HW recommended to put GR engine into reset before programming
* config_gpc_rs_map (ga10b_grmgr_config_gpc_smc_map()). * config_gpc_rs_map (ga10b_grmgr_config_gpc_smc_map()).