Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965128AbeAKSY5 (ORCPT + 1 other); Thu, 11 Jan 2018 13:24:57 -0500 Received: from mail-ot0-f194.google.com ([74.125.82.194]:34265 "EHLO mail-ot0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934296AbeAKSYz (ORCPT ); Thu, 11 Jan 2018 13:24:55 -0500 X-Google-Smtp-Source: ACJfBovkNpVucdNxyRsE+9Y7wW5ALmIzwOKENAcSr0cLypJRCy8lYWY4jY84o1zzUp56kBeJZpkAOA== Date: Thu, 11 Jan 2018 10:24:52 -0800 From: Guenter Roeck To: =?iso-8859-1?Q?Andr=E9?= Draszik Cc: linux-kernel@vger.kernel.org, Wim Van Sebroeck , linux-watchdog@vger.kernel.org, John Crispin Subject: Re: [PATCH 1/2] watchdog: mt7621: Set WDOG_HW_RUNNING, when watchdog is already running. Message-ID: <20180111182452.GA10058@roeck-us.net> References: <20180110121323.17657-1-git@andred.net> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180110121323.17657-1-git@andred.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, Jan 10, 2018 at 12:13:22PM +0000, Andr? Draszik wrote: > This patch uses the new flag WDOG_HW_RUNNING in driver. > According to the definition of this flag, it should be set > if the watchdog hardware is enabled/running during boot > before being opened here, e.g. due to a boot loader > configuring the watchdog. > > Given the watchdog driver core doesn't know what timeout was > originally set by whoever started the watchdog (boot loader), > we make sure to update the timeout in the hardware according > to what the watchdog core thinks it is. > > Signed-off-by: Andr? Draszik > Cc: Wim Van Sebroeck > Cc: Guenter Roeck > Cc: linux-watchdog@vger.kernel.org > Cc: John Crispin > --- > drivers/watchdog/mt7621_wdt.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c > index db38f8017218..0eabea2d88a2 100644 > --- a/drivers/watchdog/mt7621_wdt.c > +++ b/drivers/watchdog/mt7621_wdt.c > @@ -105,6 +105,11 @@ static int mt7621_wdt_bootcause(void) > return 0; > } > > +static int mt7621_wdt_is_running(struct watchdog_device *w) > +{ > + return !!(rt_wdt_r32(TIMER_REG_TMR1CTL) & TMR1CTL_ENABLE); > +} > + > static const struct watchdog_info mt7621_wdt_info = { > .identity = "Mediatek Watchdog", > .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE, > @@ -144,6 +149,17 @@ static int mt7621_wdt_probe(struct platform_device *pdev) > watchdog_init_timeout(&mt7621_wdt_dev, mt7621_wdt_dev.max_timeout, > &pdev->dev); > watchdog_set_nowayout(&mt7621_wdt_dev, nowayout); > + if (mt7621_wdt_is_running(&mt7621_wdt_dev)) { > + /* Make sure to apply timeout from wathdog_core, taking watchdog core > + the prescaler of this driver here into account (the > + boot loader might be using a different prescaler). > + To avoid spurious resets because of different scaling, > + we first disable the watchdog, set the new prescaler > + and timeout, and then re-enable the watchdog. */ Please use proper multi-line comments. > + mt7621_wdt_stop(&mt7621_wdt_dev); > + mt7621_wdt_start(&mt7621_wdt_dev); > + set_bit(WDOG_HW_RUNNING, &mt7621_wdt_dev.status); > + } > > ret = watchdog_register_device(&mt7621_wdt_dev); > > -- > 2.15.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html