msm_debugfs.c 4.1 KB

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