blob: aee7c8177b5df4a2e00cd24efad837f02a723921 [file] [log] [blame]
Ralf Baechle41c594a2006-04-05 09:45:45 +01001/*
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 Sharma600634972011-07-26 16:09:06 -070013#include <linux/atomic.h>
Ralf Baechle41c594a2006-04-05 09:45:45 +010014#include <asm/hardirq.h>
15#include <asm/mmu_context.h>
Ralf Baechle41c594a2006-04-05 09:45:45 +010016#include <asm/mipsregs.h>
17#include <asm/cacheflush.h>
18#include <linux/proc_fs.h>
19
20#include <asm/smtc_proc.h>
21
22/*
23 * /proc diagnostic and statistics hooks
24 */
25
26/*
27 * Statistics gathered
28 */
29unsigned long selfipis[NR_CPUS];
30
31struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
32
33static struct proc_dir_entry *smtc_stats;
34
35atomic_t smtc_fpu_recoveries;
36
37static int proc_read_smtc(char *page, char **start, off_t off,
Ralf Baechle70342282013-01-22 12:59:30 +010038 int count, int *eof, void *data)
Ralf Baechle41c594a2006-04-05 09:45:45 +010039{
40 int totalen = 0;
41 int len;
42 int i;
43 extern unsigned long ebase;
44
45 len = sprintf(page, "SMTC Status Word: 0x%08x\n", smtc_status);
46 totalen += len;
47 page += len;
48 len = sprintf(page, "Config7: 0x%08x\n", read_c0_config7());
49 totalen += len;
50 page += len;
51 len = sprintf(page, "EBASE: 0x%08lx\n", ebase);
52 totalen += len;
53 page += len;
54 len = sprintf(page, "Counter Interrupts taken per CPU (TC)\n");
55 totalen += len;
56 page += len;
57 for (i=0; i < NR_CPUS; i++) {
58 len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].timerints);
59 totalen += len;
60 page += len;
61 }
62 len = sprintf(page, "Self-IPIs by CPU:\n");
63 totalen += len;
64 page += len;
65 for(i = 0; i < NR_CPUS; i++) {
66 len = sprintf(page, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
67 totalen += len;
68 page += len;
69 }
70 len = sprintf(page, "%d Recoveries of \"stolen\" FPU\n",
Ralf Baechle70342282013-01-22 12:59:30 +010071 atomic_read(&smtc_fpu_recoveries));
Ralf Baechle41c594a2006-04-05 09:45:45 +010072 totalen += len;
73 page += len;
74
75 return totalen;
76}
77
78void init_smtc_stats(void)
79{
80 int i;
81
82 for (i=0; i<NR_CPUS; i++) {
83 smtc_cpu_stats[i].timerints = 0;
84 smtc_cpu_stats[i].selfipis = 0;
85 }
86
87 atomic_set(&smtc_fpu_recoveries, 0);
88
89 smtc_stats = create_proc_read_entry("smtc", 0444, NULL,
Ralf Baechle70342282013-01-22 12:59:30 +010090 proc_read_smtc, NULL);
Ralf Baechle41c594a2006-04-05 09:45:45 +010091}