2 * Copyright (C) 2013-2016 Red Hat
3 * Author: Rob Clark <robdclark@gmail.com>
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 struct drm_printer p
= drm_seq_file_printer(m
);
57 drm_mm_print(&dev
->vma_offset_manager
->vm_addr_space_mm
, &p
);
62 static int msm_fb_show(struct drm_device
*dev
, struct seq_file
*m
)
64 struct msm_drm_private
*priv
= dev
->dev_private
;
65 struct drm_framebuffer
*fb
, *fbdev_fb
= NULL
;
68 seq_printf(m
, "fbcon ");
69 fbdev_fb
= priv
->fbdev
->fb
;
70 msm_framebuffer_describe(fbdev_fb
, m
);
73 mutex_lock(&dev
->mode_config
.fb_lock
);
74 list_for_each_entry(fb
, &dev
->mode_config
.fb_list
, head
) {
78 seq_printf(m
, "user ");
79 msm_framebuffer_describe(fb
, m
);
81 mutex_unlock(&dev
->mode_config
.fb_lock
);
86 static int show_locked(struct seq_file
*m
, void *arg
)
88 struct drm_info_node
*node
= (struct drm_info_node
*) m
->private;
89 struct drm_device
*dev
= node
->minor
->dev
;
90 int (*show
)(struct drm_device
*dev
, struct seq_file
*m
) =
94 ret
= mutex_lock_interruptible(&dev
->struct_mutex
);
100 mutex_unlock(&dev
->struct_mutex
);
105 static struct drm_info_list msm_debugfs_list
[] = {
106 {"gpu", show_locked
, 0, msm_gpu_show
},
107 {"gem", show_locked
, 0, msm_gem_show
},
108 { "mm", show_locked
, 0, msm_mm_show
},
109 { "fb", show_locked
, 0, msm_fb_show
},
112 static int late_init_minor(struct drm_minor
*minor
)
119 ret
= msm_rd_debugfs_init(minor
);
121 dev_err(minor
->dev
->dev
, "could not install rd debugfs\n");
125 ret
= msm_perf_debugfs_init(minor
);
127 dev_err(minor
->dev
->dev
, "could not install perf debugfs\n");
134 int msm_debugfs_late_init(struct drm_device
*dev
)
137 ret
= late_init_minor(dev
->primary
);
140 ret
= late_init_minor(dev
->render
);
143 ret
= late_init_minor(dev
->control
);
147 int msm_debugfs_init(struct drm_minor
*minor
)
149 struct drm_device
*dev
= minor
->dev
;
150 struct msm_drm_private
*priv
= dev
->dev_private
;
153 ret
= drm_debugfs_create_files(msm_debugfs_list
,
154 ARRAY_SIZE(msm_debugfs_list
),
155 minor
->debugfs_root
, minor
);
158 dev_err(dev
->dev
, "could not install msm_debugfs_list\n");
162 if (priv
->kms
->funcs
->debugfs_init
)
163 ret
= priv
->kms
->funcs
->debugfs_init(priv
->kms
, minor
);
168 void msm_debugfs_cleanup(struct drm_minor
*minor
)
170 struct drm_device
*dev
= minor
->dev
;
171 struct msm_drm_private
*priv
= dev
->dev_private
;
176 if (priv
->kms
->funcs
->debugfs_cleanup
)
177 priv
->kms
->funcs
->debugfs_cleanup(priv
->kms
, minor
);
179 msm_rd_debugfs_cleanup(minor
);
180 msm_perf_debugfs_cleanup(minor
);