* [PATCH 1/2] arm64: traps: Support for registering SError hooks
@ 2021-06-17 10:40 Mikko Perttunen
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
0 siblings, 2 replies; 4+ messages in thread
From: Mikko Perttunen @ 2021-06-17 10:40 UTC (permalink / raw)
To: catalin.marinas, will, thierry.reding, jonathanh
Cc: linux-arm-kernel, linux-kernel, linux-tegra, Mikko Perttunen
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
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] soc: tegra: Add Tegra186 ARI driver
2021-06-17 10:40 [PATCH 1/2] arm64: traps: Support for registering SError hooks Mikko Perttunen
@ 2021-06-17 10:40 ` Mikko Perttunen
2021-06-17 11:46 ` [PATCH 1/2] arm64: traps: Support for registering SError hooks Mark Rutland
1 sibling, 0 replies; 4+ messages in thread
From: Mikko Perttunen @ 2021-06-17 10:40 UTC (permalink / raw)
To: catalin.marinas, will, thierry.reding, jonathanh
Cc: linux-arm-kernel, linux-kernel, linux-tegra, Mikko Perttunen
Add a driver to hook into SError interrupts and print machine check
status for debugging. Status information is retrieved via SMC. This
is supported by upstream ARM Trusted Firmware.
Signed-off-by: Mikko Perttunen <mperttunen@nvidia.com>
---
drivers/soc/tegra/Makefile | 1 +
drivers/soc/tegra/ari-tegra186.c | 78 ++++++++++++++++++++++++++++++++
2 files changed, 79 insertions(+)
create mode 100644 drivers/soc/tegra/ari-tegra186.c
diff --git a/drivers/soc/tegra/Makefile b/drivers/soc/tegra/Makefile
index 9c809c1814bd..054e862b63d8 100644
--- a/drivers/soc/tegra/Makefile
+++ b/drivers/soc/tegra/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_SOC_TEGRA_PMC) += pmc.o
obj-$(CONFIG_SOC_TEGRA_POWERGATE_BPMP) += powergate-bpmp.o
obj-$(CONFIG_SOC_TEGRA20_VOLTAGE_COUPLER) += regulators-tegra20.o
obj-$(CONFIG_SOC_TEGRA30_VOLTAGE_COUPLER) += regulators-tegra30.o
+obj-$(CONFIG_ARCH_TEGRA_186_SOC) += ari-tegra186.o
diff --git a/drivers/soc/tegra/ari-tegra186.c b/drivers/soc/tegra/ari-tegra186.c
new file mode 100644
index 000000000000..51b95af1dc78
--- /dev/null
+++ b/drivers/soc/tegra/ari-tegra186.c
@@ -0,0 +1,78 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
+ */
+
+#include <linux/arm-smccc.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+
+#include <asm/traps.h>
+
+#define SMC_SIP_INVOKE_MCE 0xc2ffff00
+#define MCE_SMC_READ_MCA 12
+
+#define MCA_ARI_CMD_RD_SERR 1
+
+#define MCA_ARI_RW_SUBIDX_STAT 1
+#define SERR_STATUS_VAL BIT_ULL(63)
+
+#define MCA_ARI_RW_SUBIDX_ADDR 2
+#define MCA_ARI_RW_SUBIDX_MSC1 3
+#define MCA_ARI_RW_SUBIDX_MSC2 4
+
+static const char * const bank_names[] = {
+ "SYS:DPMU", "ROC:IOB", "ROC:MCB", "ROC:CCE", "ROC:CQX", "ROC:CTU",
+};
+
+static void read_uncore_mca(u8 cmd, u8 idx, u8 subidx, u8 inst, u64 *data)
+{
+ struct arm_smccc_res res;
+
+ arm_smccc_smc(SMC_SIP_INVOKE_MCE | MCE_SMC_READ_MCA,
+ ((u64)inst << 24) | ((u64)idx << 16) |
+ ((u64)subidx << 8) | ((u64)cmd << 0),
+ 0, 0, 0, 0, 0, 0, &res);
+
+ *data = res.a2;
+}
+
+static void tegra186_ari_process_serror(void)
+{
+ u64 status;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(bank_names); i++) {
+ read_uncore_mca(MCA_ARI_CMD_RD_SERR, i, MCA_ARI_RW_SUBIDX_STAT,
+ 0, &status);
+
+ if (status & SERR_STATUS_VAL) {
+ u64 addr, misc1, misc2;
+
+ read_uncore_mca(MCA_ARI_CMD_RD_SERR, i,
+ MCA_ARI_RW_SUBIDX_ADDR, 0, &addr);
+ read_uncore_mca(MCA_ARI_CMD_RD_SERR, i,
+ MCA_ARI_RW_SUBIDX_MSC1, 0, &misc1);
+ read_uncore_mca(MCA_ARI_CMD_RD_SERR, i,
+ MCA_ARI_RW_SUBIDX_MSC2, 0, &misc2);
+
+ pr_crit("Machine Check Error in %s\n"
+ " status=0x%llx addr=0x%llx\n"
+ " msc1=0x%llx msc2=0x%llx\n",
+ bank_names[i], status, addr, misc1, misc2);
+ }
+ }
+}
+
+static struct serror_hook tegra186_ari_serror_hook = {
+ .fn = tegra186_ari_process_serror,
+};
+
+static int __init tegra186_ari_init(void)
+{
+ if (of_machine_is_compatible("nvidia,tegra186"))
+ register_serror_hook(&tegra186_ari_serror_hook);
+
+ return 0;
+}
+early_initcall(tegra186_ari_init);
--
2.30.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] arm64: traps: Support for registering SError hooks
2021-06-17 10:40 [PATCH 1/2] arm64: traps: Support for registering SError hooks Mikko Perttunen
2021-06-17 10:40 ` [PATCH 2/2] soc: tegra: Add Tegra186 ARI driver Mikko Perttunen
@ 2021-06-17 11:46 ` Mark Rutland
2021-06-17 12:03 ` Mikko Perttunen
1 sibling, 1 reply; 4+ messages in thread
From: Mark Rutland @ 2021-06-17 11:46 UTC (permalink / raw)
To: Mikko Perttunen
Cc: catalin.marinas, will, thierry.reding, jonathanh,
linux-arm-kernel, linux-kernel, linux-tegra
On Thu, Jun 17, 2021 at 01:40:52PM +0300, Mikko Perttunen wrote:
> 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>
Can't you dump information unconditionally in a panic notifier?
That wouldn't require any new infrastructure.
Thanks,
Mark.
> ---
> 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
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] arm64: traps: Support for registering SError hooks
2021-06-17 11:46 ` [PATCH 1/2] arm64: traps: Support for registering SError hooks Mark Rutland
@ 2021-06-17 12:03 ` Mikko Perttunen
0 siblings, 0 replies; 4+ messages in thread
From: Mikko Perttunen @ 2021-06-17 12:03 UTC (permalink / raw)
To: Mark Rutland, Mikko Perttunen
Cc: catalin.marinas, will, thierry.reding, jonathanh,
linux-arm-kernel, linux-kernel, linux-tegra
On 6/17/21 2:46 PM, Mark Rutland wrote:
> On Thu, Jun 17, 2021 at 01:40:52PM +0300, Mikko Perttunen wrote:
>> 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>
>
> Can't you dump information unconditionally in a panic notifier?
>
> That wouldn't require any new infrastructure.
That does indeed work also, thanks for the tip! Will change to use those.
Thanks,
Mikko
>
> Thanks,
> Mark.
>
>> ---
>> 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
>>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-17 12:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-17 10:40 [PATCH 1/2] arm64: traps: Support for registering SError hooks Mikko Perttunen
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
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).