3 * (C) COPYRIGHT 2014-2015 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>
24 #ifdef CONFIG_DEBUG_FS
27 * kbasep_jd_debugfs_atoms_show - Show callback for the JD atoms debugfs file.
28 * @sfile: The debugfs entry
29 * @data: Data associated with the entry
31 * This function is called to get the contents of the JD atoms debugfs file.
32 * This is a report of all atoms managed by kbase_jd_context.atoms
34 * Return: 0 if successfully prints data in debugfs entry file, failure
37 static int kbasep_jd_debugfs_atoms_show(struct seq_file *sfile, void *data)
39 struct kbase_context *kctx = sfile->private;
40 struct kbase_jd_atom *atoms;
41 unsigned long irq_flags;
44 KBASE_DEBUG_ASSERT(kctx != NULL);
47 seq_printf(sfile, "v%u\n", MALI_JD_DEBUGFS_VERSION);
49 /* Print U/K API version */
50 seq_printf(sfile, "ukv%u.%u\n", BASE_UK_VERSION_MAJOR,
51 BASE_UK_VERSION_MINOR);
53 /* Print table heading */
54 seq_puts(sfile, "atom id,core reqs,status,coreref status,predeps,start time,time on gpu\n");
56 atoms = kctx->jctx.atoms;
57 /* General atom states */
58 mutex_lock(&kctx->jctx.lock);
59 /* JS-related states */
60 spin_lock_irqsave(&kctx->kbdev->js_data.runpool_irq.lock, irq_flags);
61 for (i = 0; i != BASE_JD_ATOM_COUNT; ++i) {
62 struct kbase_jd_atom *atom = &atoms[i];
63 s64 start_timestamp = 0;
65 if (atom->status == KBASE_JD_ATOM_STATE_UNUSED)
68 /* start_timestamp is cleared as soon as the atom leaves UNUSED state
69 * and set before a job is submitted to the h/w, a non-zero value means
71 if (ktime_to_ns(atom->start_timestamp))
72 start_timestamp = ktime_to_ns(
73 ktime_sub(ktime_get(), atom->start_timestamp));
76 "%i,%u,%u,%u,%u %u,%lli,%llu\n",
77 i, atom->core_req, atom->status, atom->coreref_state,
78 (unsigned)(atom->dep[0].atom ?
79 atom->dep[0].atom - atoms : 0),
80 (unsigned)(atom->dep[1].atom ?
81 atom->dep[1].atom - atoms : 0),
82 (signed long long)start_timestamp,
83 (unsigned long long)(atom->time_spent_us ?
84 atom->time_spent_us * 1000 : start_timestamp)
87 spin_unlock_irqrestore(&kctx->kbdev->js_data.runpool_irq.lock, irq_flags);
88 mutex_unlock(&kctx->jctx.lock);
95 * kbasep_jd_debugfs_atoms_open - open operation for atom debugfs file
96 * @in: &struct inode pointer
97 * @file: &struct file pointer
99 * Return: file descriptor
101 static int kbasep_jd_debugfs_atoms_open(struct inode *in, struct file *file)
103 return single_open(file, kbasep_jd_debugfs_atoms_show, in->i_private);
106 static const struct file_operations kbasep_jd_debugfs_atoms_fops = {
107 .open = kbasep_jd_debugfs_atoms_open,
110 .release = single_release,
113 void kbasep_jd_debugfs_ctx_add(struct kbase_context *kctx)
115 KBASE_DEBUG_ASSERT(kctx != NULL);
117 /* Expose all atoms */
118 debugfs_create_file("atoms", S_IRUGO, kctx->kctx_dentry, kctx,
119 &kbasep_jd_debugfs_atoms_fops);
123 #endif /* CONFIG_DEBUG_FS */