diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/ltc.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/ltc.c | 42 |
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 | |||
21 | int 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 | |||
34 | void 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 | } | ||