lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 12 Jan 2018 15:22:55 -0800
From:   Guenter Roeck <linux@...ck-us.net>
To:     André Draszik <git@...red.net>
Cc:     linux-kernel@...r.kernel.org, Wim Van Sebroeck <wim@...ana.be>,
        linux-watchdog@...r.kernel.org, John Crispin <john@...ozen.org>
Subject: Re: [PATCH v2 1/2] watchdog: mt7621: set WDOG_HW_RUNNING bit when
 appropriate

On Fri, Jan 12, 2018 at 09:44:53AM +0000, André Draszik wrote:
> If the watchdog hardware is enabled/running during boot, e.g.
> due to a boot loader configuring it, we must tell the
> watchdog framework about this fact so that it can ping the
> watchdog until userspace opens the device and takes over
> control.
> 
> Do so using the WDOG_HW_RUNNING flag that exists for exactly
> that use-case.
> 
> 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 <git@...red.net>
> Cc: Wim Van Sebroeck <wim@...ana.be>
> Cc: Guenter Roeck <linux@...ck-us.net>
> Cc: linux-watchdog@...r.kernel.org
> Cc: John Crispin <john@...ozen.org>

Reviewed-by: Guenter Roeck <Linux@...ck-us.net>

> 
> ---
> Changes in v2:
> - fix typo and proper multi-line comment
> - update commit message to be clearer
> ---
>  drivers/watchdog/mt7621_wdt.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/drivers/watchdog/mt7621_wdt.c b/drivers/watchdog/mt7621_wdt.c
> index db38f8017218..eec57e5e1eae 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,20 @@ 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 watchdog core, taking
> +		 * 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.
> +		 */
> +		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
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ