1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include <linux/debugfs.h>
32
33#include "drmP.h"
34#include "qxl_drv.h"
35#include "qxl_object.h"
36
37
38#if defined(CONFIG_DEBUG_FS)
39static int
40qxl_debugfs_irq_received(struct seq_file *m, void *data)
41{
42 struct drm_info_node *node = (struct drm_info_node *) m->private;
43 struct qxl_device *qdev = node->minor->dev->dev_private;
44
45 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
46 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
47 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
48 seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
49 seq_printf(m, "%d\n", qdev->irq_received_error);
50 return 0;
51}
52
53static int
54qxl_debugfs_buffers_info(struct seq_file *m, void *data)
55{
56 struct drm_info_node *node = (struct drm_info_node *) m->private;
57 struct qxl_device *qdev = node->minor->dev->dev_private;
58 struct qxl_bo *bo;
59
60 list_for_each_entry(bo, &qdev->gem.objects, list) {
61 seq_printf(m, "size %ld, pc %d, sync obj %p, num releases %d\n",
62 (unsigned long)bo->gem_base.size, bo->pin_count,
63 bo->tbo.sync_obj, bo->fence.num_active_releases);
64 }
65 return 0;
66}
67
68static struct drm_info_list qxl_debugfs_list[] = {
69 { "irq_received", qxl_debugfs_irq_received, 0, NULL },
70 { "qxl_buffers", qxl_debugfs_buffers_info, 0, NULL },
71};
72#define QXL_DEBUGFS_ENTRIES ARRAY_SIZE(qxl_debugfs_list)
73#endif
74
75int
76qxl_debugfs_init(struct drm_minor *minor)
77{
78#if defined(CONFIG_DEBUG_FS)
79 drm_debugfs_create_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
80 minor->debugfs_root, minor);
81#endif
82 return 0;
83}
84
85void
86qxl_debugfs_takedown(struct drm_minor *minor)
87{
88#if defined(CONFIG_DEBUG_FS)
89 drm_debugfs_remove_files(qxl_debugfs_list, QXL_DEBUGFS_ENTRIES,
90 minor);
91#endif
92}
93
94int qxl_debugfs_add_files(struct qxl_device *qdev,
95 struct drm_info_list *files,
96 unsigned nfiles)
97{
98 unsigned i;
99
100 for (i = 0; i < qdev->debugfs_count; i++) {
101 if (qdev->debugfs[i].files == files) {
102
103 return 0;
104 }
105 }
106
107 i = qdev->debugfs_count + 1;
108 if (i > QXL_DEBUGFS_MAX_COMPONENTS) {
109 DRM_ERROR("Reached maximum number of debugfs components.\n");
110 DRM_ERROR("Report so we increase QXL_DEBUGFS_MAX_COMPONENTS.\n");
111 return -EINVAL;
112 }
113 qdev->debugfs[qdev->debugfs_count].files = files;
114 qdev->debugfs[qdev->debugfs_count].num_files = nfiles;
115 qdev->debugfs_count = i;
116#if defined(CONFIG_DEBUG_FS)
117 drm_debugfs_create_files(files, nfiles,
118 qdev->ddev->control->debugfs_root,
119 qdev->ddev->control);
120 drm_debugfs_create_files(files, nfiles,
121 qdev->ddev->primary->debugfs_root,
122 qdev->ddev->primary);
123#endif
124 return 0;
125}
126
127void qxl_debugfs_remove_files(struct qxl_device *qdev)
128{
129#if defined(CONFIG_DEBUG_FS)
130 unsigned i;
131
132 for (i = 0; i < qdev->debugfs_count; i++) {
133 drm_debugfs_remove_files(qdev->debugfs[i].files,
134 qdev->debugfs[i].num_files,
135 qdev->ddev->control);
136 drm_debugfs_remove_files(qdev->debugfs[i].files,
137 qdev->debugfs[i].num_files,
138 qdev->ddev->primary);
139 }
140#endif
141}
142