2014-04-16 07:46:11 +07:00
|
|
|
#include <linux/cpumask.h>
|
|
|
|
#include <linux/debugfs.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/percpu.h>
|
|
|
|
#include <linux/types.h>
|
2015-09-23 00:10:55 +07:00
|
|
|
#include <asm/debug.h>
|
2014-04-16 07:46:11 +07:00
|
|
|
#include <asm/fpu_emulator.h>
|
|
|
|
#include <asm/local.h>
|
|
|
|
|
|
|
|
DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
|
|
|
|
|
|
|
|
static int fpuemu_stat_get(void *data, u64 *val)
|
|
|
|
{
|
|
|
|
int cpu;
|
|
|
|
unsigned long sum = 0;
|
|
|
|
|
|
|
|
for_each_online_cpu(cpu) {
|
|
|
|
struct mips_fpu_emulator_stats *ps;
|
|
|
|
local_t *pv;
|
|
|
|
|
|
|
|
ps = &per_cpu(fpuemustats, cpu);
|
|
|
|
pv = (void *)ps + (unsigned long)data;
|
|
|
|
sum += local_read(pv);
|
|
|
|
}
|
|
|
|
*val = sum;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
|
|
|
|
|
2017-08-21 19:24:51 +07:00
|
|
|
static int fpuemustats_clear_show(struct seq_file *s, void *unused)
|
|
|
|
{
|
|
|
|
__this_cpu_write((fpuemustats).emulated, 0);
|
|
|
|
__this_cpu_write((fpuemustats).loads, 0);
|
|
|
|
__this_cpu_write((fpuemustats).stores, 0);
|
|
|
|
__this_cpu_write((fpuemustats).branches, 0);
|
|
|
|
__this_cpu_write((fpuemustats).cp1ops, 0);
|
|
|
|
__this_cpu_write((fpuemustats).cp1xops, 0);
|
|
|
|
__this_cpu_write((fpuemustats).errors, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ieee754_inexact, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ieee754_underflow, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ieee754_overflow, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ieee754_zerodiv, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ieee754_invalidop, 0);
|
|
|
|
__this_cpu_write((fpuemustats).ds_emul, 0);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int fpuemustats_clear_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, fpuemustats_clear_show, inode->i_private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations fpuemustats_clear_fops = {
|
|
|
|
.open = fpuemustats_clear_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
|
|
|
};
|
|
|
|
|
2014-04-16 07:46:11 +07:00
|
|
|
static int __init debugfs_fpuemu(void)
|
|
|
|
{
|
2017-08-21 19:24:51 +07:00
|
|
|
struct dentry *d, *dir, *reset_file;
|
2014-04-16 07:46:11 +07:00
|
|
|
|
|
|
|
if (!mips_debugfs_dir)
|
|
|
|
return -ENODEV;
|
|
|
|
dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
|
|
|
|
if (!dir)
|
|
|
|
return -ENOMEM;
|
2017-08-21 19:24:51 +07:00
|
|
|
reset_file = debugfs_create_file("fpuemustats_clear", 0444,
|
|
|
|
mips_debugfs_dir, NULL,
|
|
|
|
&fpuemustats_clear_fops);
|
|
|
|
if (!reset_file)
|
|
|
|
return -ENOMEM;
|
2014-04-16 07:46:11 +07:00
|
|
|
|
2014-04-16 16:00:12 +07:00
|
|
|
#define FPU_EMU_STAT_OFFSET(m) \
|
|
|
|
offsetof(struct mips_fpu_emulator_stats, m)
|
|
|
|
|
|
|
|
#define FPU_STAT_CREATE(m) \
|
|
|
|
do { \
|
|
|
|
d = debugfs_create_file(#m , S_IRUGO, dir, \
|
|
|
|
(void *)FPU_EMU_STAT_OFFSET(m), \
|
|
|
|
&fops_fpuemu_stat); \
|
|
|
|
if (!d) \
|
|
|
|
return -ENOMEM; \
|
|
|
|
} while (0)
|
2014-04-16 07:46:11 +07:00
|
|
|
|
|
|
|
FPU_STAT_CREATE(emulated);
|
|
|
|
FPU_STAT_CREATE(loads);
|
|
|
|
FPU_STAT_CREATE(stores);
|
2017-08-21 19:24:50 +07:00
|
|
|
FPU_STAT_CREATE(branches);
|
2014-04-16 07:46:11 +07:00
|
|
|
FPU_STAT_CREATE(cp1ops);
|
|
|
|
FPU_STAT_CREATE(cp1xops);
|
|
|
|
FPU_STAT_CREATE(errors);
|
2014-05-30 02:26:45 +07:00
|
|
|
FPU_STAT_CREATE(ieee754_inexact);
|
|
|
|
FPU_STAT_CREATE(ieee754_underflow);
|
|
|
|
FPU_STAT_CREATE(ieee754_overflow);
|
|
|
|
FPU_STAT_CREATE(ieee754_zerodiv);
|
|
|
|
FPU_STAT_CREATE(ieee754_invalidop);
|
2014-12-04 02:12:23 +07:00
|
|
|
FPU_STAT_CREATE(ds_emul);
|
2014-04-16 07:46:11 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2015-07-20 14:10:20 +07:00
|
|
|
arch_initcall(debugfs_fpuemu);
|