diff --git a/drivers/gpu/nvgpu/common/gr/obj_ctx.c b/drivers/gpu/nvgpu/common/gr/obj_ctx.c index bdc27473c..152252270 100644 --- a/drivers/gpu/nvgpu/common/gr/obj_ctx.c +++ b/drivers/gpu/nvgpu/common/gr/obj_ctx.c @@ -1151,10 +1151,6 @@ int nvgpu_gr_obj_ctx_init_golden_context_image(struct gk20a *g) struct nvgpu_gr_ctx gr_ctx = {}; int err = 0; - if (g->is_virtual) { - return 0; - } - err = gk20a_busy(g); if (err != 0) { nvgpu_err(g, "failed to power on, %d", err); diff --git a/drivers/gpu/nvgpu/hal/init/hal_ga100.c b/drivers/gpu/nvgpu/hal/init/hal_ga100.c index 890498521..afe888e28 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_ga100.c +++ b/drivers/gpu/nvgpu/hal/init/hal_ga100.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include @@ -563,6 +564,7 @@ static const struct gops_gr_fecs_trace ga100_ops_gr_fecs_trace = { #endif static const struct gops_gr_setup ga100_ops_gr_setup = { + .init_golden_image = nvgpu_gr_obj_ctx_init_golden_context_image, .alloc_obj_ctx = nvgpu_gr_setup_alloc_obj_ctx, .free_gr_ctx = nvgpu_gr_setup_free_gr_ctx, .free_subctx = nvgpu_gr_setup_free_subctx, diff --git a/drivers/gpu/nvgpu/hal/init/hal_ga10b.c b/drivers/gpu/nvgpu/hal/init/hal_ga10b.c index 2720237f4..6f65a4aa6 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_ga10b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_ga10b.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #ifdef CONFIG_NVGPU_LS_PMU #include @@ -556,6 +557,7 @@ static const struct gops_gr_fecs_trace ga10b_ops_gr_fecs_trace = { #endif static const struct gops_gr_setup ga10b_ops_gr_setup = { + .init_golden_image = nvgpu_gr_obj_ctx_init_golden_context_image, .alloc_obj_ctx = nvgpu_gr_setup_alloc_obj_ctx, .free_gr_ctx = nvgpu_gr_setup_free_gr_ctx, .free_subctx = nvgpu_gr_setup_free_subctx, diff --git a/drivers/gpu/nvgpu/hal/init/hal_gm20b.c b/drivers/gpu/nvgpu/hal/init/hal_gm20b.c index 573df7728..1078f30c1 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gm20b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gm20b.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #ifdef CONFIG_NVGPU_LS_PMU #include @@ -293,6 +294,7 @@ static const struct gops_gr_fecs_trace gm20b_ops_gr_fecs_trace = { #endif static const struct gops_gr_setup gm20b_ops_gr_setup = { + .init_golden_image = nvgpu_gr_obj_ctx_init_golden_context_image, .alloc_obj_ctx = nvgpu_gr_setup_alloc_obj_ctx, .free_gr_ctx = nvgpu_gr_setup_free_gr_ctx, #ifdef CONFIG_NVGPU_GRAPHICS diff --git a/drivers/gpu/nvgpu/hal/init/hal_gv11b.c b/drivers/gpu/nvgpu/hal/init/hal_gv11b.c index 1e62660b5..de46064ed 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_gv11b.c +++ b/drivers/gpu/nvgpu/hal/init/hal_gv11b.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #ifdef CONFIG_NVGPU_LS_PMU #include @@ -448,6 +449,7 @@ static const struct gops_gr_fecs_trace gv11b_ops_gr_fecs_trace = { #endif static const struct gops_gr_setup gv11b_ops_gr_setup = { + .init_golden_image = nvgpu_gr_obj_ctx_init_golden_context_image, .alloc_obj_ctx = nvgpu_gr_setup_alloc_obj_ctx, .free_gr_ctx = nvgpu_gr_setup_free_gr_ctx, .free_subctx = nvgpu_gr_setup_free_subctx, diff --git a/drivers/gpu/nvgpu/hal/init/hal_tu104.c b/drivers/gpu/nvgpu/hal/init/hal_tu104.c index 699b714ec..a44d87061 100644 --- a/drivers/gpu/nvgpu/hal/init/hal_tu104.c +++ b/drivers/gpu/nvgpu/hal/init/hal_tu104.c @@ -243,6 +243,7 @@ #include #include #include +#include #include #include #include @@ -491,6 +492,7 @@ static const struct gops_gr_fecs_trace tu104_ops_gr_fecs_trace = { #endif static const struct gops_gr_setup tu104_ops_gr_setup = { + .init_golden_image = nvgpu_gr_obj_ctx_init_golden_context_image, .alloc_obj_ctx = nvgpu_gr_setup_alloc_obj_ctx, .free_gr_ctx = nvgpu_gr_setup_free_gr_ctx, .free_subctx = nvgpu_gr_setup_free_subctx, diff --git a/drivers/gpu/nvgpu/include/nvgpu/gops/gr.h b/drivers/gpu/nvgpu/include/nvgpu/gops/gr.h index 02b6abf9c..658a4f555 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gops/gr.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gops/gr.h @@ -163,6 +163,7 @@ struct gops_gr_ecc { * @see gops_gr */ struct gops_gr_setup { + int (*init_golden_image)(struct gk20a *g); /** * @brief Allocate and setup object context s/w image * for GPU channel. diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c index d45248c29..ca9304934 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_channel.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_channel.c @@ -984,19 +984,18 @@ static int nvgpu_ioctl_channel_alloc_obj_ctx(struct nvgpu_channel *ch, u32 class_num, u32 user_flags) { struct gk20a *g = ch->g; - int err; - /* - * Allocate VEID0 channel and initialize the golden context image. - */ - err = nvgpu_gr_obj_ctx_init_golden_context_image(g); - if (err != 0) { - nvgpu_err(g, "golden context image init failed (%d).", - err); - return -ENOSYS; + 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 ch->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)); }