From c49ac865deffb57bb778e44d0cfa214459f10932 Mon Sep 17 00:00:00 2001 From: prsethi Date: Mon, 24 Apr 2023 16:43:11 +0000 Subject: [PATCH] gpu: nvgpu: init golden ctx image during nvgpu poweron Safety build temporal requirement is that on FECS power up it should go through entire initialization methods. init_golden_image callback is being called from devctl/ioctl path and triggers FECS method 10 and 11. As these methods are part of APP init, not being called during resume and causing quiesce on safety build. To fix this issue, calling the callback from poweron API. Bug 4082813 Bug 4037712 Change-Id: I2d27203d3cb4326ae7d8bd6025693fd61d5237df Signed-off-by: prsethi Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2893218 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/nvgpu/common/gr/gr.c | 11 +++++++++- drivers/gpu/nvgpu/common/gr/obj_ctx.c | 24 +++++++++++----------- drivers/gpu/nvgpu/common/init/nvgpu_init.c | 4 +++- drivers/gpu/nvgpu/os/linux/ioctl_channel.c | 10 --------- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/drivers/gpu/nvgpu/common/gr/gr.c b/drivers/gpu/nvgpu/common/gr/gr.c index 3fb1328c8..5d7cf3bf2 100644 --- a/drivers/gpu/nvgpu/common/gr/gr.c +++ b/drivers/gpu/nvgpu/common/gr/gr.c @@ -52,6 +52,9 @@ #include #include "gr_priv.h" +#ifndef CONFIG_NVGPU_NON_FUSA +#include "gr/obj_ctx_priv.h" +#endif static int gr_alloc_global_ctx_buffers(struct gk20a *g, struct nvgpu_gr *gr) { @@ -201,6 +204,10 @@ static void disable_gr_interrupts(struct gk20a *g) int nvgpu_gr_suspend(struct gk20a *g) { +#ifndef CONFIG_NVGPU_NON_FUSA + struct nvgpu_gr_obj_ctx_golden_image *golden_image = + nvgpu_gr_get_golden_image_ptr(g); +#endif int ret = 0; nvgpu_log_fn(g, " "); @@ -221,7 +228,9 @@ int nvgpu_gr_suspend(struct gk20a *g) nvgpu_gr_falcon_suspend(g, nvgpu_gr_get_falcon_ptr(g)); g->gr->initialized = false; - +#ifndef CONFIG_NVGPU_NON_FUSA + golden_image->ready = false; +#endif nvgpu_log_fn(g, "done"); return ret; } diff --git a/drivers/gpu/nvgpu/common/gr/obj_ctx.c b/drivers/gpu/nvgpu/common/gr/obj_ctx.c index e6d570130..eea0741cf 100644 --- a/drivers/gpu/nvgpu/common/gr/obj_ctx.c +++ b/drivers/gpu/nvgpu/common/gr/obj_ctx.c @@ -827,11 +827,6 @@ static int nvgpu_gr_obj_ctx_save_golden_ctx(struct gk20a *g, nvgpu_err(g, "golden context mismatch"); err = -ENOMEM; } - - /* free temporary copy now */ - nvgpu_gr_global_ctx_deinit_local_golden_image(g, - golden_image->local_golden_image_copy); - golden_image->local_golden_image_copy = NULL; #endif clean_up: @@ -1150,17 +1145,15 @@ int nvgpu_gr_obj_ctx_init_golden_context_image(struct gk20a *g) struct nvgpu_gr_ctx gr_ctx = {}; int err = 0; - err = gk20a_busy(g); - if (err != 0) { - nvgpu_err(g, "failed to power on, %d", err); - return err; - } - nvgpu_mutex_acquire(&golden_image->ctx_mutex); + /* Reinit golden context image during resume on safety build. This is + * needed to satisfy ctxsw temporal restrictions. */ +#ifdef CONFIG_NVGPU_NON_FUSA if (golden_image->ready) { goto out; } +#endif big_page_size = g->ops.mm.gmmu.get_default_big_page_size(); @@ -1218,7 +1211,6 @@ free_vm: nvgpu_vm_put(vm); out: nvgpu_mutex_release(&golden_image->ctx_mutex); - gk20a_idle(g); return err; } @@ -1460,6 +1452,14 @@ void nvgpu_gr_obj_ctx_deinit(struct gk20a *g, golden_image->local_golden_image); golden_image->local_golden_image = NULL; } + +#ifdef CONFIG_NVGPU_GR_GOLDEN_CTX_VERIFICATION + if (golden_image->local_golden_image_copy != NULL) { + nvgpu_gr_global_ctx_deinit_local_golden_image(g, + golden_image->local_golden_image_copy); + golden_image->local_golden_image_copy = NULL; + } +#endif #ifdef CONFIG_NVGPU_POWER_PG nvgpu_pmu_set_golden_image_initialized(g, GOLDEN_IMG_NOT_READY); #endif diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index e63a5c000..2f357bcd2 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -1048,7 +1048,9 @@ int nvgpu_finalize_poweron(struct gk20a *g) NVGPU_SUPPORT_GSP_STEST), #endif #endif - NVGPU_INIT_TABLE_ENTRY(nvgpu_nvs_init, NO_FLAG), + NVGPU_INIT_TABLE_ENTRY(nvgpu_nvs_init, NO_FLAG), + /* Initialize the golden context image. */ + NVGPU_INIT_TABLE_ENTRY(g->ops.gr.setup.init_golden_image, NO_FLAG), }; size_t i; diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index 8b3f80755..d4c8e6d2e 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -986,16 +986,6 @@ static int nvgpu_ioctl_channel_alloc_obj_ctx(struct nvgpu_channel *ch, { struct gk20a *g = ch->g; - if (g->ops.gr.setup.init_golden_image != NULL) { - int err = g->ops.gr.setup.init_golden_image(g); - - if (err != 0) { - nvgpu_err(g, "golden context image init failed (%d).", - err); - return -ENOSYS; - } - } - return g->ops.gr.setup.alloc_obj_ctx(ch, class_num, nvgpu_obj_ctx_user_flags_to_common_flags(user_flags)); }