Received: by 10.213.65.68 with SMTP id h4csp589257imn; Fri, 30 Mar 2018 11:21:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx49Go+/urVyW+Cyp60tegUXkdDIs6/LtlLmIBDhomHrryCo3ecUqVvC37M0ShuKq2FcNAY2V X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr52824plk.51.1522434108893; Fri, 30 Mar 2018 11:21:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522434108; cv=none; d=google.com; s=arc-20160816; b=ziRYRSXnkJrzn9nkVw9XFRrNZ1HjOVEMOXg1rXsMD79bJ4r2FcYj4LbuChKwFk6mFX fZzzXRdAvKpP5ETNWqMBZkctrHHNAYwQi0n0dvOZUjA/Pccv3Zs9eJE5nC26iWhb1u4w P3iKwMxYRYnnQomKqpL+E+T35PpZBEw2Y5ogHT3FEeu6BKAnMvjyNPH25lxkrUN56QgF cDhdu3m6M3Ce9SCUMr8nlAssI38pdbUszkE3xj5H4i/zEFBxjbgk9lLndIwKfFzSqCpR lj4tXLHkeVlfEjf3zk+Jmw5G6tpsDJMFUOQ+E807ObyKzhdMAqBwC7myaLoIDIO9jBAp HaNA== 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:arc-authentication-results; bh=WDB7OtJjNsFE6D5CGvQ4nHvNjbTd+xajvb73Qqedx6w=; b=zvEXuRpe/Mn+WL+jIDrv0LJL/Ja+mCpb0ZHIghTkipUTSVWN3p0kLs2I0B96Vi54Ej Wek3yoZd3saWfKqHknK3Qr+LbC14sNHvvt19LxGMqR6nIgallKTHxc2Hk2MeiAIQBdxO 4FRikgbZ7/7CLaLCl6aNj+Ul53BiDNe4i7AVLGDT7BEidgK7w3iWLw0+cvItbhA8055N 78ZkoCIm1XHgYnPFzyn+KQ4KAWMsCJ6x24O7ePslvQZwXMC1nP6JbFSgSI7emeCurvVs 2DMgDCGVAU5jfopazSACszsl72Rxe2JWyumhy8ty5YzAwXjNsMGcDV3tneIQP2PUGT3T aHwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=H6t/qH0Y; 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 c27si5950305pgn.223.2018.03.30.11.21.21; Fri, 30 Mar 2018 11:21:48 -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=H6t/qH0Y; 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 S1752365AbeC3SUB (ORCPT + 99 others); Fri, 30 Mar 2018 14:20:01 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:33675 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752269AbeC3ST6 (ORCPT ); Fri, 30 Mar 2018 14:19:58 -0400 Received: by mail-pf0-f193.google.com with SMTP id f15so5858346pfn.0; Fri, 30 Mar 2018 11:19:57 -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=WDB7OtJjNsFE6D5CGvQ4nHvNjbTd+xajvb73Qqedx6w=; b=H6t/qH0YYarKQT86qdHChKw1wAirAm8fkitfeJQStQ/kjDnQB0xTTZbIPlbaO1WAiQ BbhJip0quFSfV2+5AvGgt9OL+DwiqaMnjHgBO0Z1Sc2CVezQmbE7gQi0GbUsXX/Q2Sew vGMkq0/WvOERkCmaOYnbsihihvSF/vU8fDUTRlH0Q0MvS0W/zqnII/dg0TILQDs4DGuv j39DMq0GoZWeNUMAGU0qVA9+VjmrL38nk5IGli6CG1Bok+YXedl1leZA6xl8ByOzfBkh /U5qRIbU/y6YoLWOmZbm5WU2CS9bUqubL8qLylYoOFmsUCKw9M2GlToWa3K2+AEIyUcT gtig== 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=WDB7OtJjNsFE6D5CGvQ4nHvNjbTd+xajvb73Qqedx6w=; b=tLirYaFNCYdswxMKlAESfBkm7qdpqlbygUncmxJelDrQ+n9IHJhGDLLCBHDl2jvHKD UypOsmYl7TrPNGISzS4Q9y1CUpBHmyeWy4kuqqHXSNdA3BATJP0gvwjp3phxarE77IDT cbTKo8pilhzDYnjxG9RJYTIRultN7TgLfmL2CmmV/kNVHtVkQn7Cd6OJMRd/6b7gZ6YQ a6OaymihwaSsL70fVon8A53LsCAICRBQsjmfrI6pQ+aKnhFei3Qk94JsPemh9Egqdk5y NgS6QNItwGWe9B9ec1ywK3qV3DOc7zXmYJBkAYY1lA0Xr/9bQrMQL1TgxxNKn+ye6y7J rk9w== X-Gm-Message-State: AElRT7FrccqqKz3+aQRkL4XorW++B83+5zaiB0vPRom8DdbfgKMtcbFs bYsROFS3JaFFwu981KgfkY6cvw== X-Received: by 10.99.114.27 with SMTP id n27mr20209pgc.177.1522433997288; Fri, 30 Mar 2018 11:19:57 -0700 (PDT) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id z79sm19039162pfa.139.2018.03.30.11.19.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 30 Mar 2018 11:19:56 -0700 (PDT) Date: Fri, 30 Mar 2018 11:19:54 -0700 From: Guenter Roeck To: Tim Harvey Cc: Lee Jones , Rob Herring , Mark Rutland , Mark Brown , Dmitry Torokhov , Wim Van Sebroeck , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hwmon@vger.kernel.org, linux-input@vger.kernel.org, linux-watchdog@vger.kernel.org Subject: Re: [v3,4/4] watchdog: add Gateworks System Controller support Message-ID: <20180330181954.GA17580@roeck-us.net> References: <1522250043-8065-5-git-send-email-tharvey@gateworks.com> <20180330010757.GA12896@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 30, 2018 at 10:49:38AM -0700, Tim Harvey wrote: > On Thu, Mar 29, 2018 at 6:07 PM, Guenter Roeck wrote: > > On Wed, Mar 28, 2018 at 08:14:03AM -0700, Tim Harvey wrote: > >> Signed-off-by: Tim Harvey > >> --- > >> drivers/watchdog/Kconfig | 10 ++++ > >> drivers/watchdog/Makefile | 1 + > >> drivers/watchdog/gsc_wdt.c | 146 +++++++++++++++++++++++++++++++++++++++++++++ > >> 3 files changed, 157 insertions(+) > >> create mode 100644 drivers/watchdog/gsc_wdt.c > >> > > >> + > >> +static const struct watchdog_info gsc_wdt_info = { > >> + .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING, > > > > Please confirm that WDIOF_MAGICCLOSE is not set on purpose. > > > >> + .identity = "GSC Watchdog" > >> +}; > >> + > > >> + > >> +static int gsc_wdt_probe(struct platform_device *pdev) > >> +{ > >> + struct gsc_dev *gsc = dev_get_drvdata(pdev->dev.parent); > >> + struct device *dev = &pdev->dev; > >> + struct gsc_wdt *wdt; > >> + int ret; > >> + unsigned int reg; > >> + > > >> + /* ensure WD bit enabled */ > >> + if (regmap_read(gsc->regmap, GSC_CTRL_1, ®)) > >> + return -EIO; > >> + if (!(reg & (1 << GSC_CTRL_1_WDT_ENABLE))) { > > > > BIT() > > > >> + dev_err(dev, "not enabled - must be manually enabled\n"); > > > > This doesn't make sense. Bail out if the watchdog is disabled ? Why ? > > > >> + return -EINVAL; > >> + } > >> + > > >> + > >> + watchdog_set_nowayout(&wdt->wdt_dev, 1); > > > > WATCHDOG_NOWAYOUT ? > > > > Guenter, > > Thanks for the review! > > The watchdog implementation of the GSC is such that it is enabled and > reset via a single non-volatile I2C register bit. If this bit is set > the watchdog will start ticking down automatically on board power up. > The register definitions don't provide a condition where it can be > enabled in a volatile way such that after board power-cycle it is > disabled again nor do they provide a separate register for enable vs > reset. > > In the typical case the user boots the board, driver registers > watchdog, userspace watchdog daemon enables watchdog and it starts > ticking. User now powers down the board and later powers it back up. > The watchdog was enabled previously by userspace and the register is > non-volatile so the watchdog starts ticking before the kernel driver > and watchdog daemon yet the user breaks out into the bootloader or > boots a different OS without a watchdog daemon and the board resets > without them expecting it. The feature that the watchdog starts > ticking at board power-up before the CPU has even fetched code was > part of its design and was put there to work around some SoC errata > that can cause the CPU to fail to fetch boot code. This has caused me > to implement a watchdog driver that never actually 'enables' or > 'disables' the watchdog which is why there is no MAGIC CLOSE and why I Yet the driver does enable and disable the watchdog in its start and stop functions. And I have no idea what that has to do with the MAGICCLOSE functionality, which is quite orthogonal to the start/stop functionality. > always set nowayout. Its possible this is a fairly unique case of a > watchdog. The probe failure if the watchdog isn't enabled is because I > don't want a non-enabled watchdog to get enabled just because the > driver/daemon were there. > Huh ? The whole purpose of a watchdog is for it to be enabled when the watchdog device is opened. > I agree it's a very strange behavior and I'm not sure how to best > document or support it with the Linux watchdog API. I welcome any > recomendations! > Sorry, I fail to understand your logic. You do not explain why your code bails out if the watchdog is not already running. That does not make sense. You are saying that you don't want the watchdog driver to enable the watchdog. Since its whole purpose is to enable the watchdog if/when the watchdog device is opened, that doesn't make sense either. At the same time, you do not tell the watchdog core that the watchdog is already running, meaning the system _will_ reboot unless the watchdog device is opened within the watchdog timeout period. Again, that does not make sense. Maybe it all makes sense to you, but not to me, sorry. Guenter