3 * DRM info file implementations
5 * \author Ben Gamari <bgamari@gmail.com>
9 * Created: Sun Dec 21 13:09:50 2008 by bgamari@gmail.com
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.
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:
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
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.
36 #include <linux/seq_file.h>
40 * Called when "/proc/dri/.../name" is read.
42 * Prints the device name together with the bus id if available.
44 int drm_name_info(struct seq_file
*m
, void *data
)
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
;
54 if (drm_core_check_feature(dev
, DRIVER_USE_PLATFORM_DEVICE
)) {
56 seq_printf(m
, "%s %s %s\n",
57 dev
->driver
->platform_device
->name
,
58 dev_name(dev
->dev
), master
->unique
);
61 dev
->driver
->platform_device
->name
);
65 seq_printf(m
, "%s %s %s\n",
66 dev
->driver
->pci_driver
.name
,
67 dev_name(dev
->dev
), master
->unique
);
69 seq_printf(m
, "%s %s\n", dev
->driver
->pci_driver
.name
,
78 * Called when "/proc/dri/.../vm" is read.
80 * Prints information about all mappings in drm_device::maplist.
82 int drm_vm_info(struct seq_file
*m
, void *data
)
84 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
85 struct drm_device
*dev
= node
->minor
->dev
;
86 struct drm_local_map
*map
;
87 struct drm_map_list
*r_list
;
89 /* Hardcoded from _DRM_FRAME_BUFFER,
90 _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
91 _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
92 const char *types
[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
96 mutex_lock(&dev
->struct_mutex
);
97 seq_printf(m
, "slot offset size type flags address mtrr\n\n");
99 list_for_each_entry(r_list
, &dev
->maplist
, head
) {
103 if (map
->type
< 0 || map
->type
> 5)
106 type
= types
[map
->type
];
108 seq_printf(m
, "%4d 0x%016llx 0x%08lx %4.4s 0x%02x 0x%08lx ",
110 (unsigned long long)map
->offset
,
111 map
->size
, type
, map
->flags
,
112 (unsigned long) r_list
->user_token
);
114 seq_printf(m
, "none\n");
116 seq_printf(m
, "%4d\n", map
->mtrr
);
119 mutex_unlock(&dev
->struct_mutex
);
124 * Called when "/proc/dri/.../queues" is read.
126 int drm_queues_info(struct seq_file
*m
, void *data
)
128 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
129 struct drm_device
*dev
= node
->minor
->dev
;
133 mutex_lock(&dev
->struct_mutex
);
134 seq_printf(m
, " ctx/flags use fin"
135 " blk/rw/rwf wait flushed queued"
137 for (i
= 0; i
< dev
->queue_count
; i
++) {
138 q
= dev
->queuelist
[i
];
139 atomic_inc(&q
->use_count
);
140 seq_printf(m
, "%5d/0x%03x %5d %5d"
141 " %5d/%c%c/%c%c%c %5Zd\n",
144 atomic_read(&q
->use_count
),
145 atomic_read(&q
->finalization
),
146 atomic_read(&q
->block_count
),
147 atomic_read(&q
->block_read
) ? 'r' : '-',
148 atomic_read(&q
->block_write
) ? 'w' : '-',
149 waitqueue_active(&q
->read_queue
) ? 'r' : '-',
150 waitqueue_active(&q
->write_queue
) ? 'w' : '-',
151 waitqueue_active(&q
->flush_queue
) ? 'f' : '-',
152 DRM_BUFCOUNT(&q
->waitlist
));
153 atomic_dec(&q
->use_count
);
155 mutex_unlock(&dev
->struct_mutex
);
160 * Called when "/proc/dri/.../bufs" is read.
162 int drm_bufs_info(struct seq_file
*m
, void *data
)
164 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
165 struct drm_device
*dev
= node
->minor
->dev
;
166 struct drm_device_dma
*dma
;
169 mutex_lock(&dev
->struct_mutex
);
172 mutex_unlock(&dev
->struct_mutex
);
176 seq_printf(m
, " o size count free segs pages kB\n\n");
177 for (i
= 0; i
<= DRM_MAX_ORDER
; i
++) {
178 if (dma
->bufs
[i
].buf_count
) {
179 seg_pages
= dma
->bufs
[i
].seg_count
* (1 << dma
->bufs
[i
].page_order
);
180 seq_printf(m
, "%2d %8d %5d %5d %5d %5d %5ld\n",
182 dma
->bufs
[i
].buf_size
,
183 dma
->bufs
[i
].buf_count
,
184 atomic_read(&dma
->bufs
[i
].freelist
.count
),
185 dma
->bufs
[i
].seg_count
,
187 seg_pages
* PAGE_SIZE
/ 1024);
191 for (i
= 0; i
< dma
->buf_count
; i
++) {
194 seq_printf(m
, " %d", dma
->buflist
[i
]->list
);
197 mutex_unlock(&dev
->struct_mutex
);
202 * Called when "/proc/dri/.../vblank" is read.
204 int drm_vblank_info(struct seq_file
*m
, void *data
)
206 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
207 struct drm_device
*dev
= node
->minor
->dev
;
210 mutex_lock(&dev
->struct_mutex
);
211 for (crtc
= 0; crtc
< dev
->num_crtcs
; crtc
++) {
212 seq_printf(m
, "CRTC %d enable: %d\n",
213 crtc
, atomic_read(&dev
->vblank_refcount
[crtc
]));
214 seq_printf(m
, "CRTC %d counter: %d\n",
215 crtc
, drm_vblank_count(dev
, crtc
));
216 seq_printf(m
, "CRTC %d last wait: %d\n",
217 crtc
, dev
->last_vblank_wait
[crtc
]);
218 seq_printf(m
, "CRTC %d in modeset: %d\n",
219 crtc
, dev
->vblank_inmodeset
[crtc
]);
221 mutex_unlock(&dev
->struct_mutex
);
226 * Called when "/proc/dri/.../clients" is read.
229 int drm_clients_info(struct seq_file
*m
, void *data
)
231 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
232 struct drm_device
*dev
= node
->minor
->dev
;
233 struct drm_file
*priv
;
235 mutex_lock(&dev
->struct_mutex
);
236 seq_printf(m
, "a dev pid uid magic ioctls\n\n");
237 list_for_each_entry(priv
, &dev
->filelist
, lhead
) {
238 seq_printf(m
, "%c %3d %5d %5d %10u %10lu\n",
239 priv
->authenticated
? 'y' : 'n',
242 priv
->uid
, priv
->magic
, priv
->ioctl_count
);
244 mutex_unlock(&dev
->struct_mutex
);
249 int drm_gem_one_name_info(int id
, void *ptr
, void *data
)
251 struct drm_gem_object
*obj
= ptr
;
252 struct seq_file
*m
= data
;
254 seq_printf(m
, "name %d size %zd\n", obj
->name
, obj
->size
);
256 seq_printf(m
, "%6d %8zd %7d %8d\n",
257 obj
->name
, obj
->size
,
258 atomic_read(&obj
->handlecount
.refcount
),
259 atomic_read(&obj
->refcount
.refcount
));
263 int drm_gem_name_info(struct seq_file
*m
, void *data
)
265 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
266 struct drm_device
*dev
= node
->minor
->dev
;
268 seq_printf(m
, " name size handles refcount\n");
269 idr_for_each(&dev
->object_name_idr
, drm_gem_one_name_info
, m
);
273 int drm_gem_object_info(struct seq_file
*m
, void* data
)
275 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
276 struct drm_device
*dev
= node
->minor
->dev
;
278 seq_printf(m
, "%d objects\n", atomic_read(&dev
->object_count
));
279 seq_printf(m
, "%d object bytes\n", atomic_read(&dev
->object_memory
));
280 seq_printf(m
, "%d pinned\n", atomic_read(&dev
->pin_count
));
281 seq_printf(m
, "%d pin bytes\n", atomic_read(&dev
->pin_memory
));
282 seq_printf(m
, "%d gtt bytes\n", atomic_read(&dev
->gtt_memory
));
283 seq_printf(m
, "%d gtt total\n", dev
->gtt_total
);
289 int drm_vma_info(struct seq_file
*m
, void *data
)
291 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
292 struct drm_device
*dev
= node
->minor
->dev
;
293 struct drm_vma_entry
*pt
;
294 struct vm_area_struct
*vma
;
295 #if defined(__i386__)
299 mutex_lock(&dev
->struct_mutex
);
300 seq_printf(m
, "vma use count: %d, high_memory = %p, 0x%08llx\n",
301 atomic_read(&dev
->vma_count
),
302 high_memory
, (u64
)virt_to_phys(high_memory
));
304 list_for_each_entry(pt
, &dev
->vmalist
, head
) {
309 "\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000",
310 pt
->pid
, vma
->vm_start
, vma
->vm_end
,
311 vma
->vm_flags
& VM_READ
? 'r' : '-',
312 vma
->vm_flags
& VM_WRITE
? 'w' : '-',
313 vma
->vm_flags
& VM_EXEC
? 'x' : '-',
314 vma
->vm_flags
& VM_MAYSHARE
? 's' : 'p',
315 vma
->vm_flags
& VM_LOCKED
? 'l' : '-',
316 vma
->vm_flags
& VM_IO
? 'i' : '-',
319 #if defined(__i386__)
320 pgprot
= pgprot_val(vma
->vm_page_prot
);
321 seq_printf(m
, " %c%c%c%c%c%c%c%c%c",
322 pgprot
& _PAGE_PRESENT
? 'p' : '-',
323 pgprot
& _PAGE_RW
? 'w' : 'r',
324 pgprot
& _PAGE_USER
? 'u' : 's',
325 pgprot
& _PAGE_PWT
? 't' : 'b',
326 pgprot
& _PAGE_PCD
? 'u' : 'c',
327 pgprot
& _PAGE_ACCESSED
? 'a' : '-',
328 pgprot
& _PAGE_DIRTY
? 'd' : '-',
329 pgprot
& _PAGE_PSE
? 'm' : 'k',
330 pgprot
& _PAGE_GLOBAL
? 'g' : 'l');
334 mutex_unlock(&dev
->struct_mutex
);