From: Andi Kleen <andi@firstfloor.org>
To: Jordan Crouse <jordan.crouse@amd.com>
Cc: linux-acpi@vger.kernel.org
Subject: Re: [PATCH] WDRT based watchdog timer
Date: Tue, 07 Oct 2008 09:44:44 +0200 [thread overview]
Message-ID: <878wt0n91v.fsf@basil.nowhere.org> (raw)
In-Reply-To: <20080926232752.GA6061@cosmic.amd.com> (Jordan Crouse's message of "Fri, 26 Sep 2008 17:27:52 -0600")
Jordan Crouse <jordan.crouse@amd.com> writes:
> Attached is a patch to support watchdog timers as described
> by the WDRT (Watch Dog Resource Table). This has been tested on
> the AMD SB600 chipset, but it should work for any chipset / BIOS
> that implements the WDRT table.
Nice. I remember thinking about writing such a driver a long time
ago.
> I'm not in love with the name - but I couldn't think of anything
> better, so I'm open to suggestions. I have a limited number of
> systems that implement this interface, so I would be very happy
> to hear from other users, especially ones not using AMD chipsets.
acpi-watchdog ?
> +struct wdrt_table {
> + struct acpi_table_header header;
> + struct acpi_generic_address ctrl_addr;
> + struct acpi_generic_address count_addr;
> + u16 pci_devid;
> + u16 pci_venid;
> + u8 pci_bus;
> + u8 pci_device;
> + u8 pci_function;
> + u8 pci_segment;
You don't seem to use the PCI device information currently, but
they would be needed on IOMMU enabled systems to map the correct
device, wouldn't they?
> +static int acpiwdt_set_heartbeat(unsigned int interval)
> +{
> + u32 val;
> +
> + /* Make sure the interval is sane */
> +
> + if (((interval * 1000) / wdt_units) > wdt_max_count)
> + return -EINVAL;
It's probably not a big issue in this context, but the check
can overflow and miss wrong intervals.
> +
> + /* Enable the timer */
> +
> + val = readl(wdt_ctrl_reg);
> + writel(val | WDT_CTRL_RUN, wdt_ctrl_reg);
> +
> + timeout = interval;
> +
> + return 0;
> +}
> +
> +static int acpiwdt_open(struct inode *inode, struct file *file)
> +{
> + if (test_and_set_bit(WDT_FLAGS_OPEN, &wdt_flags))
> + return -EBUSY;
> + if (!test_and_clear_bit(WDT_FLAGS_ORPHAN, &wdt_flags))
> + __module_get(THIS_MODULE);
This shouldn't be needed because the VFS does that. Also doing it in
the module itself is always racy because the module can be unloaded
before it increases its count. That is why the VFS does it.
I suppose you copied that from somehere, that somewhere is also wrong
and should be ideally fixed too.
In general these watchdog drivers seem to have all a lot of copied
code and at some point it would be nice to write a generic driver
where the backend code is just plugged in.
-Andi
--
ak@linux.intel.com
next prev parent reply other threads:[~2008-10-07 7:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-26 23:27 [PATCH] WDRT based watchdog timer Jordan Crouse
2008-10-07 7:44 ` Andi Kleen [this message]
2008-10-07 15:39 ` Jordan Crouse
2008-10-08 20:25 ` [PATCH] " Len Brown
2008-10-08 20:36 ` Wim Van Sebroeck
2008-10-08 20:44 ` Jordan Crouse
2008-10-14 20:40 ` Wim Van Sebroeck
2008-10-15 13:33 ` Wim Van Sebroeck
2008-10-16 22:23 ` Len Brown
2008-10-16 22:40 ` Jordan Crouse
2009-01-12 20:27 ` 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=878wt0n91v.fsf@basil.nowhere.org \
--to=andi@firstfloor.org \
--cc=jordan.crouse@amd.com \
--cc=linux-acpi@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 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).