1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36#include <linux/seq_file.h>
37#include <drm/drmP.h>
38#include <drm/drm_gem.h>
39
40#include "drm_internal.h"
41#include "drm_legacy.h"
42
43
44
45
46
47
48int drm_name_info(struct seq_file *m, void *data)
49{
50 struct drm_info_node *node = (struct drm_info_node *) m->private;
51 struct drm_minor *minor = node->minor;
52 struct drm_device *dev = minor->dev;
53 struct drm_master *master;
54
55 mutex_lock(&dev->master_mutex);
56 master = dev->master;
57 seq_printf(m, "%s", dev->driver->name);
58 if (dev->dev)
59 seq_printf(m, " dev=%s", dev_name(dev->dev));
60 if (master && master->unique)
61 seq_printf(m, " master=%s", master->unique);
62 if (dev->unique)
63 seq_printf(m, " unique=%s", dev->unique);
64 seq_printf(m, "\n");
65 mutex_unlock(&dev->master_mutex);
66
67 return 0;
68}
69
70
71
72
73
74int drm_clients_info(struct seq_file *m, void *data)
75{
76 struct drm_info_node *node = (struct drm_info_node *) m->private;
77 struct drm_device *dev = node->minor->dev;
78 struct drm_file *priv;
79 kuid_t uid;
80
81 seq_printf(m,
82 "%20s %5s %3s master a %5s %10s\n",
83 "command",
84 "pid",
85 "dev",
86 "uid",
87 "magic");
88
89
90
91
92 mutex_lock(&dev->filelist_mutex);
93 list_for_each_entry_reverse(priv, &dev->filelist, lhead) {
94 struct task_struct *task;
95
96 rcu_read_lock();
97 task = pid_task(priv->pid, PIDTYPE_PID);
98 uid = task ? __task_cred(task)->euid : GLOBAL_ROOT_UID;
99 seq_printf(m, "%20s %5d %3d %c %c %5d %10u\n",
100 task ? task->comm : "<unknown>",
101 pid_vnr(priv->pid),
102 priv->minor->index,
103 drm_is_current_master(priv) ? 'y' : 'n',
104 priv->authenticated ? 'y' : 'n',
105 from_kuid_munged(seq_user_ns(m), uid),
106 priv->magic);
107 rcu_read_unlock();
108 }
109 mutex_unlock(&dev->filelist_mutex);
110 return 0;
111}
112
113static int drm_gem_one_name_info(int id, void *ptr, void *data)
114{
115 struct drm_gem_object *obj = ptr;
116 struct seq_file *m = data;
117
118 seq_printf(m, "%6d %8zd %7d %8d\n",
119 obj->name, obj->size,
120 obj->handle_count,
121 kref_read(&obj->refcount));
122 return 0;
123}
124
125int drm_gem_name_info(struct seq_file *m, void *data)
126{
127 struct drm_info_node *node = (struct drm_info_node *) m->private;
128 struct drm_device *dev = node->minor->dev;
129
130 seq_printf(m, " name size handles refcount\n");
131
132 mutex_lock(&dev->object_name_lock);
133 idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m);
134 mutex_unlock(&dev->object_name_lock);
135
136 return 0;
137}
138