3 * (C) COPYRIGHT 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/debugfs.h>
20 #include <mali_kbase.h>
21 #include <mali_kbase_as_fault_debugfs.h>
23 #ifdef CONFIG_DEBUG_FS
24 #ifdef CONFIG_MALI_DEBUG
26 static int kbase_as_fault_read(struct seq_file *sfile, void *data)
28 uintptr_t as_no = (uintptr_t) sfile->private;
30 struct list_head *entry;
31 const struct list_head *kbdev_list;
32 struct kbase_device *kbdev = NULL;
34 kbdev_list = kbase_dev_list_get();
36 list_for_each(entry, kbdev_list) {
37 kbdev = list_entry(entry, struct kbase_device, entry);
39 if(kbdev->debugfs_as_read_bitmap & (1ULL << as_no)) {
41 /* don't show this one again until another fault occors */
42 kbdev->debugfs_as_read_bitmap &= ~(1ULL << as_no);
44 /* output the last page fault addr */
45 seq_printf(sfile, "%llu\n", (u64) kbdev->as[as_no].fault_addr);
50 kbase_dev_list_put(kbdev_list);
55 static int kbase_as_fault_debugfs_open(struct inode *in, struct file *file)
57 return single_open(file, kbase_as_fault_read , in->i_private);
60 static const struct file_operations as_fault_fops = {
61 .open = kbase_as_fault_debugfs_open,
64 .release = single_release,
67 #endif /* CONFIG_MALI_DEBUG */
68 #endif /* CONFIG_DEBUG_FS */
71 * Initialize debugfs entry for each address space
73 void kbase_as_fault_debugfs_init(struct kbase_device *kbdev)
75 #ifdef CONFIG_DEBUG_FS
76 #ifdef CONFIG_MALI_DEBUG
79 struct dentry *debugfs_directory;
81 kbdev->debugfs_as_read_bitmap = 0ULL;
83 KBASE_DEBUG_ASSERT(kbdev->nr_hw_address_spaces);
84 KBASE_DEBUG_ASSERT(sizeof(kbdev->as[0].fault_addr) == sizeof(u64));
86 debugfs_directory = debugfs_create_dir("address_spaces",
87 kbdev->mali_debugfs_directory);
89 if(debugfs_directory) {
90 for(i = 0; i < kbdev->nr_hw_address_spaces; i++) {
91 snprintf(as_name, ARRAY_SIZE(as_name), "as%u", i);
92 debugfs_create_file(as_name, S_IRUGO,
93 debugfs_directory, (void*) ((uintptr_t) i), &as_fault_fops);
97 dev_warn(kbdev->dev, "unable to create address_spaces debugfs directory");
99 #endif /* CONFIG_MALI_DEBUG */
100 #endif /* CONFIG_DEBUG_FS */