Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp4934769pxb; Mon, 28 Mar 2022 05:52:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5pzGsL6LnAsDC/BRnfgPQCoAt1lufUfOk1x49L0zqxIT6/Y0762etB90ARCtHm+NXk6nq X-Received: by 2002:a05:6808:f07:b0:2da:4916:578c with SMTP id m7-20020a0568080f0700b002da4916578cmr12472809oiw.239.1648471956098; Mon, 28 Mar 2022 05:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648471956; cv=none; d=google.com; s=arc-20160816; b=IDRzFTXshmM/g33+bCyONlmT5Q/MFkLjxuj/6SGgnKqqkfOliVISOVKwMTA8PAod9F FYfbYAyGlsXaiLvWgi3kmd6iDwKxmqxF+De3yipCzTQA4TkWp+Bo/mDRdLGBcvSeBfbm 46LEmuSGYlH18P05r4cb9ZebVjHuN/ZUVsdAE1l+WXQLOCtKwKmmJFBtE//YYQ2hERhC JaPlzmA+0TsgKasYMU8PLa2SqPZx/qYqOPfH3FUrYCmXLgiub3DWPSoX0bqdgrRFh/bb mdvRwtFXP7SVmQI4TdKnJaffkdloEzZwyzW1U22PtPTApgeVnPF1AWveiPNsqOw7ydtN YOIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=uj2kenKJllwybEvWKfMMrY3Zq/gATlc8Hw2Wh/GZMuM=; b=Vhm+g5mi0bMXbIE6BM8auLqZY5kX0sHkBYdd+m+zYbWOmP+I6u5Z6TlNPWytXhjesD 95xpHLtSLncfB4RsX3Au2e+OlRAVv+mX6yvkEvggnDg2hxurv8AGqEU2JMlH3adNzJgz R7T0WD9zxvJcaaVGA6i8bRx0Np/Kp7B9UPXY3T4k9+hYE54b+NeEsQGiCyvG8Q0U9fy5 Duxeo0WTC2YG8v7lo1el1ggte3XEKk5X2Eup9a1V1nSSva+ZvmZ/Ac+sDsKzNrosIhzO k0JGIQQ+zW7RT6XDfR1TC6n/aVZZZpuA83XlZgBVe3QXZjkuUrpgUQ/CBoNUyIcmxyYz +9fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a056830204100b005cb2fc1387dsi8530229otp.249.2022.03.28.05.52.24; Mon, 28 Mar 2022 05:52:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239071AbiC1IDH (ORCPT + 99 others); Mon, 28 Mar 2022 04:03:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239063AbiC1IDG (ORCPT ); Mon, 28 Mar 2022 04:03:06 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1347452E6E for ; Mon, 28 Mar 2022 01:01:26 -0700 (PDT) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nYkJN-0001tN-JZ; Mon, 28 Mar 2022 10:01:13 +0200 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1nYkJL-00026y-Or; Mon, 28 Mar 2022 10:01:11 +0200 Date: Mon, 28 Mar 2022 10:01:11 +0200 From: Sascha Hauer To: Alistair Francis Cc: shawnguo@kernel.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org, wim@linux-watchdog.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, festevam@gmail.com, robh+dt@kernel.org Subject: Re: [PATCH v4] watchdog: imx2_wdg: Allow ping on suspend Message-ID: <20220328080111.GD12181@pengutronix.de> References: <20220323115752.360409-1-alistair@alistair23.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220323115752.360409-1-alistair@alistair23.me> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 09:59:25 up 107 days, 16:45, 84 users, load average: 0.18, 0.66, 0.69 User-Agent: Mutt/1.10.1 (2018-07-13) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Mar 23, 2022 at 09:57:52PM +1000, Alistair Francis wrote: > The i.MX watchdog cannot be disabled by software once it has been > enabled. This means that it can't be stopped before suspend. > > For systems that enter low power mode this is fine, as the watchdog will > be automatically stopped by hardware in low power mode. Not all i.MX > platforms support low power mode in the mainline kernel. For example the > i.MX7D does not enter low power mode and so will be rebooted 2 minutes > after entering sleep states. > > This patch introduces a device tree property "fsl,ping-during-suspend" > that can be used to enable ping on suspend support for these systems. This doesn't match the code anymore. Sascha > > Signed-off-by: Alistair Francis > Reviewed-by: Guenter Roeck > --- > drivers/watchdog/imx2_wdt.c | 27 ++++++++++++++++++++------- > 1 file changed, 20 insertions(+), 7 deletions(-) > > diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c > index 51bfb796898b..d0c5d47ddede 100644 > --- a/drivers/watchdog/imx2_wdt.c > +++ b/drivers/watchdog/imx2_wdt.c > @@ -66,6 +66,7 @@ struct imx2_wdt_device { > struct watchdog_device wdog; > bool ext_reset; > bool clk_is_on; > + bool no_ping; > }; > > static bool nowayout = WATCHDOG_NOWAYOUT; > @@ -312,12 +313,18 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) > > wdev->ext_reset = of_property_read_bool(dev->of_node, > "fsl,ext-reset-output"); > + /* > + * The i.MX7D doesn't support low power mode, so we need to ping the watchdog > + * during suspend. > + */ > + wdev->no_ping = !of_device_is_compatible(dev->of_node, "fsl,imx7d-wdt"); > platform_set_drvdata(pdev, wdog); > watchdog_set_drvdata(wdog, wdev); > watchdog_set_nowayout(wdog, nowayout); > watchdog_set_restart_priority(wdog, 128); > watchdog_init_timeout(wdog, timeout, dev); > - watchdog_stop_ping_on_suspend(wdog); > + if (wdev->no_ping) > + watchdog_stop_ping_on_suspend(wdog); > > if (imx2_wdt_is_running(wdev)) { > imx2_wdt_set_timeout(wdog, wdog->timeout); > @@ -366,9 +373,11 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) > imx2_wdt_ping(wdog); > } > > - clk_disable_unprepare(wdev->clk); > + if (wdev->no_ping) { > + clk_disable_unprepare(wdev->clk); > > - wdev->clk_is_on = false; > + wdev->clk_is_on = false; > + } > > return 0; > } > @@ -380,11 +389,14 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) > struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); > int ret; > > - ret = clk_prepare_enable(wdev->clk); > - if (ret) > - return ret; > + if (wdev->no_ping) { > + ret = clk_prepare_enable(wdev->clk); > > - wdev->clk_is_on = true; > + if (ret) > + return ret; > + > + wdev->clk_is_on = true; > + } > > if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { > /* > @@ -407,6 +419,7 @@ static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend, > > static const struct of_device_id imx2_wdt_dt_ids[] = { > { .compatible = "fsl,imx21-wdt", }, > + { .compatible = "fsl,imx7d-wdt", }, > { /* sentinel */ } > }; > MODULE_DEVICE_TABLE(of, imx2_wdt_dt_ids); > -- > 2.35.1 > > -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |