diff options
Diffstat (limited to 'drivers/gpu/drm/drm_info.c')
-rw-r--r-- | drivers/gpu/drm/drm_info.c | 328 |
1 files changed, 328 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c new file mode 100644 index 000000000000..f0f6c6b93f3a --- /dev/null +++ b/drivers/gpu/drm/drm_info.c | |||
@@ -0,0 +1,328 @@ | |||
1 | /** | ||
2 | * \file drm_info.c | ||
3 | * DRM info file implementations | ||
4 | * | ||
5 | * \author Ben Gamari <bgamari@gmail.com> | ||
6 | */ | ||
7 | |||
8 | /* | ||
9 | * Created: Sun Dec 21 13:09:50 2008 by bgamari@gmail.com | ||
10 | * | ||
11 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | ||
12 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | ||
13 | * Copyright 2008 Ben Gamari <bgamari@gmail.com> | ||
14 | * All Rights Reserved. | ||
15 | * | ||
16 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
17 | * copy of this software and associated documentation files (the "Software"), | ||
18 | * to deal in the Software without restriction, including without limitation | ||
19 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
20 | * and/or sell copies of the Software, and to permit persons to whom the | ||
21 | * Software is furnished to do so, subject to the following conditions: | ||
22 | * | ||
23 | * The above copyright notice and this permission notice (including the next | ||
24 | * paragraph) shall be included in all copies or substantial portions of the | ||
25 | * Software. | ||
26 | * | ||
27 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
28 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
29 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
30 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
31 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
32 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
33 | * OTHER DEALINGS IN THE SOFTWARE. | ||
34 | */ | ||
35 | |||
36 | #include <linux/seq_file.h> | ||
37 | #include "drmP.h" | ||
38 | |||
39 | /** | ||
40 | * Called when "/proc/dri/.../name" is read. | ||
41 | * | ||
42 | * Prints the device name together with the bus id if available. | ||
43 | */ | ||
44 | int drm_name_info(struct seq_file *m, void *data) | ||
45 | { | ||
46 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
47 | struct drm_minor *minor = node->minor; | ||
48 | struct drm_device *dev = minor->dev; | ||
49 | struct drm_master *master = minor->master; | ||
50 | |||
51 | if (!master) | ||
52 | return 0; | ||
53 | |||
54 | if (master->unique) { | ||
55 | seq_printf(m, "%s %s %s\n", | ||
56 | dev->driver->pci_driver.name, | ||
57 | pci_name(dev->pdev), master->unique); | ||
58 | } else { | ||
59 | seq_printf(m, "%s %s\n", dev->driver->pci_driver.name, | ||
60 | pci_name(dev->pdev)); | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Called when "/proc/dri/.../vm" is read. | ||
68 | * | ||
69 | * Prints information about all mappings in drm_device::maplist. | ||
70 | */ | ||
71 | int drm_vm_info(struct seq_file *m, void *data) | ||
72 | { | ||
73 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
74 | struct drm_device *dev = node->minor->dev; | ||
75 | struct drm_local_map *map; | ||
76 | struct drm_map_list *r_list; | ||
77 | |||
78 | /* Hardcoded from _DRM_FRAME_BUFFER, | ||
79 | _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and | ||
80 | _DRM_SCATTER_GATHER and _DRM_CONSISTENT */ | ||
81 | const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" }; | ||
82 | const char *type; | ||
83 | int i; | ||
84 | |||
85 | mutex_lock(&dev->struct_mutex); | ||
86 | seq_printf(m, "slot offset size type flags address mtrr\n\n"); | ||
87 | i = 0; | ||
88 | list_for_each_entry(r_list, &dev->maplist, head) { | ||
89 | map = r_list->map; | ||
90 | if (!map) | ||
91 | continue; | ||
92 | if (map->type < 0 || map->type > 5) | ||
93 | type = "??"; | ||
94 | else | ||
95 | type = types[map->type]; | ||
96 | |||
97 | seq_printf(m, "%4d 0x%016llx 0x%08lx %4.4s 0x%02x 0x%08lx ", | ||
98 | i, | ||
99 | (unsigned long long)map->offset, | ||
100 | map->size, type, map->flags, | ||
101 | (unsigned long) r_list->user_token); | ||
102 | if (map->mtrr < 0) | ||
103 | seq_printf(m, "none\n"); | ||
104 | else | ||
105 | seq_printf(m, "%4d\n", map->mtrr); | ||
106 | i++; | ||
107 | } | ||
108 | mutex_unlock(&dev->struct_mutex); | ||
109 | return 0; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * Called when "/proc/dri/.../queues" is read. | ||
114 | */ | ||
115 | int drm_queues_info(struct seq_file *m, void *data) | ||
116 | { | ||
117 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
118 | struct drm_device *dev = node->minor->dev; | ||
119 | int i; | ||
120 | struct drm_queue *q; | ||
121 | |||
122 | mutex_lock(&dev->struct_mutex); | ||
123 | seq_printf(m, " ctx/flags use fin" | ||
124 | " blk/rw/rwf wait flushed queued" | ||
125 | " locks\n\n"); | ||
126 | for (i = 0; i < dev->queue_count; i++) { | ||
127 | q = dev->queuelist[i]; | ||
128 | atomic_inc(&q->use_count); | ||
129 | seq_printf(m, "%5d/0x%03x %5d %5d" | ||
130 | " %5d/%c%c/%c%c%c %5Zd\n", | ||
131 | i, | ||
132 | q->flags, | ||
133 | atomic_read(&q->use_count), | ||
134 | atomic_read(&q->finalization), | ||
135 | atomic_read(&q->block_count), | ||
136 | atomic_read(&q->block_read) ? 'r' : '-', | ||
137 | atomic_read(&q->block_write) ? 'w' : '-', | ||
138 | waitqueue_active(&q->read_queue) ? 'r' : '-', | ||
139 | waitqueue_active(&q->write_queue) ? 'w' : '-', | ||
140 | waitqueue_active(&q->flush_queue) ? 'f' : '-', | ||
141 | DRM_BUFCOUNT(&q->waitlist)); | ||
142 | atomic_dec(&q->use_count); | ||
143 | } | ||
144 | mutex_unlock(&dev->struct_mutex); | ||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * Called when "/proc/dri/.../bufs" is read. | ||
150 | */ | ||
151 | int drm_bufs_info(struct seq_file *m, void *data) | ||
152 | { | ||
153 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
154 | struct drm_device *dev = node->minor->dev; | ||
155 | struct drm_device_dma *dma; | ||
156 | int i, seg_pages; | ||
157 | |||
158 | mutex_lock(&dev->struct_mutex); | ||
159 | dma = dev->dma; | ||
160 | if (!dma) { | ||
161 | mutex_unlock(&dev->struct_mutex); | ||
162 | return 0; | ||
163 | } | ||
164 | |||
165 | seq_printf(m, " o size count free segs pages kB\n\n"); | ||
166 | for (i = 0; i <= DRM_MAX_ORDER; i++) { | ||
167 | if (dma->bufs[i].buf_count) { | ||
168 | seg_pages = dma->bufs[i].seg_count * (1 << dma->bufs[i].page_order); | ||
169 | seq_printf(m, "%2d %8d %5d %5d %5d %5d %5ld\n", | ||
170 | i, | ||
171 | dma->bufs[i].buf_size, | ||
172 | dma->bufs[i].buf_count, | ||
173 | atomic_read(&dma->bufs[i].freelist.count), | ||
174 | dma->bufs[i].seg_count, | ||
175 | seg_pages, | ||
176 | seg_pages * PAGE_SIZE / 1024); | ||
177 | } | ||
178 | } | ||
179 | seq_printf(m, "\n"); | ||
180 | for (i = 0; i < dma->buf_count; i++) { | ||
181 | if (i && !(i % 32)) | ||
182 | seq_printf(m, "\n"); | ||
183 | seq_printf(m, " %d", dma->buflist[i]->list); | ||
184 | } | ||
185 | seq_printf(m, "\n"); | ||
186 | mutex_unlock(&dev->struct_mutex); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | /** | ||
191 | * Called when "/proc/dri/.../vblank" is read. | ||
192 | */ | ||
193 | int drm_vblank_info(struct seq_file *m, void *data) | ||
194 | { | ||
195 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
196 | struct drm_device *dev = node->minor->dev; | ||
197 | int crtc; | ||
198 | |||
199 | mutex_lock(&dev->struct_mutex); | ||
200 | for (crtc = 0; crtc < dev->num_crtcs; crtc++) { | ||
201 | seq_printf(m, "CRTC %d enable: %d\n", | ||
202 | crtc, atomic_read(&dev->vblank_refcount[crtc])); | ||
203 | seq_printf(m, "CRTC %d counter: %d\n", | ||
204 | crtc, drm_vblank_count(dev, crtc)); | ||
205 | seq_printf(m, "CRTC %d last wait: %d\n", | ||
206 | crtc, dev->last_vblank_wait[crtc]); | ||
207 | seq_printf(m, "CRTC %d in modeset: %d\n", | ||
208 | crtc, dev->vblank_inmodeset[crtc]); | ||
209 | } | ||
210 | mutex_unlock(&dev->struct_mutex); | ||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | /** | ||
215 | * Called when "/proc/dri/.../clients" is read. | ||
216 | * | ||
217 | */ | ||
218 | int drm_clients_info(struct seq_file *m, void *data) | ||
219 | { | ||
220 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
221 | struct drm_device *dev = node->minor->dev; | ||
222 | struct drm_file *priv; | ||
223 | |||
224 | mutex_lock(&dev->struct_mutex); | ||
225 | seq_printf(m, "a dev pid uid magic ioctls\n\n"); | ||
226 | list_for_each_entry(priv, &dev->filelist, lhead) { | ||
227 | seq_printf(m, "%c %3d %5d %5d %10u %10lu\n", | ||
228 | priv->authenticated ? 'y' : 'n', | ||
229 | priv->minor->index, | ||
230 | priv->pid, | ||
231 | priv->uid, priv->magic, priv->ioctl_count); | ||
232 | } | ||
233 | mutex_unlock(&dev->struct_mutex); | ||
234 | return 0; | ||
235 | } | ||
236 | |||
237 | |||
238 | int drm_gem_one_name_info(int id, void *ptr, void *data) | ||
239 | { | ||
240 | struct drm_gem_object *obj = ptr; | ||
241 | struct seq_file *m = data; | ||
242 | |||
243 | seq_printf(m, "name %d size %zd\n", obj->name, obj->size); | ||
244 | |||
245 | seq_printf(m, "%6d %8zd %7d %8d\n", | ||
246 | obj->name, obj->size, | ||
247 | atomic_read(&obj->handlecount.refcount), | ||
248 | atomic_read(&obj->refcount.refcount)); | ||
249 | return 0; | ||
250 | } | ||
251 | |||
252 | int drm_gem_name_info(struct seq_file *m, void *data) | ||
253 | { | ||
254 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
255 | struct drm_device *dev = node->minor->dev; | ||
256 | |||
257 | seq_printf(m, " name size handles refcount\n"); | ||
258 | idr_for_each(&dev->object_name_idr, drm_gem_one_name_info, m); | ||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | int drm_gem_object_info(struct seq_file *m, void* data) | ||
263 | { | ||
264 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
265 | struct drm_device *dev = node->minor->dev; | ||
266 | |||
267 | seq_printf(m, "%d objects\n", atomic_read(&dev->object_count)); | ||
268 | seq_printf(m, "%d object bytes\n", atomic_read(&dev->object_memory)); | ||
269 | seq_printf(m, "%d pinned\n", atomic_read(&dev->pin_count)); | ||
270 | seq_printf(m, "%d pin bytes\n", atomic_read(&dev->pin_memory)); | ||
271 | seq_printf(m, "%d gtt bytes\n", atomic_read(&dev->gtt_memory)); | ||
272 | seq_printf(m, "%d gtt total\n", dev->gtt_total); | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | #if DRM_DEBUG_CODE | ||
277 | |||
278 | int drm_vma_info(struct seq_file *m, void *data) | ||
279 | { | ||
280 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
281 | struct drm_device *dev = node->minor->dev; | ||
282 | struct drm_vma_entry *pt; | ||
283 | struct vm_area_struct *vma; | ||
284 | #if defined(__i386__) | ||
285 | unsigned int pgprot; | ||
286 | #endif | ||
287 | |||
288 | mutex_lock(&dev->struct_mutex); | ||
289 | seq_printf(m, "vma use count: %d, high_memory = %p, 0x%08llx\n", | ||
290 | atomic_read(&dev->vma_count), | ||
291 | high_memory, (u64)virt_to_phys(high_memory)); | ||
292 | |||
293 | list_for_each_entry(pt, &dev->vmalist, head) { | ||
294 | vma = pt->vma; | ||
295 | if (!vma) | ||
296 | continue; | ||
297 | seq_printf(m, | ||
298 | "\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000", | ||
299 | pt->pid, vma->vm_start, vma->vm_end, | ||
300 | vma->vm_flags & VM_READ ? 'r' : '-', | ||
301 | vma->vm_flags & VM_WRITE ? 'w' : '-', | ||
302 | vma->vm_flags & VM_EXEC ? 'x' : '-', | ||
303 | vma->vm_flags & VM_MAYSHARE ? 's' : 'p', | ||
304 | vma->vm_flags & VM_LOCKED ? 'l' : '-', | ||
305 | vma->vm_flags & VM_IO ? 'i' : '-', | ||
306 | vma->vm_pgoff); | ||
307 | |||
308 | #if defined(__i386__) | ||
309 | pgprot = pgprot_val(vma->vm_page_prot); | ||
310 | seq_printf(m, " %c%c%c%c%c%c%c%c%c", | ||
311 | pgprot & _PAGE_PRESENT ? 'p' : '-', | ||
312 | pgprot & _PAGE_RW ? 'w' : 'r', | ||
313 | pgprot & _PAGE_USER ? 'u' : 's', | ||
314 | pgprot & _PAGE_PWT ? 't' : 'b', | ||
315 | pgprot & _PAGE_PCD ? 'u' : 'c', | ||
316 | pgprot & _PAGE_ACCESSED ? 'a' : '-', | ||
317 | pgprot & _PAGE_DIRTY ? 'd' : '-', | ||
318 | pgprot & _PAGE_PSE ? 'm' : 'k', | ||
319 | pgprot & _PAGE_GLOBAL ? 'g' : 'l'); | ||
320 | #endif | ||
321 | seq_printf(m, "\n"); | ||
322 | } | ||
323 | mutex_unlock(&dev->struct_mutex); | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | #endif | ||
328 | |||