summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Kumbhar <nkumbhar@nvidia.com>2018-08-13 00:39:04 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-05 07:51:43 -0400
commitbcdac829f44afc1b08941c507e691866f3a9cb38 (patch)
tree12a4e0378a7ea5bed584ee9c87b16d047f943886
parent0406900ca944305f9713905f4d7363fc2d9cbbea (diff)
gpu: nvgpu: move therm debugfs to linux
Move debugfs related code of therm from common driver to linux specific part of the driver. gp106_therm_debugfs_init() is updated to use nvgpu_os_linux_ops. This also affects gv100 as gp106_therm_debugfs_init is used for gv100 as well. JIRA NVGPU-603 Change-Id: Ia293d14599bc0c91fd1e917b5a430bd8f3d96e56 Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1797906 GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r--drivers/gpu/nvgpu/Makefile1
-rw-r--r--drivers/gpu/nvgpu/common/therm/therm_gp106.c33
-rw-r--r--drivers/gpu/nvgpu/common/therm/therm_gp106.h5
-rw-r--r--drivers/gpu/nvgpu/gp106/hal_gp106.c3
-rw-r--r--drivers/gpu/nvgpu/gv100/hal_gv100.c3
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c49
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h29
-rw-r--r--drivers/gpu/nvgpu/os/linux/module.c8
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_linux.h4
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops.c9
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gp106.c5
-rw-r--r--drivers/gpu/nvgpu/os/linux/os_ops_gv100.c5
12 files changed, 112 insertions, 42 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 24322f82..7edcd63e 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -101,6 +101,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
101 os/linux/debug_hal.o \ 101 os/linux/debug_hal.o \
102 os/linux/debug_clk_gm20b.o \ 102 os/linux/debug_clk_gm20b.o \
103 os/linux/debug_clk_gp106.o \ 103 os/linux/debug_clk_gp106.o \
104 os/linux/debug_therm_gp106.o \
104 os/linux/debug_bios.o \ 105 os/linux/debug_bios.o \
105 os/linux/debug_ltc.o \ 106 os/linux/debug_ltc.o \
106 os/linux/debug_xve.o 107 os/linux/debug_xve.o
diff --git a/drivers/gpu/nvgpu/common/therm/therm_gp106.c b/drivers/gpu/nvgpu/common/therm/therm_gp106.c
index 1f82aa7a..cc3127d7 100644
--- a/drivers/gpu/nvgpu/common/therm/therm_gp106.c
+++ b/drivers/gpu/nvgpu/common/therm/therm_gp106.c
@@ -21,16 +21,12 @@
21 */ 21 */
22 22
23#include <nvgpu/io.h> 23#include <nvgpu/io.h>
24
24#include "gk20a/gk20a.h" 25#include "gk20a/gk20a.h"
25 26
26#include "therm_gp106.h" 27#include "therm_gp106.h"
27#include "therm/thrmpmu.h" 28#include "therm/thrmpmu.h"
28 29
29#ifdef CONFIG_DEBUG_FS
30#include <linux/debugfs.h>
31#include "os/linux/os_linux.h"
32#endif
33
34#include <nvgpu/hw/gp106/hw_therm_gp106.h> 30#include <nvgpu/hw/gp106/hw_therm_gp106.h>
35 31
36#include <nvgpu/utils.h> 32#include <nvgpu/utils.h>
@@ -66,33 +62,6 @@ int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8)
66 return err; 62 return err;
67} 63}
68 64
69#ifdef CONFIG_DEBUG_FS
70static int therm_get_internal_sensor_curr_temp(void *data, u64 *val)
71{
72 struct gk20a *g = (struct gk20a *)data;
73 u32 readval;
74 int err;
75
76 err = gp106_get_internal_sensor_curr_temp(g, &readval);
77 if (!err)
78 *val = readval;
79
80 return err;
81}
82DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n");
83
84void gp106_therm_debugfs_init(struct gk20a *g)
85{
86 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
87 struct dentry *dbgentry;
88
89 dbgentry = debugfs_create_file(
90 "temp", S_IRUGO, l->debugfs, g, &therm_ctrl_fops);
91 if (!dbgentry)
92 nvgpu_err(g, "debugfs entry create failed for therm_curr_temp");
93}
94#endif
95
96int gp106_elcg_init_idle_filters(struct gk20a *g) 65int gp106_elcg_init_idle_filters(struct gk20a *g)
97{ 66{
98 u32 gate_ctrl, idle_filter; 67 u32 gate_ctrl, idle_filter;
diff --git a/drivers/gpu/nvgpu/common/therm/therm_gp106.h b/drivers/gpu/nvgpu/common/therm/therm_gp106.h
index a92c2e0f..e29c993f 100644
--- a/drivers/gpu/nvgpu/common/therm/therm_gp106.h
+++ b/drivers/gpu/nvgpu/common/therm/therm_gp106.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * general thermal control structures & definitions 2 * general thermal control structures & definitions
3 * 3 *
4 * Copyright (c) 2016-2017, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a 6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"), 7 * copy of this software and associated documentation files (the "Software"),
@@ -31,9 +31,6 @@ struct gk20a;
31 31
32void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8); 32void gp106_get_internal_sensor_limits(s32 *max_24_8, s32 *min_24_8);
33int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8); 33int gp106_get_internal_sensor_curr_temp(struct gk20a *g, u32 *temp_f24_8);
34#ifdef CONFIG_DEBUG_FS
35void gp106_therm_debugfs_init(struct gk20a *g);
36#endif
37int gp106_elcg_init_idle_filters(struct gk20a *g); 34int gp106_elcg_init_idle_filters(struct gk20a *g);
38u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp); 35u32 gp106_configure_therm_alert(struct gk20a *g, s32 curr_warn_temp);
39 36
diff --git a/drivers/gpu/nvgpu/gp106/hal_gp106.c b/drivers/gpu/nvgpu/gp106/hal_gp106.c
index af2d4c00..24c4191d 100644
--- a/drivers/gpu/nvgpu/gp106/hal_gp106.c
+++ b/drivers/gpu/nvgpu/gp106/hal_gp106.c
@@ -605,9 +605,6 @@ static const struct gpu_ops gp106_ops = {
605 .data032_r = pram_data032_r, 605 .data032_r = pram_data032_r,
606 }, 606 },
607 .therm = { 607 .therm = {
608#ifdef CONFIG_DEBUG_FS
609 .therm_debugfs_init = gp106_therm_debugfs_init,
610#endif /* CONFIG_DEBUG_FS */
611 .init_elcg_mode = gm20b_therm_init_elcg_mode, 608 .init_elcg_mode = gm20b_therm_init_elcg_mode,
612 .init_blcg_mode = gm20b_therm_init_blcg_mode, 609 .init_blcg_mode = gm20b_therm_init_blcg_mode,
613 .elcg_init_idle_filters = gp106_elcg_init_idle_filters, 610 .elcg_init_idle_filters = gp106_elcg_init_idle_filters,
diff --git a/drivers/gpu/nvgpu/gv100/hal_gv100.c b/drivers/gpu/nvgpu/gv100/hal_gv100.c
index 78798196..6a4f874d 100644
--- a/drivers/gpu/nvgpu/gv100/hal_gv100.c
+++ b/drivers/gpu/nvgpu/gv100/hal_gv100.c
@@ -702,9 +702,6 @@ static const struct gpu_ops gv100_ops = {
702 .data032_r = pram_data032_r, 702 .data032_r = pram_data032_r,
703 }, 703 },
704 .therm = { 704 .therm = {
705#ifdef CONFIG_DEBUG_FS
706 .therm_debugfs_init = gp106_therm_debugfs_init,
707#endif /* CONFIG_DEBUG_FS */
708 /* PROD values match with H/W INIT values */ 705 /* PROD values match with H/W INIT values */
709 .init_elcg_mode = gv11b_therm_init_elcg_mode, 706 .init_elcg_mode = gv11b_therm_init_elcg_mode,
710 .init_blcg_mode = gm20b_therm_init_blcg_mode, 707 .init_blcg_mode = gm20b_therm_init_blcg_mode,
diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c
new file mode 100644
index 00000000..dfe39461
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.c
@@ -0,0 +1,49 @@
1/*
2 * Copyright (c) 2018, 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 <linux/debugfs.h>
18
19#include "os_linux.h"
20
21static int therm_get_internal_sensor_curr_temp(void *data, u64 *val)
22{
23 struct gk20a *g = (struct gk20a *)data;
24 u32 readval;
25 int err;
26
27 if (!g->ops.therm.get_internal_sensor_curr_temp)
28 return -EINVAL;
29
30 err = g->ops.therm.get_internal_sensor_curr_temp(g, &readval);
31 if (!err)
32 *val = readval;
33
34 return err;
35}
36DEFINE_SIMPLE_ATTRIBUTE(therm_ctrl_fops, therm_get_internal_sensor_curr_temp, NULL, "%llu\n");
37
38int gp106_therm_init_debugfs(struct gk20a *g)
39{
40 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
41 struct dentry *dbgentry;
42
43 dbgentry = debugfs_create_file(
44 "temp", S_IRUGO, l->debugfs, g, &therm_ctrl_fops);
45 if (!dbgentry)
46 nvgpu_err(g, "debugfs entry create failed for therm_curr_temp");
47
48 return 0;
49}
diff --git a/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h
new file mode 100644
index 00000000..6ebc9f58
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_therm_gp106.h
@@ -0,0 +1,29 @@
1/*
2 * Copyright (c) 2018, 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#ifndef __DEBUG_THERM_GP106_H
18#define __DEBUG_THERM_GP106_H
19
20#ifdef CONFIG_DEBUG_FS
21int gp106_therm_init_debugfs(struct gk20a *g);
22#else
23inline int gp106_therm_init_debugfs(struct gk20a *g)
24{
25 return 0;
26}
27#endif
28
29#endif
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index 02b0ea5c..169baaf4 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -206,6 +206,14 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
206 } 206 }
207 } 207 }
208 208
209 if (l->ops.therm.init_debugfs) {
210 err = l->ops.therm.init_debugfs(g);
211 if (err) {
212 nvgpu_err(g, "failed to init linux therm debugfs");
213 return err;
214 }
215 }
216
209 l->init_done = true; 217 l->init_done = true;
210 218
211 return 0; 219 return 0;
diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h
index 96eff12e..ff871fe5 100644
--- a/drivers/gpu/nvgpu/os/linux/os_linux.h
+++ b/drivers/gpu/nvgpu/os/linux/os_linux.h
@@ -42,6 +42,10 @@ struct nvgpu_os_linux_ops {
42 struct { 42 struct {
43 int (*init_debugfs)(struct gk20a *g); 43 int (*init_debugfs)(struct gk20a *g);
44 } clk; 44 } clk;
45
46 struct {
47 int (*init_debugfs)(struct gk20a *g);
48 } therm;
45}; 49};
46 50
47struct nvgpu_os_linux { 51struct nvgpu_os_linux {
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops.c b/drivers/gpu/nvgpu/os/linux/os_ops.c
index 5fc5beb4..5c2eb25c 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops.c
@@ -21,6 +21,10 @@
21#include "os_ops_gp106.h" 21#include "os_ops_gp106.h"
22#include "os_ops_gv100.h" 22#include "os_ops_gv100.h"
23 23
24#if defined(CONFIG_TEGRA_GPU_NEXT)
25#include "nvgpu_gpuid_next.h"
26#endif
27
24int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l) 28int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l)
25{ 29{
26 struct gk20a *g = &l->g; 30 struct gk20a *g = &l->g;
@@ -40,6 +44,11 @@ int nvgpu_init_os_linux_ops(struct nvgpu_os_linux *l)
40 case NVGPU_GPUID_GV100: 44 case NVGPU_GPUID_GV100:
41 nvgpu_gv100_init_os_ops(l); 45 nvgpu_gv100_init_os_ops(l);
42 break; 46 break;
47#if defined(CONFIG_TEGRA_GPU_NEXT)
48 case NVGPU_GPUID_NEXT:
49 NVGPU_NEXT_INIT_OS_OPS(l);
50 break;
51#endif
43 default: 52 default:
44 break; 53 break;
45 } 54 }
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
index 13ce73e6..662f4551 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gp106.c
@@ -17,14 +17,19 @@
17#include "os_linux.h" 17#include "os_linux.h"
18 18
19#include "debug_clk_gp106.h" 19#include "debug_clk_gp106.h"
20#include "debug_therm_gp106.h"
20 21
21static struct nvgpu_os_linux_ops gp106_os_linux_ops = { 22static struct nvgpu_os_linux_ops gp106_os_linux_ops = {
22 .clk = { 23 .clk = {
23 .init_debugfs = gp106_clk_init_debugfs, 24 .init_debugfs = gp106_clk_init_debugfs,
24 }, 25 },
26 .therm = {
27 .init_debugfs = gp106_therm_init_debugfs,
28 },
25}; 29};
26 30
27void nvgpu_gp106_init_os_ops(struct nvgpu_os_linux *l) 31void nvgpu_gp106_init_os_ops(struct nvgpu_os_linux *l)
28{ 32{
29 l->ops.clk = gp106_os_linux_ops.clk; 33 l->ops.clk = gp106_os_linux_ops.clk;
34 l->ops.therm = gp106_os_linux_ops.therm;
30} 35}
diff --git a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
index 9236286b..7a5174a4 100644
--- a/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
+++ b/drivers/gpu/nvgpu/os/linux/os_ops_gv100.c
@@ -17,14 +17,19 @@
17#include "os_linux.h" 17#include "os_linux.h"
18 18
19#include "debug_clk_gp106.h" 19#include "debug_clk_gp106.h"
20#include "debug_therm_gp106.h"
20 21
21static struct nvgpu_os_linux_ops gv100_os_linux_ops = { 22static struct nvgpu_os_linux_ops gv100_os_linux_ops = {
22 .clk = { 23 .clk = {
23 .init_debugfs = gp106_clk_init_debugfs, 24 .init_debugfs = gp106_clk_init_debugfs,
24 }, 25 },
26 .therm = {
27 .init_debugfs = gp106_therm_init_debugfs,
28 },
25}; 29};
26 30
27void nvgpu_gv100_init_os_ops(struct nvgpu_os_linux *l) 31void nvgpu_gv100_init_os_ops(struct nvgpu_os_linux *l)
28{ 32{
29 l->ops.clk = gv100_os_linux_ops.clk; 33 l->ops.clk = gv100_os_linux_ops.clk;
34 l->ops.therm = gv100_os_linux_ops.therm;
30} 35}