summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/os
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 /drivers/gpu/nvgpu/os
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>
Diffstat (limited to 'drivers/gpu/nvgpu/os')
-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
3 files changed, 139 insertions, 0 deletions
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;