Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 1 | /* |
| 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> |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 20 | #include <linux/debugfs.h> |
| 21 | #include <linux/seq_file.h> |
| 22 | #include <linux/spinlock.h> |
Ingo Molnar | 3f07c01 | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 23 | #include <linux/sched/signal.h> |
Ingo Molnar | 2993002 | 2017-02-08 18:51:36 +0100 | [diff] [blame] | 24 | #include <linux/sched/task.h> |
Ingo Molnar | 3f07c01 | 2017-02-08 18:51:30 +0100 | [diff] [blame] | 25 | |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 26 | #include <asm/processor.h> |
| 27 | #include <asm/mmu_context.h> |
| 28 | |
Qinglang Miao | a115363 | 2020-09-19 10:52:05 +0800 | [diff] [blame] | 29 | static int asids_debugfs_show(struct seq_file *file, void *iter) |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 30 | { |
| 31 | struct task_struct *p; |
| 32 | |
| 33 | read_lock(&tasklist_lock); |
| 34 | |
| 35 | for_each_process(p) { |
| 36 | int pid = p->pid; |
| 37 | |
| 38 | if (unlikely(!pid)) |
| 39 | continue; |
| 40 | |
| 41 | if (p->mm) |
Paul Mundt | 3a3b311c | 2009-03-17 17:59:31 +0900 | [diff] [blame] | 42 | seq_printf(file, "%5d : %04lx\n", pid, |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 43 | cpu_asid(smp_processor_id(), p->mm)); |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | read_unlock(&tasklist_lock); |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
Qinglang Miao | a115363 | 2020-09-19 10:52:05 +0800 | [diff] [blame] | 51 | DEFINE_SHOW_ATTRIBUTE(asids_debugfs); |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 52 | |
| 53 | static int __init asids_debugfs_init(void) |
| 54 | { |
Greg Kroah-Hartman | 03eb2a0 | 2019-01-22 15:50:30 +0100 | [diff] [blame] | 55 | debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir, NULL, |
| 56 | &asids_debugfs_fops); |
| 57 | return 0; |
Paul Mundt | a99d6fd | 2008-12-10 18:06:36 +0900 | [diff] [blame] | 58 | } |
Paul Gortmaker | f15412a | 2016-04-22 14:07:02 -0400 | [diff] [blame] | 59 | device_initcall(asids_debugfs_init); |