Watchdog timer
Watchdog timer
Using CentOS6.3, Watchdog timer module may not be imported, is there proper easy way to use Watchdog timer?
Re: Watchdog timer
CentOS6.3 default kernel 2.6.32, the sbc-fitpc2 watchdog appears from about 2.6.35. You need patch and recompile your kernel with sbc_fitpc2_wdt.c included.
Compulab's Linux support
Re: Watchdog timer
Dear Denis,
Thank you for the support. We will try it.
Thank you for the support. We will try it.
-
- Posts: 7
- Joined: Tue Jun 04, 2013 2:50 am
Re: Watchdog timer
I am trying to use the hardware watchdog from CentOS 6.4 Linux. CentOS includes the kernel module, sbc_fitpc2_wdt.ko. But, when I load it, the device cannot be found.
It does not matter whether the Watchdog Timer feature in the BIOS is enabled or disabled.
When it is enabled in the BIOS, the hardware watchdog does indeed reboot the system.
How can I access the hardware watchdog device from CentOS 6.4 Linux?
Thank you.
I have additional information. dmesg shows the driver loads but fails in the step when fitpc2_wdt_init() checks the DMI_BOARD_NAME:
This code in the driver seems unnecessary, since it checks next that the COMMAND_PORT and DATA_PORT are not in use. Perhaps this eliminates the need to poke the device ports to be sure they are actually there?
Perhaps the strcmp() could be changed to !strstr() in sbc_fitpc2_wdt.c:
Code: Select all
# modprobe sbc_fitpc2_wdt
FATAL: Error inserting sbc_fitpc2_wdt (/lib/modules/2.6.32-358.6.2.el6.i686/kernel/drivers/watchdog/sbc_fitpc2_wdt.ko): No such device
When it is enabled in the BIOS, the hardware watchdog does indeed reboot the system.
How can I access the hardware watchdog device from CentOS 6.4 Linux?
Thank you.
I have additional information. dmesg shows the driver loads but fails in the step when fitpc2_wdt_init() checks the DMI_BOARD_NAME:
I have a fit-PC2i, which, I assume, has the same hardware watchdog timer support as the fit-PC2.sbc_fitpc2_wdt WATCHDOG: board name is: CM-iAM/SBC-FITPC2i. Should be SBC-FITPC2
This code in the driver seems unnecessary, since it checks next that the COMMAND_PORT and DATA_PORT are not in use. Perhaps this eliminates the need to poke the device ports to be sure they are actually there?
Perhaps the strcmp() could be changed to !strstr() in sbc_fitpc2_wdt.c:
Code: Select all
if (!strstr("SBC-FITPC2", dmi_get_system_info(DMI_BOARD_NAME))) {
pr_info("board name is: %s. Should be SBC-FITPC2\n",
dmi_get_system_info(DMI_BOARD_NAME));
return -ENODEV;
}
-
- Posts: 7
- Joined: Tue Jun 04, 2013 2:50 am
Re: Watchdog timer
The solution is almost what I suggested. You have to reverse the strings to use !strstr() in place of strcmp().
Here is the patch I used (CentOS 6.4 i386), which is good for any board name that contains "SBC-FITPC2", e.g., fit-PC2 or fit-PC2i.
Here is the patch I used (CentOS 6.4 i386), which is good for any board name that contains "SBC-FITPC2", e.g., fit-PC2 or fit-PC2i.
Code: Select all
--- linux-2.6.32-358.6.2.el6/drivers/watchdog/sbc_fitpc2_wdt.c
+++ linux-2.6.32-358.6.2.el6/drivers/watchdog/sbc_fitpc2_wdt.c
@@ -204,3 +204,3 @@
- if (strcmp("SBC-FITPC2", dmi_get_system_info(DMI_BOARD_NAME))) {
+ if (!strstr(dmi_get_system_info(DMI_BOARD_NAME), "SBC-FITPC2")) {
pr_info("board name is: %s. Should be SBC-FITPC2\n",
-
- Posts: 7
- Joined: Tue Jun 04, 2013 2:50 am
Re: Watchdog timer
Now that I have the hardware watchdog timer working, I enabled the Linux watchdog daemon. The system is extremely sluggish after that. From top, I see an extraordinary amount of system CPU time being used every time the watchdog daemon runs through its chores (every 10 seconds, by default). I have not had this experience on other systems.
I looked at the code in sbc_fitpc2_wdt.c that gets executed every time there is a write to /dev/watchdog (fitpc2_wdt_write()). It falls through to call wdt_enable(). wdt_enable() then issues two calls to wdt_send_data(). Here's that portion of the driver:
Every call to wdt_send_data() results in 300 msec of busy-waiting, or 600 msecs total. I think this is the source of the large system CPU times every 10 secs.
Is this really necessary? Is it not possible to yield the processor to do other work instead of busy-waiting for so long?
I looked at the code in sbc_fitpc2_wdt.c that gets executed every time there is a write to /dev/watchdog (fitpc2_wdt_write()). It falls through to call wdt_enable(). wdt_enable() then issues two calls to wdt_send_data(). Here's that portion of the driver:
Code: Select all
static void wdt_send_data(unsigned char command, unsigned char data)
{
outb(command, COMMAND_PORT);
mdelay(100);
outb(data, DATA_PORT);
mdelay(200);
}
static void wdt_enable(void)
{
spin_lock(&wdt_lock);
wdt_send_data(IFACE_ON_COMMAND, 1);
wdt_send_data(REBOOT_COMMAND, margin);
spin_unlock(&wdt_lock);
}
Is this really necessary? Is it not possible to yield the processor to do other work instead of busy-waiting for so long?
Re: Watchdog timer
Please look at recent driver version, for example in 3.2.0
and regarding naming:
Code: Select all
static DEFINE_MUTEX(wdt_lock);
...
static void wdt_send_data(unsigned char command, unsigned char data)
{
outb(data, DATA_PORT);
msleep(200);
outb(command, COMMAND_PORT);
msleep(100);
}
static void wdt_enable(void)
{
mutex_lock(&wdt_lock);
wdt_send_data(IFACE_ON_COMMAND, 1);
wdt_send_data(REBOOT_COMMAND, margin);
mutex_unlock(&wdt_lock);
}
static void wdt_disable(void)
{
mutex_lock(&wdt_lock);
wdt_send_data(IFACE_ON_COMMAND, 0);
wdt_send_data(REBOOT_COMMAND, 0);
mutex_unlock(&wdt_lock);
}
Code: Select all
brd_name = dmi_get_system_info(DMI_BOARD_NAME);
if (!brd_name || !strstr(brd_name, "SBC-FITPC2"))
return -ENODEV;
Compulab's Linux support
-
- Posts: 7
- Joined: Tue Jun 04, 2013 2:50 am
Re: Watchdog timer
That is pretty much exactly what I did to cure the problems. For CentOS 6.4, here's the sbc_fitpc2_wdt.c patch I used. Except, your latest code reverses the COMMAND_PORT and DATA_PORT output (a bug fix?), and adds a check for !brd_name (a good sanity check).
I'll grab the latest driver and use that.
Thank you.
Code: Select all
--- linux-2.6.32-358.6.2.el6/drivers/watchdog/sbc_fitpc2_wdt.c
+++ linux-2.6.32-358.6.2.el6/drivers/watchdog/sbc_fitpc2_wdt.c
@@ -48,5 +48,5 @@
outb(command, COMMAND_PORT);
- mdelay(100);
+ msleep(100);
outb(data, DATA_PORT);
- mdelay(200);
+ msleep(200);
}
@@ -204,3 +204,3 @@
- if (strcmp("SBC-FITPC2", dmi_get_system_info(DMI_BOARD_NAME))) {
+ if (!strstr(dmi_get_system_info(DMI_BOARD_NAME), "SBC-FITPC2")) {
pr_info("board name is: %s. Should be SBC-FITPC2\n",
Thank you.
-
- Posts: 7
- Joined: Tue Jun 04, 2013 2:50 am
Re: Watchdog timer
I grabbed the latest driver from https://git.kernel.org/cgit/linux/kerne ... tpc2_wdt.c. That works fine.
Thank you.
Thank you.