From patchwork Thu Oct 23 10:40:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timo Kokkonen X-Patchwork-Id: 5139181 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DDFCBC11AC for ; Thu, 23 Oct 2014 10:45:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1B6362025A for ; Thu, 23 Oct 2014 10:45:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B534320034 for ; Thu, 23 Oct 2014 10:45:41 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhFpz-0003Oo-B2; Thu, 23 Oct 2014 10:41:47 +0000 Received: from oul135-36.netplaza.fi ([80.75.100.36] helo=lime.offcode.fi) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XhFpu-0003Kn-ED for linux-arm-kernel@lists.infradead.org; Thu, 23 Oct 2014 10:41:44 +0000 Received: from localhost (localhost [127.0.0.1]) by lime.offcode.fi (Postfix) with ESMTP id 6EEAF50638; Thu, 23 Oct 2014 14:22:42 +0300 (EEST) X-Virus-Scanned: Debian amavisd-new at lime.offcode.fi Received: from lime.offcode.fi ([127.0.0.1]) by localhost (lime.offcode.fi [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 25kWuFJCQOlB; Thu, 23 Oct 2014 14:22:40 +0300 (EEST) Received: from kampiakseli.offcode.fi (kampiakseli.offcode.fi [10.1.1.154]) by lime.offcode.fi (Postfix) with ESMTP id F1BE450514; Thu, 23 Oct 2014 14:22:39 +0300 (EEST) From: Timo Kokkonen To: linux-arm-kernel@lists.infradead.org, linux-watchdog@vger.kernel.org Subject: [PATCH] at91sam9_wdt: Allow watchdog to reset device at early boot Date: Thu, 23 Oct 2014 13:40:46 +0300 Message-Id: <1414060846-17306-1-git-send-email-timo.kokkonen@offcode.fi> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141023_034142_683871_874B72E7 X-CRM114-Status: GOOD ( 14.57 ) X-Spam-Score: 0.0 (/) Cc: Timo Kokkonen X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP By default the driver will start a kernel timer which keeps on kicking the watchdog HW until user space has opened the watchdog device. Usually this is desirable as the watchdog HW is running by default and the user space may not have any watchdog daemon running at all. However, on production systems it may be mandatory that also early crashes and lockups will lead to a watchdog reset, even if they happen before the user space has opened the watchdog device. To resolve the issue, add a new device tree property "atmel,no-early-timer" which will prevent the kernel timer from pinging the watchdog HW on behalf of user space. The default is still to use kernel timer, but more strict behavior can be enabled via the device tree property. Signed-off-by: Timo Kokkonen --- Documentation/devicetree/bindings/watchdog/atmel-wdt.txt | 4 ++++ drivers/watchdog/at91sam9_wdt.c | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt b/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt index f90e294..1b9289e 100644 --- a/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt +++ b/Documentation/devicetree/bindings/watchdog/atmel-wdt.txt @@ -28,6 +28,10 @@ Optional properties: entering idle state. - atmel,dbg-halt : Should be present if you want to stop the watchdog when entering debug state. +- atmel,no-early-timer : Should be present if you want to let the + watchdog timer to expire even before user space has opened the + device. If not set, a kernel timer will keep on pinging the + watchdog until it is opened. Example: watchdog@fffffd40 { diff --git a/drivers/watchdog/at91sam9_wdt.c b/drivers/watchdog/at91sam9_wdt.c index 489729b..8cac712 100644 --- a/drivers/watchdog/at91sam9_wdt.c +++ b/drivers/watchdog/at91sam9_wdt.c @@ -89,6 +89,7 @@ struct at91wdt { u32 mr_mask; unsigned long heartbeat; /* WDT heartbeat in jiffies */ bool nowayout; + bool no_early_timer; unsigned int irq; }; @@ -122,7 +123,7 @@ static void at91_ping(unsigned long data) { struct at91wdt *wdt = (struct at91wdt *)data; if (time_before(jiffies, wdt->next_heartbeat) || - !watchdog_active(&wdt->wdd)) { + (!watchdog_active(&wdt->wdd) && !wdt->no_early_timer)) { at91_wdt_reset(wdt); mod_timer(&wdt->timer, jiffies + wdt->heartbeat); } else { @@ -316,6 +317,9 @@ static int of_at91wdt_init(struct device_node *np, struct at91wdt *wdt) wdt->mr |= max | ((max - min) << 16); + if (of_property_read_bool(np, "atmel,no-early-timer")) + wdt->no_early_timer = 1; + return 0; } #else