summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
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
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')
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug.c7
-rw-r--r--drivers/gpu/nvgpu/common/ltc.c42
2 files changed, 43 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c
index e085aed4..a846493e 100644
--- a/drivers/gpu/nvgpu/common/linux/debug.c
+++ b/drivers/gpu/nvgpu/common/linux/debug.c
@@ -275,15 +275,10 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
275 debugfs_create_u32("log_trace", S_IRUGO|S_IWUSR, 275 debugfs_create_u32("log_trace", S_IRUGO|S_IWUSR,
276 platform->debugfs, &g->log_trace); 276 platform->debugfs, &g->log_trace);
277 277
278 nvgpu_spinlock_init(&g->debugfs_lock);
279
280 g->mm.ltc_enabled = true;
281 g->mm.ltc_enabled_debug = true;
282
283 g->debugfs_ltc_enabled = 278 g->debugfs_ltc_enabled =
284 debugfs_create_bool("ltc_enabled", S_IRUGO|S_IWUSR, 279 debugfs_create_bool("ltc_enabled", S_IRUGO|S_IWUSR,
285 platform->debugfs, 280 platform->debugfs,
286 &g->mm.ltc_enabled_debug); 281 &g->mm.ltc_enabled_target);
287 282
288 g->debugfs_gr_idle_timeout_default = 283 g->debugfs_gr_idle_timeout_default =
289 debugfs_create_u32("gr_idle_timeout_default_us", 284 debugfs_create_u32("gr_idle_timeout_default_us",
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}