diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/pmu_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/pmu_gk20a.c | 71 |
1 files changed, 13 insertions, 58 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c index 8e2a62ded331..32db00ecef41 100644 --- a/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/pmu_gk20a.c @@ -1491,57 +1491,11 @@ static int pmu_queue_close(struct pmu_gk20a *pmu, return 0; } -static void gk20a_save_pmu_sw_state(struct pmu_gk20a *pmu, - struct gk20a_pmu_save_state *save) -{ - save->seq = pmu->seq; - save->next_seq_desc = pmu->next_seq_desc; - save->mutex = pmu->mutex; - save->mutex_cnt = pmu->mutex_cnt; - save->desc = pmu->desc; - save->ucode = pmu->ucode; - save->elpg_enable = pmu->elpg_enable; - save->pg_wq = pmu->pg_wq; - save->seq_buf = pmu->seq_buf; - save->pg_buf = pmu->pg_buf; - save->sw_ready = pmu->sw_ready; - save->pg_init = pmu->pg_init; -} - -static void gk20a_restore_pmu_sw_state(struct pmu_gk20a *pmu, - struct gk20a_pmu_save_state *save) -{ - pmu->seq = save->seq; - pmu->next_seq_desc = save->next_seq_desc; - pmu->mutex = save->mutex; - pmu->mutex_cnt = save->mutex_cnt; - pmu->desc = save->desc; - pmu->ucode = save->ucode; - pmu->elpg_enable = save->elpg_enable; - pmu->pg_wq = save->pg_wq; - pmu->seq_buf = save->seq_buf; - pmu->pg_buf = save->pg_buf; - pmu->sw_ready = save->sw_ready; - pmu->pg_init = save->pg_init; -} - void gk20a_remove_pmu_support(struct pmu_gk20a *pmu) { - struct gk20a_pmu_save_state save; - gk20a_dbg_fn(""); gk20a_allocator_destroy(&pmu->dmem); - - /* Save the stuff you don't want to lose */ - gk20a_save_pmu_sw_state(pmu, &save); - - /* this function is also called by pmu_destory outside gk20a deinit that - releases gk20a struct so fill up with zeros here. */ - memset(pmu, 0, sizeof(struct pmu_gk20a)); - - /* Restore stuff you want to keep */ - gk20a_restore_pmu_sw_state(pmu, &save); } int gk20a_init_pmu_reset_enable_hw(struct gk20a *g) @@ -2197,7 +2151,7 @@ static int pmu_init_perfmon(struct pmu_gk20a *pmu) struct pmu_payload payload; u32 seq; u32 data; - int err; + int err = 0; gk20a_dbg_fn(""); @@ -2247,8 +2201,9 @@ static int pmu_init_perfmon(struct pmu_gk20a *pmu) pwr_pmu_idle_ctrl_filter_disabled_f()); gk20a_writel(g, pwr_pmu_idle_ctrl_r(2), data); - pmu->sample_buffer = 0; - err = pmu->dmem.alloc(&pmu->dmem, &pmu->sample_buffer, 2 * sizeof(u16)); + if (!pmu->sample_buffer) + err = pmu->dmem.alloc(&pmu->dmem, + &pmu->sample_buffer, 2 * sizeof(u16)); if (err) { gk20a_err(dev_from_gk20a(g), "failed to allocate perfmon sample buffer"); @@ -2347,10 +2302,11 @@ static int pmu_process_init_msg(struct pmu_gk20a *pmu, for (i = 0; i < PMU_QUEUE_COUNT; i++) pmu_queue_init(pmu, i, init); - gk20a_allocator_init(&pmu->dmem, "gk20a_pmu_dmem", - pv->get_pmu_init_msg_pmu_sw_mg_off(init), - pv->get_pmu_init_msg_pmu_sw_mg_size(init), - PMU_DMEM_ALLOC_ALIGNMENT); + if (!pmu->dmem.alloc) + gk20a_allocator_init(&pmu->dmem, "gk20a_pmu_dmem", + pv->get_pmu_init_msg_pmu_sw_mg_off(init), + pv->get_pmu_init_msg_pmu_sw_mg_size(init), + PMU_DMEM_ALLOC_ALIGNMENT); pmu->pmu_ready = true; @@ -3448,11 +3404,10 @@ int gk20a_pmu_destroy(struct gk20a *g) g->pg_gating_cnt += gating_cnt; pmu_enable(pmu, false); - - if (pmu->remove_support) { - pmu->remove_support(pmu); - pmu->remove_support = NULL; - } + pmu->pmu_ready = false; + pmu->perfmon_ready = false; + pmu->zbc_ready = false; + pmu->elpg_ready = false; gk20a_dbg_fn("done"); return 0; |