1a99d6fdeSPaul Mundt /*
2a99d6fdeSPaul Mundt * debugfs ops for process ASIDs
3a99d6fdeSPaul Mundt *
4a99d6fdeSPaul Mundt * Copyright (C) 2000, 2001 Paolo Alberelli
5a99d6fdeSPaul Mundt * Copyright (C) 2003 - 2008 Paul Mundt
6a99d6fdeSPaul Mundt * Copyright (C) 2003, 2004 Richard Curnow
7a99d6fdeSPaul Mundt *
8a99d6fdeSPaul Mundt * Provides a debugfs file that lists out the ASIDs currently associated
9a99d6fdeSPaul Mundt * with the processes.
10a99d6fdeSPaul Mundt *
11a99d6fdeSPaul Mundt * In the SH-5 case, if the DM.PC register is examined through the debug
12a99d6fdeSPaul Mundt * link, this shows ASID + PC. To make use of this, the PID->ASID
13a99d6fdeSPaul Mundt * relationship needs to be known. This is primarily for debugging.
14a99d6fdeSPaul Mundt *
15a99d6fdeSPaul Mundt * This file is subject to the terms and conditions of the GNU General Public
16a99d6fdeSPaul Mundt * License. See the file "COPYING" in the main directory of this archive
17a99d6fdeSPaul Mundt * for more details.
18a99d6fdeSPaul Mundt */
19a99d6fdeSPaul Mundt #include <linux/init.h>
20a99d6fdeSPaul Mundt #include <linux/debugfs.h>
21a99d6fdeSPaul Mundt #include <linux/seq_file.h>
22a99d6fdeSPaul Mundt #include <linux/spinlock.h>
233f07c014SIngo Molnar #include <linux/sched/signal.h>
2429930025SIngo Molnar #include <linux/sched/task.h>
253f07c014SIngo Molnar
26a99d6fdeSPaul Mundt #include <asm/processor.h>
27a99d6fdeSPaul Mundt #include <asm/mmu_context.h>
28a99d6fdeSPaul Mundt
asids_debugfs_show(struct seq_file * file,void * iter)29*a1153636SQinglang Miao static int asids_debugfs_show(struct seq_file *file, void *iter)
30a99d6fdeSPaul Mundt {
31a99d6fdeSPaul Mundt struct task_struct *p;
32a99d6fdeSPaul Mundt
33a99d6fdeSPaul Mundt read_lock(&tasklist_lock);
34a99d6fdeSPaul Mundt
35a99d6fdeSPaul Mundt for_each_process(p) {
36a99d6fdeSPaul Mundt int pid = p->pid;
37a99d6fdeSPaul Mundt
38a99d6fdeSPaul Mundt if (unlikely(!pid))
39a99d6fdeSPaul Mundt continue;
40a99d6fdeSPaul Mundt
41a99d6fdeSPaul Mundt if (p->mm)
423a3b311cSPaul Mundt seq_printf(file, "%5d : %04lx\n", pid,
43a99d6fdeSPaul Mundt cpu_asid(smp_processor_id(), p->mm));
44a99d6fdeSPaul Mundt }
45a99d6fdeSPaul Mundt
46a99d6fdeSPaul Mundt read_unlock(&tasklist_lock);
47a99d6fdeSPaul Mundt
48a99d6fdeSPaul Mundt return 0;
49a99d6fdeSPaul Mundt }
50a99d6fdeSPaul Mundt
51*a1153636SQinglang Miao DEFINE_SHOW_ATTRIBUTE(asids_debugfs);
52a99d6fdeSPaul Mundt
asids_debugfs_init(void)53a99d6fdeSPaul Mundt static int __init asids_debugfs_init(void)
54a99d6fdeSPaul Mundt {
5503eb2a08SGreg Kroah-Hartman debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir, NULL,
5603eb2a08SGreg Kroah-Hartman &asids_debugfs_fops);
5703eb2a08SGreg Kroah-Hartman return 0;
58a99d6fdeSPaul Mundt }
59f15412aaSPaul Gortmaker device_initcall(asids_debugfs_init);
60