1*85c51c51SRalf Baechle #include <linux/cpumask.h> 2*85c51c51SRalf Baechle #include <linux/debugfs.h> 3*85c51c51SRalf Baechle #include <linux/fs.h> 4*85c51c51SRalf Baechle #include <linux/init.h> 5*85c51c51SRalf Baechle #include <linux/percpu.h> 6*85c51c51SRalf Baechle #include <linux/types.h> 7*85c51c51SRalf Baechle #include <asm/fpu_emulator.h> 8*85c51c51SRalf Baechle #include <asm/local.h> 9*85c51c51SRalf Baechle 10*85c51c51SRalf Baechle DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats); 11*85c51c51SRalf Baechle 12*85c51c51SRalf Baechle static int fpuemu_stat_get(void *data, u64 *val) 13*85c51c51SRalf Baechle { 14*85c51c51SRalf Baechle int cpu; 15*85c51c51SRalf Baechle unsigned long sum = 0; 16*85c51c51SRalf Baechle 17*85c51c51SRalf Baechle for_each_online_cpu(cpu) { 18*85c51c51SRalf Baechle struct mips_fpu_emulator_stats *ps; 19*85c51c51SRalf Baechle local_t *pv; 20*85c51c51SRalf Baechle 21*85c51c51SRalf Baechle ps = &per_cpu(fpuemustats, cpu); 22*85c51c51SRalf Baechle pv = (void *)ps + (unsigned long)data; 23*85c51c51SRalf Baechle sum += local_read(pv); 24*85c51c51SRalf Baechle } 25*85c51c51SRalf Baechle *val = sum; 26*85c51c51SRalf Baechle return 0; 27*85c51c51SRalf Baechle } 28*85c51c51SRalf Baechle DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n"); 29*85c51c51SRalf Baechle 30*85c51c51SRalf Baechle extern struct dentry *mips_debugfs_dir; 31*85c51c51SRalf Baechle static int __init debugfs_fpuemu(void) 32*85c51c51SRalf Baechle { 33*85c51c51SRalf Baechle struct dentry *d, *dir; 34*85c51c51SRalf Baechle 35*85c51c51SRalf Baechle if (!mips_debugfs_dir) 36*85c51c51SRalf Baechle return -ENODEV; 37*85c51c51SRalf Baechle dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir); 38*85c51c51SRalf Baechle if (!dir) 39*85c51c51SRalf Baechle return -ENOMEM; 40*85c51c51SRalf Baechle 41*85c51c51SRalf Baechle #define FPU_STAT_CREATE(M) \ 42*85c51c51SRalf Baechle do { \ 43*85c51c51SRalf Baechle d = debugfs_create_file(#M , S_IRUGO, dir, \ 44*85c51c51SRalf Baechle (void *)offsetof(struct mips_fpu_emulator_stats, M), \ 45*85c51c51SRalf Baechle &fops_fpuemu_stat); \ 46*85c51c51SRalf Baechle if (!d) \ 47*85c51c51SRalf Baechle return -ENOMEM; \ 48*85c51c51SRalf Baechle } while (0) 49*85c51c51SRalf Baechle 50*85c51c51SRalf Baechle FPU_STAT_CREATE(emulated); 51*85c51c51SRalf Baechle FPU_STAT_CREATE(loads); 52*85c51c51SRalf Baechle FPU_STAT_CREATE(stores); 53*85c51c51SRalf Baechle FPU_STAT_CREATE(cp1ops); 54*85c51c51SRalf Baechle FPU_STAT_CREATE(cp1xops); 55*85c51c51SRalf Baechle FPU_STAT_CREATE(errors); 56*85c51c51SRalf Baechle 57*85c51c51SRalf Baechle return 0; 58*85c51c51SRalf Baechle } 59*85c51c51SRalf Baechle __initcall(debugfs_fpuemu); 60