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. #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. struct drm_printer p = drm_seq_file_printer(m);
  47. drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
  48. return 0;
  49. }
  50. static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
  51. {
  52. struct msm_drm_private *priv = dev->dev_private;
  53. struct drm_framebuffer *fb, *fbdev_fb = NULL;
  54. if (priv->fbdev) {
  55. seq_printf(m, "fbcon ");
  56. fbdev_fb = priv->fbdev->fb;
  57. msm_framebuffer_describe(fbdev_fb, m);
  58. }
  59. mutex_lock(&dev->mode_config.fb_lock);
  60. list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
  61. if (fb == fbdev_fb)
  62. continue;
  63. seq_printf(m, "user ");
  64. msm_framebuffer_describe(fb, m);
  65. }
  66. mutex_unlock(&dev->mode_config.fb_lock);
  67. return 0;
  68. }
  69. static int show_locked(struct seq_file *m, void *arg)
  70. {
  71. struct drm_info_node *node = (struct drm_info_node *) m->private;
  72. struct drm_device *dev = node->minor->dev;
  73. int (*show)(struct drm_device *dev, struct seq_file *m) =
  74. node->info_ent->data;
  75. int ret;
  76. ret = mutex_lock_interruptible(&dev->struct_mutex);
  77. if (ret)
  78. return ret;
  79. ret = show(dev, m);
  80. mutex_unlock(&dev->struct_mutex);
  81. return ret;
  82. }
  83. static struct drm_info_list msm_debugfs_list[] = {
  84. {"gpu", show_locked, 0, msm_gpu_show},
  85. {"gem", show_locked, 0, msm_gem_show},
  86. { "mm", show_locked, 0, msm_mm_show },
  87. { "fb", show_locked, 0, msm_fb_show },
  88. };
  89. static int late_init_minor(struct drm_minor *minor)
  90. {
  91. int ret;
  92. if (!minor)
  93. return 0;
  94. ret = msm_rd_debugfs_init(minor);
  95. if (ret) {
  96. dev_err(minor->dev->dev, "could not install rd debugfs\n");
  97. return ret;
  98. }
  99. ret = msm_perf_debugfs_init(minor);
  100. if (ret) {
  101. dev_err(minor->dev->dev, "could not install perf debugfs\n");
  102. return ret;
  103. }
  104. return 0;
  105. }
  106. int msm_debugfs_late_init(struct drm_device *dev)
  107. {
  108. int ret;
  109. ret = late_init_minor(dev->primary);
  110. if (ret)
  111. return ret;
  112. ret = late_init_minor(dev->render);
  113. if (ret)
  114. return ret;
  115. ret = late_init_minor(dev->control);
  116. return ret;
  117. }
  118. int msm_debugfs_init(struct drm_minor *minor)
  119. {
  120. struct drm_device *dev = minor->dev;
  121. struct msm_drm_private *priv = dev->dev_private;
  122. int ret;
  123. ret = drm_debugfs_create_files(msm_debugfs_list,
  124. ARRAY_SIZE(msm_debugfs_list),
  125. minor->debugfs_root, minor);
  126. if (ret) {
  127. dev_err(dev->dev, "could not install msm_debugfs_list\n");
  128. return ret;
  129. }
  130. if (priv->kms->funcs->debugfs_init)
  131. ret = priv->kms->funcs->debugfs_init(priv->kms, minor);
  132. return ret;
  133. }
  134. #endif