gpu: nvgpu: move mem checking of gr_ctx to .alloc_obj_ctx

Preparing for adding vgpu cmd .add_obj_ctx and memory will be allocated
on server side. Outside of implementation of .alloc_obj_ctx, code should
not check whether gr_ctx is valid by check gr_ctx mem.

Jirs GVSCI-10977

Change-Id: I6b3d826e930fdfaaae517d204186642e49f5c2d7
Signed-off-by: Richard Zhao <rizhao@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2546190
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Richard Zhao
2021-06-14 22:08:29 -07:00
committed by mobile promotions
parent ec1175123e
commit 4e08649b7f
2 changed files with 3 additions and 4 deletions

View File

@@ -920,9 +920,7 @@ void nvgpu_tsg_release(struct nvgpu_ref *ref)
return;
}
if ((tsg->gr_ctx != NULL) &&
nvgpu_mem_is_valid(nvgpu_gr_ctx_get_ctx_mem(tsg->gr_ctx)) &&
(tsg->vm != NULL)) {
if ((tsg->gr_ctx != NULL) && (tsg->vm != NULL)) {
g->ops.gr.setup.free_gr_ctx(g, tsg->vm, tsg->gr_ctx);
}

View File

@@ -262,7 +262,8 @@ void nvgpu_gr_setup_free_gr_ctx(struct gk20a *g,
{
nvgpu_log_fn(g, " ");
if (gr_ctx != NULL) {
if ((gr_ctx != NULL) &&
nvgpu_mem_is_valid(nvgpu_gr_ctx_get_ctx_mem(gr_ctx))) {
#ifdef CONFIG_DEBUG_FS
if ((g->ops.gr.ctxsw_prog.dump_ctxsw_stats != NULL) &&
nvgpu_gr_ctx_desc_dump_ctxsw_stats_on_channel_close(