Subject: [PATCH] powerpc/64e: Fix perf hardlockup detector build

From: Nicholas Piggin <[email-masked]>
Date: Mon, 7 Aug 2017 18:02:57 +1000

This fixes a couple more bits of fallout when enabling the hardlockup
detector for 64e.

It restores the required hw_nmi_get_sample_period() function for the
perf watchdog, and restores disabling of the watchdog there. It also
removes API definitions that are only defined for 64s.

Fixes: 2104180a53 ("powerpc/64s: implement arch-specific hardlockup watchdog")
Signed-off-by: Nicholas Piggin <[email-masked]>
---

This patch should go on top of the previous:

http://patchwork.ozlabs.org/patch/796202/

 arch/powerpc/include/asm/nmi.h |  3 +--
 arch/powerpc/kernel/setup_64.c | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/include/asm/nmi.h b/arch/powerpc/include/asm/nmi.h
index 6f8e79cd35d8..3760150a0ff0 100644
--- a/arch/powerpc/include/asm/nmi.h
+++ b/arch/powerpc/include/asm/nmi.h
@@ -1,9 +1,8 @@
 #ifndef _ASM_NMI_H
 #define _ASM_NMI_H
 
-#ifdef CONFIG_HARDLOCKUP_DETECTOR
+#ifdef CONFIG_PPC_WATCHDOG
 extern void arch_touch_nmi_watchdog(void);
-
 extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask,
 					   bool exclude_self);
 #define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index af23d4b576ec..5db2ddd8c31d 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -751,3 +751,24 @@ unsigned long memory_block_size_bytes(void)
 struct ppc_pci_io ppc_pci_io;
 EXPORT_SYMBOL(ppc_pci_io);
 #endif
+
+#ifdef CONFIG_HARDLOCKUP_DETECTOR_PERF
+u64 hw_nmi_get_sample_period(int watchdog_thresh)
+{
+	return ppc_proc_freq * watchdog_thresh;
+}
+
+/*
+ * The perf based hardlockup detector breaks PMU event based branches and is
+ * likely to get false positives in KVM guests, so disable it by default.
+ * Book3S has a soft-nmi version based on the decrementer interrupt so it does
+ * not suffer from these problems.
+ */
+static int __init disable_hardlockup_detector(void)
+{
+	hardlockup_detector_disable();
+
+	return 0;
+}
+early_initcall(disable_hardlockup_detector);
+#endif
-- 
2.13.3