From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755097AbcCDBfU (ORCPT ); Thu, 3 Mar 2016 20:35:20 -0500 Received: from nasmtp01.atmel.com ([192.199.1.246]:14028 "EHLO DVREDG02.corp.atmel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751103AbcCDBfL (ORCPT ); Thu, 3 Mar 2016 20:35:11 -0500 Subject: Re: [PATCH v1] watchdog: sama5d4_wdt: Reset delay on start To: Romain Izard , , , , Wim Van Sebroeck References: <1457000979-15717-1-git-send-email-romain.izard.pro@gmail.com> CC: Guenter Roeck , Nicolas Ferre From: "Yang, Wenyou" Message-ID: <56D8E649.8030500@atmel.com> Date: Fri, 4 Mar 2016 09:35:05 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1457000979-15717-1-git-send-email-romain.izard.pro@gmail.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.168.5.13] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Romain, On 2016/3/3 18:29, Romain Izard wrote: > 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 I didn't reproduce your issue on my side, run the your commands as follows, it works fine, the system reset doesn't happen. ---8<---- #!/bin/sh while [ 1 ] do sleep 5; echo 1 > /dev/watchdog done --->8---- I also check the WDT_MR register before and after enabling watchdog, the WDV and WDD fields are correct. Can you check it again? thank you. > > 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; > } Best Regards, Wenyou Yang