All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kyle Roeschley <kyle.roeschley@ni.com>
To: Josh Cartwright <joshc@ni.com>
Cc: <linux-watchdog@vger.kernel.org>
Subject: Re: [RFC 3/4] watchdog: ni9x3x_wdt: Add timeout_action sysfs attribute
Date: Fri, 5 Feb 2016 15:13:52 -0600	[thread overview]
Message-ID: <20160205211352.GC11390@senary> (raw)
In-Reply-To: <20160205200803.GC9579@jcartwri.amer.corp.natinst.com>

On Fri, Feb 05, 2016 at 02:08:03PM -0600, Josh Cartwright wrote:
> On Thu, Feb 04, 2016 at 07:28:02PM -0600, Kyle Roeschley wrote:
> [..]
> > diff --git a/drivers/watchdog/ni9x3x_wdt.c b/drivers/watchdog/ni9x3x_wdt.c
> > index 13f5c10..1fce4d0 100644
> > --- a/drivers/watchdog/ni9x3x_wdt.c
> > +++ b/drivers/watchdog/ni9x3x_wdt.c
> > @@ -15,6 +15,7 @@
> >  #include <linux/acpi.h>
> >  #include <linux/interrupt.h>
> >  #include <linux/module.h>
> > +#include <linux/sysfs.h>
> >  #include <linux/watchdog.h>
> >  
> >  #define NIWD_CONTROL	0x01
> > @@ -28,6 +29,7 @@
> >  #define NIWD_IO_SIZE	0x08
> >  
> >  #define NIWD_CONTROL_MODE		0x80
> > +#define NIWD_CONTROL_PROC_INTERRUPT	0x40
> >  #define NIWD_CONTROL_PROC_RESET		0x20
> >  #define NIWD_CONTROL_PET		0x10
> >  #define NIWD_CONTROL_RUNNING		0x08
> > @@ -48,6 +50,7 @@ struct ni9x3x_wdt {
> >  	struct acpi_device *acpi_device;
> >  	u16 io_base;
> >  	u16 io_size;
> > +	u32 irq;
> 
> Interrupts have type 'int'.
> 
> >  	spinlock_t lock;
> >  	struct watchdog_device wdog;
> >  };
> > @@ -101,6 +104,34 @@ static unsigned int ni9x3x_wdt_wdd_get_timeleft(struct watchdog_device *wdd)
> >  	return (unsigned int)((counter * (u64)NIWD_PERIOD_NS) / 1000000000);
> >  }
> >  
> > +static irqreturn_t ni9x3x_wdt_irq_handler(int irq, void *data)
> > +{
> > +	struct ni9x3x_wdt *wdt = data;
> > +	irqreturn_t ret = IRQ_NONE;
> > +	u8 control;
> > +	unsigned long flags;
> > +
> > +	spin_lock_irqsave(&wdt->lock, flags);
> 
> Interrupts are disabled already, so the _irqsave()/_irqrestore() is
> unnecessary.
> 
> > +
> > +	control = inb(wdt->io_base + NIWD_CONTROL);
> > +
> > +	if (!(NIWD_CONTROL_ALARM & control)) {
> > +		dev_err(&wdt->acpi_device->dev,
> > +			"Spurious watchdog interrupt, 0x%02X\n", control);
> 
> No need to print anything here, just return IRQ_NONE.  The irq core will
> print a much better (and rate-limited) error when/if this occurs.
> 
> > +		goto out_unlock;
> > +	}
> > +
> > +	/* Acknowledge the interrupt. */
> > +	outb(control | NIWD_CONTROL_RESET, wdt->io_base + NIWD_CONTROL);
> > +
> > +	ret = IRQ_HANDLED;
> > +
> > +out_unlock:
> > +	spin_unlock_irqrestore(&wdt->lock, flags);
> > +
> > +	return ret;
> > +}
> 
> This is...strange.  You're allowing a user to enable an interrupt reset
> action, but...there is no way that a user can actually _do_ anything
> when that action occurs.
> 
> I'm reminded of one of these:
> 
>   https://www.youtube.com/watch?v=aqAUmgE3WyM
> 
> (The only reason I can think of where this would be a legitimate thing
> to do was if we were relying on the watchdog interrupt to bring the CPU
> out of a low power state...but AFAIK that's not something we do).
> 
>   Josh

This is another reason (that I forgot to mention) for this being an RFC.
Ideally we'd poll or select the /dev/watchdogN file to wait on interrupt, but
this isn't supported by the watchdog core. My next instinct would be to have an
sysfs attribute named interrupt or event which a user could read/poll/select
to look for a 1 value indicating that an interrupt has occurred. Else, maybe
polling support could be added to the core, but I don't expect it would be very
useful.

Kyle

  reply	other threads:[~2016-02-05 21:13 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-05  1:28 [RFC 1/4] watchdog: ni9x3x_wdt: Add NI 903x/913x watchdog driver Kyle Roeschley
2016-02-05  1:28 ` [RFC 2/4] watchdog: ni9x3x_wdt: Add counter sysfs attribute Kyle Roeschley
2016-02-05 19:53   ` Josh Cartwright
2016-02-06 16:35     ` Guenter Roeck
2016-02-05  1:28 ` [RFC 3/4] watchdog: ni9x3x_wdt: Add timeout_action " Kyle Roeschley
2016-02-05 20:08   ` Josh Cartwright
2016-02-05 21:13     ` Kyle Roeschley [this message]
2016-02-05 21:40       ` Josh Cartwright
2016-02-06  0:00       ` Guenter Roeck
2016-02-05  1:28 ` [RFC 4/4] watchdog: ni9x3x_wdt: Let user control watchdog mode Kyle Roeschley
2016-02-05 20:27   ` Josh Cartwright
2016-02-05 21:03     ` Kyle Roeschley
2016-02-05 21:34       ` Josh Cartwright
2016-02-06 16:42       ` Guenter Roeck
2016-02-05 19:49 ` [RFC 1/4] watchdog: ni9x3x_wdt: Add NI 903x/913x watchdog driver Josh Cartwright
2016-02-06 16:30 ` Guenter Roeck
2016-02-08 16:06   ` Kyle Roeschley
2016-02-06 16:33 ` Guenter Roeck

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=20160205211352.GC11390@senary \
    --to=kyle.roeschley@ni.com \
    --cc=joshc@ni.com \
    --cc=linux-watchdog@vger.kernel.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.