From patchwork Thu Mar 3 10:29:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Romain Izard X-Patchwork-Id: 8491011 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 695C2C0553 for ; Thu, 3 Mar 2016 10:32:23 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7DBFF2035D for ; Thu, 3 Mar 2016 10:32:22 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9370F20351 for ; Thu, 3 Mar 2016 10:32:20 +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 1abQWW-0007ZD-Rp; Thu, 03 Mar 2016 10:30:24 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1abQWT-0006Nd-O8 for linux-arm-kernel@lists.infradead.org; Thu, 03 Mar 2016 10:30:22 +0000 Received: by mail-wm0-x244.google.com with SMTP id l68so3302446wml.3 for ; Thu, 03 Mar 2016 02:30:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=tNIJwxatAfjaJqbfVRCiXCkVmELH+7aYE3YSuxDyIRQ=; b=YFpGl6cMsqBbDRv436y5wxSeVx45/fbv7+vfy1b2g3OwNQnnn1y8n5xb5YFKtOfd+V fGPbWmnQ2CoNNgDuMyVnneDw4aUPLI+xDn5nSQvk5TVpnw4M/pLunwX6YzNnitUkyq1r 78qdmESUPZt/xlcxI9dzuXvjkvPptWkB0e2wwRgd1RZrR2A/Q0OQw+070SOkLUd8csBg ImUFZd9cN9+nGX1EdtYQH0Qccd/2bWlVYbWReS0M4FEQvpwjAHTFZu1wxhYCD9YZI0TF OEF/mc5YOf3PuHP7MUhENEuZs87wmSkMcrz543WhLNs10gUUhhU0e2+vU/nf0+nmf4b7 q16Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tNIJwxatAfjaJqbfVRCiXCkVmELH+7aYE3YSuxDyIRQ=; b=hQlzm49iM8Uwf5Tos5lOaLYVKq9nOA+sLGpVTYv7PDrGKas9iSTIPkQ5PaTWXC5sR8 NfdPywWhniyvGvn+OTpKM87U3qOlJRQBeHFviRW+8RjkNmXn0fsRGgI796JF5nJ5DJfh 9TZ/k6ecb+o3AyeO/2wKUkYG7zcVLUwWbvUHF7K7j+8TtATQnaJ7e6xPJ2KhBQFsiKP8 hcsu+DxHVmFmXo3mpjYfU7LOrtlXy/KT3wBuoKL2uuLJaPJ39H6T8r7+U3/QCpvfh3gx mG6FpZAN6PM0JyGYTM0Ym5xbz6qTtTX71eTeXs3ZVxttZdvy6KgMBbJ8cQpvQUe56o9r xEqQ== X-Gm-Message-State: AD7BkJJzfntMLX/0WsZmLis0XBo491z7fhZlLHgsIn9hagSQfR2f3l4ktNxdSe8aYXpCpg== X-Received: by 10.28.211.1 with SMTP id k1mr2768804wmg.93.1457000999682; Thu, 03 Mar 2016 02:29:59 -0800 (PST) Received: from localhost.localdomain (146.187.3.109.rev.sfr.net. [109.3.187.146]) by smtp.gmail.com with ESMTPSA id v68sm8228524wmv.10.2016.03.03.02.29.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Mar 2016 02:29:58 -0800 (PST) From: Romain Izard To: linux-kernel@vger.kernel.org, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Wim Van Sebroeck Subject: [PATCH v1] watchdog: sama5d4_wdt: Reset delay on start Date: Thu, 3 Mar 2016 11:29:39 +0100 Message-Id: <1457000979-15717-1-git-send-email-romain.izard.pro@gmail.com> X-Mailer: git-send-email 2.5.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160303_023021_955929_EBC59573 X-CRM114-Status: GOOD ( 12.59 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Romain Izard , Nicolas Ferre , Guenter Roeck , Wenyou Yang 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=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 If the internal counter is not refreshed when the watchdog is started for the first time, the watchdog will trigger very rapidly. For example, opening /dev/watchdog without writing in it will immediately trigger a reboot, instead of waiting for the delay to expire. To avoid this problem, reload the timer on opening the watchdog device. Command: "while sleep 5; do echo 1; done > /dev/watchdog" Before: system reset After: the watchdog runs correctly Signed-off-by: Romain Izard --- drivers/watchdog/sama5d4_wdt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c index a49634cdc1cc..e162fe140ae1 100644 --- a/drivers/watchdog/sama5d4_wdt.c +++ b/drivers/watchdog/sama5d4_wdt.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "at91sam9_wdt.h" @@ -58,6 +59,8 @@ static int sama5d4_wdt_start(struct watchdog_device *wdd) reg = wdt_read(wdt, AT91_WDT_MR); reg &= ~AT91_WDT_WDDIS; wdt_write(wdt, AT91_WDT_MR, reg); + udelay(125); /* > 4 cycles at 32,768 Hz */ + wdt_write(wdt, AT91_WDT_CR, AT91_WDT_KEY | AT91_WDT_WDRSTT); return 0; }