All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Hoemann <jerry.hoemann@hpe.com>
To: Guenter Roeck <linux@roeck-us.net>
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.
Date: Sat, 17 Feb 2018 13:51:19 -0700	[thread overview]
Message-ID: <20180217205119.GE27788@anatevka.americas.hpqcorp.net> (raw)
In-Reply-To: <20180217164907.GA8375@roeck-us.net>

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 <jerry.hoemann@hpe.com>
> > ---
> >  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 <linux/device.h>
> > -#include <linux/fs.h>
> > -#include <linux/io.h>
> 
> 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 <linux/bitops.h>
> >  #include <linux/kernel.h>
> > -#include <linux/miscdevice.h>
> >  #include <linux/module.h>
> >  #include <linux/moduleparam.h>
> >  #include <linux/pci.h>
> > -#include <linux/pci_ids.h>
> 
> 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 <linux/types.h>
> > -#include <linux/uaccess.h>
> >  #include <linux/watchdog.h>
> > +
> >  #include <asm/nmi.h>
> >  
> >  #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
-----------------------------------------------------------------------------

  reply	other threads:[~2018-02-17 20:51 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 23:43 [PATCH v3 00/11] watchdog/hpwdt: Update driver to use watchdog core Jerry Hoemann
2018-02-15 23:43 ` [PATCH v3 01/11] watchdog/hpwdt: Remove legacy NMI sourcing Jerry Hoemann
2018-02-16  7:22   ` Ingo Molnar
2018-02-17 16:08   ` [v3,01/11] " Guenter Roeck
2018-02-15 23:43 ` [PATCH v3 02/11] watchdog/hpwdt: remove include files no longer needed Jerry Hoemann
2018-02-17 16:10   ` [v3,02/11] " Guenter Roeck
2018-02-15 23:43 ` [PATCH v3 03/11] watchdog/hpwdt: Update nmi_panic message Jerry Hoemann
2018-02-17 16:14   ` [v3,03/11] " Guenter Roeck
2018-02-15 23:43 ` [PATCH v3 04/11] watchdog/hpwdt: white space changes Jerry Hoemann
2018-02-17 16:17   ` [v3,04/11] " Guenter Roeck
2018-02-17 19:32     ` Jerry Hoemann
2018-02-17 20:27       ` Marcus Folkesson
2018-02-17 20:33         ` Jerry Hoemann
2018-02-19 16:46       ` Guenter Roeck
2018-02-20  7:31     ` Philippe Ombredanne
2018-02-15 23:43 ` [PATCH v3 05/11] watchdog/hpwdt: Update Module info Jerry Hoemann
2018-02-17 16:19   ` [v3,05/11] " Guenter Roeck
2018-02-17 20:39     ` Jerry Hoemann
2018-02-15 23:43 ` [PATCH v3 06/11] watchdog/hpwdt: Select WATCHDOG_CORE Jerry Hoemann
2018-02-17 16:21   ` [v3,06/11] " Guenter Roeck
2018-02-17 20:08     ` Jerry Hoemann
2018-02-15 23:43 ` [PATCH v3 07/11] watchdog/hpwdt: Modify to use watchdog core Jerry Hoemann
2018-02-17 16:49   ` [v3,07/11] " Guenter Roeck
2018-02-17 20:51     ` Jerry Hoemann [this message]
2018-02-15 23:43 ` [PATCH v3 08/11] watchdog/hpwdt: Programable Pretimeout NMI Jerry Hoemann
2018-02-16 20:34   ` Guenter Roeck
2018-02-16 23:46     ` Jerry Hoemann
2018-02-16 23:55       ` Guenter Roeck
2018-02-17  1:56         ` Jerry Hoemann
2018-02-17  2:29           ` Guenter Roeck
2018-02-15 23:43 ` [PATCH v3 09/11] watchdog/hpwdt: condition early return of NMI handler on iLO5 Jerry Hoemann
2018-02-15 23:43 ` [PATCH v3 10/11] watchdog/hpwdt: remove allow_kdump module parameter Jerry Hoemann
2018-02-15 23:44 ` [PATCH v3 11/11] watchdog/hpwdt: Update driver version Jerry Hoemann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180217205119.GE27788@anatevka.americas.hpqcorp.net \
    --to=jerry.hoemann@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=marcus.folkesson@gmail.com \
    --cc=maurice.a.saldivar@hpe.com \
    --cc=mingo@kernel.org \
    --cc=rwright@hpe.com \
    --cc=wim@linux-watchdog.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.