From patchwork Tue Aug 30 15:03:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 9305509 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 E7B37607D2 for ; Tue, 30 Aug 2016 15:03:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D60F128C00 for ; Tue, 30 Aug 2016 15:03:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C907428C12; Tue, 30 Aug 2016 15:03:27 +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 DB43228C08 for ; Tue, 30 Aug 2016 15:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755506AbcH3PDX (ORCPT ); Tue, 30 Aug 2016 11:03:23 -0400 Received: from sauhun.de ([89.238.76.85]:40557 "EHLO pokefinder.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755412AbcH3PDV (ORCPT ); Tue, 30 Aug 2016 11:03:21 -0400 Received: from dslb-178-005-176-205.178.005.pools.vodafone-ip.de ([178.5.176.205]:59796 helo=localhost) by pokefinder.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1bekZJ-0003Kn-O2; Tue, 30 Aug 2016 17:03:17 +0200 From: Wolfram Sang To: linux-watchdog@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Vladimir Zapolskiy , Wolfram Sang Subject: [PATCH v2] watchdog: softdog: implement pretimeout support Date: Tue, 30 Aug 2016 17:03:06 +0200 Message-Id: <20160830150306.2254-1-wsa@the-dreams.de> X-Mailer: git-send-email 2.9.3 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: Wolfram Sang Give devices which do not have hardware support for pretimeout at least a software version of it. Signed-off-by: Wolfram Sang --- Change since v1: added 'else' block in softdog_ping(), to actually disable the timer when pretimeout value got cleared. Depends on the V4 pretimeout series from Vladimir. Vladimir: Maybe you could add this patch to the next revision of your pretimeout series? Then people have something to play around with right away. drivers/watchdog/softdog.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/softdog.c b/drivers/watchdog/softdog.c index b067edf246dff2..bab31b8df847a5 100644 --- a/drivers/watchdog/softdog.c +++ b/drivers/watchdog/softdog.c @@ -72,10 +72,27 @@ static void softdog_fire(unsigned long data) static struct timer_list softdog_ticktock = TIMER_INITIALIZER(softdog_fire, 0, 0); +static struct watchdog_device softdog_dev; + +static void softdog_pretimeout(unsigned long data) +{ + watchdog_notify_pretimeout(&softdog_dev); +} + +static struct timer_list softdog_preticktock = + TIMER_INITIALIZER(softdog_pretimeout, 0, 0); + static int softdog_ping(struct watchdog_device *w) { if (!mod_timer(&softdog_ticktock, jiffies + (w->timeout * HZ))) __module_get(THIS_MODULE); + + if (w->pretimeout) + mod_timer(&softdog_preticktock, jiffies + + (w->timeout - w->pretimeout) * HZ); + else + del_timer(&softdog_preticktock); + return 0; } @@ -84,12 +101,15 @@ static int softdog_stop(struct watchdog_device *w) if (del_timer(&softdog_ticktock)) module_put(THIS_MODULE); + del_timer(&softdog_preticktock); + return 0; } static struct watchdog_info softdog_info = { .identity = "Software Watchdog", - .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | + WDIOF_PRETIMEOUT, }; static struct watchdog_ops softdog_ops = {