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>
38 #include "drm_legacy.h"
41 * Called when "/proc/dri/.../name" is read.
43 * Prints the device name together with the bus id if available.
45 int drm_name_info(struct seq_file
*m
, void *data
)
47 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
48 struct drm_minor
*minor
= node
->minor
;
49 struct drm_device
*dev
= minor
->dev
;
50 struct drm_master
*master
= minor
->master
;
55 seq_printf(m
, "%s %s %s\n",
57 dev_name(dev
->dev
), master
->unique
);
59 seq_printf(m
, "%s %s\n",
60 dev
->driver
->name
, dev_name(dev
->dev
));
66 * Called when "/proc/dri/.../vm" is read.
68 * Prints information about all mappings in drm_device::maplist.
70 int drm_vm_info(struct seq_file
*m
, void *data
)
72 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
73 struct drm_device
*dev
= node
->minor
->dev
;
74 struct drm_local_map
*map
;
75 struct drm_map_list
*r_list
;
77 /* Hardcoded from _DRM_FRAME_BUFFER,
78 _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
79 _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
80 const char *types
[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
84 mutex_lock(&dev
->struct_mutex
);
85 seq_printf(m
, "slot offset size type flags address mtrr\n\n");
87 list_for_each_entry(r_list
, &dev
->maplist
, head
) {
91 if (map
->type
< 0 || map
->type
> 5)
94 type
= types
[map
->type
];
96 seq_printf(m
, "%4d 0x%016llx 0x%08lx %4.4s 0x%02x 0x%08lx ",
98 (unsigned long long)map
->offset
,
99 map
->size
, type
, map
->flags
,
100 (unsigned long) r_list
->user_token
);
102 seq_printf(m
, "none\n");
104 seq_printf(m
, "%4d\n", map
->mtrr
);
107 mutex_unlock(&dev
->struct_mutex
);
112 * Called when "/proc/dri/.../bufs" is read.
114 int drm_bufs_info(struct seq_file
*m
, void *data
)
116 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
117 struct drm_device
*dev
= node
->minor
->dev
;
118 struct drm_device_dma
*dma
;
121 mutex_lock(&dev
->struct_mutex
);
124 mutex_unlock(&dev
->struct_mutex
);
128 seq_printf(m
, " o size count free segs pages kB\n\n");
129 for (i
= 0; i
<= DRM_MAX_ORDER
; i
++) {
130 if (dma
->bufs
[i
].buf_count
) {
131 seg_pages
= dma
->bufs
[i
].seg_count
* (1 << dma
->bufs
[i
].page_order
);
132 seq_printf(m
, "%2d %8d %5d %5d %5d %5d %5ld\n",
134 dma
->bufs
[i
].buf_size
,
135 dma
->bufs
[i
].buf_count
,
137 dma
->bufs
[i
].seg_count
,
139 seg_pages
* PAGE_SIZE
/ 1024);
143 for (i
= 0; i
< dma
->buf_count
; i
++) {
146 seq_printf(m
, " %d", dma
->buflist
[i
]->list
);
149 mutex_unlock(&dev
->struct_mutex
);
154 * Called when "/proc/dri/.../vblank" is read.
156 int drm_vblank_info(struct seq_file
*m
, void *data
)
158 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
159 struct drm_device
*dev
= node
->minor
->dev
;
162 mutex_lock(&dev
->struct_mutex
);
163 for (crtc
= 0; crtc
< dev
->num_crtcs
; crtc
++) {
164 seq_printf(m
, "CRTC %d enable: %d\n",
165 crtc
, atomic_read(&dev
->vblank
[crtc
].refcount
));
166 seq_printf(m
, "CRTC %d counter: %d\n",
167 crtc
, drm_vblank_count(dev
, crtc
));
168 seq_printf(m
, "CRTC %d last wait: %d\n",
169 crtc
, dev
->vblank
[crtc
].last_wait
);
170 seq_printf(m
, "CRTC %d in modeset: %d\n",
171 crtc
, dev
->vblank
[crtc
].inmodeset
);
173 mutex_unlock(&dev
->struct_mutex
);
178 * Called when "/proc/dri/.../clients" is read.
181 int drm_clients_info(struct seq_file
*m
, void *data
)
183 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
184 struct drm_device
*dev
= node
->minor
->dev
;
185 struct drm_file
*priv
;
188 "%20s %5s %3s master a %5s %10s\n",
195 /* dev->filelist is sorted youngest first, but we want to present
196 * oldest first (i.e. kernel, servers, clients), so walk backwardss.
198 mutex_lock(&dev
->struct_mutex
);
199 list_for_each_entry_reverse(priv
, &dev
->filelist
, lhead
) {
200 struct task_struct
*task
;
202 rcu_read_lock(); /* locks pid_task()->comm */
203 task
= pid_task(priv
->pid
, PIDTYPE_PID
);
204 seq_printf(m
, "%20s %5d %3d %c %c %5d %10u\n",
205 task
? task
->comm
: "<unknown>",
208 priv
->is_master
? 'y' : 'n',
209 priv
->authenticated
? 'y' : 'n',
210 from_kuid_munged(seq_user_ns(m
), priv
->uid
),
214 mutex_unlock(&dev
->struct_mutex
);
219 static int drm_gem_one_name_info(int id
, void *ptr
, void *data
)
221 struct drm_gem_object
*obj
= ptr
;
222 struct seq_file
*m
= data
;
224 seq_printf(m
, "%6d %8zd %7d %8d\n",
225 obj
->name
, obj
->size
,
227 atomic_read(&obj
->refcount
.refcount
));
231 int drm_gem_name_info(struct seq_file
*m
, void *data
)
233 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
234 struct drm_device
*dev
= node
->minor
->dev
;
236 seq_printf(m
, " name size handles refcount\n");
238 mutex_lock(&dev
->object_name_lock
);
239 idr_for_each(&dev
->object_name_idr
, drm_gem_one_name_info
, m
);
240 mutex_unlock(&dev
->object_name_lock
);