From patchwork Wed May 25 13:32:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9135369 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8BC5D607D7 for ; Wed, 25 May 2016 13:34:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DAF927DB3 for ; Wed, 25 May 2016 13:34:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7299028253; Wed, 25 May 2016 13:34:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3FD527DB3 for ; Wed, 25 May 2016 13:34:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752973AbcEYNcy (ORCPT ); Wed, 25 May 2016 09:32:54 -0400 Received: from sauhun.de ([89.238.76.85]:36370 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751627AbcEYNct (ORCPT ); Wed, 25 May 2016 09:32:49 -0400 Received: from dslb-178-008-084-178.178.008.pools.vodafone-ip.de ([178.8.84.178]:46606 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1b5YvW-0007eP-Ld; Wed, 25 May 2016 15:32:47 +0200 From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: Wolfram Sang , linux-renesas-soc@vger.kernel.org, Guenter Roeck , Vladimir Zapolskiy , Robin Gong Subject: [PATCH 2/7] watchdog: pretimeout: add panic pretimeout governor Date: Wed, 25 May 2016 15:32:26 +0200 Message-Id: <1464183151-4912-3-git-send-email-wsa@the-dreams.de> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1464183151-4912-1-git-send-email-wsa@the-dreams.de> References: <1464183151-4912-1-git-send-email-wsa@the-dreams.de> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Vladimir Zapolskiy Panic watchdog pretimeout governor, on watchdog pretimeout event the kernel shall panic. Signed-off-by: Vladimir Zapolskiy Signed-off-by: Wolfram Sang --- Changes since Vladimir's last version: * rebased * shortened the panic message a little (removed redundancy) drivers/watchdog/Kconfig | 29 +++++++++++++++++++++ drivers/watchdog/Makefile | 2 ++ drivers/watchdog/pretimeout_panic.c | 47 ++++++++++++++++++++++++++++++++++ drivers/watchdog/watchdog_pretimeout.h | 6 ++++- 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 drivers/watchdog/pretimeout_panic.c diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig index 909d1021de5cbc..36b7d1f83b3c51 100644 --- a/drivers/watchdog/Kconfig +++ b/drivers/watchdog/Kconfig @@ -1782,4 +1782,33 @@ config WATCHDOG_PRETIMEOUT_GOV help The option allows to select watchdog pretimeout governors. +if WATCHDOG_PRETIMEOUT_GOV + +choice + prompt "Default Watchdog Pretimeout Governor" + default WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC + help + This option selects a default watchdog pretimeout governor. + The governor takes its action, if a watchdog is capable + to report a pretimeout event. + +config WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC + bool "panic" + select WATCHDOG_PRETIMEOUT_GOV_PANIC + help + Use panic watchdog pretimeout governor by default, if + a watchdog pretimeout event happens, consider that + a watchdog feeder is dead and reboot is unavoidable. + +endchoice + +config WATCHDOG_PRETIMEOUT_GOV_PANIC + tristate "Panic watchdog pretimeout governor" + help + Select this option to enable panic watchdog pretimeout + governor, on a watchdog pretimeout event the kernel shall + panic before an expected system reboot. + +endif # WATCHDOG_PRETIMEOUT_GOV + endif # WATCHDOG diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile index 820860cf3e8d62..56dfadc0cee2a9 100644 --- a/drivers/watchdog/Makefile +++ b/drivers/watchdog/Makefile @@ -8,6 +8,8 @@ obj-$(CONFIG_WATCHDOG_CORE) += watchdog.o watchdog-y += watchdog_core.o watchdog_dev.o watchdog-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV) += watchdog_pretimeout.o +obj-$(CONFIG_WATCHDOG_PRETIMEOUT_GOV_PANIC) += pretimeout_panic.o + # Only one watchdog can succeed. We probe the ISA/PCI/USB based # watchdog-cards first, then the architecture specific watchdog # drivers and then the architecture independent "softdog" driver. diff --git a/drivers/watchdog/pretimeout_panic.c b/drivers/watchdog/pretimeout_panic.c new file mode 100644 index 00000000000000..f8c2410d993f02 --- /dev/null +++ b/drivers/watchdog/pretimeout_panic.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015 Mentor Graphics + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + */ + +#include +#include + +#include "watchdog_pretimeout.h" + +/** + * pretimeout_panic - Panic on watchdog pretimeout event + * @wdd - watchdog_device + * + * Panic, watchdog has not been fed till pretimeout event. + */ +static void pretimeout_panic(struct watchdog_device *wdd) +{ + panic("watchdog pretimeout event"); +} + +static struct watchdog_governor watchdog_gov_panic = { + .name = "panic", + .pretimeout = pretimeout_panic, + .owner = THIS_MODULE, +}; + +static int __init watchdog_gov_panic_register(void) +{ + return watchdog_register_governor(&watchdog_gov_panic); +} +module_init(watchdog_gov_panic_register); + +static void __exit watchdog_gov_panic_unregister(void) +{ + watchdog_unregister_governor(&watchdog_gov_panic); +} +module_exit(watchdog_gov_panic_unregister); + +MODULE_AUTHOR("Vladimir Zapolskiy "); +MODULE_DESCRIPTION("Panic watchdog pretimeout governor"); +MODULE_LICENSE("GPL"); diff --git a/drivers/watchdog/watchdog_pretimeout.h b/drivers/watchdog/watchdog_pretimeout.h index 38965cdd23bebe..8b03fd480cb533 100644 --- a/drivers/watchdog/watchdog_pretimeout.h +++ b/drivers/watchdog/watchdog_pretimeout.h @@ -19,7 +19,11 @@ void watchdog_unregister_governor(struct watchdog_governor *gov); /* Interfaces to watchdog_core.c */ #ifdef CONFIG_WATCHDOG_PRETIMEOUT_GOV -#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "none" +#if IS_ENABLED(CONFIG_WATCHDOG_PRETIMEOUT_DEFAULT_GOV_PANIC) +#define WATCHDOG_PRETIMEOUT_DEFAULT_GOV "panic" +#else +#error "Default watchdog pretimeout governor is not set." +#endif int watchdog_register_pretimeout(struct watchdog_device *wdd, struct device *dev); void watchdog_unregister_pretimeout(struct watchdog_device *wdd);