aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2014-04-15 20:46:11 -0400
committerRalf Baechle <ralf@linux-mips.org>2014-05-21 05:12:55 -0400
commit85c51c511d6373d4bc859458fd3f130015db31a5 (patch)
treec0b1076aba628760c3a9da5c46b818d2158634ad /arch
parent6d18b6246d2bfb9da2d342553e41565e14422089 (diff)
MIPS: math-emu: Move all debug fs code to a separate file.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/mips/math-emu/Makefile2
-rw-r--r--arch/mips/math-emu/cp1emu.c57
-rw-r--r--arch/mips/math-emu/me-debugfs.c59
3 files changed, 62 insertions, 56 deletions
diff --git a/arch/mips/math-emu/Makefile b/arch/mips/math-emu/Makefile
index 121a848a3594..0803970dfc16 100644
--- a/arch/mips/math-emu/Makefile
+++ b/arch/mips/math-emu/Makefile
@@ -9,3 +9,5 @@ obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
9 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \ 9 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
10 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \ 10 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
11 dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o 11 dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
12
13obj-$(CONFIG_DEBUG_FS) += me-debugfs.o
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 3ef9d99a729e..c4b855e7b0e0 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -35,6 +35,7 @@
35 */ 35 */
36#include <linux/sched.h> 36#include <linux/sched.h>
37#include <linux/debugfs.h> 37#include <linux/debugfs.h>
38#include <linux/percpu-defs.h>
38#include <linux/perf_event.h> 39#include <linux/perf_event.h>
39 40
40#include <asm/branch.h> 41#include <asm/branch.h>
@@ -66,12 +67,6 @@ static int fpux_emu(struct pt_regs *,
66 struct mips_fpu_struct *, mips_instruction, void *__user *); 67 struct mips_fpu_struct *, mips_instruction, void *__user *);
67#endif 68#endif
68 69
69/* Further private data for which no space exists in mips_fpu_struct */
70
71#ifdef CONFIG_DEBUG_FS
72DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
73#endif
74
75/* Control registers */ 70/* Control registers */
76 71
77#define FPCREG_RID 0 /* $0 = revision id */ 72#define FPCREG_RID 0 /* $0 = revision id */
@@ -2158,53 +2153,3 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
2158 2153
2159 return sig; 2154 return sig;
2160} 2155}
2161
2162#ifdef CONFIG_DEBUG_FS
2163
2164static int fpuemu_stat_get(void *data, u64 *val)
2165{
2166 int cpu;
2167 unsigned long sum = 0;
2168 for_each_online_cpu(cpu) {
2169 struct mips_fpu_emulator_stats *ps;
2170 local_t *pv;
2171 ps = &per_cpu(fpuemustats, cpu);
2172 pv = (void *)ps + (unsigned long)data;
2173 sum += local_read(pv);
2174 }
2175 *val = sum;
2176 return 0;
2177}
2178DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
2179
2180extern struct dentry *mips_debugfs_dir;
2181static int __init debugfs_fpuemu(void)
2182{
2183 struct dentry *d, *dir;
2184
2185 if (!mips_debugfs_dir)
2186 return -ENODEV;
2187 dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
2188 if (!dir)
2189 return -ENOMEM;
2190
2191#define FPU_STAT_CREATE(M) \
2192 do { \
2193 d = debugfs_create_file(#M , S_IRUGO, dir, \
2194 (void *)offsetof(struct mips_fpu_emulator_stats, M), \
2195 &fops_fpuemu_stat); \
2196 if (!d) \
2197 return -ENOMEM; \
2198 } while (0)
2199
2200 FPU_STAT_CREATE(emulated);
2201 FPU_STAT_CREATE(loads);
2202 FPU_STAT_CREATE(stores);
2203 FPU_STAT_CREATE(cp1ops);
2204 FPU_STAT_CREATE(cp1xops);
2205 FPU_STAT_CREATE(errors);
2206
2207 return 0;
2208}
2209__initcall(debugfs_fpuemu);
2210#endif
diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c
new file mode 100644
index 000000000000..d895b38773df
--- /dev/null
+++ b/arch/mips/math-emu/me-debugfs.c
@@ -0,0 +1,59 @@
1#include <linux/cpumask.h>
2#include <linux/debugfs.h>
3#include <linux/fs.h>
4#include <linux/init.h>
5#include <linux/percpu.h>
6#include <linux/types.h>
7#include <asm/fpu_emulator.h>
8#include <asm/local.h>
9
10DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
11
12static int fpuemu_stat_get(void *data, u64 *val)
13{
14 int cpu;
15 unsigned long sum = 0;
16
17 for_each_online_cpu(cpu) {
18 struct mips_fpu_emulator_stats *ps;
19 local_t *pv;
20
21 ps = &per_cpu(fpuemustats, cpu);
22 pv = (void *)ps + (unsigned long)data;
23 sum += local_read(pv);
24 }
25 *val = sum;
26 return 0;
27}
28DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
29
30extern struct dentry *mips_debugfs_dir;
31static int __init debugfs_fpuemu(void)
32{
33 struct dentry *d, *dir;
34
35 if (!mips_debugfs_dir)
36 return -ENODEV;
37 dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
38 if (!dir)
39 return -ENOMEM;
40
41#define FPU_STAT_CREATE(M) \
42 do { \
43 d = debugfs_create_file(#M , S_IRUGO, dir, \
44 (void *)offsetof(struct mips_fpu_emulator_stats, M), \
45 &fops_fpuemu_stat); \
46 if (!d) \
47 return -ENOMEM; \
48 } while (0)
49
50 FPU_STAT_CREATE(emulated);
51 FPU_STAT_CREATE(loads);
52 FPU_STAT_CREATE(stores);
53 FPU_STAT_CREATE(cp1ops);
54 FPU_STAT_CREATE(cp1xops);
55 FPU_STAT_CREATE(errors);
56
57 return 0;
58}
59__initcall(debugfs_fpuemu);