xref: /linux/include/drm/drm_debugfs.h (revision 03c11eb3b16dc0058589751dfd91f254be2be613)
14834442dSDaniel Vetter /*
24834442dSDaniel Vetter  * Internal Header for the Direct Rendering Manager
34834442dSDaniel Vetter  *
44834442dSDaniel Vetter  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
54834442dSDaniel Vetter  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
64834442dSDaniel Vetter  * Copyright (c) 2009-2010, Code Aurora Forum.
74834442dSDaniel Vetter  * All rights reserved.
84834442dSDaniel Vetter  *
94834442dSDaniel Vetter  * Author: Rickard E. (Rik) Faith <faith@valinux.com>
104834442dSDaniel Vetter  * Author: Gareth Hughes <gareth@valinux.com>
114834442dSDaniel Vetter  *
124834442dSDaniel Vetter  * Permission is hereby granted, free of charge, to any person obtaining a
134834442dSDaniel Vetter  * copy of this software and associated documentation files (the "Software"),
144834442dSDaniel Vetter  * to deal in the Software without restriction, including without limitation
154834442dSDaniel Vetter  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
164834442dSDaniel Vetter  * and/or sell copies of the Software, and to permit persons to whom the
174834442dSDaniel Vetter  * Software is furnished to do so, subject to the following conditions:
184834442dSDaniel Vetter  *
194834442dSDaniel Vetter  * The above copyright notice and this permission notice (including the next
204834442dSDaniel Vetter  * paragraph) shall be included in all copies or substantial portions of the
214834442dSDaniel Vetter  * Software.
224834442dSDaniel Vetter  *
234834442dSDaniel Vetter  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
244834442dSDaniel Vetter  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
254834442dSDaniel Vetter  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
264834442dSDaniel Vetter  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
274834442dSDaniel Vetter  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
284834442dSDaniel Vetter  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
294834442dSDaniel Vetter  * OTHER DEALINGS IN THE SOFTWARE.
304834442dSDaniel Vetter  */
314834442dSDaniel Vetter 
324834442dSDaniel Vetter #ifndef _DRM_DEBUGFS_H_
334834442dSDaniel Vetter #define _DRM_DEBUGFS_H_
344834442dSDaniel Vetter 
35a7d469ccSSam Ravnborg #include <linux/types.h>
36a7d469ccSSam Ravnborg #include <linux/seq_file.h>
374f66feeaSDanilo Krummrich 
38*f72c2db4SDanilo Krummrich #include <drm/drm_gpuvm.h>
394f66feeaSDanilo Krummrich 
404f66feeaSDanilo Krummrich /**
414f66feeaSDanilo Krummrich  * DRM_DEBUGFS_GPUVA_INFO - &drm_info_list entry to dump a GPU VA space
424f66feeaSDanilo Krummrich  * @show: the &drm_info_list's show callback
434f66feeaSDanilo Krummrich  * @data: driver private data
444f66feeaSDanilo Krummrich  *
454f66feeaSDanilo Krummrich  * Drivers should use this macro to define a &drm_info_list entry to provide a
464f66feeaSDanilo Krummrich  * debugfs file for dumping the GPU VA space regions and mappings.
474f66feeaSDanilo Krummrich  *
484f66feeaSDanilo Krummrich  * For each DRM GPU VA space drivers should call drm_debugfs_gpuva_info() from
494f66feeaSDanilo Krummrich  * their @show callback.
504f66feeaSDanilo Krummrich  */
514f66feeaSDanilo Krummrich #define DRM_DEBUGFS_GPUVA_INFO(show, data) {"gpuvas", show, DRIVER_GEM_GPUVA, data}
524f66feeaSDanilo Krummrich 
534834442dSDaniel Vetter /**
540cad7f71SDaniel Vetter  * struct drm_info_list - debugfs info list entry
550cad7f71SDaniel Vetter  *
560cad7f71SDaniel Vetter  * This structure represents a debugfs file to be created by the drm
570cad7f71SDaniel Vetter  * core.
584834442dSDaniel Vetter  */
594834442dSDaniel Vetter struct drm_info_list {
600cad7f71SDaniel Vetter 	/** @name: file name */
610cad7f71SDaniel Vetter 	const char *name;
620cad7f71SDaniel Vetter 	/**
630cad7f71SDaniel Vetter 	 * @show:
640cad7f71SDaniel Vetter 	 *
650cad7f71SDaniel Vetter 	 * Show callback. &seq_file->private will be set to the &struct
660cad7f71SDaniel Vetter 	 * drm_info_node corresponding to the instance of this info on a given
670cad7f71SDaniel Vetter 	 * &struct drm_minor.
680cad7f71SDaniel Vetter 	 */
690cad7f71SDaniel Vetter 	int (*show)(struct seq_file*, void*);
700cad7f71SDaniel Vetter 	/** @driver_features: Required driver features for this entry */
710cad7f71SDaniel Vetter 	u32 driver_features;
720cad7f71SDaniel Vetter 	/** @data: Driver-private data, should not be device-specific. */
734834442dSDaniel Vetter 	void *data;
744834442dSDaniel Vetter };
754834442dSDaniel Vetter 
764834442dSDaniel Vetter /**
770cad7f71SDaniel Vetter  * struct drm_info_node - Per-minor debugfs node structure
780cad7f71SDaniel Vetter  *
790cad7f71SDaniel Vetter  * This structure represents a debugfs file, as an instantiation of a &struct
800cad7f71SDaniel Vetter  * drm_info_list on a &struct drm_minor.
810cad7f71SDaniel Vetter  *
820cad7f71SDaniel Vetter  * FIXME:
830cad7f71SDaniel Vetter  *
840cad7f71SDaniel Vetter  * No it doesn't make a hole lot of sense that we duplicate debugfs entries for
850cad7f71SDaniel Vetter  * both the render and the primary nodes, but that's how this has organically
860cad7f71SDaniel Vetter  * grown. It should probably be fixed, with a compatibility link, if needed.
874834442dSDaniel Vetter  */
884834442dSDaniel Vetter struct drm_info_node {
890cad7f71SDaniel Vetter 	/** @minor: &struct drm_minor for this node. */
904834442dSDaniel Vetter 	struct drm_minor *minor;
910cad7f71SDaniel Vetter 	/** @info_ent: template for this node. */
924834442dSDaniel Vetter 	const struct drm_info_list *info_ent;
930cad7f71SDaniel Vetter 	/* private: */
940cad7f71SDaniel Vetter 	struct list_head list;
954834442dSDaniel Vetter 	struct dentry *dent;
964834442dSDaniel Vetter };
974834442dSDaniel Vetter 
981c9cacbeSMaíra Canal /**
991c9cacbeSMaíra Canal  * struct drm_debugfs_info - debugfs info list entry
1001c9cacbeSMaíra Canal  *
1011c9cacbeSMaíra Canal  * This structure represents a debugfs file to be created by the drm
1021c9cacbeSMaíra Canal  * core.
1031c9cacbeSMaíra Canal  */
1041c9cacbeSMaíra Canal struct drm_debugfs_info {
1055855366fSMaíra Canal 	/** @name: File name */
1061c9cacbeSMaíra Canal 	const char *name;
1075855366fSMaíra Canal 
1085855366fSMaíra Canal 	/**
1095855366fSMaíra Canal 	 * @show:
1105855366fSMaíra Canal 	 *
1115855366fSMaíra Canal 	 * Show callback. &seq_file->private will be set to the &struct
1125855366fSMaíra Canal 	 * drm_debugfs_entry corresponding to the instance of this info
1135855366fSMaíra Canal 	 * on a given &struct drm_device.
1145855366fSMaíra Canal 	 */
1151c9cacbeSMaíra Canal 	int (*show)(struct seq_file*, void*);
1165855366fSMaíra Canal 
1175855366fSMaíra Canal 	/** @driver_features: Required driver features for this entry. */
1181c9cacbeSMaíra Canal 	u32 driver_features;
1195855366fSMaíra Canal 
1205855366fSMaíra Canal 	/** @data: Driver-private data, should not be device-specific. */
1211c9cacbeSMaíra Canal 	void *data;
1221c9cacbeSMaíra Canal };
1231c9cacbeSMaíra Canal 
1241c9cacbeSMaíra Canal /**
1251c9cacbeSMaíra Canal  * struct drm_debugfs_entry - Per-device debugfs node structure
1261c9cacbeSMaíra Canal  *
1271c9cacbeSMaíra Canal  * This structure represents a debugfs file, as an instantiation of a &struct
1281c9cacbeSMaíra Canal  * drm_debugfs_info on a &struct drm_device.
1291c9cacbeSMaíra Canal  */
1301c9cacbeSMaíra Canal struct drm_debugfs_entry {
1315855366fSMaíra Canal 	/** @dev: &struct drm_device for this node. */
1321c9cacbeSMaíra Canal 	struct drm_device *dev;
1335855366fSMaíra Canal 
1345855366fSMaíra Canal 	/** @file: Template for this node. */
1351c9cacbeSMaíra Canal 	struct drm_debugfs_info file;
1365855366fSMaíra Canal 
1375855366fSMaíra Canal 	/** @list: Linked list of all device nodes. */
1381c9cacbeSMaíra Canal 	struct list_head list;
1391c9cacbeSMaíra Canal };
1401c9cacbeSMaíra Canal 
1414834442dSDaniel Vetter #if defined(CONFIG_DEBUG_FS)
142a212d6a5SWambui Karuga void drm_debugfs_create_files(const struct drm_info_list *files,
1434834442dSDaniel Vetter 			      int count, struct dentry *root,
1444834442dSDaniel Vetter 			      struct drm_minor *minor);
1458e455145SChristian König int drm_debugfs_remove_files(const struct drm_info_list *files, int count,
1468e455145SChristian König 			     struct dentry *root, struct drm_minor *minor);
1471c9cacbeSMaíra Canal 
1481c9cacbeSMaíra Canal void drm_debugfs_add_file(struct drm_device *dev, const char *name,
1491c9cacbeSMaíra Canal 			  int (*show)(struct seq_file*, void*), void *data);
1501c9cacbeSMaíra Canal 
1511c9cacbeSMaíra Canal void drm_debugfs_add_files(struct drm_device *dev,
1521c9cacbeSMaíra Canal 			   const struct drm_debugfs_info *files, int count);
1534f66feeaSDanilo Krummrich 
1544f66feeaSDanilo Krummrich int drm_debugfs_gpuva_info(struct seq_file *m,
155*f72c2db4SDanilo Krummrich 			   struct drm_gpuvm *gpuvm);
1564834442dSDaniel Vetter #else
drm_debugfs_create_files(const struct drm_info_list * files,int count,struct dentry * root,struct drm_minor * minor)157a212d6a5SWambui Karuga static inline void drm_debugfs_create_files(const struct drm_info_list *files,
1584834442dSDaniel Vetter 					    int count, struct dentry *root,
1594834442dSDaniel Vetter 					    struct drm_minor *minor)
160a212d6a5SWambui Karuga {}
1614834442dSDaniel Vetter 
drm_debugfs_remove_files(const struct drm_info_list * files,int count,struct dentry * root,struct drm_minor * minor)1624834442dSDaniel Vetter static inline int drm_debugfs_remove_files(const struct drm_info_list *files,
163c286c480SNathan Chancellor 					   int count, struct dentry *root,
164c286c480SNathan Chancellor 					   struct drm_minor *minor)
1654834442dSDaniel Vetter {
1664834442dSDaniel Vetter 	return 0;
1674834442dSDaniel Vetter }
1681c9cacbeSMaíra Canal 
drm_debugfs_add_file(struct drm_device * dev,const char * name,int (* show)(struct seq_file *,void *),void * data)1691c9cacbeSMaíra Canal static inline void drm_debugfs_add_file(struct drm_device *dev, const char *name,
1701c9cacbeSMaíra Canal 					int (*show)(struct seq_file*, void*),
1711c9cacbeSMaíra Canal 					void *data)
1721c9cacbeSMaíra Canal {}
1731c9cacbeSMaíra Canal 
drm_debugfs_add_files(struct drm_device * dev,const struct drm_debugfs_info * files,int count)1741c9cacbeSMaíra Canal static inline void drm_debugfs_add_files(struct drm_device *dev,
1751c9cacbeSMaíra Canal 					 const struct drm_debugfs_info *files,
1761c9cacbeSMaíra Canal 					 int count)
1771c9cacbeSMaíra Canal {}
1784f66feeaSDanilo Krummrich 
drm_debugfs_gpuva_info(struct seq_file * m,struct drm_gpuvm * gpuvm)1794f66feeaSDanilo Krummrich static inline int drm_debugfs_gpuva_info(struct seq_file *m,
180*f72c2db4SDanilo Krummrich 					 struct drm_gpuvm *gpuvm)
1814f66feeaSDanilo Krummrich {
1824f66feeaSDanilo Krummrich 	return 0;
1834f66feeaSDanilo Krummrich }
1844834442dSDaniel Vetter #endif
1854834442dSDaniel Vetter 
1864834442dSDaniel Vetter #endif /* _DRM_DEBUGFS_H_ */
187