mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Jerry Hoemann <jerry.hoemann@hpe.com>
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: [PATCH v3 08/11] watchdog/hpwdt: Programable Pretimeout NMI
Date: Fri, 16 Feb 2018 15:55:06 -0800	[thread overview]
Message-ID: <20180216235506.GA26546@roeck-us.net> (raw)
In-Reply-To: <20180216234617.GA675@anatevka.americas.hpqcorp.net>

On Fri, Feb 16, 2018 at 04:46:17PM -0700, Jerry Hoemann wrote:
> On Fri, Feb 16, 2018 at 12:34:40PM -0800, Guenter Roeck wrote:
> > On Thu, Feb 15, 2018 at 04:43:57PM -0700, Jerry Hoemann wrote:
> > > Make whether or not the hpwdt watchdog delivers a pretimeout NMI
> > > programable by the user.
> > > 
> > > The underlying iLO hardware is programmable as to whether or not
> > > a pre-timeout NMI is delivered to the system before the iLO resets
> > > the system.  However, the iLO does not allow for programming the
> > > length of time that NMI is delivered before the system is reset.
> > > 
> > > Hence, in hpwdt_set_pretimeout, val == 0 disables the NMI. Any
> > > non-zero value sets the pretimeout length to what the hardware
> > > supports.
> > > 
> > > Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
> > > ---
> > >  drivers/watchdog/hpwdt.c | 42 ++++++++++++++++++++++++++++++++++++------
> > >  1 file changed, 36 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c
> > > index da9a04101814..dc0ad20738ed 100644
> > > --- a/drivers/watchdog/hpwdt.c
> > > +++ b/drivers/watchdog/hpwdt.c
> > > @@ -28,12 +28,15 @@
> > >  #define TICKS_TO_SECS(ticks)		((ticks) * 128 / 1000)
> > >  #define HPWDT_MAX_TIMER			TICKS_TO_SECS(65535)
> > >  #define DEFAULT_MARGIN			30
> > > +#define PRETIMEOUT_SEC			9
> > >  
> > >  static unsigned int soft_margin = DEFAULT_MARGIN;	/* in seconds */
> > > -static unsigned int reload;			/* the computed soft_margin */
> > >  static bool nowayout = WATCHDOG_NOWAYOUT;
> > >  #ifdef CONFIG_HPWDT_NMI_DECODING
> > >  static unsigned int allow_kdump = 1;
> > > +static bool pretimeout = 1;
> > > +#else
> > > +static bool pretimeout;
> > >  #endif
> > >  
> > static bool pretimeout = IS_ENABLED(CONFIG_HPWDT_NMI_DECODING);
> 
> ack. will do.
> 
> > 
> > >  static void __iomem *pci_mem_addr;		/* the PCI-memory address */
> > > @@ -55,10 +58,12 @@ static struct watchdog_device hpwdt_dev;
> > >   */
> > >  static int hpwdt_start(struct watchdog_device *dev)
> > >  {
> > > -	reload = SECS_TO_TICKS(dev->timeout);
> > > +	int control = 0x81 | (pretimeout ? 0x4 : 0);
> > > +	int reload = SECS_TO_TICKS(dev->timeout);
> > >  
> > > +	dev_dbg(dev->parent, "start watchdog 0x%08x:0x%02x\n", reload, control);
> > >  	iowrite16(reload, hpwdt_timer_reg);
> > > -	iowrite8(0x85, hpwdt_timer_con);
> > > +	iowrite8(control, hpwdt_timer_con);
> > >  
> > >  	return 0;
> > >  }
> > > @@ -67,6 +72,8 @@ static int hpwdt_stop(struct watchdog_device *dev)
> > >  {
> > >  	unsigned long data;
> > >  
> > > +	dev_dbg(dev->parent, "stop  watchdog\n");
> > > +
> > Unrelated.
> > 
> > >  	data = ioread8(hpwdt_timer_con);
> > >  	data &= 0xFE;
> > >  	iowrite8(data, hpwdt_timer_con);
> > > @@ -75,8 +82,9 @@ static int hpwdt_stop(struct watchdog_device *dev)
> > >  
> > >  static int hpwdt_ping(struct watchdog_device *dev)
> > >  {
> > > -	reload = SECS_TO_TICKS(dev->timeout);
> > > +	int reload = SECS_TO_TICKS(dev->timeout);
> > >  
> > > +	dev_dbg(dev->parent, "ping  watchdog 0x%08x\n", reload);
> > 
> > Unrelated. If you want to add debug messages, please do it
> > in a separate patch.
> 
> 
> Different patch, but same set?  I'll move these (and ones from earlier
> patch to a new separate patch later in set.)
> 
> > 
> > >  	iowrite16(reload, hpwdt_timer_reg);
> > >  
> > >  	return 0;
> > > @@ -98,12 +106,21 @@ static int hpwdt_settimeout(struct watchdog_device *dev, unsigned int val)
> > >  }
> > >  
> > >  #ifdef CONFIG_HPWDT_NMI_DECODING	/* { */
> > > +static int hpwdt_set_pretimeout(struct watchdog_device *dev, unsigned int val)
> > > +{
> > > +	if (val && (val != PRETIMEOUT_SEC)) {
> > 
> > Unnecessary ( )
> 
> 
> There are several things going on here. I'm not sure which one the above
> comment is intended.
> 
The "Unnecessary" refers to the ( ) around the second part of the expression
above. While there may be valid reasons to include extra ( ), I think we
can trust the C compiler to get it right here.

> While a pretimeout NMI isn't required by the HW to be enabled, if enabled the
> length of pretimeout is fixed by HW.
> 
> I didn't see anything in the API that would allow us to communicate to
> the user this "feature."  timeout at leasst has both min_timeout and max_timeout, but
> I didn't see similar for pretimeout.  I also don't think its reasonable to fail
> here if the requested value is not 9 as the user really has no way of knowing what
> the valid range of pretimeout values are.  So I accept, any non-zero value
> for pretimeout, but then set pretimeout to be 9.
> 
> But at the same time, I don't like to siliently change a human request
> w/o at least warning.
> 
Sorry, I lost you here.

> > 
> > The actual timeout can be a value smaller than 9 seconds.
> > Minimum is 1 second. What happens if the user configures
> > a timeout of less than 9 seconds as well as a pretimeout ?
> > Will it fire immediately ? 
> 
> The architecture is silient on this issue.  My experience with
> this is that if timeout < 9 seconds, the NMI is not issued.
> System resets when the timeout expires.  This could be implementation
> dependent.
> 
> Note, this is not a new issue.
> 
Bad argument.

> I thought about setting the min timeout to ten seconds to avoid this situation.
> 
You could reject reject request to set the pretimeout to a value <= the
timeout.

> I haven't dug into the various user level clients of watchdog so I'm not sure 
> what the impact of making this change would be to them.
> 
> 
> > 
> > > +		dev_info(dev->parent, "Setting pretimeout to %d\n", PRETIMEOUT_SEC);
> > 
> > Please no ongoing logging noise. This can easily be abused to clog
> > the kernel log.
> 
> Good point.  I will look at WARN_ONCE or something similar.
> 
A traceback if someone sets a bad timeout ? That would be even worse.

Guenter

> > 
> > > +		val = PRETIMEOUT_SEC;
> > > +	}
> > > +	dev->pretimeout = val;
> > > +	pretimeout = val ? 1 : 0;
> > 
> > 	pretimeout = !!val;
> > 
> 
> -- 
> 
> -----------------------------------------------------------------------------
> Jerry Hoemann                  Software Engineer   Hewlett Packard Enterprise
> -----------------------------------------------------------------------------

  reply	other threads:[~2018-02-16 23:55 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
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 [this message]
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=20180216235506.GA26546@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=jerry.hoemann@hpe.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome