This source file includes following definitions.
- kfd_debugfs_open
- kfd_debugfs_hang_hws_write
- kfd_debugfs_init
- kfd_debugfs_fini
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include <linux/debugfs.h>
24 #include <linux/uaccess.h>
25
26 #include "kfd_priv.h"
27
28 static struct dentry *debugfs_root;
29
30 static int kfd_debugfs_open(struct inode *inode, struct file *file)
31 {
32 int (*show)(struct seq_file *, void *) = inode->i_private;
33
34 return single_open(file, show, NULL);
35 }
36
37 static ssize_t kfd_debugfs_hang_hws_write(struct file *file,
38 const char __user *user_buf, size_t size, loff_t *ppos)
39 {
40 struct kfd_dev *dev;
41 char tmp[16];
42 uint32_t gpu_id;
43 int ret = -EINVAL;
44
45 memset(tmp, 0, 16);
46 if (size >= 16) {
47 pr_err("Invalid input for gpu id.\n");
48 goto out;
49 }
50 if (copy_from_user(tmp, user_buf, size)) {
51 ret = -EFAULT;
52 goto out;
53 }
54 if (kstrtoint(tmp, 10, &gpu_id)) {
55 pr_err("Invalid input for gpu id.\n");
56 goto out;
57 }
58 dev = kfd_device_by_id(gpu_id);
59 if (dev) {
60 kfd_debugfs_hang_hws(dev);
61 ret = size;
62 } else
63 pr_err("Cannot find device %d.\n", gpu_id);
64
65 out:
66 return ret;
67 }
68
69 static const struct file_operations kfd_debugfs_fops = {
70 .owner = THIS_MODULE,
71 .open = kfd_debugfs_open,
72 .read = seq_read,
73 .llseek = seq_lseek,
74 .release = single_release,
75 };
76
77 static const struct file_operations kfd_debugfs_hang_hws_fops = {
78 .owner = THIS_MODULE,
79 .open = kfd_debugfs_open,
80 .read = seq_read,
81 .write = kfd_debugfs_hang_hws_write,
82 .llseek = seq_lseek,
83 .release = single_release,
84 };
85
86 void kfd_debugfs_init(void)
87 {
88 debugfs_root = debugfs_create_dir("kfd", NULL);
89
90 debugfs_create_file("mqds", S_IFREG | 0444, debugfs_root,
91 kfd_debugfs_mqds_by_process, &kfd_debugfs_fops);
92 debugfs_create_file("hqds", S_IFREG | 0444, debugfs_root,
93 kfd_debugfs_hqds_by_device, &kfd_debugfs_fops);
94 debugfs_create_file("rls", S_IFREG | 0444, debugfs_root,
95 kfd_debugfs_rls_by_device, &kfd_debugfs_fops);
96 debugfs_create_file("hang_hws", S_IFREG | 0200, debugfs_root,
97 NULL, &kfd_debugfs_hang_hws_fops);
98 }
99
100 void kfd_debugfs_fini(void)
101 {
102 debugfs_remove_recursive(debugfs_root);
103 }