diff --git a/drivers/gpu/nvgpu/common/pmu/perf/perf_gv100.c b/drivers/gpu/nvgpu/common/pmu/perf/perf_gv100.c index ce5bd09cd..453feb5bd 100644 --- a/drivers/gpu/nvgpu/common/pmu/perf/perf_gv100.c +++ b/drivers/gpu/nvgpu/common/pmu/perf/perf_gv100.c @@ -1,7 +1,7 @@ /* * GV100 PERF * - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -44,8 +44,11 @@ static int pmu_set_boot_clk_runcb_fn(void *arg) while (true) { NVGPU_COND_WAIT_INTERRUPTIBLE(&vfe_init->wq, - (vfe_init->state_change == true), 0); - + (vfe_init->state_change || + nvgpu_thread_should_stop(&vfe_init->state_task)), 0); + if (nvgpu_thread_should_stop(&vfe_init->state_task)) { + break; + } vfe_init->state_change = false; (void) memset(&rpc, 0, diff --git a/drivers/gpu/nvgpu/common/pmu/perf/perf_tu104.c b/drivers/gpu/nvgpu/common/pmu/perf/perf_tu104.c index 3bd0d142c..bacf2f2ad 100644 --- a/drivers/gpu/nvgpu/common/pmu/perf/perf_tu104.c +++ b/drivers/gpu/nvgpu/common/pmu/perf/perf_tu104.c @@ -1,7 +1,7 @@ /* * GV100 PERF * - * Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -44,8 +44,11 @@ static int pmu_set_boot_clk_runcb_fn(void *arg) while (true) { NVGPU_COND_WAIT_INTERRUPTIBLE(&vfe_init->wq, - (vfe_init->state_change == true), 0); - + (vfe_init->state_change || + nvgpu_thread_should_stop(&vfe_init->state_task)), 0); + if (nvgpu_thread_should_stop(&vfe_init->state_task)) { + break; + } vfe_init->state_change = false; (void) memset(&rpc, 0, diff --git a/drivers/gpu/nvgpu/common/pmu/perf/pmu_perf.c b/drivers/gpu/nvgpu/common/pmu/perf/pmu_perf.c index c39aa8228..f1f93398a 100644 --- a/drivers/gpu/nvgpu/common/pmu/perf/pmu_perf.c +++ b/drivers/gpu/nvgpu/common/pmu/perf/pmu_perf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -144,8 +144,20 @@ int perf_pmu_init_pmupstate(struct gk20a *g) return 0; } +static void vfe_thread_stop_cb(void *data) +{ + struct nvgpu_cond *cond = (struct nvgpu_cond *)data; + + (void)nvgpu_cond_signal(cond); +} + void perf_pmu_free_pmupstate(struct gk20a *g) { + if (nvgpu_thread_is_running(&g->perf_pmu->vfe_init.state_task)) { + nvgpu_thread_stop_graceful(&g->perf_pmu->vfe_init.state_task, + vfe_thread_stop_cb, &g->perf_pmu->vfe_init.wq); + } + nvgpu_cond_destroy(&g->perf_pmu->vfe_init.wq); nvgpu_mutex_destroy(&g->perf_pmu->pstatesobjs.pstate_mutex); nvgpu_kfree(g, g->perf_pmu); g->perf_pmu = NULL;