Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/cpumask.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/debugfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <linux/percpu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <asm/debug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <asm/fpu_emulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/local.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static int fpuemu_stat_get(void *data, u64 *val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	int cpu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 	unsigned long sum = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	for_each_online_cpu(cpu) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		struct mips_fpu_emulator_stats *ps;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		local_t *pv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 		ps = &per_cpu(fpuemustats, cpu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 		pv = (void *)ps + (unsigned long)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 		sum += local_read(pv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	*val = sum;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * Used to obtain names for a debugfs instruction counter, given field name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * in fpuemustats structure. For example, for input "cmp_sueq_d", the output
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * would be "cmp.sueq.d". This is needed since dots are not allowed to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * used in structure field names, and are, on the other hand, desired to be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * used in debugfs item names to be clearly associated to corresponding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  * MIPS FPU instructions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) static void adjust_instruction_counter_name(char *out_name, char *in_name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	strcpy(out_name, in_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	while (in_name[i] != '\0') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		if (out_name[i] == '_')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			out_name[i] = '.';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) static int fpuemustats_clear_show(struct seq_file *s, void *unused)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	__this_cpu_write((fpuemustats).emulated, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	__this_cpu_write((fpuemustats).loads, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	__this_cpu_write((fpuemustats).stores, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	__this_cpu_write((fpuemustats).branches, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	__this_cpu_write((fpuemustats).cp1ops, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	__this_cpu_write((fpuemustats).cp1xops, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	__this_cpu_write((fpuemustats).errors, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	__this_cpu_write((fpuemustats).ieee754_inexact, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	__this_cpu_write((fpuemustats).ieee754_underflow, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	__this_cpu_write((fpuemustats).ieee754_overflow, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	__this_cpu_write((fpuemustats).ieee754_zerodiv, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	__this_cpu_write((fpuemustats).ieee754_invalidop, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	__this_cpu_write((fpuemustats).ds_emul, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	__this_cpu_write((fpuemustats).abs_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	__this_cpu_write((fpuemustats).abs_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	__this_cpu_write((fpuemustats).add_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	__this_cpu_write((fpuemustats).add_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	__this_cpu_write((fpuemustats).bc1eqz, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	__this_cpu_write((fpuemustats).bc1nez, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	__this_cpu_write((fpuemustats).ceil_w_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	__this_cpu_write((fpuemustats).ceil_w_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	__this_cpu_write((fpuemustats).ceil_l_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	__this_cpu_write((fpuemustats).ceil_l_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	__this_cpu_write((fpuemustats).class_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	__this_cpu_write((fpuemustats).class_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	__this_cpu_write((fpuemustats).cmp_af_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	__this_cpu_write((fpuemustats).cmp_af_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	__this_cpu_write((fpuemustats).cmp_eq_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	__this_cpu_write((fpuemustats).cmp_eq_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	__this_cpu_write((fpuemustats).cmp_le_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	__this_cpu_write((fpuemustats).cmp_le_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	__this_cpu_write((fpuemustats).cmp_lt_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	__this_cpu_write((fpuemustats).cmp_lt_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	__this_cpu_write((fpuemustats).cmp_ne_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	__this_cpu_write((fpuemustats).cmp_ne_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	__this_cpu_write((fpuemustats).cmp_or_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	__this_cpu_write((fpuemustats).cmp_or_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	__this_cpu_write((fpuemustats).cmp_ueq_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	__this_cpu_write((fpuemustats).cmp_ueq_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	__this_cpu_write((fpuemustats).cmp_ule_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	__this_cpu_write((fpuemustats).cmp_ule_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	__this_cpu_write((fpuemustats).cmp_ult_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	__this_cpu_write((fpuemustats).cmp_ult_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	__this_cpu_write((fpuemustats).cmp_un_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	__this_cpu_write((fpuemustats).cmp_un_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 	__this_cpu_write((fpuemustats).cmp_une_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	__this_cpu_write((fpuemustats).cmp_une_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	__this_cpu_write((fpuemustats).cmp_saf_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	__this_cpu_write((fpuemustats).cmp_saf_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	__this_cpu_write((fpuemustats).cmp_seq_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	__this_cpu_write((fpuemustats).cmp_seq_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	__this_cpu_write((fpuemustats).cmp_sle_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	__this_cpu_write((fpuemustats).cmp_sle_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	__this_cpu_write((fpuemustats).cmp_slt_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	__this_cpu_write((fpuemustats).cmp_slt_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	__this_cpu_write((fpuemustats).cmp_sne_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 	__this_cpu_write((fpuemustats).cmp_sne_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	__this_cpu_write((fpuemustats).cmp_sor_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	__this_cpu_write((fpuemustats).cmp_sor_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	__this_cpu_write((fpuemustats).cmp_sueq_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	__this_cpu_write((fpuemustats).cmp_sueq_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	__this_cpu_write((fpuemustats).cmp_sule_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	__this_cpu_write((fpuemustats).cmp_sule_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	__this_cpu_write((fpuemustats).cmp_sult_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	__this_cpu_write((fpuemustats).cmp_sult_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	__this_cpu_write((fpuemustats).cmp_sun_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	__this_cpu_write((fpuemustats).cmp_sun_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	__this_cpu_write((fpuemustats).cmp_sune_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	__this_cpu_write((fpuemustats).cmp_sune_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	__this_cpu_write((fpuemustats).cvt_d_l, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	__this_cpu_write((fpuemustats).cvt_d_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 	__this_cpu_write((fpuemustats).cvt_d_w, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	__this_cpu_write((fpuemustats).cvt_l_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	__this_cpu_write((fpuemustats).cvt_l_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	__this_cpu_write((fpuemustats).cvt_s_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	__this_cpu_write((fpuemustats).cvt_s_l, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	__this_cpu_write((fpuemustats).cvt_s_w, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	__this_cpu_write((fpuemustats).cvt_w_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	__this_cpu_write((fpuemustats).cvt_w_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	__this_cpu_write((fpuemustats).div_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	__this_cpu_write((fpuemustats).div_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	__this_cpu_write((fpuemustats).floor_w_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	__this_cpu_write((fpuemustats).floor_w_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	__this_cpu_write((fpuemustats).floor_l_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	__this_cpu_write((fpuemustats).floor_l_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	__this_cpu_write((fpuemustats).maddf_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	__this_cpu_write((fpuemustats).maddf_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	__this_cpu_write((fpuemustats).max_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	__this_cpu_write((fpuemustats).max_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	__this_cpu_write((fpuemustats).maxa_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	__this_cpu_write((fpuemustats).maxa_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 	__this_cpu_write((fpuemustats).min_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	__this_cpu_write((fpuemustats).min_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	__this_cpu_write((fpuemustats).mina_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	__this_cpu_write((fpuemustats).mina_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	__this_cpu_write((fpuemustats).mov_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	__this_cpu_write((fpuemustats).mov_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	__this_cpu_write((fpuemustats).msubf_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	__this_cpu_write((fpuemustats).msubf_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	__this_cpu_write((fpuemustats).mul_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	__this_cpu_write((fpuemustats).mul_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	__this_cpu_write((fpuemustats).neg_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	__this_cpu_write((fpuemustats).neg_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	__this_cpu_write((fpuemustats).recip_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	__this_cpu_write((fpuemustats).recip_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	__this_cpu_write((fpuemustats).rint_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	__this_cpu_write((fpuemustats).rint_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	__this_cpu_write((fpuemustats).round_w_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	__this_cpu_write((fpuemustats).round_w_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	__this_cpu_write((fpuemustats).round_l_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	__this_cpu_write((fpuemustats).round_l_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	__this_cpu_write((fpuemustats).rsqrt_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	__this_cpu_write((fpuemustats).rsqrt_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	__this_cpu_write((fpuemustats).sel_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	__this_cpu_write((fpuemustats).sel_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	__this_cpu_write((fpuemustats).seleqz_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	__this_cpu_write((fpuemustats).seleqz_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	__this_cpu_write((fpuemustats).selnez_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	__this_cpu_write((fpuemustats).selnez_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	__this_cpu_write((fpuemustats).sqrt_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	__this_cpu_write((fpuemustats).sqrt_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	__this_cpu_write((fpuemustats).sub_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	__this_cpu_write((fpuemustats).sub_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	__this_cpu_write((fpuemustats).trunc_w_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	__this_cpu_write((fpuemustats).trunc_w_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	__this_cpu_write((fpuemustats).trunc_l_s, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	__this_cpu_write((fpuemustats).trunc_l_d, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) DEFINE_SHOW_ATTRIBUTE(fpuemustats_clear);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) static int __init debugfs_fpuemu(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	struct dentry *fpuemu_debugfs_base_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	struct dentry *fpuemu_debugfs_inst_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	char name[32];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	fpuemu_debugfs_base_dir = debugfs_create_dir("fpuemustats",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 						     mips_debugfs_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	debugfs_create_file("fpuemustats_clear", 0444, mips_debugfs_dir, NULL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 			    &fpuemustats_clear_fops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) #define FPU_EMU_STAT_OFFSET(m)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	offsetof(struct mips_fpu_emulator_stats, m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) #define FPU_STAT_CREATE(m)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	debugfs_create_file(#m, 0444, fpuemu_debugfs_base_dir,		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 				(void *)FPU_EMU_STAT_OFFSET(m),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 				&fops_fpuemu_stat);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	FPU_STAT_CREATE(emulated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	FPU_STAT_CREATE(loads);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	FPU_STAT_CREATE(stores);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	FPU_STAT_CREATE(branches);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	FPU_STAT_CREATE(cp1ops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	FPU_STAT_CREATE(cp1xops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	FPU_STAT_CREATE(errors);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	FPU_STAT_CREATE(ieee754_inexact);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	FPU_STAT_CREATE(ieee754_underflow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	FPU_STAT_CREATE(ieee754_overflow);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	FPU_STAT_CREATE(ieee754_zerodiv);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	FPU_STAT_CREATE(ieee754_invalidop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	FPU_STAT_CREATE(ds_emul);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 	fpuemu_debugfs_inst_dir = debugfs_create_dir("instructions",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 						     fpuemu_debugfs_base_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) #define FPU_STAT_CREATE_EX(m)						\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) do {									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	adjust_instruction_counter_name(name, #m);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 									\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	debugfs_create_file(name, 0444, fpuemu_debugfs_inst_dir,	\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 				(void *)FPU_EMU_STAT_OFFSET(m),		\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 				&fops_fpuemu_stat);			\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	FPU_STAT_CREATE_EX(abs_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	FPU_STAT_CREATE_EX(abs_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	FPU_STAT_CREATE_EX(add_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	FPU_STAT_CREATE_EX(add_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	FPU_STAT_CREATE_EX(bc1eqz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	FPU_STAT_CREATE_EX(bc1nez);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	FPU_STAT_CREATE_EX(ceil_w_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	FPU_STAT_CREATE_EX(ceil_w_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	FPU_STAT_CREATE_EX(ceil_l_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	FPU_STAT_CREATE_EX(ceil_l_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	FPU_STAT_CREATE_EX(class_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	FPU_STAT_CREATE_EX(class_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	FPU_STAT_CREATE_EX(cmp_af_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	FPU_STAT_CREATE_EX(cmp_af_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	FPU_STAT_CREATE_EX(cmp_eq_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	FPU_STAT_CREATE_EX(cmp_eq_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	FPU_STAT_CREATE_EX(cmp_le_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	FPU_STAT_CREATE_EX(cmp_le_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	FPU_STAT_CREATE_EX(cmp_lt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	FPU_STAT_CREATE_EX(cmp_lt_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	FPU_STAT_CREATE_EX(cmp_ne_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	FPU_STAT_CREATE_EX(cmp_ne_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 	FPU_STAT_CREATE_EX(cmp_or_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 	FPU_STAT_CREATE_EX(cmp_or_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 	FPU_STAT_CREATE_EX(cmp_ueq_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 	FPU_STAT_CREATE_EX(cmp_ueq_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 	FPU_STAT_CREATE_EX(cmp_ule_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	FPU_STAT_CREATE_EX(cmp_ule_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 	FPU_STAT_CREATE_EX(cmp_ult_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	FPU_STAT_CREATE_EX(cmp_ult_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	FPU_STAT_CREATE_EX(cmp_un_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	FPU_STAT_CREATE_EX(cmp_un_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	FPU_STAT_CREATE_EX(cmp_une_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	FPU_STAT_CREATE_EX(cmp_une_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	FPU_STAT_CREATE_EX(cmp_saf_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	FPU_STAT_CREATE_EX(cmp_saf_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 	FPU_STAT_CREATE_EX(cmp_seq_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	FPU_STAT_CREATE_EX(cmp_seq_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 	FPU_STAT_CREATE_EX(cmp_sle_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 	FPU_STAT_CREATE_EX(cmp_sle_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	FPU_STAT_CREATE_EX(cmp_slt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	FPU_STAT_CREATE_EX(cmp_slt_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	FPU_STAT_CREATE_EX(cmp_sne_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	FPU_STAT_CREATE_EX(cmp_sne_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	FPU_STAT_CREATE_EX(cmp_sor_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	FPU_STAT_CREATE_EX(cmp_sor_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	FPU_STAT_CREATE_EX(cmp_sueq_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	FPU_STAT_CREATE_EX(cmp_sueq_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	FPU_STAT_CREATE_EX(cmp_sule_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	FPU_STAT_CREATE_EX(cmp_sule_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	FPU_STAT_CREATE_EX(cmp_sult_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 	FPU_STAT_CREATE_EX(cmp_sult_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	FPU_STAT_CREATE_EX(cmp_sun_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	FPU_STAT_CREATE_EX(cmp_sun_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	FPU_STAT_CREATE_EX(cmp_sune_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	FPU_STAT_CREATE_EX(cmp_sune_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	FPU_STAT_CREATE_EX(cvt_d_l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	FPU_STAT_CREATE_EX(cvt_d_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	FPU_STAT_CREATE_EX(cvt_d_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 	FPU_STAT_CREATE_EX(cvt_l_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	FPU_STAT_CREATE_EX(cvt_l_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	FPU_STAT_CREATE_EX(cvt_s_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	FPU_STAT_CREATE_EX(cvt_s_l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	FPU_STAT_CREATE_EX(cvt_s_w);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 	FPU_STAT_CREATE_EX(cvt_w_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	FPU_STAT_CREATE_EX(cvt_w_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	FPU_STAT_CREATE_EX(div_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	FPU_STAT_CREATE_EX(div_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	FPU_STAT_CREATE_EX(floor_w_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	FPU_STAT_CREATE_EX(floor_w_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	FPU_STAT_CREATE_EX(floor_l_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	FPU_STAT_CREATE_EX(floor_l_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	FPU_STAT_CREATE_EX(maddf_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	FPU_STAT_CREATE_EX(maddf_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	FPU_STAT_CREATE_EX(max_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	FPU_STAT_CREATE_EX(max_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	FPU_STAT_CREATE_EX(maxa_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	FPU_STAT_CREATE_EX(maxa_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	FPU_STAT_CREATE_EX(min_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	FPU_STAT_CREATE_EX(min_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	FPU_STAT_CREATE_EX(mina_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	FPU_STAT_CREATE_EX(mina_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	FPU_STAT_CREATE_EX(mov_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	FPU_STAT_CREATE_EX(mov_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	FPU_STAT_CREATE_EX(msubf_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	FPU_STAT_CREATE_EX(msubf_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	FPU_STAT_CREATE_EX(mul_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	FPU_STAT_CREATE_EX(mul_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	FPU_STAT_CREATE_EX(neg_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	FPU_STAT_CREATE_EX(neg_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	FPU_STAT_CREATE_EX(recip_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	FPU_STAT_CREATE_EX(recip_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	FPU_STAT_CREATE_EX(rint_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	FPU_STAT_CREATE_EX(rint_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 	FPU_STAT_CREATE_EX(round_w_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	FPU_STAT_CREATE_EX(round_w_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	FPU_STAT_CREATE_EX(round_l_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	FPU_STAT_CREATE_EX(round_l_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	FPU_STAT_CREATE_EX(rsqrt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	FPU_STAT_CREATE_EX(rsqrt_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	FPU_STAT_CREATE_EX(sel_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	FPU_STAT_CREATE_EX(sel_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	FPU_STAT_CREATE_EX(seleqz_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	FPU_STAT_CREATE_EX(seleqz_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	FPU_STAT_CREATE_EX(selnez_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	FPU_STAT_CREATE_EX(selnez_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	FPU_STAT_CREATE_EX(sqrt_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	FPU_STAT_CREATE_EX(sqrt_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 	FPU_STAT_CREATE_EX(sub_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	FPU_STAT_CREATE_EX(sub_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 	FPU_STAT_CREATE_EX(trunc_w_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	FPU_STAT_CREATE_EX(trunc_w_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 	FPU_STAT_CREATE_EX(trunc_l_s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 	FPU_STAT_CREATE_EX(trunc_l_d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) arch_initcall(debugfs_fpuemu);