All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@redhat.com>
To: x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-sound@vger.kernel.org, platform-driver-x86@vger.kernel.org
Subject: [PATCH 3/4] bug: use the aural error reporting framework to report warnings
Date: Mon,  1 Apr 2019 12:24:54 +0200	[thread overview]
Message-ID: <20190401102456.11162-4-mcroce@redhat.com> (raw)
In-Reply-To: <20190401102456.11162-1-mcroce@redhat.com>

Use the new aural error reporting framework to signal kernel bugs. Emit the
sound at the end of the __warn(), so the WARN_* are all covered.
If panic_on_warn is set, panic() will play its sound and never return,
so there is no risk to emit two sounds or the wrong one.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 kernel/panic.c    | 18 ++++++++++++++++++
 lib/Kconfig.debug | 10 ++++++++++
 2 files changed, 28 insertions(+)

diff --git a/kernel/panic.c b/kernel/panic.c
index 360578e092e7..b87c4403924d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -81,6 +81,22 @@ static struct note panic_sound[] = {
 };
 #endif
 
+#ifdef CONFIG_AUDIBLE_WARN
+static struct note warn_sound[] = {
+	{ 440, 400 },
+	{ 440, 300 },
+	{ 440, 100 },
+	{ 440, 400 },
+	{ 523, 300 },
+	{ 494, 100 },
+	{ 494, 300 },
+	{ 440, 100 },
+	{ 440, 300 },
+	{ 440, 100 },
+	{ 440, 800 },
+};
+#endif
+
 static long no_blink(int state)
 {
 	return 0;
@@ -609,6 +625,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 
 	/* Just a warning, don't kill lockdep. */
 	add_taint(taint, LOCKDEP_STILL_OK);
+
+	play(warn_sound, ARRAY_SIZE(warn_sound));
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e5d187dfc74a..909c271d283b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1007,6 +1007,16 @@ config AUDIBLE_PANIC
 	  the system buzzer and not via any soundcard.
 	  Not available on all platforms.
 
+config AUDIBLE_WARN
+	bool "Aural warning"
+	select PLAY_LIB
+	default n
+	help
+	  If you say Y here, warnings will play a sound just
+	  after the stacktrace and registers dump. The sound is played via
+	  the system buzzer and not via any soundcard.
+	  Not available on all platforms.
+
 config SCHED_DEBUG
 	bool "Collect scheduler debugging info"
 	depends on DEBUG_KERNEL && PROC_FS
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Matteo Croce <mcroce@redhat.com>
To: x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	linux-sound@vger.kernel.org, platform-driver-x86@vger.kernel.org
Subject: [PATCH 3/4] bug: use the aural error reporting framework to report warnings
Date: Mon, 01 Apr 2019 10:24:54 +0000	[thread overview]
Message-ID: <20190401102456.11162-4-mcroce@redhat.com> (raw)
In-Reply-To: <20190401102456.11162-1-mcroce@redhat.com>

Use the new aural error reporting framework to signal kernel bugs. Emit the
sound at the end of the __warn(), so the WARN_* are all covered.
If panic_on_warn is set, panic() will play its sound and never return,
so there is no risk to emit two sounds or the wrong one.

Signed-off-by: Matteo Croce <mcroce@redhat.com>
---
 kernel/panic.c    | 18 ++++++++++++++++++
 lib/Kconfig.debug | 10 ++++++++++
 2 files changed, 28 insertions(+)

diff --git a/kernel/panic.c b/kernel/panic.c
index 360578e092e7..b87c4403924d 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -81,6 +81,22 @@ static struct note panic_sound[] = {
 };
 #endif
 
+#ifdef CONFIG_AUDIBLE_WARN
+static struct note warn_sound[] = {
+	{ 440, 400 },
+	{ 440, 300 },
+	{ 440, 100 },
+	{ 440, 400 },
+	{ 523, 300 },
+	{ 494, 100 },
+	{ 494, 300 },
+	{ 440, 100 },
+	{ 440, 300 },
+	{ 440, 100 },
+	{ 440, 800 },
+};
+#endif
+
 static long no_blink(int state)
 {
 	return 0;
@@ -609,6 +625,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint,
 
 	/* Just a warning, don't kill lockdep. */
 	add_taint(taint, LOCKDEP_STILL_OK);
+
+	play(warn_sound, ARRAY_SIZE(warn_sound));
 }
 
 #ifdef WANT_WARN_ON_SLOWPATH
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index e5d187dfc74a..909c271d283b 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -1007,6 +1007,16 @@ config AUDIBLE_PANIC
 	  the system buzzer and not via any soundcard.
 	  Not available on all platforms.
 
+config AUDIBLE_WARN
+	bool "Aural warning"
+	select PLAY_LIB
+	default n
+	help
+	  If you say Y here, warnings will play a sound just
+	  after the stacktrace and registers dump. The sound is played via
+	  the system buzzer and not via any soundcard.
+	  Not available on all platforms.
+
 config SCHED_DEBUG
 	bool "Collect scheduler debugging info"
 	depends on DEBUG_KERNEL && PROC_FS
-- 
2.20.1

  parent reply	other threads:[~2019-04-01 10:25 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-01 10:24 [PATCH 0/4] Introduce the aural error reporting framework Matteo Croce
2019-04-01 10:24 ` Matteo Croce
2019-04-01 10:24 ` [PATCH 1/4] " Matteo Croce
2019-04-01 10:24   ` Matteo Croce
2019-04-01 10:24 ` [PATCH 2/4] panic: use the aural error reporting framework to report panics Matteo Croce
2019-04-01 10:24   ` Matteo Croce
2019-04-01 10:24 ` Matteo Croce [this message]
2019-04-01 10:24   ` [PATCH 3/4] bug: use the aural error reporting framework to report warnings Matteo Croce
2019-04-01 10:24 ` [PATCH 4/4] oops: use the aural error reporting framework to report oopses Matteo Croce
2019-04-01 10:24   ` Matteo Croce
2019-04-01 10:24 ` [PATCH 5/4] procfs: utility handler to trigger different errors Matteo Croce
2019-04-01 10:24   ` Matteo Croce
2019-04-01 11:03 ` [PATCH 0/4] Introduce the aural error reporting framework Peter Zijlstra
2019-04-01 11:03   ` Peter Zijlstra
2019-04-02  8:49   ` Thomas Gleixner
2019-04-02  8:49     ` Thomas Gleixner
2019-04-02 11:50     ` Matteo Croce
2019-04-02 11:50       ` Matteo Croce
2019-04-02 13:21       ` Thomas Gleixner
2019-04-02 13:21         ` Thomas Gleixner
2019-04-01 13:45 ` Emiliano Russo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190401102456.11162-4-mcroce@redhat.com \
    --to=mcroce@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.