diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/pmu')
-rw-r--r-- | drivers/gpu/nvgpu/common/pmu/pmu.c | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/common/pmu/pmu.c b/drivers/gpu/nvgpu/common/pmu/pmu.c index 3447f40d..d595097b 100644 --- a/drivers/gpu/nvgpu/common/pmu/pmu.c +++ b/drivers/gpu/nvgpu/common/pmu/pmu.c | |||
@@ -155,6 +155,31 @@ static int nvgpu_init_task_pg_init(struct gk20a *g) | |||
155 | return err; | 155 | return err; |
156 | } | 156 | } |
157 | 157 | ||
158 | void nvgpu_kill_task_pg_init(struct gk20a *g) | ||
159 | { | ||
160 | struct nvgpu_pmu *pmu = &g->pmu; | ||
161 | struct nvgpu_timeout timeout; | ||
162 | |||
163 | /* make sure the pending operations are finished before we continue */ | ||
164 | if (nvgpu_thread_is_running(&pmu->pg_init.state_task)) { | ||
165 | |||
166 | /* post PMU_STATE_EXIT to exit PMU state machine loop */ | ||
167 | nvgpu_pmu_state_change(g, PMU_STATE_EXIT, true); | ||
168 | |||
169 | /* Make thread stop*/ | ||
170 | nvgpu_thread_stop(&pmu->pg_init.state_task); | ||
171 | |||
172 | /* wait to confirm thread stopped */ | ||
173 | nvgpu_timeout_init(g, &timeout, 1000, NVGPU_TIMER_RETRY_TIMER); | ||
174 | do { | ||
175 | if (!nvgpu_thread_is_running(&pmu->pg_init.state_task)) | ||
176 | break; | ||
177 | nvgpu_udelay(2); | ||
178 | } while (!nvgpu_timeout_expired_msg(&timeout, | ||
179 | "timeout - waiting PMU state machine thread stop")); | ||
180 | } | ||
181 | } | ||
182 | |||
158 | static int nvgpu_init_pmu_setup_sw(struct gk20a *g) | 183 | static int nvgpu_init_pmu_setup_sw(struct gk20a *g) |
159 | { | 184 | { |
160 | struct nvgpu_pmu *pmu = &g->pmu; | 185 | struct nvgpu_pmu *pmu = &g->pmu; |
@@ -469,7 +494,6 @@ int nvgpu_pmu_destroy(struct gk20a *g) | |||
469 | { | 494 | { |
470 | struct nvgpu_pmu *pmu = &g->pmu; | 495 | struct nvgpu_pmu *pmu = &g->pmu; |
471 | struct pmu_pg_stats_data pg_stat_data = { 0 }; | 496 | struct pmu_pg_stats_data pg_stat_data = { 0 }; |
472 | struct nvgpu_timeout timeout; | ||
473 | int i; | 497 | int i; |
474 | 498 | ||
475 | nvgpu_log_fn(g, " "); | 499 | nvgpu_log_fn(g, " "); |
@@ -477,24 +501,7 @@ int nvgpu_pmu_destroy(struct gk20a *g) | |||
477 | if (!g->support_pmu) | 501 | if (!g->support_pmu) |
478 | return 0; | 502 | return 0; |
479 | 503 | ||
480 | /* make sure the pending operations are finished before we continue */ | 504 | nvgpu_kill_task_pg_init(g); |
481 | if (nvgpu_thread_is_running(&pmu->pg_init.state_task)) { | ||
482 | |||
483 | /* post PMU_STATE_EXIT to exit PMU state machine loop */ | ||
484 | nvgpu_pmu_state_change(g, PMU_STATE_EXIT, true); | ||
485 | |||
486 | /* Make thread stop*/ | ||
487 | nvgpu_thread_stop(&pmu->pg_init.state_task); | ||
488 | |||
489 | /* wait to confirm thread stopped */ | ||
490 | nvgpu_timeout_init(g, &timeout, 1000, NVGPU_TIMER_RETRY_TIMER); | ||
491 | do { | ||
492 | if (!nvgpu_thread_is_running(&pmu->pg_init.state_task)) | ||
493 | break; | ||
494 | nvgpu_udelay(2); | ||
495 | } while (!nvgpu_timeout_expired_msg(&timeout, | ||
496 | "timeout - waiting PMU state machine thread stop")); | ||
497 | } | ||
498 | 505 | ||
499 | nvgpu_pmu_get_pg_stats(g, | 506 | nvgpu_pmu_get_pg_stats(g, |
500 | PMU_PG_ELPG_ENGINE_ID_GRAPHICS, &pg_stat_data); | 507 | PMU_PG_ELPG_ENGINE_ID_GRAPHICS, &pg_stat_data); |