Skip to contentSkip to conversation

hpwdt HP WatchDog Patch <resend>

HP ProLiant WatchDog driver [email protected] 4 participants 6 messages Oct 22, 2007 – Oct 24, 2007 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

Hp is providing a Hardware WatchDog Timer driver that will only work with the specific HW Timer located in the HP ProLiant iLO 2 ASIC. The iLO 2 HW Timer will generate a Non-maskable Interrupt (NMI) 9 seconds before physically resetting the server, by removing power, so that the event can be logged to the HP Integrated Management Log (IML), a Non-Volatile Random Access Memory (NVRAM). The logging of the event is performed using the HP ProLiant ROM via an Industry Standard access known as a BIOS Service Directory Entry.

drivers/char/watchdog/Makefile renamed from drivers/char/watchdog/Makefile.orig +7 -0
@@ -118,3 +118,10 @@
 
 # Architecture Independant
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
+
+#
+# Makefile for the hp WatchDog driver.
+#
+CFLAGS_hpwdt.o += -O
+obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o
+
drivers/char/watchdog/Kconfig renamed from drivers/char/watchdog/Kconfig.orig +13 -0
@@ -55,6 +55,19 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called softdog.
 
+config HP_WATCHDOG
+        tristate "Hewlett-Packard watchdog"
+        depends on WATCHDOG && X86
+        help
+          A software monitoring watchdog and NMI sourcing driver. This driver
+          will detect lockups and provide stack trace. Also, when an NMI
+          occurs this driver will make the necessary BIOS calls to log
+          the cause of the NMI. This is a driver that will only load on a
+          HP ProLiant system with a minimum of iLO2 support.
+          To compile this driver as a module, choose M here: the
+          module will be called hpwdt.
+
+
 # ALPHA Architecture
 
 # ARM Architecture
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +877 -0

878 lines not on this page · raw message

#1 lore raw

drivers/char/watchdog/Kconfig line 60

Quoted 3 lines · On Monday 22 October 2007 05:09:51 pm [email protected] wrote:
drivers/char/watchdog/Kconfig renamed from drivers/char/watchdog/Kconfig.orig +3 -0
+config HP_WATCHDOG
+        tristate "Hewlett-Packard watchdog"
+        depends on WATCHDOG && X86

I wouldn't be surprised if this device someday turned up on non-x86 systems. I know there's some x86 firmware stuff in there that clearly requires x86. But it'd be nice if the rest of the driver compiled and worked (minus the x86 firmware functionality) on other architectures. For example, you could wrap all the event logging code in "#ifdef CONFIG_X86" and provide a null implementation for !X86.

Quoted 28 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +28 -0
+asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
+			       unsigned long *pRomEntry)
+{
+#ifdef CONFIG_X86_64
+	asm("pushq      %rbp            \n\t"
+	    "movq       %rsp, %rbp      \n\t"
+	    "pushq      %rax            \n\t"
+	    "pushq      %rbx            \n\t"
+	    "pushq      %rdx            \n\t"
+	    "pushq      %r12            \n\t"
+	    "pushq      %r9             \n\t"
+	    "movq       %rsi, %r12      \n\t"
+	    "movq       %rdi, %r9       \n\t"
+	    "movl       4(%r9),%ebx     \n\t"
+	    "movl       8(%r9),%ecx     \n\t"
+	    "movl       12(%r9),%edx    \n\t"
+	    "movl       16(%r9),%esi    \n\t"
+	    "movl       20(%r9),%edi    \n\t"
+	    "movl       (%r9),%eax      \n\t"
+	    "call       *%r12           \n\t"
+	    "pushfq                     \n\t"
+	    "popq        %r12           \n\t"
+	    "popfq                      \n\t"
+	    "movl       %eax, (%r9)     \n\t"
+	    "movl       %ebx, 4(%r9)    \n\t"
+	    "movl       %ecx, 8(%r9)    \n\t"
+	    "movl       %edx, 12(%r9)   \n\t"
+	    "movl       %esi, 16(%r9)   \n\t"

drivers/char/watchdog/hpwdt.c line 219

Quoted 10 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +10 -0
+	    "movl       %edi, 20(%r9)   \n\t"
+	    "movq       %r12, %rax      \n\t"
+	    "movl       %eax, 28(%r9)   \n\t"
+	    "popq       %r9             \n\t"
+	    "popq       %r12            \n\t"
+	    "popq       %rdx            \n\t"
+	    "popq       %rbx            \n\t"
+	    "popq       %rax            \n\t"
+	    "leave                      \n\t" "ret");
+#endif

This is more dangerous than using the gcc assembler operand syntax, because it assumes things about how the parameters are put on the stack.

drivers/char/watchdog/hpwdt.c line 740

Quoted 8 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +8 -0
+static int __devinit hpwdt_init_one(struct pci_dev *dev,
+				    const struct pci_device_id *ent)
+{
+	int retval;
+
+	if (pci_enable_device(dev)) {
+		printk(KERN_WARNING
+		       "hpwdt: Not possible to enable PCI Device\n");

You might consider using dev_printk(), dev_warn(), etc, instead of most of your printk calls. Then you get the device ID and driver name automatically.

drivers/char/watchdog/hpwdt.c line 743

Quoted 3 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +3 -0
+		return -ENODEV;
+	}
+	pci_enable = 1;

The driver assumes only a single instance of the device. But PCI being what it is, it's often possible to have multiple cards, so you might want some protection in case you trip over more than one.

#2 lore raw
Quoted 3 lines · Bjorn Helgaas

The driver assumes only a single instance of the device. But PCI being what it is, it's often possible to have multiple cards, so you might want some protection in case you trip over more than one.

Yes. And even with that protection please move all the global variables into some per-device structure. That makes the code a lot more understandable and future-proof in case multiple devices of this type may appear somewhere.

#3 lore raw

We will never have more than one iLO2 device in a server so no multiple instances are possible.

Tom

-----Original Message-----
From: Christoph Hellwig [mailto:[email protected]]
Sent: Tuesday, October 23, 2007 4:21 PM
To: Helgaas, Bjorn
Cc: Mingarelli, Thomas; [email protected]; Wim Van Sebroeck
Subject: Re: [HP ProLiant WatchDog driver] hpwdt HP WatchDog Patch <resend>

Quoted 3 lines · Bjorn Helgaas

The driver assumes only a single instance of the device. But PCI being what it is, it's often possible to have multiple cards, so you might want some protection in case you trip over more than one.

Yes. And even with that protection please move all the global variables into some per-device structure. That makes the code a lot more understandable and future-proof in case multiple devices of this type may appear somewhere.

#4 lore raw
In reply to Bjorn Helgaas

As I stated before, we will never have more than one ilO2 device on a system. Also, this device will only be used on x86 and x86_64 architectures. I will check in the dev_warn changes asap.

Tom

-----Original Message-----
From: Helgaas, Bjorn
Sent: Tuesday, October 23, 2007 3:31 PM
To: Mingarelli, Thomas
Cc: [email protected]; Wim Van Sebroeck
Subject: Re: [HP ProLiant WatchDog driver] hpwdt HP WatchDog Patch <resend>

drivers/char/watchdog/Kconfig line 60

Quoted 3 lines · On Monday 22 October 2007 05:09:51 pm [email protected] wrote:
drivers/char/watchdog/Kconfig renamed from drivers/char/watchdog/Kconfig.orig +3 -0
+config HP_WATCHDOG
+        tristate "Hewlett-Packard watchdog"
+        depends on WATCHDOG && X86

I wouldn't be surprised if this device someday turned up on non-x86 systems. I know there's some x86 firmware stuff in there that clearly requires x86. But it'd be nice if the rest of the driver compiled and worked (minus the x86 firmware functionality) on other architectures. For example, you could wrap all the event logging code in "#ifdef CONFIG_X86" and provide a null implementation for !X86.

Quoted 28 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +28 -0
+asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
+			       unsigned long *pRomEntry)
+{
+#ifdef CONFIG_X86_64
+	asm("pushq      %rbp            \n\t"
+	    "movq       %rsp, %rbp      \n\t"
+	    "pushq      %rax            \n\t"
+	    "pushq      %rbx            \n\t"
+	    "pushq      %rdx            \n\t"
+	    "pushq      %r12            \n\t"
+	    "pushq      %r9             \n\t"
+	    "movq       %rsi, %r12      \n\t"
+	    "movq       %rdi, %r9       \n\t"
+	    "movl       4(%r9),%ebx     \n\t"
+	    "movl       8(%r9),%ecx     \n\t"
+	    "movl       12(%r9),%edx    \n\t"
+	    "movl       16(%r9),%esi    \n\t"
+	    "movl       20(%r9),%edi    \n\t"
+	    "movl       (%r9),%eax      \n\t"
+	    "call       *%r12           \n\t"
+	    "pushfq                     \n\t"
+	    "popq        %r12           \n\t"
+	    "popfq                      \n\t"
+	    "movl       %eax, (%r9)     \n\t"
+	    "movl       %ebx, 4(%r9)    \n\t"
+	    "movl       %ecx, 8(%r9)    \n\t"
+	    "movl       %edx, 12(%r9)   \n\t"
+	    "movl       %esi, 16(%r9)   \n\t"

drivers/char/watchdog/hpwdt.c line 219

Quoted 10 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +10 -0
+	    "movl       %edi, 20(%r9)   \n\t"
+	    "movq       %r12, %rax      \n\t"
+	    "movl       %eax, 28(%r9)   \n\t"
+	    "popq       %r9             \n\t"
+	    "popq       %r12            \n\t"
+	    "popq       %rdx            \n\t"
+	    "popq       %rbx            \n\t"
+	    "popq       %rax            \n\t"
+	    "leave                      \n\t" "ret");
+#endif

This is more dangerous than using the gcc assembler operand syntax, because it assumes things about how the parameters are put on the stack.

drivers/char/watchdog/hpwdt.c line 740

Quoted 7 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +7 -0
+static int __devinit hpwdt_init_one(struct pci_dev *dev,
+				    const struct pci_device_id *ent) {
+	int retval;
+
+	if (pci_enable_device(dev)) {
+		printk(KERN_WARNING
+		       "hpwdt: Not possible to enable PCI Device\n");

You might consider using dev_printk(), dev_warn(), etc, instead of most of your printk calls. Then you get the device ID and driver name automatically.

drivers/char/watchdog/hpwdt.c line 743

Quoted 3 lines
drivers/char/watchdog/hpwdt.c renamed from drivers/char/watchdog/hpwdt.c.orig +3 -0
+		return -ENODEV;
+	}
+	pci_enable = 1;

The driver assumes only a single instance of the device. But PCI being what it is, it's often possible to have multiple cards, so you might want some protection in case you trip over more than one.

#5 lore raw
In reply to [email protected]

Hi Thomas,

Quoted 25 lines
drivers/char/watchdog/Makefile renamed from drivers/char/watchdog/Makefile.orig +7 -0
@@ -118,3 +118,10 @@
 
 # Architecture Independant
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
+
+#
+# Makefile for the hp WatchDog driver.
+#
+CFLAGS_hpwdt.o += -O
+obj-$(CONFIG_HP_WATCHDOG) += hpwdt.o
+
drivers/char/watchdog/Kconfig renamed from drivers/char/watchdog/Kconfig.orig +6 -0
@@ -55,6 +55,19 @@
 	  To compile this driver as a module, choose M here: the
 	  module will be called softdog.
 
+config HP_WATCHDOG
+        tristate "Hewlett-Packard watchdog"
+        depends on WATCHDOG && X86
+        help
+          A software monitoring watchdog and NMI sourcing driver. This driver
+          will detect lockups and provide stack trace. Also, when an NMI

drivers/char/watchdog/Kconfig line 73

Quoted 10 lines
drivers/char/watchdog/Kconfig renamed from drivers/char/watchdog/Kconfig.orig +7 -0
+          occurs this driver will make the necessary BIOS calls to log
+          the cause of the NMI. This is a driver that will only load on a
+          HP ProLiant system with a minimum of iLO2 support.
+          To compile this driver as a module, choose M here: the
+          module will be called hpwdt.
+
+
 # ALPHA Architecture
 
 # ARM Architecture

Before reviewing the rest of your driver: can you please put your "X86 Architecture related" driver in the X86 related parts of Kconfig and Makefile ? Also the depend on WATCHDOG is not needed since we allready have a general dependency for all the drivers in Kconfig.

Please also note that we just shifted the watchdog drivers from drivers/char/watchdog to drivers/watchdog -> so your driver will appear in the drivers/watchdog directory when it will be included.

Greetings,
Wim.