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]
Message-ID: <efc34ded-720d-ef57-8906-37e8ab36c3cf@roeck-us.net>
Date:   Fri, 14 May 2021 06:42:12 -0700
From:   Guenter Roeck <linux@...ck-us.net>
To:     Robin Gong <yibin.gong@....com>, wim@...ux-watchdog.org,
        shawnguo@...nel.org, s.hauer@...gutronix.de, festevam@...il.com
Cc:     linux-imx@....com, kernel@...gutronix.de,
        linux-watchdog@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] watchdog: imx2_wdt: avoid to ping before resume back

On 5/14/21 10:21 AM, Robin Gong wrote:
> Since watchdog_ping_work is not freezable so that it maybe scheduled before
> imx2_wdt_resume where watchdog clock enabled, hence, kernel will hang in
> imx2_wdt_ping without clock, and then watchdog reset happen. Add clk_is_on
> to prevent the above case by ignoring ping until watchdog driver resume
> back indeed.
> 
> Signed-off-by: Robin Gong <yibin.gong@....com>

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

> ---
>   drivers/watchdog/imx2_wdt.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c
> index b84f80f..cc86018 100644
> --- a/drivers/watchdog/imx2_wdt.c
> +++ b/drivers/watchdog/imx2_wdt.c
> @@ -65,6 +65,7 @@ struct imx2_wdt_device {
>   	struct regmap *regmap;
>   	struct watchdog_device wdog;
>   	bool ext_reset;
> +	bool clk_is_on;
>   };
>   
>   static bool nowayout = WATCHDOG_NOWAYOUT;
> @@ -160,6 +161,9 @@ static int imx2_wdt_ping(struct watchdog_device *wdog)
>   {
>   	struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog);
>   
> +	if (!wdev->clk_is_on)
> +		return 0;
> +
>   	regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ1);
>   	regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ2);
>   	return 0;
> @@ -301,6 +305,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev)
>   	if (ret)
>   		return ret;
>   
> +	wdev->clk_is_on = true;
> +
>   	regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val);
>   	wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0;
>   
> @@ -361,6 +367,8 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev)
>   
>   	clk_disable_unprepare(wdev->clk);
>   
> +	wdev->clk_is_on = false;
> +
>   	return 0;
>   }
>   
> @@ -375,6 +383,8 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev)
>   	if (ret)
>   		return ret;
>   
> +	wdev->clk_is_on = true;
> +
>   	if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) {
>   		/*
>   		 * If the watchdog is still active and resumes
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ