Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 1 | /* |
| 2 | * /proc hooks for SMTC kernel |
| 3 | * Copyright (C) 2005 Mips Technologies, Inc |
| 4 | */ |
| 5 | |
| 6 | #include <linux/kernel.h> |
| 7 | #include <linux/sched.h> |
| 8 | #include <linux/cpumask.h> |
| 9 | #include <linux/interrupt.h> |
| 10 | |
| 11 | #include <asm/cpu.h> |
| 12 | #include <asm/processor.h> |
Arun Sharma | 60063497 | 2011-07-26 16:09:06 -0700 | [diff] [blame] | 13 | #include <linux/atomic.h> |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 14 | #include <asm/hardirq.h> |
| 15 | #include <asm/mmu_context.h> |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 16 | #include <asm/mipsregs.h> |
| 17 | #include <asm/cacheflush.h> |
| 18 | #include <linux/proc_fs.h> |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 19 | #include <linux/seq_file.h> |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 20 | |
| 21 | #include <asm/smtc_proc.h> |
| 22 | |
| 23 | /* |
| 24 | * /proc diagnostic and statistics hooks |
| 25 | */ |
| 26 | |
| 27 | /* |
| 28 | * Statistics gathered |
| 29 | */ |
| 30 | unsigned long selfipis[NR_CPUS]; |
| 31 | |
| 32 | struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS]; |
| 33 | |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 34 | atomic_t smtc_fpu_recoveries; |
| 35 | |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 36 | static int smtc_proc_show(struct seq_file *m, void *v) |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 37 | { |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 38 | int i; |
| 39 | extern unsigned long ebase; |
| 40 | |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 41 | seq_printf(m, "SMTC Status Word: 0x%08x\n", smtc_status); |
| 42 | seq_printf(m, "Config7: 0x%08x\n", read_c0_config7()); |
| 43 | seq_printf(m, "EBASE: 0x%08lx\n", ebase); |
| 44 | seq_printf(m, "Counter Interrupts taken per CPU (TC)\n"); |
| 45 | for (i=0; i < NR_CPUS; i++) |
| 46 | seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].timerints); |
| 47 | seq_printf(m, "Self-IPIs by CPU:\n"); |
| 48 | for(i = 0; i < NR_CPUS; i++) |
| 49 | seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis); |
| 50 | seq_printf(m, "%d Recoveries of \"stolen\" FPU\n", |
| 51 | atomic_read(&smtc_fpu_recoveries)); |
| 52 | return 0; |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 53 | } |
| 54 | |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 55 | static int smtc_proc_open(struct inode *inode, struct file *file) |
| 56 | { |
| 57 | return single_open(file, smtc_proc_show, NULL); |
| 58 | } |
| 59 | |
| 60 | static const struct file_operations smtc_proc_fops = { |
| 61 | .open = smtc_proc_open, |
| 62 | .read = seq_read, |
| 63 | .llseek = seq_lseek, |
Al Viro | acf300d | 2013-05-05 00:09:30 -0400 | [diff] [blame] | 64 | .release = single_release, |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 65 | }; |
| 66 | |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 67 | void init_smtc_stats(void) |
| 68 | { |
| 69 | int i; |
| 70 | |
| 71 | for (i=0; i<NR_CPUS; i++) { |
| 72 | smtc_cpu_stats[i].timerints = 0; |
| 73 | smtc_cpu_stats[i].selfipis = 0; |
| 74 | } |
| 75 | |
| 76 | atomic_set(&smtc_fpu_recoveries, 0); |
| 77 | |
David Howells | 2427015 | 2013-04-11 00:21:15 +0100 | [diff] [blame] | 78 | proc_create("smtc", 0444, NULL, &smtc_proc_fops); |
Ralf Baechle | 41c594a | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 79 | } |