drm_proc.c 14.5 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

L
Linus Torvalds 已提交
75 76 77 78 79 80 81 82 83 84
#define DRM_PROC_ENTRIES (sizeof(drm_proc_list)/sizeof(drm_proc_list[0]))

/**
 * 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%".
 */
D
Dave Airlie 已提交
90 91
int drm_proc_init(drm_device_t * dev, int minor,
		  struct proc_dir_entry *root, struct proc_dir_entry **dev_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

	sprintf(name, "%d", minor);
98
	*dev_root = proc_mkdir(name, root);
L
Linus Torvalds 已提交
99 100 101 102 103 104 105
	if (!*dev_root) {
		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,
D
Dave Airlie 已提交
106
					S_IFREG | S_IRUGO, *dev_root);
L
Linus Torvalds 已提交
107 108 109 110 111 112 113 114 115 116
		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,
						  *dev_root);
			remove_proc_entry(name, root);
			return -1;
		}
		ent->read_proc = drm_proc_list[i].f;
D
Dave Airlie 已提交
117
		ent->data = dev;
L
Linus Torvalds 已提交
118 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().
 */
int drm_proc_cleanup(int minor, struct proc_dir_entry *root,
D
Dave Airlie 已提交
134
		     struct proc_dir_entry *dev_root)
L
Linus Torvalds 已提交
135
{
D
Dave Airlie 已提交
136
	int i;
L
Linus Torvalds 已提交
137 138
	char name[64];

D
Dave Airlie 已提交
139 140
	if (!root || !dev_root)
		return 0;
L
Linus Torvalds 已提交
141 142 143 144 145 146 147 148 149 150 151

	for (i = 0; i < DRM_PROC_ENTRIES; i++)
		remove_proc_entry(drm_proc_list[i].name, dev_root);
	sprintf(name, "%d", minor);
	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
{
D
Dave Airlie 已提交
166 167
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
L
Linus Torvalds 已提交
168 169 170 171 172 173 174

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

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

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

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

/**
 * Called when "/proc/dri/.../vm" is read.
D
Dave Airlie 已提交
194
 *
L
Linus Torvalds 已提交
195 196 197 198 199 200 201
 * \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 已提交
202
 *
L
Linus Torvalds 已提交
203 204 205
 * 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 已提交
206
			int *eof, void *data)
L
Linus Torvalds 已提交
207
{
D
Dave Airlie 已提交
208 209 210
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
	drm_map_t *map;
L
Linus Torvalds 已提交
211 212 213
	drm_map_list_t *r_list;
	struct list_head *list;

D
Dave Airlie 已提交
214 215 216 217 218 219
	/* 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 已提交
220 221 222 223 224 225 226

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

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

	DRM_PROC_PRINT("slot	 offset	      size type flags	 "
		       "address mtrr\n\n");
	i = 0;
D
Dave Airlie 已提交
232 233
	if (dev->maplist != NULL)
		list_for_each(list, &dev->maplist->head) {
L
Linus Torvalds 已提交
234 235
		r_list = list_entry(list, drm_map_list_t, head);
		map = r_list->map;
D
Dave Airlie 已提交
236
		if (!map)
D
Dave Airlie 已提交
237 238 239
			continue;
		if (map->type < 0 || map->type > 5)
			type = "??";
D
Dave Airlie 已提交
240
		else
D
Dave Airlie 已提交
241
			type = types[map->type];
242
		DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s  0x%02x 0x%08x ",
L
Linus Torvalds 已提交
243 244
			       i,
			       map->offset,
D
Dave Airlie 已提交
245
			       map->size, type, map->flags, 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++;
D
Dave Airlie 已提交
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
{
D
Dave Airlie 已提交
266 267
	drm_device_t *dev = (drm_device_t *) data;
	int ret;
L
Linus Torvalds 已提交
268

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

/**
 * Called when "/proc/dri/.../queues" is read.
D
Dave Airlie 已提交
277
 *
L
Linus Torvalds 已提交
278 279 280 281 282 283 284 285 286
 * \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 已提交
287
			    int request, int *eof, void *data)
L
Linus Torvalds 已提交
288
{
D
Dave Airlie 已提交
289 290 291 292
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
	int i;
	drm_queue_t *q;
L
Linus Torvalds 已提交
293 294 295 296 297 298 299

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

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

	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 已提交
318 319 320 321 322
				   waitqueue_active(&q->read_queue) ? 'r' : '-',
				   waitqueue_active(&q->
						    write_queue) ? 'w' : '-',
				   waitqueue_active(&q->
						    flush_queue) ? 'f' : '-',
L
Linus Torvalds 已提交
323 324 325 326
				   DRM_BUFCOUNT(&q->waitlist));
		atomic_dec(&q->use_count);
	}

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

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

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

/**
 * Called when "/proc/dri/.../bufs" is read.
D
Dave Airlie 已提交
350
 *
L
Linus Torvalds 已提交
351 352 353 354 355 356 357 358 359
 * \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 已提交
360
			  int *eof, void *data)
L
Linus Torvalds 已提交
361
{
D
Dave Airlie 已提交
362 363
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
L
Linus Torvalds 已提交
364
	drm_device_dma_t *dma = dev->dma;
D
Dave Airlie 已提交
365
	int i;
L
Linus Torvalds 已提交
366 367 368 369 370 371 372

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

	*start = &buf[offset];
D
Dave Airlie 已提交
373
	*eof = 0;
L
Linus Torvalds 已提交
374 375 376 377 378 379 380 381 382 383 384 385

	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 已提交
386
				       * (1 << dma->bufs[i].page_order),
L
Linus Torvalds 已提交
387 388 389 390 391 392
				       (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 已提交
393 394
		if (i && !(i % 32))
			DRM_PROC_PRINT("\n");
L
Linus Torvalds 已提交
395 396 397 398
		DRM_PROC_PRINT(" %d", dma->buflist[i]->list);
	}
	DRM_PROC_PRINT("\n");

D
Dave Airlie 已提交
399 400
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
401 402 403 404 405
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
406
 * Simply calls _bufs_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
407 408
 */
static int drm_bufs_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
409
			 int *eof, void *data)
L
Linus Torvalds 已提交
410
{
D
Dave Airlie 已提交
411 412
	drm_device_t *dev = (drm_device_t *) data;
	int ret;
L
Linus Torvalds 已提交
413

D
Dave Airlie 已提交
414
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
415
	ret = drm__bufs_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
416
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
417 418 419 420 421
	return ret;
}

/**
 * Called when "/proc/dri/.../clients" is read.
D
Dave Airlie 已提交
422
 *
L
Linus Torvalds 已提交
423 424 425 426 427 428 429 430 431
 * \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 已提交
432
			     int request, int *eof, void *data)
L
Linus Torvalds 已提交
433
{
D
Dave Airlie 已提交
434 435 436
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
	drm_file_t *priv;
L
Linus Torvalds 已提交
437 438 439 440 441 442 443

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

	*start = &buf[offset];
D
Dave Airlie 已提交
444
	*eof = 0;
L
Linus Torvalds 已提交
445 446 447 448 449 450 451

	DRM_PROC_PRINT("a dev	pid    uid	magic	  ioctls\n\n");
	for (priv = dev->file_first; priv; priv = priv->next) {
		DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n",
			       priv->authenticated ? 'y' : 'n',
			       priv->minor,
			       priv->pid,
D
Dave Airlie 已提交
452
			       priv->uid, priv->magic, priv->ioctl_count);
L
Linus Torvalds 已提交
453 454
	}

D
Dave Airlie 已提交
455 456
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
457 458 459 460 461
	*eof = 1;
	return len - offset;
}

/**
D
Dave Airlie 已提交
462
 * Simply calls _clients_info() while holding the drm_device::struct_mutex lock.
L
Linus Torvalds 已提交
463 464
 */
static int drm_clients_info(char *buf, char **start, off_t offset,
D
Dave Airlie 已提交
465
			    int request, int *eof, void *data)
L
Linus Torvalds 已提交
466
{
D
Dave Airlie 已提交
467 468
	drm_device_t *dev = (drm_device_t *) data;
	int ret;
L
Linus Torvalds 已提交
469

D
Dave Airlie 已提交
470
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
471
	ret = drm__clients_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
472
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
473 474 475 476 477 478
	return ret;
}

#if DRM_DEBUG_CODE

static int drm__vma_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
479
			 int *eof, void *data)
L
Linus Torvalds 已提交
480
{
D
Dave Airlie 已提交
481 482 483
	drm_device_t *dev = (drm_device_t *) data;
	int len = 0;
	drm_vma_entry_t *pt;
L
Linus Torvalds 已提交
484 485
	struct vm_area_struct *vma;
#if defined(__i386__)
D
Dave Airlie 已提交
486
	unsigned int pgprot;
L
Linus Torvalds 已提交
487 488 489 490 491 492 493 494
#endif

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

	*start = &buf[offset];
D
Dave Airlie 已提交
495
	*eof = 0;
L
Linus Torvalds 已提交
496 497 498 499 500

	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));
	for (pt = dev->vmalist; pt; pt = pt->next) {
D
Dave Airlie 已提交
501 502
		if (!(vma = pt->vma))
			continue;
L
Linus Torvalds 已提交
503 504 505 506
		DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx",
			       pt->pid,
			       vma->vm_start,
			       vma->vm_end,
D
Dave Airlie 已提交
507 508 509
			       vma->vm_flags & VM_READ ? 'r' : '-',
			       vma->vm_flags & VM_WRITE ? 'w' : '-',
			       vma->vm_flags & VM_EXEC ? 'x' : '-',
L
Linus Torvalds 已提交
510
			       vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
D
Dave Airlie 已提交
511 512
			       vma->vm_flags & VM_LOCKED ? 'l' : '-',
			       vma->vm_flags & VM_IO ? 'i' : '-',
L
Linus Torvalds 已提交
513 514 515 516 517
			       VM_OFFSET(vma));

#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 已提交
518 519 520 521 522
			       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 已提交
523
			       pgprot & _PAGE_ACCESSED ? 'a' : '-',
D
Dave Airlie 已提交
524 525 526
			       pgprot & _PAGE_DIRTY ? 'd' : '-',
			       pgprot & _PAGE_PSE ? 'm' : 'k',
			       pgprot & _PAGE_GLOBAL ? 'g' : 'l');
L
Linus Torvalds 已提交
527 528 529 530
#endif
		DRM_PROC_PRINT("\n");
	}

D
Dave Airlie 已提交
531 532
	if (len > request + offset)
		return request;
L
Linus Torvalds 已提交
533 534 535 536 537
	*eof = 1;
	return len - offset;
}

static int drm_vma_info(char *buf, char **start, off_t offset, int request,
D
Dave Airlie 已提交
538
			int *eof, void *data)
L
Linus Torvalds 已提交
539
{
D
Dave Airlie 已提交
540 541
	drm_device_t *dev = (drm_device_t *) data;
	int ret;
L
Linus Torvalds 已提交
542

D
Dave Airlie 已提交
543
	mutex_lock(&dev->struct_mutex);
L
Linus Torvalds 已提交
544
	ret = drm__vma_info(buf, start, offset, request, eof, data);
D
Dave Airlie 已提交
545
	mutex_unlock(&dev->struct_mutex);
L
Linus Torvalds 已提交
546 547 548
	return ret;
}
#endif