msm_debugfs.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Copyright (C) 2013-2016 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifdef CONFIG_DEBUG_FS
  18. #include "msm_drv.h"
  19. #include "msm_gpu.h"
  20. #include "msm_debugfs.h"
  21. static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)
  22. {
  23. struct msm_drm_private *priv = dev->dev_private;
  24. struct msm_gpu *gpu = priv->gpu;
  25. if (gpu) {
  26. seq_printf(m, "%s Status:\n", gpu->name);
  27. gpu->funcs->show(gpu, m);
  28. }
  29. return 0;
  30. }
  31. static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
  32. {
  33. struct msm_drm_private *priv = dev->dev_private;
  34. struct msm_gpu *gpu = priv->gpu;
  35. if (gpu) {
  36. seq_printf(m, "Active Objects (%s):\n", gpu->name);
  37. msm_gem_describe_objects(&gpu->active_list, m);
  38. }
  39. seq_printf(m, "Inactive Objects:\n");
  40. msm_gem_describe_objects(&priv->inactive_list, m);
  41. return 0;
  42. }
  43. static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
  44. {
  45. return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
  46. }
  47. static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
  48. {
  49. struct msm_drm_private *priv = dev->dev_private;
  50. struct drm_framebuffer *fb, *fbdev_fb = NULL;
  51. if (priv->fbdev) {
  52. seq_printf(m, "fbcon ");
  53. fbdev_fb = priv->fbdev->fb;
  54. msm_framebuffer_describe(fbdev_fb, m);
  55. }
  56. mutex_lock(&dev->mode_config.fb_lock);
  57. list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
  58. if (fb == fbdev_fb)
  59. continue;
  60. seq_printf(m, "user ");
  61. msm_framebuffer_describe(fb, m);
  62. }
  63. mutex_unlock(&dev->mode_config.fb_lock);
  64. return 0;
  65. }
  66. static int show_locked(struct seq_file *m, void *arg)
  67. {
  68. struct drm_info_node *node = (struct drm_info_node *) m->private;
  69. struct drm_device *dev = node->minor->dev;
  70. int (*show)(struct drm_device *dev, struct seq_file *m) =
  71. node->info_ent->data;
  72. int ret;
  73. ret = mutex_lock_interruptible(&dev->struct_mutex);
  74. if (ret)
  75. return ret;
  76. ret = show(dev, m);
  77. mutex_unlock(&dev->struct_mutex);
  78. return ret;
  79. }
  80. static struct drm_info_list msm_debugfs_list[] = {
  81. {"gpu", show_locked, 0, msm_gpu_show},
  82. {"gem", show_locked, 0, msm_gem_show},
  83. { "mm", show_locked, 0, msm_mm_show },
  84. { "fb", show_locked, 0, msm_fb_show },
  85. };
  86. static int late_init_minor(struct drm_minor *minor)
  87. {
  88. int ret;
  89. if (!minor)
  90. return 0;
  91. ret = msm_rd_debugfs_init(minor);
  92. if (ret) {
  93. dev_err(minor->dev->dev, "could not install rd debugfs\n");
  94. return ret;
  95. }
  96. ret = msm_perf_debugfs_init(minor);
  97. if (ret) {
  98. dev_err(minor->dev->dev, "could not install perf debugfs\n");
  99. return ret;
  100. }
  101. return 0;
  102. }
  103. int msm_debugfs_late_init(struct drm_device *dev)
  104. {
  105. int ret;
  106. ret = late_init_minor(dev->primary);
  107. if (ret)
  108. return ret;
  109. ret = late_init_minor(dev->render);
  110. if (ret)
  111. return ret;
  112. ret = late_init_minor(dev->control);
  113. return ret;
  114. }
  115. int msm_debugfs_init(struct drm_minor *minor)
  116. {
  117. struct drm_device *dev = minor->dev;
  118. int ret;
  119. ret = drm_debugfs_create_files(msm_debugfs_list,
  120. ARRAY_SIZE(msm_debugfs_list),
  121. minor->debugfs_root, minor);
  122. if (ret) {
  123. dev_err(dev->dev, "could not install msm_debugfs_list\n");
  124. return ret;
  125. }
  126. return 0;
  127. }
  128. void msm_debugfs_cleanup(struct drm_minor *minor)
  129. {
  130. drm_debugfs_remove_files(msm_debugfs_list,
  131. ARRAY_SIZE(msm_debugfs_list), minor);
  132. if (!minor->dev->dev_private)
  133. return;
  134. msm_rd_debugfs_cleanup(minor);
  135. msm_perf_debugfs_cleanup(minor);
  136. }
  137. #endif