summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/common
diff options
context:
space:
mode:
authorTerje Bergstrom <tbergstrom@nvidia.com>2017-08-08 13:53:25 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-09-12 16:00:19 -0400
commit89772b03cb093b3556dd4803e5a8deee60046ac9 (patch)
treec609de388b57161e9bb58ff21ef5aaf7ab663a5e /drivers/gpu/nvgpu/common
parentb610bb95108afe54895219e06859cf241fabc9db (diff)
gpu: nvgpu: Move XVE debugfs code to Linux module
Move XVE debugfs initialization code to live under common/linux. JIRA NVGPU-62 Change-Id: Ic6677511d249bc0a2455dde01db5b230afc70bb1 Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1535133 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.c3
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_xve.c176
-rw-r--r--drivers/gpu/nvgpu/common/linux/debug_xve.h21
3 files changed, 200 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug.c b/drivers/gpu/nvgpu/common/linux/debug.c
index abc8b907..5750800f 100644
--- a/drivers/gpu/nvgpu/common/linux/debug.c
+++ b/drivers/gpu/nvgpu/common/linux/debug.c
@@ -22,6 +22,7 @@
22#include "debug_pmu.h" 22#include "debug_pmu.h"
23#include "debug_sched.h" 23#include "debug_sched.h"
24#include "debug_hal.h" 24#include "debug_hal.h"
25#include "debug_xve.h"
25#include "os_linux.h" 26#include "os_linux.h"
26 27
27#include "gk20a/gk20a.h" 28#include "gk20a/gk20a.h"
@@ -394,6 +395,8 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
394#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE 395#ifdef CONFIG_NVGPU_TRACK_MEM_USAGE
395 nvgpu_kmem_debugfs_init(g); 396 nvgpu_kmem_debugfs_init(g);
396#endif 397#endif
398 if (g->pci_vendor_id)
399 nvgpu_xve_debugfs_init(g);
397} 400}
398 401
399void gk20a_debug_deinit(struct gk20a *g) 402void gk20a_debug_deinit(struct gk20a *g)
diff --git a/drivers/gpu/nvgpu/common/linux/debug_xve.c b/drivers/gpu/nvgpu/common/linux/debug_xve.c
new file mode 100644
index 00000000..743702a2
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/debug_xve.c
@@ -0,0 +1,176 @@
1/*
2 * Copyright (C) 2017 NVIDIA Corporation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <nvgpu/types.h>
16#include <nvgpu/xve.h>
17
18#include "debug_xve.h"
19#include "os_linux.h"
20
21#include <linux/debugfs.h>
22#include <linux/uaccess.h>
23
24static ssize_t xve_link_speed_write(struct file *filp,
25 const char __user *buff,
26 size_t len, loff_t *off)
27{
28 struct gk20a *g = ((struct seq_file *)filp->private_data)->private;
29 char kbuff[16];
30 u32 buff_size, check_len;
31 u32 link_speed = 0;
32 int ret;
33
34 buff_size = min_t(size_t, 16, len);
35
36 memset(kbuff, 0, 16);
37 if (copy_from_user(kbuff, buff, buff_size))
38 return -EFAULT;
39
40 check_len = strlen("Gen1");
41 if (strncmp(kbuff, "Gen1", check_len) == 0)
42 link_speed = GPU_XVE_SPEED_2P5;
43 else if (strncmp(kbuff, "Gen2", check_len) == 0)
44 link_speed = GPU_XVE_SPEED_5P0;
45 else if (strncmp(kbuff, "Gen3", check_len) == 0)
46 link_speed = GPU_XVE_SPEED_8P0;
47 else
48 nvgpu_err(g, "%s: Unknown PCIe speed: %s",
49 __func__, kbuff);
50
51 if (!link_speed)
52 return -EINVAL;
53
54 /* Brief pause... To help rate limit this. */
55 nvgpu_msleep(250);
56
57 /*
58 * And actually set the speed. Yay.
59 */
60 ret = g->ops.xve.set_speed(g, link_speed);
61 if (ret)
62 return ret;
63
64 return len;
65}
66
67static int xve_link_speed_show(struct seq_file *s, void *unused)
68{
69 struct gk20a *g = s->private;
70 u32 speed;
71 int err;
72
73 err = g->ops.xve.get_speed(g, &speed);
74 if (err)
75 return err;
76
77 seq_printf(s, "Current PCIe speed:\n %s\n", xve_speed_to_str(speed));
78
79 return 0;
80}
81
82static int xve_link_speed_open(struct inode *inode, struct file *file)
83{
84 return single_open(file, xve_link_speed_show, inode->i_private);
85}
86
87static const struct file_operations xve_link_speed_fops = {
88 .open = xve_link_speed_open,
89 .read = seq_read,
90 .write = xve_link_speed_write,
91 .llseek = seq_lseek,
92 .release = single_release,
93};
94
95static int xve_available_speeds_show(struct seq_file *s, void *unused)
96{
97 struct gk20a *g = s->private;
98 u32 available_speeds;
99
100 g->ops.xve.available_speeds(g, &available_speeds);
101
102 seq_puts(s, "Available PCIe bus speeds:\n");
103 if (available_speeds & GPU_XVE_SPEED_2P5)
104 seq_puts(s, " Gen1\n");
105 if (available_speeds & GPU_XVE_SPEED_5P0)
106 seq_puts(s, " Gen2\n");
107 if (available_speeds & GPU_XVE_SPEED_8P0)
108 seq_puts(s, " Gen3\n");
109
110 return 0;
111}
112
113static int xve_available_speeds_open(struct inode *inode, struct file *file)
114{
115 return single_open(file, xve_available_speeds_show, inode->i_private);
116}
117
118static const struct file_operations xve_available_speeds_fops = {
119 .open = xve_available_speeds_open,
120 .read = seq_read,
121 .llseek = seq_lseek,
122 .release = single_release,
123};
124
125static int xve_link_control_status_show(struct seq_file *s, void *unused)
126{
127 struct gk20a *g = s->private;
128 u32 link_status;
129
130 link_status = g->ops.xve.get_link_control_status(g);
131 seq_printf(s, "0x%08x\n", link_status);
132
133 return 0;
134}
135
136static int xve_link_control_status_open(struct inode *inode, struct file *file)
137{
138 return single_open(file, xve_link_control_status_show, inode->i_private);
139}
140
141static const struct file_operations xve_link_control_status_fops = {
142 .open = xve_link_control_status_open,
143 .read = seq_read,
144 .llseek = seq_lseek,
145 .release = single_release,
146};
147
148int nvgpu_xve_debugfs_init(struct gk20a *g)
149{
150 int err = -ENODEV;
151
152 struct nvgpu_os_linux *l = nvgpu_os_linux_from_gk20a(g);
153 struct dentry *gpu_root = l->debugfs;
154
155 l->debugfs_xve = debugfs_create_dir("xve", gpu_root);
156 if (IS_ERR_OR_NULL(l->debugfs_xve))
157 goto fail;
158
159 /*
160 * These are just debug nodes. If they fail to get made it's not worth
161 * worrying the higher level SW.
162 */
163 debugfs_create_file("link_speed", S_IRUGO,
164 l->debugfs_xve, g,
165 &xve_link_speed_fops);
166 debugfs_create_file("available_speeds", S_IRUGO,
167 l->debugfs_xve, g,
168 &xve_available_speeds_fops);
169 debugfs_create_file("link_control_status", S_IRUGO,
170 l->debugfs_xve, g,
171 &xve_link_control_status_fops);
172
173 err = 0;
174fail:
175 return err;
176}
diff --git a/drivers/gpu/nvgpu/common/linux/debug_xve.h b/drivers/gpu/nvgpu/common/linux/debug_xve.h
new file mode 100644
index 00000000..f3b1ac54
--- /dev/null
+++ b/drivers/gpu/nvgpu/common/linux/debug_xve.h
@@ -0,0 +1,21 @@
1/*
2 * Copyright (C) 2017 NVIDIA Corporation. All rights reserved.
3 *
4 * This software is licensed under the terms of the GNU General Public
5 * License version 2, as published by the Free Software Foundation, and
6 * may be copied, distributed, and modified under those terms.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#ifndef __NVGPU_DEBUG_XVE_H__
16#define __NVGPU_DEBUG_XVE_H__
17
18struct gk20a;
19int nvgpu_xve_debugfs_init(struct gk20a *g);
20
21#endif /* __NVGPU_DEBUG_SVE_H__ */