Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3641102ybb; Tue, 31 Mar 2020 09:08:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuRlYIUCF8PGjdP/1p8CSIm8hUQi7mJu3R6yEUN4Bm0GP25E5PMZOCYqQbC8S/YV8RjDp9f X-Received: by 2002:a9d:6c89:: with SMTP id c9mr13220375otr.337.1585670884103; Tue, 31 Mar 2020 09:08:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585670884; cv=none; d=google.com; s=arc-20160816; b=PzsY4DIHJekXpxO9tEr6lcX+T8HFfzm9/Jw45iOJNDhDucb5aDI1uLOllFnAgFURok KfP9LRfrvpGtA4MDj1fnMUXcYH27uK5fgyxftp6gEIo9ZadMHafnhbw/ZMi/Jmb10AzW N4ilARIIpxuS85xXbz97ky/SM9AxdDP4Pt6F+H0TY0Xlkb7D0LxtoF8ftYuTvGYC2Ig6 xPqwtmlT42sas+/hykCHLUOlCxwOTJ/6uTSgknBrnMfMk4omS7m6Pb7P53wSi6QG33XK 22yLByr/BKvkVR/2d4JEutUhQ7YFyyh3abhGt09Ws5RndVwrTiikmxUpI/Sv1q0M/3eq 2Xxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=X1SdScS0pJ3mpXQidkxmuvpGZqOVzChrbcKXKudpDIE=; b=wwMBJfps3uDMzHVnookmmQY2NQxgxcJxqbbsT8JoPGvsnepgTNffe/Nj/H+5TOhmmC 7LVD9VlXsnp4+eReALiXU3eng3c9d+u+l+e2GdA1IvuPjORGIyAXJrUhk5uTB0Op5d6d 00mAnDSjF0RUDy5HisF46+HmZtqEiGNMhOhNIOKl9n4Cy6arnyoU93L8dtlREy4/lj40 3XaJPx4GpCzLzKVOKorRh1ltuyDm2qN+ZSW+EtxUEApy5+iI4c0OXCqKhO5nbG0IeM5Z NdCHPWOdjs4fNsHGXcj2KvkiBf1dFzReR2vqNvpdQjLaht6uIydO8Evdqctm68CPXL+0 UynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=h+JLJxK7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si7365726oib.32.2020.03.31.09.07.36; Tue, 31 Mar 2020 09:08:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=h+JLJxK7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731402AbgCaQEb (ORCPT + 99 others); Tue, 31 Mar 2020 12:04:31 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:36476 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731149AbgCaQE3 (ORCPT ); Tue, 31 Mar 2020 12:04:29 -0400 Received: by mail-pl1-f196.google.com with SMTP id g2so8286362plo.3; Tue, 31 Mar 2020 09:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=X1SdScS0pJ3mpXQidkxmuvpGZqOVzChrbcKXKudpDIE=; b=h+JLJxK7CFJYfYvYfWqX5h/pazSbJqr8Ek50GeADQYHW/2KqN4zP/w06oOvbpKlAv3 kokFeznSBsgR06ybz8/OAD65dey+GNq2fZ6lHZ5NVrM8Ubb6RaYj5hLjzUUfy7OHrWLt FaPZIIxqk8lMiUNyM822AEjaZAyWg1SMLhhzEEbmlR+RwkYokXWxCEbdMsjmySYboWiS 2qpeu6x5sTJ2wsv9IxH53gUCwQrgxqKIQPaYELY56gizC7PUuzAw6FahG9hZVSg/8gGX 4fc4ElrvSB8NrTFypCUSeTtRA2Sevqnft/A6U1AwDIo8COjJ1RkJlIivz+uOTyBJ1SGl lk+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=X1SdScS0pJ3mpXQidkxmuvpGZqOVzChrbcKXKudpDIE=; b=Lu+kFiGm7s4r1xx7miP5dFbd1M6viNuMfURr1jvHfQJRg7gaug7Y5ihswjzD6PLPq9 xWlHmjVcrQmfsV/HHIh86d5k3AxM5r4N56NbTDpydMHzu/paq1A+mr2BAiXyrdVfoelX X5BMAyD72rcMD9EIfNLoQCtcDbTU34vkSA1PSE2I/gjYaCH8PP1BW5LI+h+AHwLU622u 9qivxF+HTcweZcfL+WiXOytULK00w5GLyv891hwduoyT3KqIXKsHi4onxY1QLCMMBCOY v7bhDKtfxoK1Urq19hg7+TT56vTxpJWEgquCJyuxZXk31oKYMUXWDLjkyZKPYUARwMqI K4jg== X-Gm-Message-State: AGi0Pub+x+tpTT3KE0KGw93wctV5cVKpT/4jMkIZ9/6FvJFrDNFmbxq+ Nm334VzB8lYH+AryfDc2pUqTxNGv X-Received: by 2002:a17:90b:14cf:: with SMTP id jz15mr4929463pjb.36.1585670667858; Tue, 31 Mar 2020 09:04:27 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k189sm11972590pgc.24.2020.03.31.09.04.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Mar 2020 09:04:27 -0700 (PDT) Date: Tue, 31 Mar 2020 09:04:26 -0700 From: Guenter Roeck To: Stefan Riedmueller Cc: Wim Van Sebroeck , Support Opensource , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] watchdog: da9062: Use pre-configured timeout until userspace takes over Message-ID: <20200331160426.GA41516@roeck-us.net> References: <20200326150203.371673-1-s.riedmueller@phytec.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200326150203.371673-1-s.riedmueller@phytec.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 26, 2020 at 04:02:01PM +0100, Stefan Riedmueller wrote: > If the watchdog is already running during probe read back its > pre-configured timeout (set e.g. by the bootloader) and use it to ping > the watchdog until userspace takes over. Otherwise the default timeout > set before might not result in a fast enough ping. > > Signed-off-by: Stefan Riedmueller > --- > drivers/watchdog/da9062_wdt.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/drivers/watchdog/da9062_wdt.c b/drivers/watchdog/da9062_wdt.c > index 0ad15d55071c..6d81b1276b87 100644 > --- a/drivers/watchdog/da9062_wdt.c > +++ b/drivers/watchdog/da9062_wdt.c > @@ -35,6 +35,14 @@ struct da9062_watchdog { > bool use_sw_pm; > }; > > +static unsigned int da9062_wdt_read_timeout(struct da9062_watchdog *wdt) > +{ > + int val; > + > + regmap_read(wdt->hw->regmap, DA9062AA_CONTROL_D, &val); > + return wdt_timeout[val & DA9062AA_TWDSCALE_MASK]; > +} > + > static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs) > { > unsigned int i; > @@ -184,6 +192,7 @@ static int da9062_wdt_probe(struct platform_device *pdev) > { > struct device *dev = &pdev->dev; > int ret; > + int timeout; > struct da9062 *chip; > struct da9062_watchdog *wdt; > > @@ -213,6 +222,13 @@ static int da9062_wdt_probe(struct platform_device *pdev) > watchdog_set_drvdata(&wdt->wdtdev, wdt); > dev_set_drvdata(dev, &wdt->wdtdev); > > + timeout = da9062_wdt_read_timeout(wdt); > + if (timeout > 0) { > + wdt->wdtdev.timeout = timeout; > + set_bit(WDOG_HW_RUNNING, &wdt->wdtdev.status); > + dev_info(wdt->hw->dev, "watchdog is running (%u s)", timeout); > + } Oh, and I agree with the comment made for the da9063 driver: This driver should really implement watchdog_init_timeout() and set the default timeout accordingly if specified in dt (or, in other words, follow the da9063 implementation). Guenter > + > ret = devm_watchdog_register_device(dev, &wdt->wdtdev); > if (ret < 0) > return ret;