aboutsummaryrefslogtreecommitdiffstats
path: root/features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch
diff options
context:
space:
mode:
Diffstat (limited to 'features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch')
-rw-r--r--features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch b/features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch
new file mode 100644
index 00000000..c1a46aa5
--- /dev/null
+++ b/features/clear_warn_once/clear_warn_once-expand-debugfs-to-include-read-suppo.patch
@@ -0,0 +1,77 @@
+From 2365198f516a84982bca08e7b3f862d264b7a17e Mon Sep 17 00:00:00 2001
+From: Paul Gortmaker <paul.gortmaker@windriver.com>
+Date: Wed, 16 Dec 2020 12:22:56 -0500
+Subject: [PATCH 1/3] clear_warn_once: expand debugfs to include read support
+
+The existing clear_warn_once variable is write-only; used as per the
+documentation to reset the warn_once to as-booted state with:
+
+ echo 1 > /sys/kernel/debug/clear_warn_once
+
+The objective is to expand on that functionality, which requires the
+debugfs variable to be read/write and not just write-only.
+
+Here, we deal with the debugfs boilerplate associated with converting
+it from write-only to read-write, in order to factor that out for easier
+review, and for what may be a possible future useful bisect point.
+
+Existing functionality is unchanged - the only difference is that we
+have tied in a variable that lets you now read the variable and see
+the last value written.
+
+Link: https://lore.kernel.org/r/20201126063029.2030-1-paul.gortmaker@windriver.com
+Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
+Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
+---
+ kernel/panic.c | 25 ++++++++++++++++++++-----
+ 1 file changed, 20 insertions(+), 5 deletions(-)
+
+diff --git a/kernel/panic.c b/kernel/panic.c
+index f470a038b05b..53088219d7df 100644
+--- a/kernel/panic.c
++++ b/kernel/panic.c
+@@ -635,21 +635,36 @@ EXPORT_SYMBOL(__warn_printk);
+
+ /* Support resetting WARN*_ONCE state */
+
+-static int clear_warn_once_set(void *data, u64 val)
++static u64 clear_warn_once;
++
++static void do_clear_warn_once(void)
+ {
+ generic_bug_clear_once();
+ memset(__start_once, 0, __end_once - __start_once);
++}
++
++static int warn_once_get(void *data, u64 *val)
++{
++ *val = clear_warn_once;
++ return 0;
++}
++
++static int warn_once_set(void *data, u64 val)
++{
++ clear_warn_once = val;
++
++ do_clear_warn_once();
+ return 0;
+ }
+
+-DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, NULL, clear_warn_once_set,
+- "%lld\n");
++DEFINE_DEBUGFS_ATTRIBUTE(clear_warn_once_fops, warn_once_get, warn_once_set,
++ "%llu\n");
+
+ static __init int register_warn_debugfs(void)
+ {
+ /* Don't care about failure */
+- debugfs_create_file_unsafe("clear_warn_once", 0200, NULL, NULL,
+- &clear_warn_once_fops);
++ debugfs_create_file_unsafe("clear_warn_once", 0600, NULL,
++ &clear_warn_once, &clear_warn_once_fops);
+ return 0;
+ }
+
+--
+2.19.1
+