From 4e08649b7f0745d00d20f3b54414407d86fc3024 Mon Sep 17 00:00:00 2001 From: Richard Zhao Date: Mon, 14 Jun 2021 22:08:29 -0700 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2546190 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/tsg.c | 4 +--- drivers/gpu/nvgpu/common/gr/gr_setup.c | 3 ++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/common/fifo/tsg.c b/drivers/gpu/nvgpu/common/fifo/tsg.c index 392503dc3..6f9b18e83 100644 --- a/drivers/gpu/nvgpu/common/fifo/tsg.c +++ b/drivers/gpu/nvgpu/common/fifo/tsg.c @@ -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); } diff --git a/drivers/gpu/nvgpu/common/gr/gr_setup.c b/drivers/gpu/nvgpu/common/gr/gr_setup.c index 6d7df6967..71b4e335c 100644 --- a/drivers/gpu/nvgpu/common/gr/gr_setup.c +++ b/drivers/gpu/nvgpu/common/gr/gr_setup.c @@ -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(