diff --git a/drivers/gpu/nvgpu/common/grmgr/grmgr.c b/drivers/gpu/nvgpu/common/grmgr/grmgr.c index 99e9649c1..43f2b9e88 100644 --- a/drivers/gpu/nvgpu/common/grmgr/grmgr.c +++ b/drivers/gpu/nvgpu/common/grmgr/grmgr.c @@ -88,7 +88,18 @@ int nvgpu_init_gr_manager(struct gk20a *g) } nvgpu_assert(local_gpc_mask == 0U); } - gr_syspipe->max_veid_count_per_tsg = g->fifo.max_subctx_count; + + if (g->ops.gr.init.get_max_subctx_count != NULL) { + gr_syspipe->max_veid_count_per_tsg = + g->ops.gr.init.get_max_subctx_count(); + } else { + /* + * For vgpu, NvGpu has to rely on chip constant + * queried from nvgpu server. + * For legacy chips, g->fifo.max_subctx_count should be 0U. + */ + gr_syspipe->max_veid_count_per_tsg = g->fifo.max_subctx_count; + } gr_syspipe->veid_start_offset = 0U; gpu_instance->num_lce = nvgpu_device_get_copies(g, gpu_instance->lce_devs, diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 1ebd33212..5a93345b6 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -42,6 +42,7 @@ #include #include #include +#include #ifdef CONFIG_NVGPU_LS_PMU #include @@ -585,6 +586,38 @@ static bool needs_init(struct gk20a *g, nvgpu_init_func_t func, u32 enable_flag) nvgpu_is_enabled(g, enable_flag)) && (func != NULL); } +int nvgpu_early_poweron(struct gk20a *g) +{ + int err = 0; + + err = nvgpu_detect_chip(g); + if (err != 0) { + nvgpu_err(g, "nvgpu_detect_chip failed[%d]", err); + goto done; + } + + /* + * Initialize the GPU's device list. Needed before NVLINK + * init since the NVLINK IOCTRL block is enumerated in the + * device list. + */ + err = nvgpu_device_init(g); + if (err != 0) { + nvgpu_err(g, "nvgpu_device_init failed[%d]", err); + goto done; + } + + err = g->ops.grmgr.init_gr_manager(g); + if (err != 0) { + nvgpu_device_cleanup(g); + nvgpu_err(g, "g->ops.grmgr.init_gr_manager failed[%d]", err); + goto done; + } + +done: + return err; +} + int nvgpu_finalize_poweron(struct gk20a *g) { int err = 0; @@ -610,12 +643,6 @@ int nvgpu_finalize_poweron(struct gk20a *g) NVGPU_INIT_TABLE_ENTRY(&nvgpu_falcons_sw_init, NO_FLAG), NVGPU_INIT_TABLE_ENTRY(g->ops.pmu.pmu_early_init, NO_FLAG), - /* - * Initialize the GPU's device list. Needed before NVLINK - * init since the NVLINK IOCTRL block is enumerated in the - * device list. - */ - NVGPU_INIT_TABLE_ENTRY(&nvgpu_device_init, NO_FLAG), #ifdef CONFIG_NVGPU_DGPU NVGPU_INIT_TABLE_ENTRY(g->ops.sec2.init_sec2_setup_sw, NVGPU_SUPPORT_SEC2_RTOS), @@ -665,7 +692,6 @@ int nvgpu_finalize_poweron(struct gk20a *g) NVGPU_INIT_TABLE_ENTRY(&nvgpu_init_acquire_tpc_pg_lock, NO_FLAG), NVGPU_INIT_TABLE_ENTRY(&nvgpu_init_power_gate_gr, NO_FLAG), #endif - NVGPU_INIT_TABLE_ENTRY(g->ops.grmgr.init_gr_manager, NO_FLAG), NVGPU_INIT_TABLE_ENTRY(&nvgpu_netlist_init_ctx_vars, NO_FLAG), /* prepare portion of sw required for enable hw */ NVGPU_INIT_TABLE_ENTRY(&nvgpu_gr_alloc, NO_FLAG), diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h index 9897dcbe3..d5daaf26c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvgpu_init.h @@ -79,6 +79,20 @@ struct nvgpu_ref; * + nvgpu_check_gpu_state() - Restart if the state is invalid. */ +/** + * @brief Initial driver initialization + * + * @param g [in] The GPU + * + * Initializes device and grmgr subunits in the early stage of + * GPU power on sequence. This separate routine is required to create + * the GPU dev node in the early stage of GPU power on sequence. + * Each sub-unit is responsible for HW initialization. + * + * @return 0 in case of success, < 0 in case of failure. + */ +int nvgpu_early_poweron(struct gk20a *g); + /** * @brief Final driver initialization * diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index a091eba67..a68736b47 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -41,7 +41,6 @@ #include #endif /* CONFIG_NVGPU_TEGRA_FUSE */ -#include #include #include #include @@ -434,14 +433,12 @@ int gk20a_pm_finalize_poweron(struct device *dev) nvgpu_restore_usermode_for_poweron(g); - err = nvgpu_detect_chip(g); - if (err) + err = nvgpu_early_poweron(g); + if (err != 0) { + nvgpu_err(g, "nvgpu_early_poweron failed[%d]", err); goto done; + } - /** - * TODO: Need to add nvgpu_early_poweron() sequence before - * creating device nodes. - */ if (!l->dev_nodes_created) { err = gk20a_user_init(dev); if (err) {