blob: 78b26c8dc697fefa651efbe506326c4e44ea105e [file] [log] [blame]
Ralf Baechle85c51c52014-04-16 02:46:11 +02001#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>
Paul Burton75dcfc12015-09-22 10:10:55 -07007#include <asm/debug.h>
Ralf Baechle85c51c52014-04-16 02:46:11 +02008#include <asm/fpu_emulator.h>
9#include <asm/local.h>
10
11DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
12
13static int fpuemu_stat_get(void *data, u64 *val)
14{
15 int cpu;
16 unsigned long sum = 0;
17
18 for_each_online_cpu(cpu) {
19 struct mips_fpu_emulator_stats *ps;
20 local_t *pv;
21
22 ps = &per_cpu(fpuemustats, cpu);
23 pv = (void *)ps + (unsigned long)data;
24 sum += local_read(pv);
25 }
26 *val = sum;
27 return 0;
28}
29DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
30
Ralf Baechle85c51c52014-04-16 02:46:11 +020031static 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
Ralf Baechle47fa0c02014-04-16 11:00:12 +020041#define FPU_EMU_STAT_OFFSET(m) \
42 offsetof(struct mips_fpu_emulator_stats, m)
43
44#define FPU_STAT_CREATE(m) \
45do { \
46 d = debugfs_create_file(#m , S_IRUGO, dir, \
47 (void *)FPU_EMU_STAT_OFFSET(m), \
48 &fops_fpuemu_stat); \
49 if (!d) \
50 return -ENOMEM; \
51} while (0)
Ralf Baechle85c51c52014-04-16 02:46:11 +020052
53 FPU_STAT_CREATE(emulated);
54 FPU_STAT_CREATE(loads);
55 FPU_STAT_CREATE(stores);
Aleksandar Markovicae5f3f52017-08-21 14:24:50 +020056 FPU_STAT_CREATE(branches);
Ralf Baechle85c51c52014-04-16 02:46:11 +020057 FPU_STAT_CREATE(cp1ops);
58 FPU_STAT_CREATE(cp1xops);
59 FPU_STAT_CREATE(errors);
Deng-Cheng Zhuc4103522014-05-29 12:26:45 -070060 FPU_STAT_CREATE(ieee754_inexact);
61 FPU_STAT_CREATE(ieee754_underflow);
62 FPU_STAT_CREATE(ieee754_overflow);
63 FPU_STAT_CREATE(ieee754_zerodiv);
64 FPU_STAT_CREATE(ieee754_invalidop);
David Daney2707cd22014-12-03 11:12:23 -080065 FPU_STAT_CREATE(ds_emul);
Ralf Baechle85c51c52014-04-16 02:46:11 +020066
67 return 0;
68}
Ralf Baechle1249ed32015-07-20 09:10:20 +020069arch_initcall(debugfs_fpuemu);