Linux 4.8-rc8
[linux/fpc-iii.git] / arch / sh / mm / asids-debugfs.c
blobbf95fdaedd0cf1eee835a92fcb1a32b8ad6b2ed9
1 /*
2 * debugfs ops for process ASIDs
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2003 - 2008 Paul Mundt
6 * Copyright (C) 2003, 2004 Richard Curnow
8 * Provides a debugfs file that lists out the ASIDs currently associated
9 * with the processes.
11 * In the SH-5 case, if the DM.PC register is examined through the debug
12 * link, this shows ASID + PC. To make use of this, the PID->ASID
13 * relationship needs to be known. This is primarily for debugging.
15 * This file is subject to the terms and conditions of the GNU General Public
16 * License. See the file "COPYING" in the main directory of this archive
17 * for more details.
19 #include <linux/init.h>
20 #include <linux/debugfs.h>
21 #include <linux/seq_file.h>
22 #include <linux/spinlock.h>
23 #include <asm/processor.h>
24 #include <asm/mmu_context.h>
26 static int asids_seq_show(struct seq_file *file, void *iter)
28 struct task_struct *p;
30 read_lock(&tasklist_lock);
32 for_each_process(p) {
33 int pid = p->pid;
35 if (unlikely(!pid))
36 continue;
38 if (p->mm)
39 seq_printf(file, "%5d : %04lx\n", pid,
40 cpu_asid(smp_processor_id(), p->mm));
43 read_unlock(&tasklist_lock);
45 return 0;
48 static int asids_debugfs_open(struct inode *inode, struct file *file)
50 return single_open(file, asids_seq_show, inode->i_private);
53 static const struct file_operations asids_debugfs_fops = {
54 .owner = THIS_MODULE,
55 .open = asids_debugfs_open,
56 .read = seq_read,
57 .llseek = seq_lseek,
58 .release = single_release,
61 static int __init asids_debugfs_init(void)
63 struct dentry *asids_dentry;
65 asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir,
66 NULL, &asids_debugfs_fops);
67 if (!asids_dentry)
68 return -ENOMEM;
70 return PTR_ERR_OR_ZERO(asids_dentry);
72 device_initcall(asids_debugfs_init);