| 
									
										
										
										
											2014-04-16 02:46:11 +02: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>
 | 
					
						
							|  |  |  | #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"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | extern struct dentry *mips_debugfs_dir; | 
					
						
							|  |  |  | static int __init debugfs_fpuemu(void) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	struct dentry *d, *dir; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	if (!mips_debugfs_dir) | 
					
						
							|  |  |  | 		return -ENODEV; | 
					
						
							|  |  |  | 	dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir); | 
					
						
							|  |  |  | 	if (!dir) | 
					
						
							|  |  |  | 		return -ENOMEM; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-16 11:00:12 +02: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 02:46:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(emulated); | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(loads); | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(stores); | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(cp1ops); | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(cp1xops); | 
					
						
							|  |  |  | 	FPU_STAT_CREATE(errors); | 
					
						
							| 
									
										
										
										
											2014-05-29 12: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-04-16 02:46:11 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | __initcall(debugfs_fpuemu); |