]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
powerpc/xmon: add debugfs entry for xmon
authorGuilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Wed, 22 Mar 2017 19:27:51 +0000 (16:27 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 27 Mar 2017 23:52:01 +0000 (10:52 +1100)
Currently the xmon debugger is set only via kernel boot command-line.
It's disabled by default, and can be enabled with "xmon=on" on the
command-line. Also, xmon may be accessed via sysrq mechanism.
But we cannot enable/disable xmon in runtime, it needs kernel reload.

This patch introduces a debugfs entry for xmon, allowing user to query
its current state and change it if desired. Basically, the "xmon" file
to read from/write to is under the debugfs mount point, on powerpc
directory. It's a simple attribute, value 0 meaning xmon is disabled
and value 1 the opposite. Writing these states to the file will take
immediate effect in the debugger.

Signed-off-by: Guilherme G. Piccoli <gpiccoli@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/xmon/xmon.c

index 25a32815f310cb7387e9e23d0fd33f71135ae822..0fab9d7349ebb887de2addce4c3cc712e2c5c24b 100644 (file)
 #include <linux/nmi.h>
 #include <linux/ctype.h>
 
+#ifdef CONFIG_DEBUG_FS
+#include <linux/debugfs.h>
+#endif
+
 #include <asm/ptrace.h>
 #include <asm/string.h>
 #include <asm/prom.h>
@@ -3316,6 +3320,33 @@ static int __init setup_xmon_sysrq(void)
 device_initcall(setup_xmon_sysrq);
 #endif /* CONFIG_MAGIC_SYSRQ */
 
+#ifdef CONFIG_DEBUG_FS
+static int xmon_dbgfs_set(void *data, u64 val)
+{
+       xmon_on = !!val;
+       xmon_init(xmon_on);
+
+       return 0;
+}
+
+static int xmon_dbgfs_get(void *data, u64 *val)
+{
+       *val = xmon_on;
+       return 0;
+}
+
+DEFINE_SIMPLE_ATTRIBUTE(xmon_dbgfs_ops, xmon_dbgfs_get,
+                       xmon_dbgfs_set, "%llu\n");
+
+static int __init setup_xmon_dbgfs(void)
+{
+       debugfs_create_file("xmon", 0600, powerpc_debugfs_root, NULL,
+                               &xmon_dbgfs_ops);
+       return 0;
+}
+device_initcall(setup_xmon_dbgfs);
+#endif /* CONFIG_DEBUG_FS */
+
 static int xmon_early __initdata;
 
 static int __init early_parse_xmon(char *p)