public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Wim Van Sebroeck <wim@iguana.be>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Linux Watchdog Mailing List <linux-watchdog@vger.kernel.org>,
	Alan Cox <alan@lxorguk.ukuu.org.uk>
Subject: Re: [PATCH 1/10 v2] Generic Watchdog Timer Driver
Date: Fri, 24 Jun 2011 15:59:15 +0200	[thread overview]
Message-ID: <201106241559.16416.arnd@arndb.de> (raw)
In-Reply-To: <20110622195024.GA26745@infomag.iguana.be>

On Wednesday 22 June 2011 21:50:24 Wim Van Sebroeck wrote:

> > I'm pretty sure you don't need bitops.h or uaccess.h here, because all the
> > code using those has moved into the core.
> 
> bitops will be used later on, but this can indeed be cleaned up.
> 
> > > +#include <linux/io.h>
> > 
> > This is also not needed here, although it will probably be needed in most
> > real drivers.
> 
> Same.

Nevermind then.

> > > +#include <linux/platform_device.h>
> > > +
> > > +/* Hardware heartbeat in seconds */
> > > +#define WDT_HW_HEARTBEAT 2
> > > +
> > > +/* Timer heartbeat (500ms) */
> > > +#define WDT_HEARTBEAT	(HZ/2)	/* should be <= ((WDT_HW_HEARTBEAT*HZ)/2) */
> > > +
> > > +/* User land timeout */
> > > +#define WDT_TIMEOUT 15
> > > +static int timeout = WDT_TIMEOUT;
> > > +module_param(timeout, int, 0);
> > > +MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. "
> > > +	"(default = " __MODULE_STRING(WDT_TIMEOUT) ")");
> > 
> > Should the module parameter really be part of each individual driver?
> > It would be nice if that can be moved into the core as well.
> 
> Yes, the module parameter is needed for each individual driver.
> If we go for supporting multiple watchdog devices, then we will have to support
> different timeout values. The timeout ranges also differ for different devices.

Ok, but you'd still have to worry about a single driver supporting multiple
distinct devices that each want a separate timeout, right?

OTOH, we can still find a solution when it ever gets to the point of
supporting multiple devices.

> > > +static void wdt_timer_tick(unsigned long data);
> > 
> > I usually recommend reordering all functions so that you don't need any forward
> > declarations, that makes the driver easier to read IMHO.
> > 
> > > +static DEFINE_TIMER(timer, wdt_timer_tick, 0, 0);
> > > +					/* The timer that pings the watchdog */
> 
> Yes, I also tend to do that but it's used in the DEFINE_TIMER(timer, wdt_timer_tick, 0, 0);
> just under it. No clean way to do that better imho...

Ah, right. I missed that. You could get rid of the forward declaration
by dynamically initializing the timer struct, but that would be no
better than what you have now.

> > Is it common for watchdog these days to have both a kernel timer and
> > a user space timer?
> 
> No, it is only common for watchdog devices that
> 1) don't stop once started
> 2) device that have very small (mostly < 1second) heartbeat values.
> All other watchdog device timers don't need and use the kernel timer.

Ok, I hadn't thought of these.

> > If yes, that might be good to support in the core as well, instead of
> > having to implement it in each driver.
> > 
> > If no, it might not be ideal to have in an example driver.
> 
> As said, it's an example for a common exception. You should not look at this
> as a common example driver. I added it, because it's a common exception that
> people understand less.

ok.

> > > +struct watchdog_device {
> > > +	char *name;
> > > +	const struct watchdog_ops *ops;
> > > +	long status;
> > > +};
> > > +
> > > +It contains following fields:
> > > +* name: a pointer to the (preferably unique) name of the watchdog timer device.
> > > +* ops: a pointer to the list of watchdog operations that the watchdog supports.
> > > +* status: this field contains a number of status bits that give extra
> > > +  information about the status of the device (Like: is the device opened via
> > > +  the /dev/watchdog interface or not, ...)
> > 
> > I think this should really have a pointer to the struct device implementing the
> > watchdog, so that a driver that gets called with a struct watchdog_device can
> > find its own state from there. Alternatively, you could have struct device
> > embedded in struct watchdog_device and register it as a child of the hardware
> > device.
> 
> Would go for a pointer to private data then.

Ok.

	Arnd

  reply	other threads:[~2011-06-24 13:59 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-18 17:19 [PATCH 1/10 v2] Generic Watchdog Timer Driver Wim Van Sebroeck
2011-06-18 18:58 ` Arnd Bergmann
2011-06-20  3:44   ` Randy Dunlap
2011-06-22 20:15     ` Wim Van Sebroeck
2011-06-22 12:24   ` Mark Brown
2011-06-22 19:50   ` Wim Van Sebroeck
2011-06-24 13:59     ` Arnd Bergmann [this message]
2011-06-24 19:27       ` Wim Van Sebroeck
2011-07-06 19:17   ` Wim Van Sebroeck
2011-07-06 19:26     ` Alan Cox
2011-07-06 19:30     ` Wolfram Sang
2011-06-22 18:28 ` Chris Friesen
2011-06-22 20:25   ` Wim Van Sebroeck

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=201106241559.16416.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=wim@iguana.be \
    /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