drm_proc.c 15.0 KB
Newer Older
L
Linus Torvalds 已提交
1
/**
D
Dave Airlie 已提交
2
 * \file drm_proc.c
L
Linus Torvalds 已提交
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 37 38 39 40 41
 * /proc support for DRM
 *
 * \author Rickard E. (Rik) Faith <faith@valinux.com>
 * \author Gareth Hughes <gareth@valinux.com>
 *
 * \par Acknowledgements:
 *    Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
 *    the problem with the proc files not outputting all their information.
 */

/*
 * Created: Mon Jan 11 09:48:47 1999 by faith@valinux.com
 *
 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
 * All Rights Reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice (including the next
 * paragraph) shall be included in all copies or substantial portions of the
 * Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

#include "drmP.h"

D
Dave Airlie 已提交
42 43 44 45 46 47 48 49 50 51
static int drm_name_info(char *buf, char **start, off_t offset,
			 int request, int *eof, void *data);
static int drm_vm_info(char *buf, char **start, off_t offset,
		       int request, int *eof, void *data);
static int drm_clients_info(char *buf, char **start, off_t offset,
			    int request, int *eof, void *data);
static int drm_queues_info(char *buf, char **start, off_t offset,
			   int request, int *eof, void *data);
static int drm_bufs_info(char *buf, char **start, off_t offset,
			 int request, int *eof, void *data);
L
Linus Torvalds 已提交
52
#if DRM_DEBUG_CODE
D
Dave Airlie 已提交
53 54
static int drm_vma_info(char *buf, char **start, off_t offset,
			int request, int *eof, void *data);
L
Linus Torvalds 已提交
55 56 57 58 59
#endif

/**
 * Proc file list.
 */
D
Dave Airlie 已提交
60
static struct drm_proc_list {
L
Linus Torvalds 已提交
61
	const char *name;	/**< file name */
D
Dave Airlie 已提交
62
	int (*f) (char *, char **, off_t, int, int *, void *);		/**< proc callback*/
L
Linus Torvalds 已提交
63
} drm_proc_list[] = {
D
Dave Airlie 已提交
64 65 66 67 68 69
	{"name", drm_name_info},
	{"mem", drm_mem_info},
	{"vm", drm_vm_info},
	{"clients", drm_clients_info},
	{"queues", drm_queues_info},
	{"bufs", drm_bufs_info},
L
Linus Torvalds 已提交
70
#if DRM_DEBUG_CODE
D
Dave Airlie 已提交
71
	{"vma", drm_vma_info},
L
Linus Torvalds 已提交
72 73
#endif
};
D
Dave Airlie 已提交
74

75
#define DRM_PROC_ENTRIES ARRAY_SIZE(drm_proc_list)
L
Linus Torvalds 已提交
76 77 78 79 80 81 82 83 84

/**
 * Initialize the DRI proc filesystem for a device.
 *
 * \param dev DRM device.
 * \param minor device minor number.
 * \param root DRI proc dir entry.
 * \param dev_root resulting DRI device proc dir entry.
 * \return root entry pointer on success, or NULL on failure.
D
Dave Airlie 已提交
85
 *
L
Linus Torvalds 已提交
86 87 88 89
 * Create the DRI proc root entry "/proc/dri", the device proc root entry
 * "/proc/dri/%minor%/", and each entry in proc_list as
 * "/proc/dri/%minor%/%name%".
 */
90 91
int drm_proc_init(struct drm_minor *minor, int minor_id,
		  struct proc_dir_entry *root)
L
Linus Torvalds 已提交
92 93
{
	struct proc_dir_entry *ent;
D
Dave Airlie 已提交
94 95
	int i, j;
	char name[64];
L
Linus Torvalds 已提交
96

97 98 99
	sprintf(name, "%d", minor_id);
	minor->dev_root = proc_mkdir(name, root);
	if (!minor->dev_root) {
L
Linus Torvalds 已提交
100 101 102 103 104 105
		DRM_ERROR("Cannot create /proc/dri/%s\n", name);
		return -1;
	}

	for (i = 0; i < DRM_PROC_ENTRIES; i++) {
		ent = create_proc_entry(drm_proc_list[i].name,
106
					S_IFREG | S_IRUGO, minor->dev_root);
L
Linus Torvalds 已提交
107 108 109 110 111
		if (!ent) {
			DRM_ERROR("Cannot create /proc/dri/%s/%s\n",
				  name, drm_proc_list[i].name);
			for (j = 0; j < i; j++)
				remove_proc_entry(drm_proc_list[i].name,
112
						  minor->dev_root);
L
Linus Torvalds 已提交
113
			remove_proc_entry(name, root);
114
			minor->dev_root = NULL;
L
Linus Torvalds 已提交
115 116 117
			return -1;
		}
		ent->read_proc = drm_proc_list[i].f;
118
		ent->data = minor;
L
Linus Torvalds 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
	}

	return 0;
}

/**
 * Cleanup the proc filesystem resources.
 *
 * \param minor device minor number.
 * \param root DRI proc dir entry.
 * \param dev_root DRI device proc dir entry.
 * \return always zero.
 *
 * Remove all proc entries created by proc_init().
 */
134
int drm_proc_cleanup(struct drm_minor *minor, struct proc_dir_entry *root)
L
Linus Torvalds 已提交
135
{
D
Dave Airlie 已提交
136
	int i;
L
Linus Torvalds 已提交
137 138
	char name[64];

139
	if (!root || !minor->dev_root)
D
Dave Airlie 已提交
140
		return 0;
L
Linus Torvalds 已提交
141 142

	for (i = 0; i < DRM_PROC_ENTRIES; i++)
143 144
		remove_proc_entry(drm_proc_list[i].name, minor->dev_root);
	sprintf(name, "%d", minor->index);
L
Linus Torvalds 已提交
145 146 147 148 149 150 151
	remove_proc_entry(name, root);

	return 0;
}

/**
 * Called when "/proc/dri/.../name" is read.
D
Dave Airlie 已提交
152
 *
L
Linus Torvalds 已提交
153 154 155 156 157 158 159
 * \param buf output buffer.
 * \param start start of output data.
 * \param offset requested start offset.
 * \param request requested number of bytes.
 * \param eof whether there is no more data to return.
 * \param data private data.
 * \return number of written bytes.
D
Dave Airlie 已提交
160
 *
L
Linus Torvalds 已提交
161 162 163
 * Prints the device name together with the bus id if available.
 */
static int drm_name_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
164
			 int *eof, void *data)
L
Linus Torvalds 已提交
165
{
166 167
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
168
	int len = 0;
L
Linus Torvalds 已提交
169 170 171 172 173 174 175

	if (offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
176
	*eof = 0;
L
Linus Torvalds 已提交
177 178 179

	if (dev->unique) {
		DRM_PROC_PRINT("%s %s %s\n",
D
Dave Airlie 已提交
180 181
			       dev->driver->pci_driver.name,
			       pci_name(dev->pdev), dev->unique);
L
Linus Torvalds 已提交
182
	} else {
D
Dave Airlie 已提交
183 184
		DRM_PROC_PRINT("%s %s\n", dev->driver->pci_driver.name,
			       pci_name(dev->pdev));
L
Linus Torvalds 已提交
185 186
	}

D
Dave Airlie 已提交
187 188
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
189 190 191 192 193 194
	*eof = 1;
	return len - offset;
}

/**
 * Called when "/proc/dri/.../vm" is read.
D
Dave Airlie 已提交
195
 *
L
Linus Torvalds 已提交
196 197 198 199 200 201 202
 * \param buf output buffer.
 * \param start start of output data.
 * \param offset requested start offset.
 * \param request requested number of bytes.
 * \param eof whether there is no more data to return.
 * \param data private data.
 * \return number of written bytes.
D
Dave Airlie 已提交
203
 *
L
Linus Torvalds 已提交
204 205 206
 * Prints information about all mappings in drm_device::maplist.
 */
static int drm__vm_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
207
			int *eof, void *data)
L
Linus Torvalds 已提交
208
{
209 210
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
211
	int len = 0;
212
	struct drm_map *map;
D
Dave Airlie 已提交
213
	struct drm_map_list *r_list;
L
Linus Torvalds 已提交
214

D
Dave Airlie 已提交
215 216 217 218 219 220
	/* Hardcoded from _DRM_FRAME_BUFFER,
	   _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
	   _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
	const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
	const char *type;
	int i;
L
Linus Torvalds 已提交
221 222 223 224 225 226 227

	if (offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
228
	*eof = 0;
L
Linus Torvalds 已提交
229 230 231 232

	DRM_PROC_PRINT("slot	 offset	      size type flags	 "
		       "address mtrr\n\n");
	i = 0;
233
	list_for_each_entry(r_list, &dev->maplist, head) {
L
Linus Torvalds 已提交
234
		map = r_list->map;
D
Dave Airlie 已提交
235
		if (!map)
D
Dave Airlie 已提交
236 237 238
			continue;
		if (map->type < 0 || map->type > 5)
			type = "??";
D
Dave Airlie 已提交
239
		else
D
Dave Airlie 已提交
240
			type = types[map->type];
241
		DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s  0x%02x 0x%08lx ",
L
Linus Torvalds 已提交
242 243
			       i,
			       map->offset,
244
			       map->size, type, map->flags,
245
			       (unsigned long) r_list->user_token);
L
Linus Torvalds 已提交
246 247 248 249 250 251
		if (map->mtrr < 0) {
			DRM_PROC_PRINT("none\n");
		} else {
			DRM_PROC_PRINT("%4d\n", map->mtrr);
		}
		i++;
252
	}
L
Linus Torvalds 已提交
253

D
Dave Airlie 已提交
254 255
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
256 257 258 259 260
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
261
 * Simply calls _vm_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
262 263
 */
static int drm_vm_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
264
		       int *eof, void *data)
L
Linus Torvalds 已提交
265
{
266 267
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
268
	int ret;
L
Linus Torvalds 已提交
269

D
Dave Airlie 已提交
270
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
271
	ret = drm__vm_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
272
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
273 274 275 276 277
	return ret;
}

/**
 * Called when "/proc/dri/.../queues" is read.
D
Dave Airlie 已提交
278
 *
L
Linus Torvalds 已提交
279 280 281 282 283 284 285 286 287
 * \param buf output buffer.
 * \param start start of output data.
 * \param offset requested start offset.
 * \param request requested number of bytes.
 * \param eof whether there is no more data to return.
 * \param data private data.
 * \return number of written bytes.
 */
static int drm__queues_info(char *buf, char **start, off_t offset,
D
Dave Airlie 已提交
288
			    int request, int *eof, void *data)
L
Linus Torvalds 已提交
289
{
290 291
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
292 293
	int len = 0;
	int i;
294
	struct drm_queue *q;
L
Linus Torvalds 已提交
295 296 297 298 299 300 301

	if (offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
302
	*eof = 0;
L
Linus Torvalds 已提交
303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319

	DRM_PROC_PRINT("  ctx/flags   use   fin"
		       "   blk/rw/rwf  wait    flushed	   queued"
		       "      locks\n\n");
	for (i = 0; i < dev->queue_count; i++) {
		q = dev->queuelist[i];
		atomic_inc(&q->use_count);
		DRM_PROC_PRINT_RET(atomic_dec(&q->use_count),
				   "%5d/0x%03x %5d %5d"
				   " %5d/%c%c/%c%c%c %5Zd\n",
				   i,
				   q->flags,
				   atomic_read(&q->use_count),
				   atomic_read(&q->finalization),
				   atomic_read(&q->block_count),
				   atomic_read(&q->block_read) ? 'r' : '-',
				   atomic_read(&q->block_write) ? 'w' : '-',
D
Dave Airlie 已提交
320 321 322 323 324
				   waitqueue_active(&q->read_queue) ? 'r' : '-',
				   waitqueue_active(&q->
						    write_queue) ? 'w' : '-',
				   waitqueue_active(&q->
						    flush_queue) ? 'f' : '-',
L
Linus Torvalds 已提交
325 326 327 328
				   DRM_BUFCOUNT(&q->waitlist));
		atomic_dec(&q->use_count);
	}

D
Dave Airlie 已提交
329 330
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
331 332 333 334 335
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
336
 * Simply calls _queues_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
337 338
 */
static int drm_queues_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
339
			   int *eof, void *data)
L
Linus Torvalds 已提交
340
{
341 342
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
343
	int ret;
L
Linus Torvalds 已提交
344

D
Dave Airlie 已提交
345
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
346
	ret = drm__queues_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
347
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
348 349 350 351 352
	return ret;
}

/**
 * Called when "/proc/dri/.../bufs" is read.
D
Dave Airlie 已提交
353
 *
L
Linus Torvalds 已提交
354 355 356 357 358 359 360 361 362
 * \param buf output buffer.
 * \param start start of output data.
 * \param offset requested start offset.
 * \param request requested number of bytes.
 * \param eof whether there is no more data to return.
 * \param data private data.
 * \return number of written bytes.
 */
static int drm__bufs_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
363
			  int *eof, void *data)
L
Linus Torvalds 已提交
364
{
365 366
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
367
	int len = 0;
368
	struct drm_device_dma *dma = dev->dma;
D
Dave Airlie 已提交
369
	int i;
L
Linus Torvalds 已提交
370 371 372 373 374 375 376

	if (!dma || offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
377
	*eof = 0;
L
Linus Torvalds 已提交
378 379 380 381 382 383 384 385 386 387 388 389

	DRM_PROC_PRINT(" o     size count  free	 segs pages    kB\n\n");
	for (i = 0; i <= DRM_MAX_ORDER; i++) {
		if (dma->bufs[i].buf_count)
			DRM_PROC_PRINT("%2d %8d %5d %5d %5d %5d %5ld\n",
				       i,
				       dma->bufs[i].buf_size,
				       dma->bufs[i].buf_count,
				       atomic_read(&dma->bufs[i]
						   .freelist.count),
				       dma->bufs[i].seg_count,
				       dma->bufs[i].seg_count
D
Dave Airlie 已提交
390
				       * (1 << dma->bufs[i].page_order),
L
Linus Torvalds 已提交
391 392 393 394 395 396
				       (dma->bufs[i].seg_count
					* (1 << dma->bufs[i].page_order))
				       * PAGE_SIZE / 1024);
	}
	DRM_PROC_PRINT("\n");
	for (i = 0; i < dma->buf_count; i++) {
D
Dave Airlie 已提交
397 398
		if (i && !(i % 32))
			DRM_PROC_PRINT("\n");
L
Linus Torvalds 已提交
399 400 401 402
		DRM_PROC_PRINT(" %d", dma->buflist[i]->list);
	}
	DRM_PROC_PRINT("\n");

D
Dave Airlie 已提交
403 404
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
405 406 407 408 409
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
410
 * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
411 412
 */
static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
413
			 int *eof, void *data)
L
Linus Torvalds 已提交
414
{
415 416
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
417
	int ret;
L
Linus Torvalds 已提交
418

D
Dave Airlie 已提交
419
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
420
	ret = drm__bufs_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
421
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
422 423 424 425 426
	return ret;
}

/**
 * Called when "/proc/dri/.../clients" is read.
D
Dave Airlie 已提交
427
 *
L
Linus Torvalds 已提交
428 429 430 431 432 433 434 435 436
 * \param buf output buffer.
 * \param start start of output data.
 * \param offset requested start offset.
 * \param request requested number of bytes.
 * \param eof whether there is no more data to return.
 * \param data private data.
 * \return number of written bytes.
 */
static int drm__clients_info(char *buf, char **start, off_t offset,
D
Dave Airlie 已提交
437
			     int request, int *eof, void *data)
L
Linus Torvalds 已提交
438
{
439 440
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
441
	int len = 0;
442
	struct drm_file *priv;
L
Linus Torvalds 已提交
443 444 445 446 447 448 449

	if (offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
450
	*eof = 0;
L
Linus Torvalds 已提交
451 452

	DRM_PROC_PRINT("a dev	pid    uid	magic	  ioctls\n\n");
453
	list_for_each_entry(priv, &dev->filelist, lhead) {
L
Linus Torvalds 已提交
454 455
		DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n",
			       priv->authenticated ? 'y' : 'n',
456
			       priv->minor->index,
L
Linus Torvalds 已提交
457
			       priv->pid,
D
Dave Airlie 已提交
458
			       priv->uid, priv->magic, priv->ioctl_count);
L
Linus Torvalds 已提交
459 460
	}

D
Dave Airlie 已提交
461 462
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
463 464 465 466 467
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
468
 * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
469 470
 */
static int drm_clients_info(char *buf, char **start, off_t offset,
D
Dave Airlie 已提交
471
			    int request, int *eof, void *data)
L
Linus Torvalds 已提交
472
{
473 474
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
475
	int ret;
L
Linus Torvalds 已提交
476

D
Dave Airlie 已提交
477
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
478
	ret = drm__clients_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
479
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
480 481 482 483 484 485
	return ret;
}

#if DRM_DEBUG_CODE

static int drm__vma_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
486
			 int *eof, void *data)
L
Linus Torvalds 已提交
487
{
488 489
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
490
	int len = 0;
491
	struct drm_vma_entry *pt;
L
Linus Torvalds 已提交
492 493
	struct vm_area_struct *vma;
#if defined(__i386__)
D
Dave Airlie 已提交
494
	unsigned int pgprot;
L
Linus Torvalds 已提交
495 496 497 498 499 500 501 502
#endif

	if (offset > DRM_PROC_LIMIT) {
		*eof = 1;
		return 0;
	}

	*start = &buf[offset];
D
Dave Airlie 已提交
503
	*eof = 0;
L
Linus Torvalds 已提交
504 505 506 507

	DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n",
		       atomic_read(&dev->vma_count),
		       high_memory, virt_to_phys(high_memory));
508
	list_for_each_entry(pt, &dev->vmalist, head) {
D
Dave Airlie 已提交
509 510
		if (!(vma = pt->vma))
			continue;
511
		DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx000",
L
Linus Torvalds 已提交
512 513 514
			       pt->pid,
			       vma->vm_start,
			       vma->vm_end,
D
Dave Airlie 已提交
515 516 517
			       vma->vm_flags & VM_READ ? 'r' : '-',
			       vma->vm_flags & VM_WRITE ? 'w' : '-',
			       vma->vm_flags & VM_EXEC ? 'x' : '-',
L
Linus Torvalds 已提交
518
			       vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
D
Dave Airlie 已提交
519 520
			       vma->vm_flags & VM_LOCKED ? 'l' : '-',
			       vma->vm_flags & VM_IO ? 'i' : '-',
521
			       vma->vm_pgoff);
L
Linus Torvalds 已提交
522 523 524 525

#if defined(__i386__)
		pgprot = pgprot_val(vma->vm_page_prot);
		DRM_PROC_PRINT(" %c%c%c%c%c%c%c%c%c",
D
Dave Airlie 已提交
526 527 528 529 530
			       pgprot & _PAGE_PRESENT ? 'p' : '-',
			       pgprot & _PAGE_RW ? 'w' : 'r',
			       pgprot & _PAGE_USER ? 'u' : 's',
			       pgprot & _PAGE_PWT ? 't' : 'b',
			       pgprot & _PAGE_PCD ? 'u' : 'c',
L
Linus Torvalds 已提交
531
			       pgprot & _PAGE_ACCESSED ? 'a' : '-',
D
Dave Airlie 已提交
532 533 534
			       pgprot & _PAGE_DIRTY ? 'd' : '-',
			       pgprot & _PAGE_PSE ? 'm' : 'k',
			       pgprot & _PAGE_GLOBAL ? 'g' : 'l');
L
Linus Torvalds 已提交
535 536 537 538
#endif
		DRM_PROC_PRINT("\n");
	}

D
Dave Airlie 已提交
539 540
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
541 542 543 544 545
	*eof = 1;
	return len - offset;
}

static int drm_vma_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
546
			int *eof, void *data)
L
Linus Torvalds 已提交
547
{
548 549
	struct drm_minor *minor = (struct drm_minor *) data;
	struct drm_device *dev = minor->dev;
D
Dave Airlie 已提交
550
	int ret;
L
Linus Torvalds 已提交
551

D
Dave Airlie 已提交
552
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
553
	ret = drm__vma_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
554
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
555 556 557
	return ret;
}
#endif