drm_debugfs.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Internal Header for the Direct Rendering Manager
  3. *
  4. * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
  5. * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
  6. * Copyright (c) 2009-2010, Code Aurora Forum.
  7. * All rights reserved.
  8. *
  9. * Author: Rickard E. (Rik) Faith <faith@valinux.com>
  10. * Author: Gareth Hughes <gareth@valinux.com>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice (including the next
  20. * paragraph) shall be included in all copies or substantial portions of the
  21. * Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  26. * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  27. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  28. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  29. * OTHER DEALINGS IN THE SOFTWARE.
  30. */
  31. #ifndef _DRM_DEBUGFS_H_
  32. #define _DRM_DEBUGFS_H_
  33. #include <linux/types.h>
  34. #include <linux/seq_file.h>
  35. #include <drm/drm_gpuvm.h>
  36. /**
  37. * DRM_DEBUGFS_GPUVA_INFO - &drm_info_list entry to dump a GPU VA space
  38. * @show: the &drm_info_list's show callback
  39. * @data: driver private data
  40. *
  41. * Drivers should use this macro to define a &drm_info_list entry to provide a
  42. * debugfs file for dumping the GPU VA space regions and mappings.
  43. *
  44. * For each DRM GPU VA space drivers should call drm_debugfs_gpuva_info() from
  45. * their @show callback.
  46. */
  47. #define DRM_DEBUGFS_GPUVA_INFO(show, data) {"gpuvas", show, DRIVER_GEM_GPUVA, data}
  48. /**
  49. * struct drm_info_list - debugfs info list entry
  50. *
  51. * This structure represents a debugfs file to be created by the drm
  52. * core.
  53. */
  54. struct drm_info_list {
  55. /** @name: file name */
  56. const char *name;
  57. /**
  58. * @show:
  59. *
  60. * Show callback. &seq_file->private will be set to the &struct
  61. * drm_info_node corresponding to the instance of this info on a given
  62. * &struct drm_minor.
  63. */
  64. int (*show)(struct seq_file*, void*);
  65. /** @driver_features: Required driver features for this entry */
  66. u32 driver_features;
  67. /** @data: Driver-private data, should not be device-specific. */
  68. void *data;
  69. };
  70. /**
  71. * struct drm_info_node - Per-minor debugfs node structure
  72. *
  73. * This structure represents a debugfs file, as an instantiation of a &struct
  74. * drm_info_list on a &struct drm_minor.
  75. *
  76. * FIXME:
  77. *
  78. * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
  79. * both the render and the primary nodes, but that's how this has organically
  80. * grown. It should probably be fixed, with a compatibility link, if needed.
  81. */
  82. struct drm_info_node {
  83. /** @minor: &struct drm_minor for this node. */
  84. struct drm_minor *minor;
  85. /** @info_ent: template for this node. */
  86. const struct drm_info_list *info_ent;
  87. /* private: */
  88. struct list_head list;
  89. struct dentry *dent;
  90. };
  91. /**
  92. * struct drm_debugfs_info - debugfs info list entry
  93. *
  94. * This structure represents a debugfs file to be created by the drm
  95. * core.
  96. */
  97. struct drm_debugfs_info {
  98. /** @name: File name */
  99. const char *name;
  100. /**
  101. * @show:
  102. *
  103. * Show callback. &seq_file->private will be set to the &struct
  104. * drm_debugfs_entry corresponding to the instance of this info
  105. * on a given &struct drm_device.
  106. */
  107. int (*show)(struct seq_file*, void*);
  108. /** @driver_features: Required driver features for this entry. */
  109. u32 driver_features;
  110. /** @data: Driver-private data, should not be device-specific. */
  111. void *data;
  112. };
  113. /**
  114. * struct drm_debugfs_entry - Per-device debugfs node structure
  115. *
  116. * This structure represents a debugfs file, as an instantiation of a &struct
  117. * drm_debugfs_info on a &struct drm_device.
  118. */
  119. struct drm_debugfs_entry {
  120. /** @dev: &struct drm_device for this node. */
  121. struct drm_device *dev;
  122. /** @file: Template for this node. */
  123. struct drm_debugfs_info file;
  124. /** @list: Linked list of all device nodes. */
  125. struct list_head list;
  126. };
  127. #if defined(CONFIG_DEBUG_FS)
  128. void drm_debugfs_create_files(const struct drm_info_list *files,
  129. int count, struct dentry *root,
  130. struct drm_minor *minor);
  131. int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
  132. struct dentry *root, struct drm_minor *minor);
  133. void drm_debugfs_add_file(struct drm_device *dev, const char *name,
  134. int (*show)(struct seq_file*, void*), void *data);
  135. void drm_debugfs_add_files(struct drm_device *dev,
  136. const struct drm_debugfs_info *files, int count);
  137. int drm_debugfs_gpuva_info(struct seq_file *m,
  138. struct drm_gpuvm *gpuvm);
  139. void drm_debugfs_clients_add(struct drm_file *file);
  140. void drm_debugfs_clients_remove(struct drm_file *file);
  141. #else
  142. static inline void drm_debugfs_create_files(const struct drm_info_list *files,
  143. int count, struct dentry *root,
  144. struct drm_minor *minor)
  145. {}
  146. static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
  147. int count, struct dentry *root,
  148. struct drm_minor *minor)
  149. {
  150. return 0;
  151. }
  152. static inline void drm_debugfs_add_file(struct drm_device *dev, const char *name,
  153. int (*show)(struct seq_file*, void*),
  154. void *data)
  155. {}
  156. static inline void drm_debugfs_add_files(struct drm_device *dev,
  157. const struct drm_debugfs_info *files,
  158. int count)
  159. {}
  160. static inline int drm_debugfs_gpuva_info(struct seq_file *m,
  161. struct drm_gpuvm *gpuvm)
  162. {
  163. return 0;
  164. }
  165. static inline void drm_debugfs_clients_add(struct drm_file *file)
  166. {
  167. }
  168. static inline void drm_debugfs_clients_remove(struct drm_file *file)
  169. {
  170. }
  171. #endif
  172. #endif /* _DRM_DEBUGFS_H_ */