187 lines · c
1/*2 * Internal Header for the Direct Rendering Manager3 *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 a13 * copy of this software and associated documentation files (the "Software"),14 * to deal in the Software without restriction, including without limitation15 * the rights to use, copy, modify, merge, publish, distribute, sublicense,16 * and/or sell copies of the Software, and to permit persons to whom the17 * Software is furnished to do so, subject to the following conditions:18 *19 * The above copyright notice and this permission notice (including the next20 * paragraph) shall be included in all copies or substantial portions of the21 * Software.22 *23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,25 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL26 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR27 * 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 OR29 * OTHER DEALINGS IN THE SOFTWARE.30 */31 32#ifndef _DRM_DEBUGFS_H_33#define _DRM_DEBUGFS_H_34 35#include <linux/types.h>36#include <linux/seq_file.h>37 38#include <drm/drm_gpuvm.h>39 40/**41 * DRM_DEBUGFS_GPUVA_INFO - &drm_info_list entry to dump a GPU VA space42 * @show: the &drm_info_list's show callback43 * @data: driver private data44 *45 * Drivers should use this macro to define a &drm_info_list entry to provide a46 * debugfs file for dumping the GPU VA space regions and mappings.47 *48 * For each DRM GPU VA space drivers should call drm_debugfs_gpuva_info() from49 * their @show callback.50 */51#define DRM_DEBUGFS_GPUVA_INFO(show, data) {"gpuvas", show, DRIVER_GEM_GPUVA, data}52 53/**54 * struct drm_info_list - debugfs info list entry55 *56 * This structure represents a debugfs file to be created by the drm57 * core.58 */59struct drm_info_list {60 /** @name: file name */61 const char *name;62 /**63 * @show:64 *65 * Show callback. &seq_file->private will be set to the &struct66 * drm_info_node corresponding to the instance of this info on a given67 * &struct drm_minor.68 */69 int (*show)(struct seq_file*, void*);70 /** @driver_features: Required driver features for this entry */71 u32 driver_features;72 /** @data: Driver-private data, should not be device-specific. */73 void *data;74};75 76/**77 * struct drm_info_node - Per-minor debugfs node structure78 *79 * This structure represents a debugfs file, as an instantiation of a &struct80 * drm_info_list on a &struct drm_minor.81 *82 * FIXME:83 *84 * No it doesn't make a hole lot of sense that we duplicate debugfs entries for85 * both the render and the primary nodes, but that's how this has organically86 * grown. It should probably be fixed, with a compatibility link, if needed.87 */88struct drm_info_node {89 /** @minor: &struct drm_minor for this node. */90 struct drm_minor *minor;91 /** @info_ent: template for this node. */92 const struct drm_info_list *info_ent;93 /* private: */94 struct list_head list;95 struct dentry *dent;96};97 98/**99 * struct drm_debugfs_info - debugfs info list entry100 *101 * This structure represents a debugfs file to be created by the drm102 * core.103 */104struct drm_debugfs_info {105 /** @name: File name */106 const char *name;107 108 /**109 * @show:110 *111 * Show callback. &seq_file->private will be set to the &struct112 * drm_debugfs_entry corresponding to the instance of this info113 * on a given &struct drm_device.114 */115 int (*show)(struct seq_file*, void*);116 117 /** @driver_features: Required driver features for this entry. */118 u32 driver_features;119 120 /** @data: Driver-private data, should not be device-specific. */121 void *data;122};123 124/**125 * struct drm_debugfs_entry - Per-device debugfs node structure126 *127 * This structure represents a debugfs file, as an instantiation of a &struct128 * drm_debugfs_info on a &struct drm_device.129 */130struct drm_debugfs_entry {131 /** @dev: &struct drm_device for this node. */132 struct drm_device *dev;133 134 /** @file: Template for this node. */135 struct drm_debugfs_info file;136 137 /** @list: Linked list of all device nodes. */138 struct list_head list;139};140 141#if defined(CONFIG_DEBUG_FS)142void drm_debugfs_create_files(const struct drm_info_list *files,143 int count, struct dentry *root,144 struct drm_minor *minor);145int drm_debugfs_remove_files(const struct drm_info_list *files, int count,146 struct dentry *root, struct drm_minor *minor);147 148void drm_debugfs_add_file(struct drm_device *dev, const char *name,149 int (*show)(struct seq_file*, void*), void *data);150 151void drm_debugfs_add_files(struct drm_device *dev,152 const struct drm_debugfs_info *files, int count);153 154int drm_debugfs_gpuva_info(struct seq_file *m,155 struct drm_gpuvm *gpuvm);156#else157static inline void drm_debugfs_create_files(const struct drm_info_list *files,158 int count, struct dentry *root,159 struct drm_minor *minor)160{}161 162static inline int drm_debugfs_remove_files(const struct drm_info_list *files,163 int count, struct dentry *root,164 struct drm_minor *minor)165{166 return 0;167}168 169static inline void drm_debugfs_add_file(struct drm_device *dev, const char *name,170 int (*show)(struct seq_file*, void*),171 void *data)172{}173 174static inline void drm_debugfs_add_files(struct drm_device *dev,175 const struct drm_debugfs_info *files,176 int count)177{}178 179static inline int drm_debugfs_gpuva_info(struct seq_file *m,180 struct drm_gpuvm *gpuvm)181{182 return 0;183}184#endif185 186#endif /* _DRM_DEBUGFS_H_ */187