summaryrefslogtreecommitdiff
path: root/arch/mips/math-emu/me-debugfs.c
diff options
context:
space:
mode:
authorAleksandar Markovic <aleksandar.markovic@imgtec.com>2017-08-21 15:24:51 +0300
committerRalf Baechle <ralf@linux-mips.org>2017-08-29 16:21:57 +0300
commit25ad8db632ec54c60daad9107ddf25a2a608a450 (patch)
tree51efd0b8e1eb701820e6081dabeda8988bd610c4 /arch/mips/math-emu/me-debugfs.c
parentae5f3f5b81dd2c776f0ad49d6d121ce1255b35eb (diff)
downloadlinux-25ad8db632ec54c60daad9107ddf25a2a608a450.tar.xz
MIPS: math-emu: Add FP emu debugfs clear functionality
Add capability for the user to clear all FP emu debugfs counters. This is achieved by having a special debugfs file "fpuemustats_clear" (under default location "/sys/kernel/debug/mips"). Each access to the file results in setting all counters to zero (it is enough, let's say, to issue a "cat /sys/kernel/debug/mips/fpuemustats_clear"). This functionality already exists for R2 emulation statistics, but was missing for FP emulation statistics. The implementation in this patch is consistent with its R2 emulation counterpart. Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Goran Ferenc <goran.ferenc@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Cc: Douglas Leung <douglas.leung@imgtec.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: Paul Burton <paul.burton@imgtec.com> Cc: Petar Jovanovic <petar.jovanovic@imgtec.com> Cc: Raghu Gandham <raghu.gandham@imgtec.com> Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/17144/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/me-debugfs.c')
-rw-r--r--arch/mips/math-emu/me-debugfs.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/arch/mips/math-emu/me-debugfs.c b/arch/mips/math-emu/me-debugfs.c
index 78b26c8dc697..f080493ba743 100644
--- a/arch/mips/math-emu/me-debugfs.c
+++ b/arch/mips/math-emu/me-debugfs.c
@@ -28,15 +28,51 @@ static int fpuemu_stat_get(void *data, u64 *val)
}
DEFINE_SIMPLE_ATTRIBUTE(fops_fpuemu_stat, fpuemu_stat_get, NULL, "%llu\n");
+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,
+};
+
static int __init debugfs_fpuemu(void)
{
- struct dentry *d, *dir;
+ struct dentry *d, *dir, *reset_file;
if (!mips_debugfs_dir)
return -ENODEV;
dir = debugfs_create_dir("fpuemustats", mips_debugfs_dir);
if (!dir)
return -ENOMEM;
+ reset_file = debugfs_create_file("fpuemustats_clear", 0444,
+ mips_debugfs_dir, NULL,
+ &fpuemustats_clear_fops);
+ if (!reset_file)
+ return -ENOMEM;
#define FPU_EMU_STAT_OFFSET(m) \
offsetof(struct mips_fpu_emulator_stats, m)