summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNitin Kumbhar <nkumbhar@nvidia.com>2018-08-16 08:17:21 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2018-09-05 07:51:50 -0400
commit78b4ab269f5d733c8b540a6a75db1f390172cc29 (patch)
tree72341f9ff90c8af8a822d707855953e5e1ef2682
parentbcdac829f44afc1b08941c507e691866f3a9cb38 (diff)
gpu: nvgpu: move pmgr debugfs to linux
Move debugfs related part of pmgr to linux files. JIRA NVGPU-603 Change-Id: I478491e06e2e7cdbe3826166aafd8491d1e6c1e7 Signed-off-by: Nitin Kumbhar <nkumbhar@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1801086 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/os/linux/debug_pmgr.c104
-rw-r--r--drivers/gpu/nvgpu/os/linux/debug_pmgr.h28
-rw-r--r--drivers/gpu/nvgpu/os/linux/module.c7
-rw-r--r--drivers/gpu/nvgpu/pmgr/pmgr.c77
5 files changed, 140 insertions, 77 deletions
diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile
index 7edcd63e..43a36221 100644
--- a/drivers/gpu/nvgpu/Makefile
+++ b/drivers/gpu/nvgpu/Makefile
@@ -96,6 +96,7 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
96 os/linux/debug_fifo.o \ 96 os/linux/debug_fifo.o \
97 os/linux/debug_ce.o \ 97 os/linux/debug_ce.o \
98 os/linux/debug_pmu.o \ 98 os/linux/debug_pmu.o \
99 os/linux/debug_pmgr.o \
99 os/linux/debug_sched.o \ 100 os/linux/debug_sched.o \
100 os/linux/debug_allocator.o \ 101 os/linux/debug_allocator.o \
101 os/linux/debug_hal.o \ 102 os/linux/debug_hal.o \
diff --git a/drivers/gpu/nvgpu/os/linux/debug_pmgr.c b/drivers/gpu/nvgpu/os/linux/debug_pmgr.c
new file mode 100644
index 00000000..c2649785
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_pmgr.c
@@ -0,0 +1,104 @@
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
21#include "pmgr/pmgr.h"
22
23static int pmgr_pwr_devices_get_power_u64(void *data, u64 *p)
24{
25 struct gk20a *g = (struct gk20a *)data;
26 int err;
27 u32 val;
28
29 err = pmgr_pwr_devices_get_power(g, &val);
30 *p = val;
31
32 return err;
33}
34
35static int pmgr_pwr_devices_get_current_u64(void *data, u64 *p)
36{
37 struct gk20a *g = (struct gk20a *)data;
38 int err;
39 u32 val;
40
41 err = pmgr_pwr_devices_get_current(g, &val);
42 *p = val;
43
44 return err;
45}
46
47static int pmgr_pwr_devices_get_voltage_u64(void *data, u64 *p)
48{
49 struct gk20a *g = (struct gk20a *)data;
50 int err;
51 u32 val;
52
53 err = pmgr_pwr_devices_get_voltage(g, &val);
54 *p = val;
55
56 return err;
57}
58
59DEFINE_SIMPLE_ATTRIBUTE(
60 pmgr_power_ctrl_fops, pmgr_pwr_devices_get_power_u64, NULL, "%llu\n");
61
62DEFINE_SIMPLE_ATTRIBUTE(
63 pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current_u64, NULL, "%llu\n");
64
65DEFINE_SIMPLE_ATTRIBUTE(
66 pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n");
67
68static void pmgr_debugfs_init(struct gk20a *g)
69{
70 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
71 struct dentry *dbgentry;
72
73 dbgentry = debugfs_create_file(
74 "power", S_IRUGO, l->debugfs, g, &pmgr_power_ctrl_fops);
75 if (!dbgentry)
76 nvgpu_err(g, "debugfs entry create failed for power");
77
78 dbgentry = debugfs_create_file(
79 "current", S_IRUGO, l->debugfs, g, &pmgr_current_ctrl_fops);
80 if (!dbgentry)
81 nvgpu_err(g, "debugfs entry create failed for current");
82
83 dbgentry = debugfs_create_file(
84 "voltage", S_IRUGO, l->debugfs, g, &pmgr_voltage_ctrl_fops);
85 if (!dbgentry)
86 nvgpu_err(g, "debugfs entry create failed for voltage");
87}
88
89int nvgpu_pmgr_init_debugfs_linux(struct nvgpu_os_linux *l)
90{
91 struct gk20a *g = &l->g;
92 int ret = 0;
93
94 if (!nvgpu_is_enabled(g, NVGPU_PMU_PSTATE))
95 return ret;
96
97 if (!g->ops.clk.support_pmgr_domain)
98 return ret;
99
100 pmgr_debugfs_init(g);
101
102 return ret;
103}
104
diff --git a/drivers/gpu/nvgpu/os/linux/debug_pmgr.h b/drivers/gpu/nvgpu/os/linux/debug_pmgr.h
new file mode 100644
index 00000000..bd6c5567
--- /dev/null
+++ b/drivers/gpu/nvgpu/os/linux/debug_pmgr.h
@@ -0,0 +1,28 @@
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 __LINUX_DEBUG_PMGR_H
18#define __LINUX_DEBUG_PMGR_H
19
20#ifdef CONFIG_DEBUG_FS
21int nvgpu_pmgr_init_debugfs_linux(struct nvgpu_os_linux *l);
22#else
23int nvgpu_pmgr_init_debugfs_linux(struct nvgpu_os_linux *l)
24{
25 return 0;
26}
27#endif
28#endif
diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c
index 169baaf4..55f55f00 100644
--- a/drivers/gpu/nvgpu/os/linux/module.c
+++ b/drivers/gpu/nvgpu/os/linux/module.c
@@ -60,6 +60,7 @@
60#include "ctxsw_trace.h" 60#include "ctxsw_trace.h"
61#include "driver_common.h" 61#include "driver_common.h"
62#include "channel.h" 62#include "channel.h"
63#include "debug_pmgr.h"
63 64
64#ifdef CONFIG_NVGPU_SUPPORT_CDE 65#ifdef CONFIG_NVGPU_SUPPORT_CDE
65#include "cde.h" 66#include "cde.h"
@@ -214,6 +215,12 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
214 } 215 }
215 } 216 }
216 217
218 err = nvgpu_pmgr_init_debugfs_linux(l);
219 if (err) {
220 nvgpu_err(g, "failed to init linux pmgr debugfs");
221 return err;
222 }
223
217 l->init_done = true; 224 l->init_done = true;
218 225
219 return 0; 226 return 0;
diff --git a/drivers/gpu/nvgpu/pmgr/pmgr.c b/drivers/gpu/nvgpu/pmgr/pmgr.c
index 3d028c98..3d6a96af 100644
--- a/drivers/gpu/nvgpu/pmgr/pmgr.c
+++ b/drivers/gpu/nvgpu/pmgr/pmgr.c
@@ -24,11 +24,6 @@
24#include "pwrdev.h" 24#include "pwrdev.h"
25#include "pmgrpmu.h" 25#include "pmgrpmu.h"
26 26
27#ifdef CONFIG_DEBUG_FS
28#include <linux/debugfs.h>
29#include "os/linux/os_linux.h"
30#endif
31
32int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val) 27int pmgr_pwr_devices_get_power(struct gk20a *g, u32 *val)
33{ 28{
34 struct nv_pmu_pmgr_pwr_devices_query_payload payload; 29 struct nv_pmu_pmgr_pwr_devices_query_payload payload;
@@ -74,74 +69,6 @@ int pmgr_pwr_devices_get_voltage(struct gk20a *g, u32 *val)
74 return status; 69 return status;
75} 70}
76 71
77#ifdef CONFIG_DEBUG_FS
78static int pmgr_pwr_devices_get_power_u64(void *data, u64 *p)
79{
80 struct gk20a *g = (struct gk20a *)data;
81 int err;
82 u32 val;
83
84 err = pmgr_pwr_devices_get_power(g, &val);
85 *p = val;
86
87 return err;
88}
89
90static int pmgr_pwr_devices_get_current_u64(void *data, u64 *p)
91{
92 struct gk20a *g = (struct gk20a *)data;
93 int err;
94 u32 val;
95
96 err = pmgr_pwr_devices_get_current(g, &val);
97 *p = val;
98
99 return err;
100}
101
102static int pmgr_pwr_devices_get_voltage_u64(void *data, u64 *p)
103{
104 struct gk20a *g = (struct gk20a *)data;
105 int err;
106 u32 val;
107
108 err = pmgr_pwr_devices_get_voltage(g, &val);
109 *p = val;
110
111 return err;
112}
113
114DEFINE_SIMPLE_ATTRIBUTE(
115 pmgr_power_ctrl_fops, pmgr_pwr_devices_get_power_u64, NULL, "%llu\n");
116
117DEFINE_SIMPLE_ATTRIBUTE(
118 pmgr_current_ctrl_fops, pmgr_pwr_devices_get_current_u64, NULL, "%llu\n");
119
120DEFINE_SIMPLE_ATTRIBUTE(
121 pmgr_voltage_ctrl_fops, pmgr_pwr_devices_get_voltage_u64, NULL, "%llu\n");
122
123static void pmgr_debugfs_init(struct gk20a *g)
124{
125 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
126 struct dentry *dbgentry;
127
128 dbgentry = debugfs_create_file(
129 "power", S_IRUGO, l->debugfs, g, &pmgr_power_ctrl_fops);
130 if (!dbgentry)
131 nvgpu_err(g, "debugfs entry create failed for power");
132
133 dbgentry = debugfs_create_file(
134 "current", S_IRUGO, l->debugfs, g, &pmgr_current_ctrl_fops);
135 if (!dbgentry)
136 nvgpu_err(g, "debugfs entry create failed for current");
137
138 dbgentry = debugfs_create_file(
139 "voltage", S_IRUGO, l->debugfs, g, &pmgr_voltage_ctrl_fops);
140 if (!dbgentry)
141 nvgpu_err(g, "debugfs entry create failed for voltage");
142}
143#endif
144
145u32 pmgr_domain_sw_setup(struct gk20a *g) 72u32 pmgr_domain_sw_setup(struct gk20a *g)
146{ 73{
147 u32 status; 74 u32 status;
@@ -170,10 +97,6 @@ u32 pmgr_domain_sw_setup(struct gk20a *g)
170 goto exit; 97 goto exit;
171 } 98 }
172 99
173#ifdef CONFIG_DEBUG_FS
174 pmgr_debugfs_init(g);
175#endif
176
177exit: 100exit:
178 return status; 101 return status;
179} 102}