2 * Copyright (C) 2013-2016 Red Hat
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.
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
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/>.
18 #ifdef CONFIG_DEBUG_FS
22 #include "msm_debugfs.h"
24 static int msm_gpu_show(struct drm_device *dev, struct seq_file *m)
26 struct msm_drm_private *priv = dev->dev_private;
27 struct msm_gpu *gpu = priv->gpu;
30 seq_printf(m, "%s Status:\n", gpu->name);
31 gpu->funcs->show(gpu, m);
37 static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
39 struct msm_drm_private *priv = dev->dev_private;
40 struct msm_gpu *gpu = priv->gpu;
43 seq_printf(m, "Active Objects (%s):\n", gpu->name);
44 msm_gem_describe_objects(&gpu->active_list, m);
47 seq_printf(m, "Inactive Objects:\n");
48 msm_gem_describe_objects(&priv->inactive_list, m);
53 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
55 return drm_mm_dump_table(m, &dev->vma_offset_manager->vm_addr_space_mm);
58 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
60 struct msm_drm_private *priv = dev->dev_private;
61 struct drm_framebuffer *fb, *fbdev_fb = NULL;
64 seq_printf(m, "fbcon ");
65 fbdev_fb = priv->fbdev->fb;
66 msm_framebuffer_describe(fbdev_fb, m);
69 mutex_lock(&dev->mode_config.fb_lock);
70 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
74 seq_printf(m, "user ");
75 msm_framebuffer_describe(fb, m);
77 mutex_unlock(&dev->mode_config.fb_lock);
82 static int show_locked(struct seq_file *m, void *arg)
84 struct drm_info_node *node = (struct drm_info_node *) m->private;
85 struct drm_device *dev = node->minor->dev;
86 int (*show)(struct drm_device *dev, struct seq_file *m) =
90 ret = mutex_lock_interruptible(&dev->struct_mutex);
96 mutex_unlock(&dev->struct_mutex);
101 static struct drm_info_list msm_debugfs_list[] = {
102 {"gpu", show_locked, 0, msm_gpu_show},
103 {"gem", show_locked, 0, msm_gem_show},
104 { "mm", show_locked, 0, msm_mm_show },
105 { "fb", show_locked, 0, msm_fb_show },
108 static int late_init_minor(struct drm_minor *minor)
115 ret = msm_rd_debugfs_init(minor);
117 dev_err(minor->dev->dev, "could not install rd debugfs\n");
121 ret = msm_perf_debugfs_init(minor);
123 dev_err(minor->dev->dev, "could not install perf debugfs\n");
130 int msm_debugfs_late_init(struct drm_device *dev)
133 ret = late_init_minor(dev->primary);
136 ret = late_init_minor(dev->render);
139 ret = late_init_minor(dev->control);
143 int msm_debugfs_init(struct drm_minor *minor)
145 struct drm_device *dev = minor->dev;
146 struct msm_drm_private *priv = dev->dev_private;
149 ret = drm_debugfs_create_files(msm_debugfs_list,
150 ARRAY_SIZE(msm_debugfs_list),
151 minor->debugfs_root, minor);
154 dev_err(dev->dev, "could not install msm_debugfs_list\n");
158 if (priv->kms->funcs->debugfs_init)
159 ret = priv->kms->funcs->debugfs_init(priv->kms, minor);
164 void msm_debugfs_cleanup(struct drm_minor *minor)
166 struct drm_device *dev = minor->dev;
167 struct msm_drm_private *priv = dev->dev_private;
169 drm_debugfs_remove_files(msm_debugfs_list,
170 ARRAY_SIZE(msm_debugfs_list), minor);
174 if (priv->kms->funcs->debugfs_cleanup)
175 priv->kms->funcs->debugfs_cleanup(priv->kms, minor);
177 msm_rd_debugfs_cleanup(minor);
178 msm_perf_debugfs_cleanup(minor);