Page 1 of 1
Watchdog timer
Posted: Thu Jan 24, 2013 7:45 am
by Takenaka
Using CentOS6.3, Watchdog timer module may not be imported, is there proper easy way to use Watchdog timer?
Re: Watchdog timer
Posted: Mon Jan 28, 2013 4:06 pm
by Denis
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.
Re: Watchdog timer
Posted: Tue Jan 29, 2013 3:08 am
by Takenaka
Dear Denis,
Thank you for the support. We will try it.
Re: Watchdog timer
Posted: Tue Jun 04, 2013 11:23 pm
by LarryBaker
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.
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
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:
sbc_fitpc2_wdt WATCHDOG: board name is: CM-iAM/SBC-FITPC2i. Should be SBC-FITPC2
I have a fit-PC2i, which, I assume, has the same hardware watchdog timer support as the fit-PC2.
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;
}
Re: Watchdog timer
Posted: Wed Jun 05, 2013 3:26 am
by LarryBaker
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.
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",
Re: Watchdog timer
Posted: Wed Jun 05, 2013 5:38 am
by LarryBaker
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:
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);
}
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?
Re: Watchdog timer
Posted: Wed Jun 05, 2013 4:05 pm
by Denis
Please look at recent driver version, for example in 3.2.0
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);
}
and regarding naming:
Code: Select all
brd_name = dmi_get_system_info(DMI_BOARD_NAME);
if (!brd_name || !strstr(brd_name, "SBC-FITPC2"))
return -ENODEV;
Re: Watchdog timer
Posted: Thu Jun 06, 2013 12:48 am
by LarryBaker
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).
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",
I'll grab the latest driver and use that.
Thank you.
Re: Watchdog timer
Posted: Thu Jun 06, 2013 3:24 am
by LarryBaker
I grabbed the latest driver from
https://git.kernel.org/cgit/linux/kerne ... tpc2_wdt.c. That works fine.
Thank you.