Blame view

arch/sh/mm/asids-debugfs.c 1.83 KB
a99d6fde6   Paul Mundt   sh: Convert sh64 ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  /*
   * debugfs ops for process ASIDs
   *
   *  Copyright (C) 2000, 2001  Paolo Alberelli
   *  Copyright (C) 2003 - 2008  Paul Mundt
   *  Copyright (C) 2003, 2004  Richard Curnow
   *
   * Provides a debugfs file that lists out the ASIDs currently associated
   * with the processes.
   *
   * In the SH-5 case, if the DM.PC register is examined through the debug
   * link, this shows ASID + PC. To make use of this, the PID->ASID
   * relationship needs to be known. This is primarily for debugging.
   *
   * This file is subject to the terms and conditions of the GNU General Public
   * License.  See the file "COPYING" in the main directory of this archive
   * for more details.
   */
  #include <linux/init.h>
  #include <linux/module.h>
  #include <linux/debugfs.h>
  #include <linux/seq_file.h>
  #include <linux/spinlock.h>
  #include <asm/processor.h>
  #include <asm/mmu_context.h>
  
  static int asids_seq_show(struct seq_file *file, void *iter)
  {
  	struct task_struct *p;
  
  	read_lock(&tasklist_lock);
  
  	for_each_process(p) {
  		int pid = p->pid;
  
  		if (unlikely(!pid))
  			continue;
  
  		if (p->mm)
3a3b311ca   Paul Mundt   sh: Update debugf...
40
41
  			seq_printf(file, "%5d : %04lx
  ", pid,
a99d6fde6   Paul Mundt   sh: Convert sh64 ...
42
  				   cpu_asid(smp_processor_id(), p->mm));
a99d6fde6   Paul Mundt   sh: Convert sh64 ...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
  	}
  
  	read_unlock(&tasklist_lock);
  
  	return 0;
  }
  
  static int asids_debugfs_open(struct inode *inode, struct file *file)
  {
  	return single_open(file, asids_seq_show, inode->i_private);
  }
  
  static const struct file_operations asids_debugfs_fops = {
  	.owner		= THIS_MODULE,
  	.open		= asids_debugfs_open,
  	.read		= seq_read,
  	.llseek		= seq_lseek,
  	.release	= single_release,
  };
  
  static int __init asids_debugfs_init(void)
  {
  	struct dentry *asids_dentry;
3f224f4e0   Paul Mundt   sh: provide gener...
66
  	asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir,
a99d6fde6   Paul Mundt   sh: Convert sh64 ...
67
68
69
70
71
72
73
74
75
76
77
  					   NULL, &asids_debugfs_fops);
  	if (!asids_dentry)
  		return -ENOMEM;
  	if (IS_ERR(asids_dentry))
  		return PTR_ERR(asids_dentry);
  
  	return 0;
  }
  module_init(asids_debugfs_init);
  
  MODULE_LICENSE("GPL v2");