blob: ecfc6b0c1da1061d781b49d9a6e9cb2713d09bfa [file] [log] [blame]
Paul Mundta99d6fd2008-12-10 18:06:36 +09001/*
2 * debugfs ops for process ASIDs
3 *
4 * Copyright (C) 2000, 2001 Paolo Alberelli
5 * Copyright (C) 2003 - 2008 Paul Mundt
6 * Copyright (C) 2003, 2004 Richard Curnow
7 *
8 * Provides a debugfs file that lists out the ASIDs currently associated
9 * with the processes.
10 *
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.
14 *
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.
18 */
19#include <linux/init.h>
20#include <linux/module.h>
21#include <linux/debugfs.h>
22#include <linux/seq_file.h>
23#include <linux/spinlock.h>
24#include <asm/processor.h>
25#include <asm/mmu_context.h>
26
27static int asids_seq_show(struct seq_file *file, void *iter)
28{
29 struct task_struct *p;
30
31 read_lock(&tasklist_lock);
32
33 for_each_process(p) {
34 int pid = p->pid;
35
36 if (unlikely(!pid))
37 continue;
38
39 if (p->mm)
Paul Mundt3a3b3112009-03-17 17:59:31 +090040 seq_printf(file, "%5d : %04lx\n", pid,
Paul Mundta99d6fd2008-12-10 18:06:36 +090041 cpu_asid(smp_processor_id(), p->mm));
Paul Mundta99d6fd2008-12-10 18:06:36 +090042 }
43
44 read_unlock(&tasklist_lock);
45
46 return 0;
47}
48
49static int asids_debugfs_open(struct inode *inode, struct file *file)
50{
51 return single_open(file, asids_seq_show, inode->i_private);
52}
53
54static const struct file_operations asids_debugfs_fops = {
55 .owner = THIS_MODULE,
56 .open = asids_debugfs_open,
57 .read = seq_read,
58 .llseek = seq_lseek,
59 .release = single_release,
60};
61
62static int __init asids_debugfs_init(void)
63{
64 struct dentry *asids_dentry;
65
Paul Mundt3f224f42010-09-24 04:04:26 +090066 asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir,
Paul Mundta99d6fd2008-12-10 18:06:36 +090067 NULL, &asids_debugfs_fops);
68 if (!asids_dentry)
69 return -ENOMEM;
Paul Mundta99d6fd2008-12-10 18:06:36 +090070
Fabian Frederick88f98022014-08-06 16:03:41 -070071 return PTR_ERR_OR_ZERO(asids_dentry);
Paul Mundta99d6fd2008-12-10 18:06:36 +090072}
73module_init(asids_debugfs_init);
74
75MODULE_LICENSE("GPL v2");