summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common/ltc.c
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-07-27 15:58:03 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-08-04 12:23:56 -0400
commitb8efd9d04537d6129e2ce8b067417e46b0e7436f (patch)
tree1a40179a893e10c0fdcdd56797599bcdf6b55206 /drivers/gpu/nvgpu/common/ltc.c
parentc16797e35c2926bf34a61d5d8f37d5675ec23b1b (diff)
gpu: nvgpu: Make LTC disabling common code
Refactor the sync_debugfs LTC HAL op so that the logic to enable or disable LTC goes to common code nvgpu_ltc_sync_enabled() and the LTC HAL set_enabled only performs the hardware register access. Create a new common function nvgpu_init_ltc_support() to initialize the LTC software variable, and move hardware initialization of LTC to be called from it. JIRA NVGPU-62 Change-Id: Ib1cf4f5b83ca3dac08407464ed56a732e0a33923 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1528262 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/ltc.c')
-rw-r--r--drivers/gpu/nvgpu/common/ltc.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/ltc.c b/drivers/gpu/nvgpu/common/ltc.c
new file mode 100644
index 00000000..0965caa3
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/ltc.c
@@ -0,0 +1,42 @@
1/*
2 * Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11 * more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include <nvgpu/ltc.h>
18
19#include "gk20a/gk20a.h"
20
21int nvgpu_init_ltc_support(struct gk20a *g)
22{
23 nvgpu_spinlock_init(&g->ltc_enabled_lock);
24
25 g->mm.ltc_enabled_current = true;
26 g->mm.ltc_enabled_target = true;
27
28 if (g->ops.ltc.init_fs_state)
29 g->ops.ltc.init_fs_state(g);
30
31 return 0;
32}
33
34void nvgpu_ltc_sync_enabled(struct gk20a *g)
35{
36 nvgpu_spinlock_acquire(&g->ltc_enabled_lock);
37 if (g->mm.ltc_enabled_current != g->mm.ltc_enabled_target) {
38 g->ops.ltc.set_enabled(g, g->mm.ltc_enabled_target);
39 g->mm.ltc_enabled_current = g->mm.ltc_enabled_target;
40 }
41 nvgpu_spinlock_release(&g->ltc_enabled_lock);
42}