From: Josh Boyer <jwboyer@linux.vnet.ibm.com>
To: Timur Tabi <timur@freescale.com>
Cc: linuxppc-dev@ozlabs.org, kumar.gala@freescale.com,
linux-watchdog@vger.kernel.org
Subject: Re: [PATCH] watchdog: add CONFIG_WATCHDOG_NOWAYOUT support to PowerPC Book-E watchdog driver
Date: Fri, 3 Dec 2010 13:07:51 -0500 [thread overview]
Message-ID: <20101203180751.GA1903@zod.rchland.ibm.com> (raw)
In-Reply-To: <1291395103-12394-1-git-send-email-timur@freescale.com>
On Fri, Dec 03, 2010 at 10:51:43AM -0600, Timur Tabi wrote:
>Normally, the watchdog is disabled when dev/watchdog is closed, but if
>CONFIG_WATCHDOG_NOWAYOUT is defined, then it means that the watchdog should
>remain enabled. So we should disable it only if CONFIG_WATCHDOG_NOWAYOUT is
>not defined.
>
>Also ensure that /dev/watchdog is only opened by one process at a time. That
>way, a second process can't accidentally disable the watchdog while the first
>process has it open. There shouldn't be any need for more than one process to
>open /dev/watchdog anyway.
>
>Signed-off-by: Timur Tabi <timur@freescale.com>
>---
>
>Kumar, please pick up this patch for 2.6.37.
>
> drivers/watchdog/booke_wdt.c | 16 ++++++++++++++++
> 1 files changed, 16 insertions(+), 0 deletions(-)
>
>diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c
>index d11ffb0..636e013 100644
>--- a/drivers/watchdog/booke_wdt.c
>+++ b/drivers/watchdog/booke_wdt.c
>@@ -193,8 +193,15 @@ static long booke_wdt_ioctl(struct file *file,
> return 0;
> }
>
>+/* wdt_is_active stores wether or not the /dev/watchdog device is opened */
>+static unsigned long wdt_is_active;
>+
> static int booke_wdt_open(struct inode *inode, struct file *file)
> {
>+ /* /dev/watchdog can only be opened once */
>+ if (test_and_set_bit(0, &wdt_is_active))
>+ return -EBUSY;
>+
> spin_lock(&booke_wdt_lock);
> if (booke_wdt_enabled == 0) {
> booke_wdt_enabled = 1;
I'm confused why you can't use booke_wdt_enabled for the purposes of the
device having been opened. It seems the use of the wdt_is_active
basically duplicates this functionalit (and oddly with the bit
manipulation instead of just atomic_inc/dec).
>@@ -210,8 +217,17 @@ static int booke_wdt_open(struct inode *inode, struct file *file)
>
> static int booke_wdt_release(struct inode *inode, struct file *file)
> {
>+#ifndef CONFIG_WATCHDOG_NOWAYOUT
>+ /* Normally, the watchdog is disabled when /dev/watchdog is closed, but
>+ * if CONFIG_WATCHDOG_NOWAYOUT is defined, then it means that the
>+ * watchdog should remain enabled. So we disable it only if
>+ * CONFIG_WATCHDOG_NOWAYOUT is not defined.
>+ */
> on_each_cpu(__booke_wdt_disable, NULL, 0);
> booke_wdt_enabled = 0;
>+#endif
>+
>+ clear_bit(0, &wdt_is_active);
If you were to keep this variable instead of just using
booke_wdt_enabled, wouldn't it be more correct to have the clear_bit
only done inside the #ifndef? The timer is very much still active if
NOWAYOUT is set...
josh
next prev parent reply other threads:[~2010-12-03 18:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-03 16:51 [PATCH] watchdog: add CONFIG_WATCHDOG_NOWAYOUT support to PowerPC Book-E watchdog driver Timur Tabi
2010-12-03 18:07 ` Josh Boyer [this message]
2010-12-03 18:22 ` Timur Tabi
2010-12-03 19:05 ` Josh Boyer
2010-12-03 19:10 ` Timur Tabi
2010-12-03 19:39 ` Josh Boyer
2010-12-03 19:43 ` Timur Tabi
2010-12-03 19:50 ` Josh Boyer
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=20101203180751.GA1903@zod.rchland.ibm.com \
--to=jwboyer@linux.vnet.ibm.com \
--cc=kumar.gala@freescale.com \
--cc=linux-watchdog@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=timur@freescale.com \
/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;
as well as URLs for NNTP newsgroup(s).