msm_debugfs.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)
  21. {
  22. struct msm_drm_private *priv = dev->dev_private;
  23. struct msm_gpu *gpu = priv->gpu;
  24. if (gpu) {
  25. seq_printf(m, "%s Status:\n", gpu->name);
  26. gpu->funcs->show(gpu, m);
  27. }
  28. return 0;
  29. }
  30. static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
  31. {
  32. struct msm_drm_private *priv = dev->dev_private;
  33. struct msm_gpu *gpu = priv->gpu;
  34. if (gpu) {
  35. seq_printf(m, "Active Objects (%s):\n", gpu->name);
  36. msm_gem_describe_objects(&gpu->active_list, m);
  37. }
  38. seq_printf(m, "Inactive Objects:\n");
  39. msm_gem_describe_objects(&priv->inactive_list, m);
  40. return 0;
  41. }
  42. static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
  43. {
  44. return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
  45. }
  46. static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
  47. {
  48. struct msm_drm_private *priv = dev->dev_private;
  49. struct drm_framebuffer *fb, *fbdev_fb = NULL;
  50. if (priv->fbdev) {
  51. seq_printf(m, "fbcon ");
  52. fbdev_fb = priv->fbdev->fb;
  53. msm_framebuffer_describe(fbdev_fb, m);
  54. }
  55. mutex_lock(&dev->mode_config.fb_lock);
  56. list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
  57. if (fb == fbdev_fb)
  58. continue;
  59. seq_printf(m, "user ");
  60. msm_framebuffer_describe(fb, m);
  61. }
  62. mutex_unlock(&dev->mode_config.fb_lock);
  63. return 0;
  64. }
  65. static int show_locked(struct seq_file *m, void *arg)
  66. {
  67. struct drm_info_node *node = (struct drm_info_node *) m->private;
  68. struct drm_device *dev = node->minor->dev;
  69. int (*show)(struct drm_device *dev, struct seq_file *m) =
  70. node->info_ent->data;
  71. int ret;
  72. ret = mutex_lock_interruptible(&dev->struct_mutex);
  73. if (ret)
  74. return ret;
  75. ret = show(dev, m);
  76. mutex_unlock(&dev->struct_mutex);
  77. return ret;
  78. }
  79. static struct drm_info_list msm_debugfs_list[] = {
  80. {"gpu", show_locked, 0, msm_gpu_show},
  81. {"gem", show_locked, 0, msm_gem_show},
  82. { "mm", show_locked, 0, msm_mm_show },
  83. { "fb", show_locked, 0, msm_fb_show },
  84. };
  85. static int late_init_minor(struct drm_minor *minor)
  86. {
  87. int ret;
  88. if (!minor)
  89. return 0;
  90. ret = msm_rd_debugfs_init(minor);
  91. if (ret) {
  92. dev_err(minor->dev->dev, "could not install rd debugfs\n");
  93. return ret;
  94. }
  95. ret = msm_perf_debugfs_init(minor);
  96. if (ret) {
  97. dev_err(minor->dev->dev, "could not install perf debugfs\n");
  98. return ret;
  99. }
  100. return 0;
  101. }
  102. int msm_debugfs_late_init(struct drm_device *dev)
  103. {
  104. int ret;
  105. ret = late_init_minor(dev->primary);
  106. if (ret)
  107. return ret;
  108. ret = late_init_minor(dev->render);
  109. if (ret)
  110. return ret;
  111. ret = late_init_minor(dev->control);
  112. return ret;
  113. }
  114. int msm_debugfs_init(struct drm_minor *minor)
  115. {
  116. struct drm_device *dev = minor->dev;
  117. int ret;
  118. ret = drm_debugfs_create_files(msm_debugfs_list,
  119. ARRAY_SIZE(msm_debugfs_list),
  120. minor->debugfs_root, minor);
  121. if (ret) {
  122. dev_err(dev->dev, "could not install msm_debugfs_list\n");
  123. return ret;
  124. }
  125. return 0;
  126. }
  127. void msm_debugfs_cleanup(struct drm_minor *minor)
  128. {
  129. drm_debugfs_remove_files(msm_debugfs_list,
  130. ARRAY_SIZE(msm_debugfs_list), minor);
  131. if (!minor->dev->dev_private)
  132. return;
  133. msm_rd_debugfs_cleanup(minor);
  134. msm_perf_debugfs_cleanup(minor);
  135. }
  136. #endif