drm_proc.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:17k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* drm_proc.h -- /proc support for DRM -*- linux-c -*-
  2.  * Created: Mon Jan 11 09:48:47 1999 by faith@valinux.com
  3.  *
  4.  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  5.  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  6.  * All Rights Reserved.
  7.  *
  8.  * Permission is hereby granted, free of charge, to any person obtaining a
  9.  * copy of this software and associated documentation files (the "Software"),
  10.  * to deal in the Software without restriction, including without limitation
  11.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  12.  * and/or sell copies of the Software, and to permit persons to whom the
  13.  * Software is furnished to do so, subject to the following conditions:
  14.  *
  15.  * The above copyright notice and this permission notice (including the next
  16.  * paragraph) shall be included in all copies or substantial portions of the
  17.  * Software.
  18.  *
  19.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  22.  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  23.  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  24.  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  25.  * OTHER DEALINGS IN THE SOFTWARE.
  26.  *
  27.  * Authors:
  28.  *    Rickard E. (Rik) Faith <faith@valinux.com>
  29.  *    Gareth Hughes <gareth@valinux.com>
  30.  *
  31.  * Acknowledgements:
  32.  *    Matthew J Sottek <matthew.j.sottek@intel.com> sent in a patch to fix
  33.  *    the problem with the proc files not outputting all their information.
  34.  */
  35. #include "drmP.h"
  36. static int    DRM(name_info)(char *buf, char **start, off_t offset,
  37.   int request, int *eof, void *data);
  38. static int    DRM(vm_info)(char *buf, char **start, off_t offset,
  39. int request, int *eof, void *data);
  40. static int    DRM(clients_info)(char *buf, char **start, off_t offset,
  41.      int request, int *eof, void *data);
  42. static int    DRM(queues_info)(char *buf, char **start, off_t offset,
  43.     int request, int *eof, void *data);
  44. static int    DRM(bufs_info)(char *buf, char **start, off_t offset,
  45.   int request, int *eof, void *data);
  46. #if DRM_DEBUG_CODE
  47. static int    DRM(vma_info)(char *buf, char **start, off_t offset,
  48.  int request, int *eof, void *data);
  49. #endif
  50. #if __HAVE_DMA_HISTOGRAM
  51. static int    DRM(histo_info)(char *buf, char **start, off_t offset,
  52.    int request, int *eof, void *data);
  53. #endif
  54. struct drm_proc_list {
  55. const char *name;
  56. int    (*f)(char *, char **, off_t, int, int *, void *);
  57. } DRM(proc_list)[] = {
  58. { "name",    DRM(name_info)    },
  59. { "mem",     DRM(mem_info)     },
  60. { "vm",      DRM(vm_info)      },
  61. { "clients", DRM(clients_info) },
  62. { "queues",  DRM(queues_info)  },
  63. { "bufs",    DRM(bufs_info)    },
  64. #if DRM_DEBUG_CODE
  65. { "vma",     DRM(vma_info)     },
  66. #endif
  67. #if __HAVE_DMA_HISTOGRAM
  68. { "histo",   DRM(histo_info)   },
  69. #endif
  70. };
  71. #define DRM_PROC_ENTRIES (sizeof(DRM(proc_list))/sizeof(DRM(proc_list)[0]))
  72. struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev, int minor,
  73.       struct proc_dir_entry *root,
  74.       struct proc_dir_entry **dev_root)
  75. {
  76. struct proc_dir_entry *ent;
  77. int       i, j;
  78. char                  name[64];
  79. if (!minor) root = create_proc_entry("dri", S_IFDIR, NULL);
  80. if (!root) {
  81. DRM_ERROR("Cannot create /proc/drin");
  82. return NULL;
  83. }
  84. sprintf(name, "%d", minor);
  85. *dev_root = create_proc_entry(name, S_IFDIR, root);
  86. if (!*dev_root) {
  87. DRM_ERROR("Cannot create /proc/%sn", name);
  88. return NULL;
  89. }
  90. for (i = 0; i < DRM_PROC_ENTRIES; i++) {
  91. ent = create_proc_entry(DRM(proc_list)[i].name,
  92. S_IFREG|S_IRUGO, *dev_root);
  93. if (!ent) {
  94. DRM_ERROR("Cannot create /proc/dri/%s/%sn",
  95.   name, DRM(proc_list)[i].name);
  96. for (j = 0; j < i; j++)
  97. remove_proc_entry(DRM(proc_list)[i].name,
  98.   *dev_root);
  99. remove_proc_entry(name, root);
  100. if (!minor) remove_proc_entry("dri", NULL);
  101. return NULL;
  102. }
  103. ent->read_proc = DRM(proc_list)[i].f;
  104. ent->data      = dev;
  105. }
  106. return root;
  107. }
  108. int DRM(proc_cleanup)(int minor, struct proc_dir_entry *root,
  109.       struct proc_dir_entry *dev_root)
  110. {
  111. int  i;
  112. char name[64];
  113. if (!root || !dev_root) return 0;
  114. for (i = 0; i < DRM_PROC_ENTRIES; i++)
  115. remove_proc_entry(DRM(proc_list)[i].name, dev_root);
  116. sprintf(name, "%d", minor);
  117. remove_proc_entry(name, root);
  118. if (!minor) remove_proc_entry("dri", NULL);
  119. return 0;
  120. }
  121. static int DRM(name_info)(char *buf, char **start, off_t offset, int request,
  122.   int *eof, void *data)
  123. {
  124. drm_device_t *dev = (drm_device_t *)data;
  125. int          len  = 0;
  126. if (offset > DRM_PROC_LIMIT) {
  127. *eof = 1;
  128. return 0;
  129. }
  130. *start = &buf[offset];
  131. *eof   = 0;
  132. if (dev->unique) {
  133. DRM_PROC_PRINT("%s 0x%x %sn",
  134.        dev->name, dev->device, dev->unique);
  135. } else {
  136. DRM_PROC_PRINT("%s 0x%xn", dev->name, dev->device);
  137. }
  138. if (len > request + offset) return request;
  139. *eof = 1;
  140. return len - offset;
  141. }
  142. static int DRM(_vm_info)(char *buf, char **start, off_t offset, int request,
  143.  int *eof, void *data)
  144. {
  145. drm_device_t *dev = (drm_device_t *)data;
  146. int          len  = 0;
  147. drm_map_t    *map;
  148. drm_map_list_t *r_list;
  149. struct list_head *list;
  150. /* Hardcoded from _DRM_FRAME_BUFFER,
  151.                                    _DRM_REGISTERS, _DRM_SHM, and
  152.                                    _DRM_AGP. */
  153. const char   *types[] = { "FB", "REG", "SHM", "AGP" };
  154. const char   *type;
  155. int      i;
  156. if (offset > DRM_PROC_LIMIT) {
  157. *eof = 1;
  158. return 0;
  159. }
  160. *start = &buf[offset];
  161. *eof   = 0;
  162. DRM_PROC_PRINT("slot  offset       size type flags  "
  163.        "address mtrrnn");
  164. i = 0;
  165. if (dev->maplist != NULL) list_for_each(list, &dev->maplist->head) {
  166. r_list = (drm_map_list_t *)list;
  167. map = r_list->map;
  168. if(!map) continue;
  169. if (map->type < 0 || map->type > 3) type = "??";
  170. else     type = types[map->type];
  171. DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s  0x%02x 0x%08lx ",
  172.        i,
  173.        map->offset,
  174.        map->size,
  175.        type,
  176.        map->flags,
  177.        (unsigned long)map->handle);
  178. if (map->mtrr < 0) {
  179. DRM_PROC_PRINT("nonen");
  180. } else {
  181. DRM_PROC_PRINT("%4dn", map->mtrr);
  182. }
  183. i++;
  184. }
  185. if (len > request + offset) return request;
  186. *eof = 1;
  187. return len - offset;
  188. }
  189. static int DRM(vm_info)(char *buf, char **start, off_t offset, int request,
  190. int *eof, void *data)
  191. {
  192. drm_device_t *dev = (drm_device_t *)data;
  193. int      ret;
  194. down(&dev->struct_sem);
  195. ret = DRM(_vm_info)(buf, start, offset, request, eof, data);
  196. up(&dev->struct_sem);
  197. return ret;
  198. }
  199. static int DRM(_queues_info)(char *buf, char **start, off_t offset,
  200.      int request, int *eof, void *data)
  201. {
  202. drm_device_t *dev = (drm_device_t *)data;
  203. int          len  = 0;
  204. int      i;
  205. drm_queue_t  *q;
  206. if (offset > DRM_PROC_LIMIT) {
  207. *eof = 1;
  208. return 0;
  209. }
  210. *start = &buf[offset];
  211. *eof   = 0;
  212. DRM_PROC_PRINT("  ctx/flags   use   fin"
  213.        "   blk/rw/rwf  wait    flushed    queued"
  214.        "      locksnn");
  215. for (i = 0; i < dev->queue_count; i++) {
  216. q = dev->queuelist[i];
  217. atomic_inc(&q->use_count);
  218. DRM_PROC_PRINT_RET(atomic_dec(&q->use_count),
  219.    "%5d/0x%03x %5d %5d"
  220.    " %5d/%c%c/%c%c%c %5Zdn",
  221.    i,
  222.    q->flags,
  223.    atomic_read(&q->use_count),
  224.    atomic_read(&q->finalization),
  225.    atomic_read(&q->block_count),
  226.    atomic_read(&q->block_read) ? 'r' : '-',
  227.    atomic_read(&q->block_write) ? 'w' : '-',
  228.    waitqueue_active(&q->read_queue) ? 'r':'-',
  229.    waitqueue_active(&q->write_queue) ? 'w':'-',
  230.    waitqueue_active(&q->flush_queue) ? 'f':'-',
  231.    DRM_BUFCOUNT(&q->waitlist));
  232. atomic_dec(&q->use_count);
  233. }
  234. if (len > request + offset) return request;
  235. *eof = 1;
  236. return len - offset;
  237. }
  238. static int DRM(queues_info)(char *buf, char **start, off_t offset, int request,
  239.     int *eof, void *data)
  240. {
  241. drm_device_t *dev = (drm_device_t *)data;
  242. int      ret;
  243. down(&dev->struct_sem);
  244. ret = DRM(_queues_info)(buf, start, offset, request, eof, data);
  245. up(&dev->struct_sem);
  246. return ret;
  247. }
  248. /* drm_bufs_info is called whenever a process reads
  249.    /dev/dri/<dev>/bufs. */
  250. static int DRM(_bufs_info)(char *buf, char **start, off_t offset, int request,
  251.    int *eof, void *data)
  252. {
  253. drm_device_t  *dev = (drm_device_t *)data;
  254. int              len  = 0;
  255. drm_device_dma_t *dma = dev->dma;
  256. int  i;
  257. if (!dma || offset > DRM_PROC_LIMIT) {
  258. *eof = 1;
  259. return 0;
  260. }
  261. *start = &buf[offset];
  262. *eof   = 0;
  263. DRM_PROC_PRINT(" o     size count  free  segs pages    kBnn");
  264. for (i = 0; i <= DRM_MAX_ORDER; i++) {
  265. if (dma->bufs[i].buf_count)
  266. DRM_PROC_PRINT("%2d %8d %5d %5d %5d %5d %5ldn",
  267.        i,
  268.        dma->bufs[i].buf_size,
  269.        dma->bufs[i].buf_count,
  270.        atomic_read(&dma->bufs[i]
  271.    .freelist.count),
  272.        dma->bufs[i].seg_count,
  273.        dma->bufs[i].seg_count
  274.        *(1 << dma->bufs[i].page_order),
  275.        (dma->bufs[i].seg_count
  276. * (1 << dma->bufs[i].page_order))
  277.        * PAGE_SIZE / 1024);
  278. }
  279. DRM_PROC_PRINT("n");
  280. for (i = 0; i < dma->buf_count; i++) {
  281. if (i && !(i%32)) DRM_PROC_PRINT("n");
  282. DRM_PROC_PRINT(" %d", dma->buflist[i]->list);
  283. }
  284. DRM_PROC_PRINT("n");
  285. if (len > request + offset) return request;
  286. *eof = 1;
  287. return len - offset;
  288. }
  289. static int DRM(bufs_info)(char *buf, char **start, off_t offset, int request,
  290.   int *eof, void *data)
  291. {
  292. drm_device_t *dev = (drm_device_t *)data;
  293. int      ret;
  294. down(&dev->struct_sem);
  295. ret = DRM(_bufs_info)(buf, start, offset, request, eof, data);
  296. up(&dev->struct_sem);
  297. return ret;
  298. }
  299. static int DRM(_clients_info)(char *buf, char **start, off_t offset,
  300.       int request, int *eof, void *data)
  301. {
  302. drm_device_t *dev = (drm_device_t *)data;
  303. int          len  = 0;
  304. drm_file_t   *priv;
  305. if (offset > DRM_PROC_LIMIT) {
  306. *eof = 1;
  307. return 0;
  308. }
  309. *start = &buf[offset];
  310. *eof   = 0;
  311. DRM_PROC_PRINT("a dev pid    uid magic   ioctlsnn");
  312. for (priv = dev->file_first; priv; priv = priv->next) {
  313. DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lun",
  314.        priv->authenticated ? 'y' : 'n',
  315.        priv->minor,
  316.        priv->pid,
  317.        priv->uid,
  318.        priv->magic,
  319.        priv->ioctl_count);
  320. }
  321. if (len > request + offset) return request;
  322. *eof = 1;
  323. return len - offset;
  324. }
  325. static int DRM(clients_info)(char *buf, char **start, off_t offset,
  326.      int request, int *eof, void *data)
  327. {
  328. drm_device_t *dev = (drm_device_t *)data;
  329. int      ret;
  330. down(&dev->struct_sem);
  331. ret = DRM(_clients_info)(buf, start, offset, request, eof, data);
  332. up(&dev->struct_sem);
  333. return ret;
  334. }
  335. #if DRM_DEBUG_CODE
  336. #define DRM_VMA_VERBOSE 0
  337. static int DRM(_vma_info)(char *buf, char **start, off_t offset, int request,
  338.   int *eof, void *data)
  339. {
  340. drm_device_t       *dev = (drm_device_t *)data;
  341. int                   len  = 0;
  342. drm_vma_entry_t       *pt;
  343. struct vm_area_struct *vma;
  344. #if DRM_VMA_VERBOSE
  345. unsigned long       i;
  346. unsigned long       address;
  347. pgd_t       *pgd;
  348. pmd_t       *pmd;
  349. pte_t       *pte;
  350. #endif
  351. #if defined(__i386__)
  352. unsigned int       pgprot;
  353. #endif
  354. if (offset > DRM_PROC_LIMIT) {
  355. *eof = 1;
  356. return 0;
  357. }
  358. *start = &buf[offset];
  359. *eof   = 0;
  360. DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lxn",
  361.        atomic_read(&dev->vma_count),
  362.        high_memory, virt_to_phys(high_memory));
  363. for (pt = dev->vmalist; pt; pt = pt->next) {
  364. if (!(vma = pt->vma)) continue;
  365. DRM_PROC_PRINT("n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx",
  366.        pt->pid,
  367.        vma->vm_start,
  368.        vma->vm_end,
  369.        vma->vm_flags & VM_READ    ? 'r' : '-',
  370.        vma->vm_flags & VM_WRITE    ? 'w' : '-',
  371.        vma->vm_flags & VM_EXEC    ? 'x' : '-',
  372.        vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
  373.        vma->vm_flags & VM_LOCKED   ? 'l' : '-',
  374.        vma->vm_flags & VM_IO    ? 'i' : '-',
  375.        VM_OFFSET(vma));
  376. #if defined(__i386__)
  377. pgprot = pgprot_val(vma->vm_page_prot);
  378. DRM_PROC_PRINT(" %c%c%c%c%c%c%c%c%c",
  379.        pgprot & _PAGE_PRESENT  ? 'p' : '-',
  380.        pgprot & _PAGE_RW       ? 'w' : 'r',
  381.        pgprot & _PAGE_USER     ? 'u' : 's',
  382.        pgprot & _PAGE_PWT      ? 't' : 'b',
  383.        pgprot & _PAGE_PCD      ? 'u' : 'c',
  384.        pgprot & _PAGE_ACCESSED ? 'a' : '-',
  385.        pgprot & _PAGE_DIRTY    ? 'd' : '-',
  386.        pgprot & _PAGE_PSE      ? 'm' : 'k',
  387.        pgprot & _PAGE_GLOBAL   ? 'g' : 'l' );
  388. #endif
  389. DRM_PROC_PRINT("n");
  390. #if 0
  391. for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
  392. pgd = pgd_offset(vma->vm_mm, i);
  393. pmd = pmd_offset(pgd, i);
  394. pte = pte_offset(pmd, i);
  395. if (pte_present(*pte)) {
  396. address = __pa(pte_page(*pte))
  397. + (i & (PAGE_SIZE-1));
  398. DRM_PROC_PRINT("      0x%08lx -> 0x%08lx"
  399.        " %c%c%c%c%cn",
  400.        i,
  401.        address,
  402.        pte_read(*pte)  ? 'r' : '-',
  403.        pte_write(*pte) ? 'w' : '-',
  404.        pte_exec(*pte)  ? 'x' : '-',
  405.        pte_dirty(*pte) ? 'd' : '-',
  406.        pte_young(*pte) ? 'a' : '-' );
  407. } else {
  408. DRM_PROC_PRINT("      0x%08lxn", i);
  409. }
  410. }
  411. #endif
  412. }
  413. if (len > request + offset) return request;
  414. *eof = 1;
  415. return len - offset;
  416. }
  417. static int DRM(vma_info)(char *buf, char **start, off_t offset, int request,
  418.  int *eof, void *data)
  419. {
  420. drm_device_t *dev = (drm_device_t *)data;
  421. int      ret;
  422. down(&dev->struct_sem);
  423. ret = DRM(_vma_info)(buf, start, offset, request, eof, data);
  424. up(&dev->struct_sem);
  425. return ret;
  426. }
  427. #endif
  428. #if __HAVE_DMA_HISTOGRAM
  429. static int DRM(_histo_info)(char *buf, char **start, off_t offset, int request,
  430.     int *eof, void *data)
  431. {
  432. drm_device_t  *dev = (drm_device_t *)data;
  433. int              len  = 0;
  434. drm_device_dma_t *dma = dev->dma;
  435. int  i;
  436. unsigned long  slot_value = DRM_DMA_HISTOGRAM_INITIAL;
  437. unsigned long  prev_value = 0;
  438. drm_buf_t  *buffer;
  439. if (offset > DRM_PROC_LIMIT) {
  440. *eof = 1;
  441. return 0;
  442. }
  443. *start = &buf[offset];
  444. *eof   = 0;
  445. DRM_PROC_PRINT("general statistics:n");
  446. DRM_PROC_PRINT("total  %10un", atomic_read(&dev->histo.total));
  447. DRM_PROC_PRINT("open  %10un",
  448.        atomic_read(&dev->counts[_DRM_STAT_OPENS]));
  449. DRM_PROC_PRINT("close  %10un",
  450.        atomic_read(&dev->counts[_DRM_STAT_CLOSES]));
  451. DRM_PROC_PRINT("ioctl  %10un",
  452.        atomic_read(&dev->counts[_DRM_STAT_IOCTLS]));
  453. DRM_PROC_PRINT("nlock statistics:n");
  454. DRM_PROC_PRINT("locks  %10un",
  455.        atomic_read(&dev->counts[_DRM_STAT_LOCKS]));
  456. DRM_PROC_PRINT("unlocks  %10un",
  457.        atomic_read(&dev->counts[_DRM_STAT_UNLOCKS]));
  458. if (dma) {
  459. #if 0
  460. DRM_PROC_PRINT("ndma statistics:n");
  461. DRM_PROC_PRINT("prio  %10un",
  462.        atomic_read(&dma->total_prio));
  463. DRM_PROC_PRINT("bytes  %10un",
  464.        atomic_read(&dma->total_bytes));
  465. DRM_PROC_PRINT("dmas  %10un",
  466.        atomic_read(&dma->total_dmas));
  467. DRM_PROC_PRINT("missed:n");
  468. DRM_PROC_PRINT("  dma  %10un",
  469.        atomic_read(&dma->total_missed_dma));
  470. DRM_PROC_PRINT("  lock  %10un",
  471.        atomic_read(&dma->total_missed_lock));
  472. DRM_PROC_PRINT("  free  %10un",
  473.        atomic_read(&dma->total_missed_free));
  474. DRM_PROC_PRINT("  sched  %10un",
  475.        atomic_read(&dma->total_missed_sched));
  476. DRM_PROC_PRINT("tried  %10un",
  477.        atomic_read(&dma->total_tried));
  478. DRM_PROC_PRINT("hit  %10un",
  479.        atomic_read(&dma->total_hit));
  480. DRM_PROC_PRINT("lost  %10un",
  481.        atomic_read(&dma->total_lost));
  482. #endif
  483. buffer = dma->next_buffer;
  484. if (buffer) {
  485. DRM_PROC_PRINT("next_buffer %7dn", buffer->idx);
  486. } else {
  487. DRM_PROC_PRINT("next_buffer    nonen");
  488. }
  489. buffer = dma->this_buffer;
  490. if (buffer) {
  491. DRM_PROC_PRINT("this_buffer %7dn", buffer->idx);
  492. } else {
  493. DRM_PROC_PRINT("this_buffer    nonen");
  494. }
  495. }
  496. DRM_PROC_PRINT("nvalues:n");
  497. if (dev->lock.hw_lock) {
  498. DRM_PROC_PRINT("lock        0x%08xn",
  499.        dev->lock.hw_lock->lock);
  500. } else {
  501. DRM_PROC_PRINT("lock      nonen");
  502. }
  503. DRM_PROC_PRINT("context_flag   0x%08lxn", dev->context_flag);
  504. DRM_PROC_PRINT("interrupt_flag 0x%08lxn", dev->interrupt_flag);
  505. DRM_PROC_PRINT("dma_flag       0x%08lxn", dev->dma_flag);
  506. DRM_PROC_PRINT("queue_count    %10dn",  dev->queue_count);
  507. DRM_PROC_PRINT("last_context   %10dn",  dev->last_context);
  508. DRM_PROC_PRINT("last_switch    %10lun", dev->last_switch);
  509. DRM_PROC_PRINT("last_checked   %10dn",  dev->last_checked);
  510. DRM_PROC_PRINT("n        q2d   d2c      c2f"
  511.        " q2c    q2f       dma  sch"
  512.        " ctx   lacq      lhldnn");
  513. for (i = 0; i < DRM_DMA_HISTOGRAM_SLOTS; i++) {
  514. DRM_PROC_PRINT("%s %10lu %10u %10u %10u %10u %10u"
  515.        " %10u %10u %10u %10u %10un",
  516.        i == DRM_DMA_HISTOGRAM_SLOTS - 1 ? ">=" : "< ",
  517.        i == DRM_DMA_HISTOGRAM_SLOTS - 1
  518.        ? prev_value : slot_value ,
  519.        atomic_read(&dev->histo
  520.    .queued_to_dispatched[i]),
  521.        atomic_read(&dev->histo
  522.    .dispatched_to_completed[i]),
  523.        atomic_read(&dev->histo
  524.    .completed_to_freed[i]),
  525.        atomic_read(&dev->histo
  526.    .queued_to_completed[i]),
  527.        atomic_read(&dev->histo
  528.    .queued_to_freed[i]),
  529.        atomic_read(&dev->histo.dma[i]),
  530.        atomic_read(&dev->histo.schedule[i]),
  531.        atomic_read(&dev->histo.ctx[i]),
  532.        atomic_read(&dev->histo.lacq[i]),
  533.        atomic_read(&dev->histo.lhld[i]));
  534. prev_value = slot_value;
  535. slot_value = DRM_DMA_HISTOGRAM_NEXT(slot_value);
  536. }
  537. if (len > request + offset) return request;
  538. *eof = 1;
  539. return len - offset;
  540. }
  541. static int DRM(histo_info)(char *buf, char **start, off_t offset, int request,
  542.    int *eof, void *data)
  543. {
  544. drm_device_t *dev = (drm_device_t *)data;
  545. int      ret;
  546. down(&dev->struct_sem);
  547. ret = DRM(_histo_info)(buf, start, offset, request, eof, data);
  548. up(&dev->struct_sem);
  549. return ret;
  550. }
  551. #endif