[PATCH 3/3] ampere/arm64: instrument the altra workarounds

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is mostly a debugging aid to measure the impact of workarounds.

Signed-off-by: Alex Bennée <alex.bennee@xxxxxxxxxx>
---
 arch/arm64/include/asm/pgtable.h   |  2 ++
 arch/arm64/mm/fault.c              |  9 +++--
 arch/arm64/mm/ioremap.c            | 11 ++++++
 include/trace/events/altra_fixup.h | 57 ++++++++++++++++++++++++++++++
 4 files changed, 77 insertions(+), 2 deletions(-)
 create mode 100644 include/trace/events/altra_fixup.h

diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index f4603924390eb..26812b7fc6d93 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -679,6 +679,7 @@ static inline bool pud_table(pud_t pud) { return true; }
 
 #ifdef CONFIG_ALTRA_ERRATUM_82288
 extern bool __read_mostly have_altra_erratum_82288;
+void do_trace_altra_mkspecial(pte_t pte);
 #endif
 
 static inline pte_t pte_mkspecial(pte_t pte)
@@ -692,6 +693,7 @@ static inline pte_t pte_mkspecial(pte_t pte)
 	     (phys >= 0x200000000000 && phys < 0x400000000000) ||
 	     (phys >= 0x600000000000 && phys < 0x800000000000))) {
 		pte = __pte(__phys_to_pte_val(phys) | pgprot_val(pgprot_device(prot)));
+		do_trace_altra_mkspecial(pte);
 	}
 #endif
 
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 744e7b1664b1c..6cb3c600cc56a 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -45,6 +45,8 @@
 #include <asm/traps.h>
 #include <asm/patching.h>
 
+#include <trace/events/altra_fixup.h>
+
 struct fault_info {
 	/* fault handler, return 0 on successful handling */
 	int	(*fn)(unsigned long far, unsigned long esr,
@@ -1376,6 +1378,8 @@ static int fixup_alignment(unsigned long addr, unsigned int esr,
 	u32 insn;
 	int res;
 
+	trace_altra_fixup_alignment(addr, esr);
+
 	if (user_mode(regs)) {
 		__le32 insn_le;
 
@@ -1414,8 +1418,9 @@ static int do_alignment_fault(unsigned long far, unsigned long esr,
 			      struct pt_regs *regs)
 {
 #ifdef CONFIG_ALTRA_ERRATUM_82288
-	 if (!fixup_alignment(far, esr, regs))
-	 return 0;
+	if (!fixup_alignment(far, esr, regs)) {
+		return 0;
+	}
 #endif
 	if (IS_ENABLED(CONFIG_COMPAT_ALIGNMENT_FIXUPS) &&
 	    compat_user_mode(regs))
diff --git a/arch/arm64/mm/ioremap.c b/arch/arm64/mm/ioremap.c
index 8965766181359..d38d903d8a063 100644
--- a/arch/arm64/mm/ioremap.c
+++ b/arch/arm64/mm/ioremap.c
@@ -5,9 +5,19 @@
 
 #ifdef CONFIG_ALTRA_ERRATUM_82288
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/altra_fixup.h>
+
 bool have_altra_erratum_82288 __read_mostly;
 EXPORT_SYMBOL(have_altra_erratum_82288);
 
+void do_trace_altra_mkspecial(pte_t pte)
+{
+	trace_altra_mkspecial(pte);
+}
+EXPORT_SYMBOL(do_trace_altra_mkspecial);
+EXPORT_TRACEPOINT_SYMBOL(altra_mkspecial);
+
 static bool is_altra_pci(phys_addr_t phys_addr, size_t size)
 {
 	phys_addr_t end = phys_addr + size;
@@ -25,6 +35,7 @@ pgprot_t ioremap_map_prot(phys_addr_t phys_addr, size_t size,
 #ifdef CONFIG_ALTRA_ERRATUM_82288
 	if (unlikely(have_altra_erratum_82288 && is_altra_pci(phys_addr, size))) {
 		prot = pgprot_device(prot);
+		trace_altra_ioremap_prot(prot);
 	}
 #endif
 	return prot;
diff --git a/include/trace/events/altra_fixup.h b/include/trace/events/altra_fixup.h
new file mode 100644
index 0000000000000..73115740c5d84
--- /dev/null
+++ b/include/trace/events/altra_fixup.h
@@ -0,0 +1,57 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM altra_fixup
+
+#if !defined(_ALTERA_FIXUP_H_) || defined(TRACE_HEADER_MULTI_READ)
+#define _ALTRA_FIXUP_H_
+
+#include <linux/tracepoint.h>
+#include <linux/io.h>
+
+#ifdef CONFIG_ALTRA_ERRATUM_82288
+
+TRACE_EVENT(altra_fixup_alignment,
+	    TP_PROTO(unsigned long far, unsigned long esr),
+	    TP_ARGS(far, esr),
+	    TP_STRUCT__entry(
+		__field(unsigned long, far)
+		__field(unsigned long, esr)
+	    ),
+	    TP_fast_assign(
+		__entry->far = far;
+		__entry->esr = esr;
+	    ),
+	    TP_printk("far=0x%016lx esr=0x%016lx",
+		      __entry->far, __entry->esr)
+);
+
+TRACE_EVENT(altra_mkspecial,
+	    TP_PROTO(pte_t pte),
+	    TP_ARGS(pte),
+	    TP_STRUCT__entry(
+		__field(pteval_t, pte)
+	    ),
+	    TP_fast_assign(
+		__entry->pte = pte_val(pte);
+	    ),
+	    TP_printk("pte=0x%016llx", __entry->pte)
+);
+
+TRACE_EVENT(altra_ioremap_prot,
+	    TP_PROTO(pgprot_t prot),
+	    TP_ARGS(prot),
+	    TP_STRUCT__entry(
+		__field(pteval_t, pte)
+	    ),
+	    TP_fast_assign(
+		__entry->pte = pgprot_val(prot);
+	    ),
+	    TP_printk("prot=0x%016llx", __entry->pte)
+);
+
+#endif /* CONFIG_ALTRA_ERRATUM_82288 */
+
+#endif /* _ALTRA_FIXUP_H_ */
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
-- 
2.39.2





[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux