asids-debugfs.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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>
  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. static int asids_seq_show(struct seq_file *file, void *iter)
  27. {
  28. struct task_struct *p;
  29. read_lock(&tasklist_lock);
  30. for_each_process(p) {
  31. int pid = p->pid;
  32. if (unlikely(!pid))
  33. continue;
  34. if (p->mm)
  35. seq_printf(file, "%5d : %04lx\n", pid,
  36. cpu_asid(smp_processor_id(), p->mm));
  37. }
  38. read_unlock(&tasklist_lock);
  39. return 0;
  40. }
  41. static int asids_debugfs_open(struct inode *inode, struct file *file)
  42. {
  43. return single_open(file, asids_seq_show, inode->i_private);
  44. }
  45. static const struct file_operations asids_debugfs_fops = {
  46. .owner = THIS_MODULE,
  47. .open = asids_debugfs_open,
  48. .read = seq_read,
  49. .llseek = seq_lseek,
  50. .release = single_release,
  51. };
  52. static int __init asids_debugfs_init(void)
  53. {
  54. struct dentry *asids_dentry;
  55. asids_dentry = debugfs_create_file("asids", S_IRUSR, arch_debugfs_dir,
  56. NULL, &asids_debugfs_fops);
  57. if (!asids_dentry)
  58. return -ENOMEM;
  59. return PTR_ERR_OR_ZERO(asids_dentry);
  60. }
  61. module_init(asids_debugfs_init);
  62. MODULE_LICENSE("GPL v2");