diff --git a/drivers/gpu/nvgpu/common/init/nvgpu_init.c b/drivers/gpu/nvgpu/common/init/nvgpu_init.c index 83bd068c8..d50ae4a80 100644 --- a/drivers/gpu/nvgpu/common/init/nvgpu_init.c +++ b/drivers/gpu/nvgpu/common/init/nvgpu_init.c @@ -346,7 +346,7 @@ int nvgpu_finalize_poweron(struct gk20a *g) return err; } - err = g->ops.pmu.pmu_early_init(g, &g->pmu); + err = g->ops.pmu.pmu_early_init(g); if (err != 0) { nvgpu_err(g, "failed to early init pmu sw"); goto done; @@ -523,7 +523,7 @@ int nvgpu_finalize_poweron(struct gk20a *g) #endif #ifdef CONFIG_NVGPU_LS_PMU - err = nvgpu_pmu_rtos_init(g, g->pmu); + err = nvgpu_pmu_rtos_init(g); if (err != 0) { nvgpu_err(g, "failed to init gk20a pmu"); nvgpu_mutex_release(&g->tpc_pg_lock); diff --git a/drivers/gpu/nvgpu/common/pmu/pmu.c b/drivers/gpu/nvgpu/common/pmu/pmu.c index 4514219ec..dce4ef5e9 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu.c @@ -143,14 +143,14 @@ void nvgpu_pmu_remove_support(struct gk20a *g, struct nvgpu_pmu *pmu) } /* PMU unit init */ -int nvgpu_pmu_early_init(struct gk20a *g, struct nvgpu_pmu **pmu_p) +int nvgpu_pmu_early_init(struct gk20a *g) { int err = 0; struct nvgpu_pmu *pmu; nvgpu_log_fn(g, " "); - if (*pmu_p != NULL) { + if (g->pmu != NULL) { /* skip alloc/reinit for unrailgate sequence */ nvgpu_pmu_dbg(g, "skip pmu init for unrailgate sequence"); goto exit; @@ -162,7 +162,7 @@ int nvgpu_pmu_early_init(struct gk20a *g, struct nvgpu_pmu **pmu_p) goto exit; } - *pmu_p = pmu; + g->pmu = pmu; pmu->g = g; pmu->flcn = &g->pmu_flcn; diff --git a/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c b/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c index ded548fd6..e7dde78d1 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu_rtos_init.c @@ -209,17 +209,17 @@ exit: return err; } -int nvgpu_pmu_rtos_init(struct gk20a *g, struct nvgpu_pmu *pmu) +int nvgpu_pmu_rtos_init(struct gk20a *g) { int err = 0; nvgpu_log_fn(g, " "); - if (!g->support_ls_pmu) { + if (!g->support_ls_pmu || (g->pmu == NULL)) { goto exit; } - err = pmu_sw_setup(g, pmu); + err = pmu_sw_setup(g, g->pmu); if (err != 0) { goto exit; } @@ -252,8 +252,8 @@ int nvgpu_pmu_rtos_init(struct gk20a *g, struct nvgpu_pmu *pmu) g->ops.pmu.setup_apertures(g); } - err = nvgpu_pmu_lsfm_ls_pmu_cmdline_args_copy(g, pmu, - pmu->lsfm); + err = nvgpu_pmu_lsfm_ls_pmu_cmdline_args_copy(g, g->pmu, + g->pmu->lsfm); if (err != 0) { goto exit; } @@ -271,13 +271,13 @@ int nvgpu_pmu_rtos_init(struct gk20a *g, struct nvgpu_pmu *pmu) } } else { /* non-secure boot */ - err = nvgpu_pmu_ns_fw_bootstrap(g, pmu); + err = nvgpu_pmu_ns_fw_bootstrap(g, g->pmu); if (err != 0) { goto exit; } } - nvgpu_pmu_fw_state_change(g, pmu, PMU_FW_STATE_STARTING, false); + nvgpu_pmu_fw_state_change(g, g->pmu, PMU_FW_STATE_STARTING, false); exit: return err; diff --git a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h index 5c287c141..29b740ade 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gk20a.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gk20a.h @@ -1207,8 +1207,7 @@ struct gpu_ops { u32 (*idle_slowdown_disable)(struct gk20a *g); } therm; struct { - int (*pmu_early_init)(struct gk20a *g, - struct nvgpu_pmu **pmu_p); + int (*pmu_early_init)(struct gk20a *g); int (*pmu_destroy)(struct gk20a *g, struct nvgpu_pmu *pmu); int (*pmu_pstate_sw_setup)(struct gk20a *g); int (*pmu_pstate_pmu_setup)(struct gk20a *g); diff --git a/drivers/gpu/nvgpu/include/nvgpu/pmu.h b/drivers/gpu/nvgpu/include/nvgpu/pmu.h index c5179170e..2c6763e1b 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/pmu.h +++ b/drivers/gpu/nvgpu/include/nvgpu/pmu.h @@ -329,7 +329,7 @@ int nvgpu_pmu_lock_release(struct gk20a *g, struct nvgpu_pmu *pmu, /* PMU RTOS init/setup functions*/ int nvgpu_pmu_rtos_early_init(struct gk20a *g, struct nvgpu_pmu *pmu); -int nvgpu_pmu_rtos_init(struct gk20a *g, struct nvgpu_pmu *pmu); +int nvgpu_pmu_rtos_init(struct gk20a *g); int nvgpu_pmu_destroy(struct gk20a *g, struct nvgpu_pmu *pmu); #endif @@ -366,7 +366,6 @@ int nvgpu_pmu_reset(struct gk20a *g); * detected chip, * * @param g [in] The GPU driver struct. - * @param nvgpu_pmu [in] The PMU unit. * * Initializes PMU unit data struct in the GPU driver based on detected chip. * Allocate memory for #nvgpu_pmu data struct & set PMU Engine h/w properties, @@ -375,7 +374,7 @@ int nvgpu_pmu_reset(struct gk20a *g); * * @return 0 in case of success, < 0 in case of failure. */ -int nvgpu_pmu_early_init(struct gk20a *g, struct nvgpu_pmu **pmu_p); +int nvgpu_pmu_early_init(struct gk20a *g); /** * @brief PMU remove to free space allocted for PMU unit diff --git a/userspace/units/pmu/nvgpu-pmu.c b/userspace/units/pmu/nvgpu-pmu.c index 8c10cd475..951a05453 100644 --- a/userspace/units/pmu/nvgpu-pmu.c +++ b/userspace/units/pmu/nvgpu-pmu.c @@ -154,7 +154,7 @@ static int test_pmu_early_init(struct unit_module *m, * allocation failure */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 0); - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (err != -ENOMEM) { unit_return_fail(m, @@ -165,7 +165,7 @@ static int test_pmu_early_init(struct unit_module *m, nvgpu_pmu_remove_support(g, g->pmu); /* Case 2: nvgpu_pmu_early_init() passes */ - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (err != 0) { unit_return_fail(m, "nvgpu_pmu_early_init failed\n"); } @@ -175,7 +175,7 @@ static int test_pmu_early_init(struct unit_module *m, /* case 3: */ g->support_ls_pmu = false; - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (err != 0) { unit_return_fail(m, "support_ls_pmu failed\n"); } @@ -185,7 +185,7 @@ static int test_pmu_early_init(struct unit_module *m, /* case 4: */ g->support_ls_pmu = true; g->ops.pmu.is_pmu_supported = stub_gv11b_is_pmu_supported; - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (g->support_ls_pmu != false || g->can_elpg != false || g->elpg_enabled != false || g->aelpg_enabled != false) { @@ -203,7 +203,7 @@ static int test_pmu_remove_support(struct unit_module *m, { int err; - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (err != 0) { unit_return_fail(m, "support_ls_pmu failed\n"); } @@ -228,7 +228,7 @@ static int test_pmu_reset(struct unit_module *m, } /* initialize PMU */ - err = nvgpu_pmu_early_init(g, &g->pmu); + err = nvgpu_pmu_early_init(g); if (err != 0) { unit_return_fail(m, "nvgpu_pmu_early_init failed\n"); }