msm_debugfs.c 3.9 KB

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