From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: [PATCH 1/3] xen/watchdog: Move watchdog from being x86 specific to common code. Date: Mon, 12 Aug 2013 14:37:58 +0100 Message-ID: <1376314680-12548-2-git-send-email-andrew.cooper3@citrix.com> References: <1376314680-12548-1-git-send-email-andrew.cooper3@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1376314680-12548-1-git-send-email-andrew.cooper3@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Xen-devel Cc: Andrew Cooper , Keir Fraser , Jan Beulich , Tim Deegan List-Id: xen-devel@lists.xenproject.org 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 CC: Keir Fraser CC: Jan Beulich CC: Tim Deegan --- xen/arch/x86/nmi.c | 8 +++++++- xen/arch/x86/setup.c | 1 + xen/arch/x86/shutdown.c | 2 +- xen/arch/x86/traps.c | 1 + xen/arch/x86/x86_64/traps.c | 1 + xen/common/kexec.c | 2 +- xen/common/keyhandler.c | 2 +- xen/common/shutdown.c | 2 +- xen/drivers/char/console.c | 2 +- xen/include/asm-x86/config.h | 1 + xen/include/asm-x86/nmi.h | 4 ---- xen/include/xen/watchdog.h | 35 +++++++++++++++++++++++++++++++++++ 12 files changed, 51 insertions(+), 10 deletions(-) create mode 100644 xen/include/xen/watchdog.h diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index c93812f..3eb2456 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -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) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index a70d31b..c550e8e 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -26,6 +26,7 @@ #include #include #include /* for opt_tmem only */ +#include #include #include #include diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c index c637883..4715681 100644 --- a/xen/arch/x86/shutdown.c +++ b/xen/arch/x86/shutdown.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 57dbd0c..b445b2f 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c index bcd7609..ea2ffb6 100644 --- a/xen/arch/x86/x86_64/traps.c +++ b/xen/arch/x86/x86_64/traps.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/common/kexec.c b/xen/common/kexec.c index 1ba8556..7cd151f 100644 --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 5072133..e5c15d6 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index 73a7d7b..20f04b0 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include #ifdef CONFIG_KEXEC diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 8ac32e4..52ffa70 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/include/asm-x86/config.h b/xen/include/asm-x86/config.h index 0044edb..cb7b2e4 100644 --- a/xen/include/asm-x86/config.h +++ b/xen/include/asm-x86/config.h @@ -49,6 +49,7 @@ #define CONFIG_XENOPROF 1 #define CONFIG_KEXEC 1 +#define CONFIG_WATCHDOG 1 #define HZ 100 diff --git a/xen/include/asm-x86/nmi.h b/xen/include/asm-x86/nmi.h index e9faa72..98b5e04 100644 --- a/xen/include/asm-x86/nmi.h +++ b/xen/include/asm-x86/nmi.h @@ -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 index 0000000..e786b9b --- /dev/null +++ b/xen/include/xen/watchdog.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * watchdog.h + * + * Common watchdog code + */ + +#ifndef __XEN_WATCHDOG_H__ +#define __XEN_WATCHDOG_H__ + +#include + +#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__ */ -- 1.7.10.4