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 pm_runtime_get_sync(&gpu->pdev->dev);
32 gpu->funcs->show(gpu, m);
33 pm_runtime_put_sync(&gpu->pdev->dev);
39 static int msm_gem_show(struct drm_device *dev, struct seq_file *m)
41 struct msm_drm_private *priv = dev->dev_private;
42 struct msm_gpu *gpu = priv->gpu;
45 seq_printf(m, "Active Objects (%s):\n", gpu->name);
46 msm_gem_describe_objects(&gpu->active_list, m);
49 seq_printf(m, "Inactive Objects:\n");
50 msm_gem_describe_objects(&priv->inactive_list, m);
55 static int msm_mm_show(struct drm_device *dev, struct seq_file *m)
57 struct drm_printer p = drm_seq_file_printer(m);
59 drm_mm_print(&dev->vma_offset_manager->vm_addr_space_mm, &p);
64 static int msm_fb_show(struct drm_device *dev, struct seq_file *m)
66 struct msm_drm_private *priv = dev->dev_private;
67 struct drm_framebuffer *fb, *fbdev_fb = NULL;
70 seq_printf(m, "fbcon ");
71 fbdev_fb = priv->fbdev->fb;
72 msm_framebuffer_describe(fbdev_fb, m);
75 mutex_lock(&dev->mode_config.fb_lock);
76 list_for_each_entry(fb, &dev->mode_config.fb_list, head) {
80 seq_printf(m, "user ");
81 msm_framebuffer_describe(fb, m);
83 mutex_unlock(&dev->mode_config.fb_lock);
88 static int show_locked(struct seq_file *m, void *arg)
90 struct drm_info_node *node = (struct drm_info_node *) m->private;
91 struct drm_device *dev = node->minor->dev;
92 int (*show)(struct drm_device *dev, struct seq_file *m) =
96 ret = mutex_lock_interruptible(&dev->struct_mutex);
102 mutex_unlock(&dev->struct_mutex);
107 static struct drm_info_list msm_debugfs_list[] = {
108 {"gpu", show_locked, 0, msm_gpu_show},
109 {"gem", show_locked, 0, msm_gem_show},
110 { "mm", show_locked, 0, msm_mm_show },
111 { "fb", show_locked, 0, msm_fb_show },
114 static int late_init_minor(struct drm_minor *minor)
121 ret = msm_rd_debugfs_init(minor);
123 dev_err(minor->dev->dev, "could not install rd debugfs\n");
127 ret = msm_perf_debugfs_init(minor);
129 dev_err(minor->dev->dev, "could not install perf debugfs\n");
136 int msm_debugfs_late_init(struct drm_device *dev)
139 ret = late_init_minor(dev->primary);
142 ret = late_init_minor(dev->render);
145 ret = late_init_minor(dev->control);
149 int msm_debugfs_init(struct drm_minor *minor)
151 struct drm_device *dev = minor->dev;
152 struct msm_drm_private *priv = dev->dev_private;
155 ret = drm_debugfs_create_files(msm_debugfs_list,
156 ARRAY_SIZE(msm_debugfs_list),
157 minor->debugfs_root, minor);
160 dev_err(dev->dev, "could not install msm_debugfs_list\n");
164 if (priv->kms->funcs->debugfs_init)
165 ret = priv->kms->funcs->debugfs_init(priv->kms, minor);