linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mikko Perttunen <mperttunen@nvidia.com>
To: catalin.marinas@arm.com, will@kernel.org,
	thierry.reding@gmail.com, jonathanh@nvidia.com
Cc: linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
	Mikko Perttunen <mperttunen@nvidia.com>
Subject: [PATCH 1/2] arm64: traps: Support for registering SError hooks
Date: Thu, 17 Jun 2021 13:40:52 +0300	[thread overview]
Message-ID: <20210617104053.765434-1-mperttunen@nvidia.com> (raw)

Add the ability for drivers to register SError hooks to be run
on a fatal SError interrupt. This allows printing of system-specific
error information to aid with debugging.

Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
 arch/arm64/include/asm/traps.h |  6 ++++++
 arch/arm64/kernel/traps.c      | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/arch/arm64/include/asm/traps.h b/arch/arm64/include/asm/traps.h
index 54f32a0675df..054fecfa22f0 100644
--- a/arch/arm64/include/asm/traps.h
+++ b/arch/arm64/include/asm/traps.h
@@ -22,8 +22,14 @@ struct undef_hook {
 	int (*fn)(struct pt_regs *regs, u32 instr);
 };
 
+struct serror_hook {
+	struct list_head node;
+	void (*fn)(void);
+};
+
 void register_undef_hook(struct undef_hook *hook);
 void unregister_undef_hook(struct undef_hook *hook);
+void register_serror_hook(struct serror_hook *hook);
 void force_signal_inject(int signal, int code, unsigned long address, unsigned int err);
 void arm64_notify_segfault(unsigned long addr);
 void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *str);
diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c
index 273066279bb5..02dbaab71ea3 100644
--- a/arch/arm64/kernel/traps.c
+++ b/arch/arm64/kernel/traps.c
@@ -890,8 +890,23 @@ void panic_bad_stack(struct pt_regs *regs, unsigned int esr, unsigned long far)
 }
 #endif
 
+static LIST_HEAD(serror_hook);
+static DEFINE_RAW_SPINLOCK(serror_lock);
+
+void register_serror_hook(struct serror_hook *hook)
+{
+	unsigned long flags;
+
+	raw_spin_lock_irqsave(&serror_lock, flags);
+	list_add(&hook->node, &serror_hook);
+	raw_spin_unlock_irqrestore(&serror_lock, flags);
+}
+
 void __noreturn arm64_serror_panic(struct pt_regs *regs, u32 esr)
 {
+	struct serror_hook *hook;
+	unsigned long flags;
+
 	console_verbose();
 
 	pr_crit("SError Interrupt on CPU%d, code 0x%08x -- %s\n",
@@ -899,6 +914,11 @@ void __noreturn arm64_serror_panic(struct pt_regs *regs, u32 esr)
 	if (regs)
 		__show_regs(regs);
 
+	raw_spin_lock_irqsave(&serror_lock, flags);
+	list_for_each_entry(hook, &serror_hook, node)
+		hook->fn();
+	raw_spin_unlock_irqrestore(&serror_lock, flags);
+
 	nmi_panic(regs, "Asynchronous SError Interrupt");
 
 	cpu_park_loop();
-- 
2.30.1


             reply	other threads:[~2021-06-17 10:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-17 10:40 Mikko Perttunen [this message]
2021-06-17 10:40 ` [PATCH 2/2] soc: tegra: Add Tegra186 ARI driver Mikko Perttunen
2021-06-17 11:46 ` [PATCH 1/2] arm64: traps: Support for registering SError hooks Mark Rutland
2021-06-17 12:03   ` Mikko Perttunen

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=20210617104053.765434-1-mperttunen@nvidia.com \
    --to=mperttunen@nvidia.com \
    --cc=catalin.marinas@arm.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=will@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).