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 <prsethi@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2893218
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
prsethi
2023-04-24 16:43:11 +00:00
committed by mobile promotions
parent 1de86155d8
commit c49ac865de
4 changed files with 25 additions and 24 deletions

View File

@@ -52,6 +52,9 @@
#include <nvgpu/grmgr.h> #include <nvgpu/grmgr.h>
#include "gr_priv.h" #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) 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) 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; int ret = 0;
nvgpu_log_fn(g, " "); 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)); nvgpu_gr_falcon_suspend(g, nvgpu_gr_get_falcon_ptr(g));
g->gr->initialized = false; g->gr->initialized = false;
#ifndef CONFIG_NVGPU_NON_FUSA
golden_image->ready = false;
#endif
nvgpu_log_fn(g, "done"); nvgpu_log_fn(g, "done");
return ret; return ret;
} }

View File

@@ -827,11 +827,6 @@ static int nvgpu_gr_obj_ctx_save_golden_ctx(struct gk20a *g,
nvgpu_err(g, "golden context mismatch"); nvgpu_err(g, "golden context mismatch");
err = -ENOMEM; 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 #endif
clean_up: clean_up:
@@ -1150,17 +1145,15 @@ int nvgpu_gr_obj_ctx_init_golden_context_image(struct gk20a *g)
struct nvgpu_gr_ctx gr_ctx = {}; struct nvgpu_gr_ctx gr_ctx = {};
int err = 0; 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); 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) { if (golden_image->ready) {
goto out; goto out;
} }
#endif
big_page_size = g->ops.mm.gmmu.get_default_big_page_size(); big_page_size = g->ops.mm.gmmu.get_default_big_page_size();
@@ -1218,7 +1211,6 @@ free_vm:
nvgpu_vm_put(vm); nvgpu_vm_put(vm);
out: out:
nvgpu_mutex_release(&golden_image->ctx_mutex); nvgpu_mutex_release(&golden_image->ctx_mutex);
gk20a_idle(g);
return err; 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);
golden_image->local_golden_image = NULL; 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 #ifdef CONFIG_NVGPU_POWER_PG
nvgpu_pmu_set_golden_image_initialized(g, GOLDEN_IMG_NOT_READY); nvgpu_pmu_set_golden_image_initialized(g, GOLDEN_IMG_NOT_READY);
#endif #endif

View File

@@ -1049,6 +1049,8 @@ int nvgpu_finalize_poweron(struct gk20a *g)
#endif #endif
#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; size_t i;

View File

@@ -986,16 +986,6 @@ static int nvgpu_ioctl_channel_alloc_obj_ctx(struct nvgpu_channel *ch,
{ {
struct gk20a *g = ch->g; 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, return g->ops.gr.setup.alloc_obj_ctx(ch, class_num,
nvgpu_obj_ctx_user_flags_to_common_flags(user_flags)); nvgpu_obj_ctx_user_flags_to_common_flags(user_flags));
} }