All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Markus Pargmann <mpa@pengutronix.de>, Wim Van Sebroeck <wim@iguana.be>
Cc: linux-watchdog@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH] watchdog: core: module param to activate watchdog
Date: Sat, 01 Mar 2014 21:11:18 -0800	[thread overview]
Message-ID: <5312BD76.2080102@roeck-us.net> (raw)
In-Reply-To: <1393604183-8755-1-git-send-email-mpa@pengutronix.de>

On 02/28/2014 08:16 AM, Markus Pargmann wrote:
> Many watchdog driver reset the watchdog device on initialization. This
> is a problem if the watchdog is activated by the bootloader and should
> be active the whole time until the userspace can write to it.
>

Shouldn't those watchdog drivers be fixed to keep the watchdog running
if it was already active ? Otherwise there is still the time between
driver initialization, which disables the watchdog, and it being re-enabled
by watchdog registration.

Also, does this affect or impact drivers which _do_ keep the watchdog
enabled ?

> This patch adds a module parameter (watchdog.activate_first) that
> activates the first registered watchdog. Using this parameter it is
> possible to have an active watchdog during the whole boot process.
>
> Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
> ---
>   drivers/watchdog/watchdog_core.c |  4 ++++
>   drivers/watchdog/watchdog_core.h |  4 ++++
>   drivers/watchdog/watchdog_dev.c  | 21 ++++++++++++++++++++-
>   3 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c
> index cec9b55..6db16eb 100644
> --- a/drivers/watchdog/watchdog_core.c
> +++ b/drivers/watchdog/watchdog_core.c
> @@ -43,6 +43,10 @@
>   static DEFINE_IDA(watchdog_ida);
>   static struct class *watchdog_class;
>
> +unsigned int activate_first = 0;

Bad variable name for a global variable.

> +module_param(activate_first, uint, 0);
> +MODULE_PARM_DESC(activate_first, "Activation timeout for first watchdog registered. 0 means no activation.");
> +

Does that _have_ to be in this file ? Would be much easier
if it was in watchdog_dev.c, where it is used.

>   static void watchdog_check_min_max_timeout(struct watchdog_device *wdd)
>   {
>   	/*
> diff --git a/drivers/watchdog/watchdog_core.h b/drivers/watchdog/watchdog_core.h
> index 6c95141..4526170 100644
> --- a/drivers/watchdog/watchdog_core.h
> +++ b/drivers/watchdog/watchdog_core.h
> @@ -28,6 +28,10 @@
>
>   #define MAX_DOGS	32	/* Maximum number of watchdog devices */
>
> +/* Activate first registered watchdog and set this as the timeout value
> + * (only != 0) */

Coding style.

> +extern unsigned int activate_first;
> +
>   /*
>    *	Functions/procedures to be called by the core
>    */
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index 6aaefba..fe60fdc 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -553,8 +553,27 @@ int watchdog_dev_register(struct watchdog_device *watchdog)
>   			misc_deregister(&watchdog_miscdev);
>   			old_wdd = NULL;
>   		}
> +

Is that extra empty line really necessary ?

> +		return err;
>   	}
> -	return err;
> +
> +	if (activate_first && watchdog->id == 0) {
> +		err = watchdog_set_timeout(watchdog, activate_first);
> +		if (err && err != -EOPNOTSUPP) {
> +			pr_err("watchdog%d failed to set timeout for first activation\n",
> +					watchdog->id);
> +			return err;
> +		}
> +
> +		err = watchdog_start(watchdog);
> +		if (err) {
> +			pr_err("watchdog%d failed to start first watchdog\n",
> +					watchdog->id);
> +			return err;
> +		}
> +	}
> +
> +	return 0;
>   }
>
>   /*
>


  reply	other threads:[~2014-03-02  5:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 16:16 [PATCH] watchdog: core: module param to activate watchdog Markus Pargmann
2014-03-02  5:11 ` Guenter Roeck [this message]
2014-03-03  9:39   ` Markus Pargmann
2014-03-02  9:43 ` Wim Van Sebroeck
2014-03-03  9:27   ` Markus Pargmann
2014-03-03 10:19     ` Wim Van Sebroeck
2014-03-03 11:09       ` Markus Pargmann
2014-03-03 14:38         ` 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=5312BD76.2080102@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=kernel@pengutronix.de \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=mpa@pengutronix.de \
    --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 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.