Received: by 10.213.65.68 with SMTP id h4csp564983imn; Fri, 30 Mar 2018 10:52:08 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+YoEMRJghnig33Ua5uwmrKCBMe609icyyao22rKKdQ8S2VYraoNJ9Y1veCwvIA/KdBUI03 X-Received: by 10.167.131.135 with SMTP id u7mr10500264pfm.50.1522432328532; Fri, 30 Mar 2018 10:52:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522432328; cv=none; d=google.com; s=arc-20160816; b=Wb4a9MzNNwX8K5pZWvvLHuICqVJEZvMNO8bZVNwQwj620x5WQCrVGWcJELuzWOpUse HqS3dtRsaKqoPw8wQvTRtWHt1ixhyHQo6kwqu8PCBc1LOBpxygBuHnpft2uxb2XsP/Xd zGNUTR7Uow3RiVWLz9YF2IbV9Xe49hKfOCf15R1HbYzVTOiwghKZr3ZstaJofG78Ta9E H82QZRGDDgsQ8ZpCuNi/G9eeQarEJDuPQ8RyD40/tTFeuH1+9tk+tYIrpTTdjo9a5o5U sphaJFV/WE2ddpCVViY5LvGUtz/UW5SgeYFbprbqhCuv6Q88q+UpXD+uxAUvv2K2S7W8 p4fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=hQXb0Wg626/HhNHP9z32W5/2LFMYc7V5bYklkhoiZek=; b=hwCNx3pLNUTvceHNcfMnBDWb2sDdz2bmgVQ7jWaWB/KARtKln29M+V1Tff25440gT7 fc42R4nnkOQfJb25dfK4tPcpqG8wC4F+rkxdoZOI9b/+FPZtVhYROurQ17Yv6C6V0rcn 2vDVqj6Nc1pEO3UbAGENablhc1VnsO9aZpHXZfg3ow4lxVkMmhGaLon23AxnkR1Mao5D rMyEnoDGZYAlZXabqyZYyovJiPTfpMVjKHhc3auLi1ylAbE+x/83Bbki+Zc89UqEDkuW UhTkI2OrttryrVsaBIWFlZW4AkG4B8UrS00/OpI88yhk9/vtBoviZDFAdQkmezocfSL0 0C4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=wroksduU; 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 b60-v6si8768135plc.75.2018.03.30.10.51.54; Fri, 30 Mar 2018 10:52:08 -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=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=wroksduU; 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 S1752281AbeC3Rtn (ORCPT + 99 others); Fri, 30 Mar 2018 13:49:43 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:55556 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeC3Rtk (ORCPT ); Fri, 30 Mar 2018 13:49:40 -0400 Received: by mail-wm0-f65.google.com with SMTP id b127so15798850wmf.5 for ; Fri, 30 Mar 2018 10:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=hQXb0Wg626/HhNHP9z32W5/2LFMYc7V5bYklkhoiZek=; b=wroksduUKfvQfIgpNAL96xpVA7Kh+2oN/g9lTY0yL9O0XvLl7T0Izbw4NBYnk2lJiG GnM9N7xKu08fCzcxrnCaqQYp1/MlqZUNjyFWQhBAQsNw9FVDsU/ZULnY4o3OgBr/OP4m INKeSuGZe2dAtjwRSLTOyBIolWvAHwW8GTjZlNJxyu7nOh15gFAUYdUExVuOyBXFRiTo HV9I+kMhqzF4mUiXEhT0SN9d8aMcnhMYpiC62LtSvTCLEz4ex1MnpUASn2sxT6XjhjI/ SDX7ofmVE3Dl/57niaBHkmUTt+1h3rqZ5DNtLGZkjLFbeSxcqEt0ll9AximyeCcQEnK0 xqYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=hQXb0Wg626/HhNHP9z32W5/2LFMYc7V5bYklkhoiZek=; b=RUJkuWfK5T8NLEy8CLnz35SUoMxlDZOfpz4H6bkvbKF5sjcTARYgKIeRd5L/A6JbSd 8kY+ljQD7kPheaf+010NSbRz0VnutYOjop22ErC8fPaMhyuVJdiZ473+jdBoccHgnEds RAah4dmftCx1b70tGf2l0AoPsFXh9KG1vsWOwaQ3gtbM0FOp0RZSXI4L8ubpX2KtAnGw AZtjcadvcOnhdPMpU53sWzzo1IRze7HZXkO1VLBoXd1kbwo8o/zz2KPaE9IGzBdepqIa WoYMBYe6iFSlEAOOata38B0AufOi83rYfHrx73gWZMP9U16EGocvpZqKrRzZrnH5zWjo ll2w== X-Gm-Message-State: AElRT7EgQvjXC2RtzZQaTsOWeopE+7GQxBeqTzA+wHE/iqwTBtMIOs6C +QFGJs0Mmp+K7zz1ifx4Xt0grnNCJ3yu/2kdP0VL/w== X-Received: by 10.28.126.145 with SMTP id z139mr2742038wmc.18.1522432179183; Fri, 30 Mar 2018 10:49:39 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.6.66 with HTTP; Fri, 30 Mar 2018 10:49:38 -0700 (PDT) In-Reply-To: <20180330010757.GA12896@roeck-us.net> References: <1522250043-8065-5-git-send-email-tharvey@gateworks.com> <20180330010757.GA12896@roeck-us.net> From: Tim Harvey Date: Fri, 30 Mar 2018 10:49:38 -0700 Message-ID: Subject: Re: [v3,4/4] watchdog: add Gateworks System Controller support To: Guenter Roeck 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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. 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! Regards, Tim