diff options
author | Terje Bergstrom <tbergstrom@nvidia.com> | 2018-04-18 15:59:00 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2018-06-15 20:47:31 -0400 |
commit | 2a2c16af5f9f1ccfc93a13e820d5381e5c881e92 (patch) | |
tree | 2e5d7b042270a649978e5bb540857012c85fb5b5 /drivers/gpu/nvgpu/common/linux/debug_xve.c | |
parent | 98d996f4ffb0137d119b5849cae46d7b7e5693e1 (diff) |
gpu: nvgpu: Move Linux files away from common
Move all Linux source code files to drivers/gpu/nvgpu/os/linux from
drivers/gpu/nvgpu/common/linux. This changes the meaning of common
to be OS independent.
JIRA NVGPU-598
JIRA NVGPU-601
Change-Id: Ib7f2a43d3688bb0d0b7dcc48469a6783fd988ce9
Signed-off-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1747714
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/common/linux/debug_xve.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/debug_xve.c | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/debug_xve.c b/drivers/gpu/nvgpu/common/linux/debug_xve.c deleted file mode 100644 index 743702a2..00000000 --- a/drivers/gpu/nvgpu/common/linux/debug_xve.c +++ /dev/null | |||
@@ -1,176 +0,0 @@ | |||
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 | |||
24 | static 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 | |||
67 | static 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 | |||
82 | static 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 | |||
87 | static 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 | |||
95 | static 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 | |||
113 | static 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 | |||
118 | static 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 | |||
125 | static 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 | |||
136 | static 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 | |||
141 | static 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 | |||
148 | int 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; | ||
174 | fail: | ||
175 | return err; | ||
176 | } | ||