Received: by 10.223.185.116 with SMTP id b49csp2125484wrg; Sat, 17 Feb 2018 12:52:12 -0800 (PST) X-Google-Smtp-Source: AH8x227zK8WpkOX50P7weEjS4t/bE6pvSUsy/a/3LOUn3oQ30+on3Zo1LTeBlDqF4c/k9DSzngR0 X-Received: by 10.99.56.7 with SMTP id f7mr8504999pga.114.1518900732412; Sat, 17 Feb 2018 12:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518900732; cv=none; d=google.com; s=arc-20160816; b=Lex1IX03N0Z/dliQ7CvZr/eZ851E1WYp1b59RjcdQu+xR5QuU33DyOIxfTcUZaYh5u 6CxKd5cQLdKyWu0hsJuXzslVB7w4+yUAA0oxHfrtKu1CHIbar+nidtwkIGmh/dqw6SAi mE6zQxw5+TfwwCq2k3kPCKLTTssiQ2Uv+NM1fVQanWqndUkpsmFK6lTUzb31iMP6Y/PL b3r85KHoqSHHU6i2bjMgTUk/9hpoHlM+vDqQm+9imuFHgJGrC+Yfr61sM+zko5UegvXR fSHbZXHrxB/eIGlO2VnqbQ0EYon9fmnYdlQhC4LoHk2JVaL4aUSpWLYUHx4T8lNZ6D9d WVTA== 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:reply-to:message-id :subject:cc:to:from:date:arc-authentication-results; bh=8PP44Dkkyoo0ZuHy9JD7P/W0asCugVr+kdf7mcz4f7o=; b=wWrdJ7nqsfJGY9mJDs9hPnKHq58YQaUvdLIybAgdrhAk/xMNrA4oVlpz5iX1rb4sLD Dj4ZFgkK2e3EPZQ0D79TTEZzXOjNhGMmmIHtwaSvbqnJ+4oVzymM/224n9/hS3pqY0ti mGOVcEmFtxDOCP0gzRrKKY06gplZ1kVQI2DIjGkoDemWKDVM2Xg8ICGjwsac96ydh5Fu uyICWhUmomAaHuw7tLNAXGaYClwh5YSIl1SCiYtVseuQfoYRTrtSpw9eAuOisLpRzzzh OtekodbFZx2Iqy7sTvvWAqIpnvmcqj0huS9XuR6jG4w5nvF6VX1z/1TDyc+yPoIqFA8y hO2A== ARC-Authentication-Results: i=1; mx.google.com; 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 bb4-v6si1462236plb.507.2018.02.17.12.51.57; Sat, 17 Feb 2018 12:52:12 -0800 (PST) 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; 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 S1751336AbeBQUvW (ORCPT + 99 others); Sat, 17 Feb 2018 15:51:22 -0500 Received: from g4t3425.houston.hpe.com ([15.241.140.78]:40012 "EHLO g4t3425.houston.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbeBQUvV (ORCPT ); Sat, 17 Feb 2018 15:51:21 -0500 Received: from g4t3433.houston.hpecorp.net (g4t3433.houston.hpecorp.net [16.208.49.245]) by g4t3425.houston.hpe.com (Postfix) with ESMTP id 3E3675F; Sat, 17 Feb 2018 20:51:20 +0000 (UTC) Received: from anatevka.americas.hpqcorp.net (anatevka.americas.hpqcorp.net [10.34.81.6]) by g4t3433.houston.hpecorp.net (Postfix) with ESMTP id 7040146; Sat, 17 Feb 2018 20:51:19 +0000 (UTC) Date: Sat, 17 Feb 2018 13:51:19 -0700 From: Jerry Hoemann To: Guenter Roeck Cc: wim@linux-watchdog.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, rwright@hpe.com, maurice.a.saldivar@hpe.com, mingo@kernel.org, marcus.folkesson@gmail.com Subject: Re: [v3,07/11] watchdog/hpwdt: Modify to use watchdog core. Message-ID: <20180217205119.GE27788@anatevka.americas.hpqcorp.net> Reply-To: Jerry.Hoemann@hpe.com References: <20180215234400.5022-8-jerry.hoemann@hpe.com> <20180217164907.GA8375@roeck-us.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180217164907.GA8375@roeck-us.net> User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 17, 2018 at 08:49:07AM -0800, Guenter Roeck wrote: > On Thu, Feb 15, 2018 at 04:43:56PM -0700, Jerry Hoemann wrote: > > Follow Documentation/watchdog/convert_drivers_to_kernel_api.txt to > > convert hpwdt from legacy watchdog driver to use the watchdog core. > > > > Removed functions: hpwdt_open, hpwdt_release, hpwdt_write, hpwdt_ioctl > > Removed data structures: hpwdt_fops, hpwdt_miscdev, watchdog_device > > Modified functions: hpwdt_start, hpwdt_stop, hpwdt_ping, hpwdt_gettimeleft > > Added functions: hpwdt_settimeout > > Added structures: watchdog_device > > > > Signed-off-by: Jerry Hoemann > > --- > > drivers/watchdog/hpwdt.c | 249 ++++++++++++----------------------------------- > > 1 file changed, 63 insertions(+), 186 deletions(-) > > > > diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c > > index 71e49d0ab789..da9a04101814 100644 > > --- a/drivers/watchdog/hpwdt.c > > +++ b/drivers/watchdog/hpwdt.c > > @@ -14,18 +14,13 @@ > > #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt > > > > #include > > -#include > > -#include > > The driver still performs direct IO. Why do you remove this > include file ? I was just removing file includes no longer needed to compile the module. While there are sential ifdef protecting against compile errors for multiply including the same file, the extra open and parsing of the file does add a little bit of overhead to the build time. Probably not as important today as it used to be. I will redact the change. > > > -#include > > #include > > -#include > > #include > > #include > > #include > > -#include > > The PCI vendor IDs used by the driver are declared in this file. > Is there a direction somewhere suggesting that this file > should not be directly included ? See above. > > > #include > > -#include > > #include > > + > > #include > > > > #define HPWDT_VERSION "1.4.0" > > @@ -40,8 +35,6 @@ static bool nowayout = WATCHDOG_NOWAYOUT; > > #ifdef CONFIG_HPWDT_NMI_DECODING > > static unsigned int allow_kdump = 1; > > #endif > > -static char expect_release; > > -static unsigned long hpwdt_is_open; > > > > static void __iomem *pci_mem_addr; /* the PCI-memory address */ > > static unsigned long __iomem *hpwdt_nmistat; > > @@ -55,53 +48,58 @@ static const struct pci_device_id hpwdt_devices[] = { > > }; > > MODULE_DEVICE_TABLE(pci, hpwdt_devices); > > > > +static struct watchdog_device hpwdt_dev; > > Please no double declarations. This is only needed for the NMI > code to pass to hpwdt_stop where it isn't used. It would be > easy to introduce _hpwdt_stop() with no parameter and call that > function frm hpwdt_stop(). I'll redact this change. I'll add a new function hpwdt_stop_new (or something like that) which takes the watchdog_devices as input and it will call current upstream hpwdt_stop. > > > > > - retval = misc_register(&hpwdt_miscdev); > > + hpwdt_dev.parent = &dev->dev; > > + retval = watchdog_register_device(&hpwdt_dev); > > if (retval < 0) { > > - dev_warn(&dev->dev, > > - "Unable to register miscdev on minor=%d (err=%d).\n", > > - WATCHDOG_MINOR, retval); > > - goto error_misc_register; > > + dev_warn(&dev->dev, "Unable to register hpe watchdog (err=%d).\n", retval); > > checkpatch warning. Also, this should be dev_err() since it is fatal. i'll change to dev_err. i'll shorten the message to something similar. > > > + goto error_wd_register; > > } > > > > + /* Make sure that timer is disabled until /dev/watchdog is opened */ > > + hpwdt_stop(&hpwdt_dev); > > The watchdog is already registered and the device can already have been > opened at this point. The watchdog would have to be stopped before > registering the watchdog. > > A better approach would be to detect if the watchdog is running and inform > the watchdog core about it. The code in the stop function suggests that > this would be possible. This would ensure that the watchdog protection > during boot is retained. I will redact this change as it will no longer be necessary. See above. > > > + > > + watchdog_set_nowayout(&hpwdt_dev, nowayout); > > + if (watchdog_init_timeout(&hpwdt_dev, soft_margin, NULL)) > > + dev_warn(&dev->dev, "Invalid soft_margin: %d. Using default\n", soft_margin); > > + > Those two functions should be called before registering the watchdog. > Also, there is a checkpatch warning. > Will change. Please update the Documentation/watchdog/watchdog-kernel-api.txt. It is not clear from the documentation which interfaces are to be called before watchdog_register_device and which ones are to be called after. -- ----------------------------------------------------------------------------- Jerry Hoemann Software Engineer Hewlett Packard Enterprise -----------------------------------------------------------------------------