watchdog: Move watchdog from being x86 specific to common code
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 13 Aug 2013 12:29:00 +0000 (14:29 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 13 Aug 2013 12:29:00 +0000 (14:29 +0200)
Augment watchdog_setup() to be able to possibly return an error, and introduce
watchdog_enabled() as a better alternative to knowing the architectures
internal details.

This patch does not change the x86 implementaion, beyond making it compile.

For header files, some includes of xen/nmi.h were only for the watchdog
functions, so are replaced rather than adding an extra include of
xen/watchdog.h

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
12 files changed:
xen/arch/x86/nmi.c
xen/arch/x86/setup.c
xen/arch/x86/shutdown.c
xen/arch/x86/traps.c
xen/arch/x86/x86_64/traps.c
xen/common/kexec.c
xen/common/keyhandler.c
xen/common/shutdown.c
xen/drivers/char/console.c
xen/include/asm-x86/config.h
xen/include/asm-x86/nmi.h
xen/include/xen/watchdog.h [new file with mode: 0644]

index c93812f0f956e2cc566ef2b1ed61e7e94bc70440..3eb245683684777f8902f8aa9e77cb380546fc9a 100644 (file)
@@ -410,7 +410,12 @@ void watchdog_enable(void)
     atomic_dec(&watchdog_disable_count);
 }
 
-void __init watchdog_setup(void)
+bool_t watchdog_enabled(void)
+{
+    return !atomic_read(&watchdog_disable_count);
+}
+
+int __init watchdog_setup(void)
 {
     unsigned int cpu;
 
@@ -423,6 +428,7 @@ void __init watchdog_setup(void)
     register_cpu_notifier(&cpu_nmi_nfb);
 
     watchdog_enable();
+    return 0;
 }
 
 void nmi_watchdog_tick(struct cpu_user_regs * regs)
index a70d31bbbba93bc373af7df4e240e97fd445749c..c550e8e5d872027f64159a6e32fd1d0789eb1626 100644 (file)
@@ -26,6 +26,7 @@
 #include <xen/pfn.h>
 #include <xen/nodemask.h>
 #include <xen/tmem_xen.h> /* for opt_tmem only */
+#include <xen/watchdog.h>
 #include <public/version.h>
 #include <compat/platform.h>
 #include <compat/xen.h>
index c63788389ee2baeeb457190221cfdd68935699fe..471568196f63a9ad373b5de2f54842adcd6f5f59 100644 (file)
@@ -12,7 +12,7 @@
 #include <xen/delay.h>
 #include <xen/dmi.h>
 #include <xen/irq.h>
-#include <xen/nmi.h>
+#include <xen/watchdog.h>
 #include <xen/console.h>
 #include <xen/shutdown.h>
 #include <xen/acpi.h>
index 57dbd0c120122de22603cbf94c8ba485ea3ebe85..b445b2fa3b5c60f5e5e301e84a15dd48b5e426f5 100644 (file)
@@ -49,6 +49,7 @@
 #include <xen/kexec.h>
 #include <xen/trace.h>
 #include <xen/paging.h>
+#include <xen/watchdog.h>
 #include <asm/system.h>
 #include <asm/io.h>
 #include <asm/atomic.h>
index bcd760908e8c2855eb16cbda3f85f3859839aa3e..ea2ffb644b9081fd3358c9c0172473aa32405c56 100644 (file)
@@ -13,6 +13,7 @@
 #include <xen/shutdown.h>
 #include <xen/nmi.h>
 #include <xen/guest_access.h>
+#include <xen/watchdog.h>
 #include <asm/current.h>
 #include <asm/flushtlb.h>
 #include <asm/traps.h>
index 1ba85564dbea158a7c6833d55388e132e2c0519f..7cd151fb577c3916955ec81772be0f615c5b17ee 100644 (file)
@@ -12,7 +12,7 @@
 #include <xen/ctype.h>
 #include <xen/errno.h>
 #include <xen/guest_access.h>
-#include <xen/nmi.h>
+#include <xen/watchdog.h>
 #include <xen/sched.h>
 #include <xen/types.h>
 #include <xen/hypercall.h>
index 507213360c25a7229b459df6074cb337c0c6a8eb..e5c15d67c5accea70430ee8136267facc80b7dbb 100644 (file)
@@ -16,7 +16,7 @@
 #include <xen/ctype.h>
 #include <xen/perfc.h>
 #include <xen/mm.h>
-#include <xen/nmi.h>
+#include <xen/watchdog.h>
 #include <xen/init.h>
 #include <asm/debugger.h>
 #include <asm/div64.h>
index 73a7d7b2a603966661fcc7dc47b0567682e2b159..20f04b07877b527206e9ed015098f2ec6e0e2cd7 100644 (file)
@@ -4,7 +4,7 @@
 #include <xen/sched.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
-#include <xen/nmi.h>
+#include <xen/watchdog.h>
 #include <xen/shutdown.h>
 #include <xen/console.h>
 #ifdef CONFIG_KEXEC
index 8ac32e4f22efccea02d732b8cebadb6fba839234..52ffa70ec2c2ea097d14cfdcabec38ca4b173d53 100644 (file)
@@ -20,7 +20,7 @@
 #include <xen/keyhandler.h>
 #include <xen/delay.h>
 #include <xen/guest_access.h>
-#include <xen/nmi.h>
+#include <xen/watchdog.h>
 #include <xen/shutdown.h>
 #include <xen/video.h>
 #include <xen/kexec.h>
index 0044edb0603900ad94dfac3bc29e9171406ae300..cb7b2e4a05a4709bd5a5d3aa61cf4ca48f69f44a 100644 (file)
@@ -49,6 +49,7 @@
 
 #define CONFIG_XENOPROF 1
 #define CONFIG_KEXEC 1
+#define CONFIG_WATCHDOG 1
 
 #define HZ 100
 
index e9faa72f390cabb2a5720763289d001e630047ea..98b5e04341bf0e047ef2c7f8179e84c80126c3db 100644 (file)
@@ -41,8 +41,4 @@ long register_guest_nmi_callback(unsigned long address);
  */
 long unregister_guest_nmi_callback(void);
 
-void watchdog_disable(void);
-void watchdog_enable(void);
-void watchdog_setup(void);
-
 #endif /* ASM_NMI_H */
diff --git a/xen/include/xen/watchdog.h b/xen/include/xen/watchdog.h
new file mode 100644 (file)
index 0000000..e786b9b
--- /dev/null
@@ -0,0 +1,35 @@
+/******************************************************************************
+ * watchdog.h
+ *
+ * Common watchdog code
+ */
+
+#ifndef __XEN_WATCHDOG_H__
+#define __XEN_WATCHDOG_H__
+
+#include <xen/types.h>
+
+#ifdef CONFIG_WATCHDOG
+
+/* Try to set up a watchdog. */
+int watchdog_setup(void);
+
+/* Enable the watchdog. */
+void watchdog_enable(void);
+
+/* Disable the watchdog. */
+void watchdog_disable(void);
+
+/* Is the watchdog currently enabled. */
+bool_t watchdog_enabled(void);
+
+#else
+
+#define watchdog_setup() ((void)0)
+#define watchdog_enable() ((void)0)
+#define watchdog_disable() ((void)0)
+#define watchdog_enabled() ((void)0)
+
+#endif
+
+#endif /* __XEN_WATCHDOG_H__ */