3 * (C) COPYRIGHT 2014-2016 ARM Limited. All rights reserved.
5 * This program is free software and is provided to you under the terms of the
6 * GNU General Public License version 2 as published by the Free Software
7 * Foundation, and any use by you of this program is subject to the terms
10 * A copy of the licence is included with the program, and can also be obtained
11 * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12 * Boston, MA 02110-1301, USA.
18 #include <linux/seq_file.h>
20 #include <mali_kbase.h>
22 #include <mali_kbase_jd_debugfs.h>
23 #include <mali_kbase_dma_fence.h>
25 #ifdef CONFIG_DEBUG_FS
27 struct kbase_jd_debugfs_depinfo
{
33 #include <mali_kbase_sync.h>
35 #endif /* CONFIG_SYNC */
38 static void kbase_jd_debugfs_fence_info(struct kbase_jd_atom
*atom
,
39 struct seq_file
*sfile
)
42 struct sync_fence
*fence
= atom
->fence
;
45 switch (atom
->core_req
& BASE_JD_REQ_SOFT_JOB_TYPE
) {
46 case BASE_JD_REQ_SOFT_FENCE_TRIGGER
:
50 status
= kbase_fence_get_status(fence
);
52 seq_printf(sfile
, "Sa([%p]%d) ",
55 case BASE_JD_REQ_SOFT_FENCE_WAIT
:
59 status
= kbase_fence_get_status(fence
);
61 seq_printf(sfile
, "Wa([%p]%d) ",
67 #endif /* CONFIG_SYNC */
69 #ifdef CONFIG_MALI_DMA_FENCE
70 if (atom
->core_req
& BASE_JD_REQ_EXTERNAL_RESOURCES
) {
71 struct kbase_dma_fence_cb
*cb
;
73 if (atom
->dma_fence
.fence
) {
74 struct fence
*fence
= atom
->dma_fence
.fence
;
77 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
84 fence_is_signaled(fence
) ?
85 "signaled" : "active");
88 list_for_each_entry(cb
, &atom
->dma_fence
.callbacks
,
90 struct fence
*fence
= cb
->fence
;
93 #if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0))
100 fence_is_signaled(fence
) ?
101 "signaled" : "active");
104 #endif /* CONFIG_MALI_DMA_FENCE */
108 static void kbasep_jd_debugfs_atom_deps(
109 struct kbase_jd_debugfs_depinfo
*deps
,
110 struct kbase_jd_atom
*atom
)
112 struct kbase_context
*kctx
= atom
->kctx
;
115 for (i
= 0; i
< 2; i
++) {
116 deps
[i
].id
= (unsigned)(atom
->dep
[i
].atom
?
117 kbase_jd_atom_id(kctx
, atom
->dep
[i
].atom
) : 0);
119 switch (atom
->dep
[i
].dep_type
) {
120 case BASE_JD_DEP_TYPE_INVALID
:
123 case BASE_JD_DEP_TYPE_DATA
:
126 case BASE_JD_DEP_TYPE_ORDER
:
136 * kbasep_jd_debugfs_atoms_show - Show callback for the JD atoms debugfs file.
137 * @sfile: The debugfs entry
138 * @data: Data associated with the entry
140 * This function is called to get the contents of the JD atoms debugfs file.
141 * This is a report of all atoms managed by kbase_jd_context.atoms
143 * Return: 0 if successfully prints data in debugfs entry file, failure
146 static int kbasep_jd_debugfs_atoms_show(struct seq_file
*sfile
, void *data
)
148 struct kbase_context
*kctx
= sfile
->private;
149 struct kbase_jd_atom
*atoms
;
150 unsigned long irq_flags
;
153 KBASE_DEBUG_ASSERT(kctx
!= NULL
);
156 seq_printf(sfile
, "v%u\n", MALI_JD_DEBUGFS_VERSION
);
158 /* Print U/K API version */
159 seq_printf(sfile
, "ukv%u.%u\n", BASE_UK_VERSION_MAJOR
,
160 BASE_UK_VERSION_MINOR
);
162 /* Print table heading */
163 seq_puts(sfile
, " ID, Core req, St, CR, Predeps, Start time, Additional info...\n");
165 atoms
= kctx
->jctx
.atoms
;
166 /* General atom states */
167 mutex_lock(&kctx
->jctx
.lock
);
168 /* JS-related states */
169 spin_lock_irqsave(&kctx
->kbdev
->hwaccess_lock
, irq_flags
);
170 for (i
= 0; i
!= BASE_JD_ATOM_COUNT
; ++i
) {
171 struct kbase_jd_atom
*atom
= &atoms
[i
];
172 s64 start_timestamp
= 0;
173 struct kbase_jd_debugfs_depinfo deps
[2];
175 if (atom
->status
== KBASE_JD_ATOM_STATE_UNUSED
)
178 /* start_timestamp is cleared as soon as the atom leaves UNUSED state
179 * and set before a job is submitted to the h/w, a non-zero value means
181 if (ktime_to_ns(atom
->start_timestamp
))
182 start_timestamp
= ktime_to_ns(
183 ktime_sub(ktime_get(), atom
->start_timestamp
));
185 kbasep_jd_debugfs_atom_deps(deps
, atom
);
188 "%3u, %8x, %2u, %2u, %c%3u %c%3u, %20lld, ",
189 i
, atom
->core_req
, atom
->status
,
191 deps
[0].type
, deps
[0].id
,
192 deps
[1].type
, deps
[1].id
,
196 kbase_jd_debugfs_fence_info(atom
, sfile
);
198 seq_puts(sfile
, "\n");
200 spin_unlock_irqrestore(&kctx
->kbdev
->hwaccess_lock
, irq_flags
);
201 mutex_unlock(&kctx
->jctx
.lock
);
208 * kbasep_jd_debugfs_atoms_open - open operation for atom debugfs file
209 * @in: &struct inode pointer
210 * @file: &struct file pointer
212 * Return: file descriptor
214 static int kbasep_jd_debugfs_atoms_open(struct inode
*in
, struct file
*file
)
216 return single_open(file
, kbasep_jd_debugfs_atoms_show
, in
->i_private
);
219 static const struct file_operations kbasep_jd_debugfs_atoms_fops
= {
220 .open
= kbasep_jd_debugfs_atoms_open
,
223 .release
= single_release
,
226 void kbasep_jd_debugfs_ctx_init(struct kbase_context
*kctx
)
228 KBASE_DEBUG_ASSERT(kctx
!= NULL
);
230 /* Expose all atoms */
231 debugfs_create_file("atoms", S_IRUGO
, kctx
->kctx_dentry
, kctx
,
232 &kbasep_jd_debugfs_atoms_fops
);
236 #endif /* CONFIG_DEBUG_FS */