i915_gem_debugfs.c 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /*
  2. * Copyright © 2008 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  21. * IN THE SOFTWARE.
  22. *
  23. * Authors:
  24. * Eric Anholt <eric@anholt.net>
  25. * Keith Packard <keithp@keithp.com>
  26. *
  27. */
  28. #include <linux/seq_file.h>
  29. #include "drmP.h"
  30. #include "drm.h"
  31. #include "i915_drm.h"
  32. #include "i915_drv.h"
  33. #define DRM_I915_RING_DEBUG 1
  34. #if defined(CONFIG_DEBUG_FS)
  35. #define ACTIVE_LIST 1
  36. #define FLUSHING_LIST 2
  37. #define INACTIVE_LIST 3
  38. static int i915_gem_object_list_info(struct seq_file *m, void *data)
  39. {
  40. struct drm_info_node *node = (struct drm_info_node *) m->private;
  41. uintptr_t list = (uintptr_t) node->info_ent->data;
  42. struct list_head *head;
  43. struct drm_device *dev = node->minor->dev;
  44. drm_i915_private_t *dev_priv = dev->dev_private;
  45. struct drm_i915_gem_object *obj_priv;
  46. switch (list) {
  47. case ACTIVE_LIST:
  48. seq_printf(m, "Active:\n");
  49. head = &dev_priv->mm.active_list;
  50. break;
  51. case INACTIVE_LIST:
  52. seq_printf(m, "Inctive:\n");
  53. head = &dev_priv->mm.inactive_list;
  54. break;
  55. case FLUSHING_LIST:
  56. seq_printf(m, "Flushing:\n");
  57. head = &dev_priv->mm.flushing_list;
  58. break;
  59. default:
  60. DRM_INFO("Ooops, unexpected list\n");
  61. return 0;
  62. }
  63. list_for_each_entry(obj_priv, head, list)
  64. {
  65. struct drm_gem_object *obj = obj_priv->obj;
  66. if (obj->name) {
  67. seq_printf(m, " %p(%d): %08x %08x %d\n",
  68. obj, obj->name,
  69. obj->read_domains, obj->write_domain,
  70. obj_priv->last_rendering_seqno);
  71. } else {
  72. seq_printf(m, " %p: %08x %08x %d\n",
  73. obj,
  74. obj->read_domains, obj->write_domain,
  75. obj_priv->last_rendering_seqno);
  76. }
  77. }
  78. return 0;
  79. }
  80. static int i915_gem_request_info(struct seq_file *m, void *data)
  81. {
  82. struct drm_info_node *node = (struct drm_info_node *) m->private;
  83. struct drm_device *dev = node->minor->dev;
  84. drm_i915_private_t *dev_priv = dev->dev_private;
  85. struct drm_i915_gem_request *gem_request;
  86. seq_printf(m, "Request:\n");
  87. list_for_each_entry(gem_request, &dev_priv->mm.request_list, list) {
  88. seq_printf(m, " %d @ %d\n",
  89. gem_request->seqno,
  90. (int) (jiffies - gem_request->emitted_jiffies));
  91. }
  92. return 0;
  93. }
  94. static int i915_gem_seqno_info(struct seq_file *m, void *data)
  95. {
  96. struct drm_info_node *node = (struct drm_info_node *) m->private;
  97. struct drm_device *dev = node->minor->dev;
  98. drm_i915_private_t *dev_priv = dev->dev_private;
  99. if (dev_priv->hw_status_page != NULL) {
  100. seq_printf(m, "Current sequence: %d\n",
  101. i915_get_gem_seqno(dev));
  102. } else {
  103. seq_printf(m, "Current sequence: hws uninitialized\n");
  104. }
  105. seq_printf(m, "Waiter sequence: %d\n",
  106. dev_priv->mm.waiting_gem_seqno);
  107. seq_printf(m, "IRQ sequence: %d\n", dev_priv->mm.irq_gem_seqno);
  108. return 0;
  109. }
  110. static int i915_interrupt_info(struct seq_file *m, void *data)
  111. {
  112. struct drm_info_node *node = (struct drm_info_node *) m->private;
  113. struct drm_device *dev = node->minor->dev;
  114. drm_i915_private_t *dev_priv = dev->dev_private;
  115. seq_printf(m, "Interrupt enable: %08x\n",
  116. I915_READ(IER));
  117. seq_printf(m, "Interrupt identity: %08x\n",
  118. I915_READ(IIR));
  119. seq_printf(m, "Interrupt mask: %08x\n",
  120. I915_READ(IMR));
  121. seq_printf(m, "Pipe A stat: %08x\n",
  122. I915_READ(PIPEASTAT));
  123. seq_printf(m, "Pipe B stat: %08x\n",
  124. I915_READ(PIPEBSTAT));
  125. seq_printf(m, "Interrupts received: %d\n",
  126. atomic_read(&dev_priv->irq_received));
  127. if (dev_priv->hw_status_page != NULL) {
  128. seq_printf(m, "Current sequence: %d\n",
  129. i915_get_gem_seqno(dev));
  130. } else {
  131. seq_printf(m, "Current sequence: hws uninitialized\n");
  132. }
  133. seq_printf(m, "Waiter sequence: %d\n",
  134. dev_priv->mm.waiting_gem_seqno);
  135. seq_printf(m, "IRQ sequence: %d\n",
  136. dev_priv->mm.irq_gem_seqno);
  137. return 0;
  138. }
  139. static int i915_hws_info(struct seq_file *m, void *data)
  140. {
  141. struct drm_info_node *node = (struct drm_info_node *) m->private;
  142. struct drm_device *dev = node->minor->dev;
  143. drm_i915_private_t *dev_priv = dev->dev_private;
  144. int i;
  145. volatile u32 *hws;
  146. hws = (volatile u32 *)dev_priv->hw_status_page;
  147. if (hws == NULL)
  148. return 0;
  149. for (i = 0; i < 4096 / sizeof(u32) / 4; i += 4) {
  150. seq_printf(m, "0x%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n",
  151. i * 4,
  152. hws[i], hws[i + 1], hws[i + 2], hws[i + 3]);
  153. }
  154. return 0;
  155. }
  156. static struct drm_info_list i915_gem_debugfs_list[] = {
  157. {"i915_gem_active", i915_gem_object_list_info, 0, (void *) ACTIVE_LIST},
  158. {"i915_gem_flushing", i915_gem_object_list_info, 0, (void *) FLUSHING_LIST},
  159. {"i915_gem_inactive", i915_gem_object_list_info, 0, (void *) INACTIVE_LIST},
  160. {"i915_gem_request", i915_gem_request_info, 0},
  161. {"i915_gem_seqno", i915_gem_seqno_info, 0},
  162. {"i915_gem_interrupt", i915_interrupt_info, 0},
  163. {"i915_gem_hws", i915_hws_info, 0},
  164. };
  165. #define I915_GEM_DEBUGFS_ENTRIES ARRAY_SIZE(i915_gem_debugfs_list)
  166. int i915_gem_debugfs_init(struct drm_minor *minor)
  167. {
  168. return drm_debugfs_create_files(i915_gem_debugfs_list,
  169. I915_GEM_DEBUGFS_ENTRIES,
  170. minor->debugfs_root, minor);
  171. }
  172. void i915_gem_debugfs_cleanup(struct drm_minor *minor)
  173. {
  174. drm_debugfs_remove_files(i915_gem_debugfs_list,
  175. I915_GEM_DEBUGFS_ENTRIES, minor);
  176. }
  177. #endif /* CONFIG_DEBUG_FS */