Skip to contentSkip to conversation

hpwdt: make NMI code a config option (+ other cleanup)

PATCH In review dann frazier 3 participants 26 messages Jul 27, 2010 – Aug 13, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hpwdt: make NMI code a config option (+ other cleanup)

hwpdt includes an NMI-decoding feature, but the watchdog interface is quite usable without it. This patchset makes it possible to build hpwdt without the NMI functionality, as well as some general cleanup.

 Kconfig |   22 +++++--
 hpwdt.c |  181 ++++++++++++++++++++++++++++++++++++----------------------------
 2 files changed, 119 insertions(+), 84 deletions(-)
#1 lore raw

PATCH 1/15 hpwdt_pretimeout reorganization

Reorganize this function to remove excess indentation and highlight the single return code.

No functional change.

---
 drivers/watchdog/hpwdt.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)
drivers/watchdog/hpwdt.c +19 -17
index dbe650e..64ea6fc 100644
@@ -476,24 +476,26 @@ static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason,
 	static int die_nmi_called;
 
 	if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI)
-		return NOTIFY_OK;
-
-	if (hpwdt_nmi_sourcing) {
-		spin_lock_irqsave(&rom_lock, rom_pl);
-		if (!die_nmi_called)
-			asminline_call(&cmn_regs, cru_rom_addr);
-		die_nmi_called = 1;
-		spin_unlock_irqrestore(&rom_lock, rom_pl);
-		if (cmn_regs.u1.ral == 0) {
-			printk(KERN_WARNING "hpwdt: An NMI occurred, "
-				"but unable to determine source.\n");
-		} else {
-			if (allow_kdump)
-				hpwdt_stop();
-			panic("An NMI occurred, please see the Integrated "
-				"Management Log for details.\n");
-		}
+		goto out;
+
+	if (!hpwdt_nmi_sourcing)
+		goto out;
+
+	spin_lock_irqsave(&rom_lock, rom_pl);
+	if (!die_nmi_called)
+		asminline_call(&cmn_regs, cru_rom_addr);
+	die_nmi_called = 1;
+	spin_unlock_irqrestore(&rom_lock, rom_pl);
+	if (cmn_regs.u1.ral == 0) {
+		printk(KERN_WARNING "hpwdt: An NMI occurred, "
+			"but unable to determine source.\n");
+	} else {
+		if (allow_kdump)
+			hpwdt_stop();
+		panic("An NMI occurred, please see the Integrated "
+			"Management Log for details.\n");
 	}
+out:
 	return NOTIFY_OK;
 }
 
Signature · 1 line
1.7.1
#2 lore raw

PATCH 2/15 remove unnecessary includes

In reply to dann frazier
---
 drivers/watchdog/hpwdt.c |   10 ----------
 1 files changed, 0 insertions(+), 10 deletions(-)
drivers/watchdog/hpwdt.c +0 -10
index 64ea6fc..fc81122 100644
@@ -16,30 +16,20 @@
 #include <linux/device.h>
 #include <linux/fs.h>
 #include <linux/init.h>
-#include <linux/interrupt.h>
 #include <linux/io.h>
-#include <linux/irq.h>
 #include <linux/nmi.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
-#include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/kdebug.h>
 #include <linux/moduleparam.h>
 #include <linux/notifier.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
-#include <linux/reboot.h>
-#include <linux/sched.h>
-#include <linux/timer.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
 #include <linux/watchdog.h>
 #include <linux/dmi.h>
-#include <linux/efi.h>
-#include <linux/string.h>
-#include <linux/bootmem.h>
-#include <asm/desc.h>
 #include <asm/cacheflush.h>
 
 #define PCI_BIOS32_SD_VALUE		0x5F32335F	/* "_32_" */
Signature · 1 line
1.7.1
#3 lore raw

PATCH 3/15 include spinlock.h

In reply to dann frazier

We use a spinlock, but lacked the include

---
 drivers/watchdog/hpwdt.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/watchdog/hpwdt.c +1 -0
index fc81122..48bb536 100644
@@ -30,6 +30,7 @@
 #include <linux/uaccess.h>
 #include <linux/watchdog.h>
 #include <linux/dmi.h>
+#include <linux/spinlock.h>
 #include <asm/cacheflush.h>
 
 #define PCI_BIOS32_SD_VALUE		0x5F32335F	/* "_32_" */
Signature · 1 line
1.7.1
#4 lore raw

PATCH 4/15 add include for linux/bitops.h

In reply to dann frazier

Needed for test_and_set_bit/clear_bit

---
 drivers/watchdog/hpwdt.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
drivers/watchdog/hpwdt.c +1 -0
index 48bb536..391bb43 100644
@@ -18,6 +18,7 @@
 #include <linux/init.h>
 #include <linux/io.h>
 #include <linux/nmi.h>
+#include <linux/bitops.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
Signature · 1 line
1.7.1
#5 lore raw

PATCH 5/15 Group together includes specific to NMI sourcing

In reply to dann frazier

No functional change.

---
 drivers/watchdog/hpwdt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/hpwdt.c +3 -3
index 391bb43..b8b791f 100644
@@ -17,14 +17,11 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/io.h>
-#include <linux/nmi.h>
 #include <linux/bitops.h>
 #include <linux/kernel.h>
 #include <linux/miscdevice.h>
 #include <linux/module.h>
-#include <linux/kdebug.h>
 #include <linux/moduleparam.h>
-#include <linux/notifier.h>
 #include <linux/pci.h>
 #include <linux/pci_ids.h>
 #include <linux/types.h>
@@ -32,6 +29,9 @@
 #include <linux/watchdog.h>
 #include <linux/dmi.h>
 #include <linux/spinlock.h>
+#include <linux/nmi.h>
+#include <linux/kdebug.h>
+#include <linux/notifier.h>
 #include <asm/cacheflush.h>
 
 #define PCI_BIOS32_SD_VALUE		0x5F32335F	/* "_32_" */
Signature · 1 line
1.7.1
#6 lore raw

PATCH 6/15 Group options that affect watchdog behavior together

In reply to dann frazier

Reorganization only.

---
 drivers/watchdog/hpwdt.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/watchdog/hpwdt.c +3 -3
index b8b791f..796fcb8 100644
@@ -808,13 +808,13 @@ MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
 module_param(soft_margin, int, 0);
 MODULE_PARM_DESC(soft_margin, "Watchdog timeout in seconds");
 
-module_param(allow_kdump, int, 0);
-MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs");
-
 module_param(nowayout, int, 0);
 MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
 		__MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
+module_param(allow_kdump, int, 0);
+MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs");
+
 module_param(priority, int, 0);
 MODULE_PARM_DESC(priority, "The hpwdt driver handles NMIs first or last"
 		" (default = 0/Last)\n");
Signature · 1 line
1.7.1
#7 lore raw

PATCH 7/15 Group defines only used by NMI sourcing together

In reply to dann frazier

No functional change.

---
 drivers/watchdog/hpwdt.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
drivers/watchdog/hpwdt.c +5 -5
index 796fcb8..f337c22 100644
@@ -34,16 +34,16 @@
 #include <linux/notifier.h>
 #include <asm/cacheflush.h>
 
+#define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
+#define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
+#define HPWDT_MAX_TIMER	TICKS_TO_SECS(65535)
+#define HPWDT_VERSION			"1.1.1"
+
 #define PCI_BIOS32_SD_VALUE		0x5F32335F	/* "_32_" */
 #define CRU_BIOS_SIGNATURE_VALUE	0x55524324
 #define PCI_BIOS32_PARAGRAPH_LEN	16
 #define PCI_ROM_BASE1			0x000F0000
 #define ROM_SIZE			0x10000
-#define HPWDT_VERSION			"1.1.1"
-
-#define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
-#define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
-#define HPWDT_MAX_TIMER	TICKS_TO_SECS(65535)
 
 struct bios32_service_dir {
 	u32 signature;
Signature · 1 line
1.7.1
#8 lore raw

PATCH 8/15 Group declarations specific to NMI sourcing together

In reply to dann frazier

No functional change.

---
 drivers/watchdog/hpwdt.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)
drivers/watchdog/hpwdt.c +6 -8
index f337c22..cedcc61 100644
@@ -115,19 +115,11 @@ static int nowayout = WATCHDOG_NOWAYOUT;
 static char expect_release;
 static unsigned long hpwdt_is_open;
 static unsigned int allow_kdump;
-static unsigned int hpwdt_nmi_sourcing;
-static unsigned int priority;		/* hpwdt at end of die_notify list */
 
 static void __iomem *pci_mem_addr;		/* the PCI-memory address */
 static unsigned long __iomem *hpwdt_timer_reg;
 static unsigned long __iomem *hpwdt_timer_con;
 
-static DEFINE_SPINLOCK(rom_lock);
-
-static void *cru_rom_addr;
-
-static struct cmn_registers cmn_regs;
-
 static struct pci_device_id hpwdt_devices[] = {
 	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) },
 	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) },
@@ -135,6 +127,12 @@ static struct pci_device_id hpwdt_devices[] = {
 };
 MODULE_DEVICE_TABLE(pci, hpwdt_devices);
 
+static unsigned int hpwdt_nmi_sourcing;
+static unsigned int priority;		/* hpwdt at end of die_notify list */
+static DEFINE_SPINLOCK(rom_lock);
+static void *cru_rom_addr;
+static struct cmn_registers cmn_regs;
+
 extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
 						unsigned long *pRomEntry);
 
Signature · 1 line
1.7.1
#9 lore raw

PATCH 9/15 Despecificate driver from iLO2

In reply to dann frazier

This driver supports both iLO2 and iLO3, but our user-visible strings currently only reference iLO2. Let's just call it "iLO" to avoid having to update strings for each iLO generation. This driver doesn't support iLO ASICs prior to iLO2, but that is sufficiently explained in Kconfig.

---
 drivers/watchdog/Kconfig |    2 +-
 drivers/watchdog/hpwdt.c |   14 +++++++-------
 2 files changed, 8 insertions(+), 8 deletions(-)
drivers/watchdog/Kconfig +1 -1
index afcfacc..cde31f9 100644
@@ -556,7 +556,7 @@ config IT87_WDT
 	  be called it87_wdt.
 
 config HP_WATCHDOG
-	tristate "HP Proliant iLO 2 Hardware Watchdog Timer"
+	tristate "HP Proliant iLO Hardware Watchdog Timer"
 	depends on X86
 	help
 	  A software monitoring watchdog and NMI sourcing driver. This driver
drivers/watchdog/hpwdt.c +7 -7
index cedcc61..a6b37fe 100644
@@ -121,8 +121,8 @@ static unsigned long __iomem *hpwdt_timer_reg;
 static unsigned long __iomem *hpwdt_timer_con;
 
 static struct pci_device_id hpwdt_devices[] = {
-	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) },
-	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) },
+	{ PCI_DEVICE(PCI_VENDOR_ID_COMPAQ, 0xB203) },	/* iLO2 */
+	{ PCI_DEVICE(PCI_VENDOR_ID_HP, 0x3306) },	/* iLO3 */
 	{0},			/* terminate list */
 };
 MODULE_DEVICE_TABLE(pci, hpwdt_devices);
@@ -557,7 +557,7 @@ static const struct watchdog_info ident = {
 	.options = WDIOF_SETTIMEOUT |
 		   WDIOF_KEEPALIVEPING |
 		   WDIOF_MAGICCLOSE,
-	.identity = "HP iLO2 HW Watchdog Timer",
+	.identity = "HP iLO HW Watchdog Timer",
 };
 
 static long hpwdt_ioctl(struct file *file, unsigned int cmd,
@@ -667,13 +667,13 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 	hpwdt_check_nmi_sourcing(dev);
 
 	/*
-	 * First let's find out if we are on an iLO2 server. We will
+	 * First let's find out if we are on an iLO2+ server. We will
 	 * not run on a legacy ASM box.
 	 * So we only support the G5 ProLiant servers and higher.
 	 */
 	if (dev->subsystem_vendor != PCI_VENDOR_ID_HP) {
-		dev_warn(&dev->dev,
-			"This server does not have an iLO2 ASIC.\n");
+		dev_warn(&dev->dev, "This server does not have an iLO ASIC"
+			 " version 2 or greater.\n");
 		return -ENODEV;
 	}
 
@@ -687,7 +687,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 	pci_mem_addr = pci_iomap(dev, 1, 0x80);
 	if (!pci_mem_addr) {
 		dev_warn(&dev->dev,
-			"Unable to detect the iLO2 server memory.\n");
+			"Unable to detect the iLO server memory.\n");
 		retval = -ENOMEM;
 		goto error_pci_iomap;
 	}
Signature · 1 line
1.7.1
#10 lore raw

Re: [PATCH 09/15] Despecificate driver from iLO2

Hi Dan,

Quoted 4 lines

This driver supports both iLO2 and iLO3, but our user-visible strings currently only reference iLO2. Let's just call it "iLO" to avoid having to update strings for each iLO generation. This driver doesn't support iLO ASICs prior to iLO2, but that is sufficiently explained in Kconfig.

Just a thought: Wouldn't it be more consistent if it's called iLO2+ everywhere?

drivers/watchdog/Kconfig config IT87_WDT · line 559

Quoted 2 lines
drivers/watchdog/Kconfig +1 -1
-	tristate "HP Proliant iLO 2 Hardware Watchdog Timer"
+	tristate "HP Proliant iLO Hardware Watchdog Timer"

would be: tristate "HP Proliant iLO2+ Hardware Watchdog Timer"

drivers/watchdog/hpwdt.c static const struct watchdog_info ident = { · line 560

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-	.identity = "HP iLO2 HW Watchdog Timer",
+	.identity = "HP iLO HW Watchdog Timer",

and: .identity = "HP iLO2+ HW Watchdog Timer",

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 676

Quoted 7 lines
drivers/watchdog/hpwdt.c +3 -3
-	 * First let's find out if we are on an iLO2 server. We will
+	 * First let's find out if we are on an iLO2+ server. We will
 
-		dev_warn(&dev->dev,
-			"This server does not have an iLO2 ASIC.\n");
+		dev_warn(&dev->dev, "This server does not have an iLO ASIC"
+			 " version 2 or greater.\n");

dev_warn(&dev->dev,

	"This server does not have an iLO2+ ASIC.\n");

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 690

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-			"Unable to detect the iLO2 server memory.\n");
+			"Unable to detect the iLO server memory.\n");

"Unable to detect the iLO2+ server memory.\n");

For the rest I'm still reviewing the code.

Kind regards,
Wim.

#11 lore raw

RE: [PATCH 09/15] Despecificate driver from iLO2

I like that suggestion Wim. Sure would make future iLO releases easier to include.

Tom

Quoted 47 lines

-----Original Message-----
From: Wim Van Sebroeck [mailto:[email protected]]
Sent: Wednesday, August 04, 2010 3:14 PM
To: Frazier, Daniel Kent (ProLiant Linux)
Cc: [email protected]; Mingarelli, Thomas
Subject: Re: [PATCH 09/15] Despecificate driver from iLO2

Hi Dan,

Quoted 4 lines

This driver supports both iLO2 and iLO3, but our user-visible strings currently only reference iLO2. Let's just call it "iLO" to avoid having to update strings for each iLO generation. This driver doesn't support iLO ASICs prior to iLO2, but that is sufficiently explained in Kconfig.

Just a thought: Wouldn't it be more consistent if it's called iLO2+ everywhere?

drivers/watchdog/Kconfig config IT87_WDT · line 559

Quoted 2 lines
drivers/watchdog/Kconfig +1 -1
-	tristate "HP Proliant iLO 2 Hardware Watchdog Timer"
+	tristate "HP Proliant iLO Hardware Watchdog Timer"

would be: tristate "HP Proliant iLO2+ Hardware Watchdog Timer"

drivers/watchdog/hpwdt.c static const struct watchdog_info ident = { · line 560

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-	.identity = "HP iLO2 HW Watchdog Timer",
+	.identity = "HP iLO HW Watchdog Timer",

and: .identity = "HP iLO2+ HW Watchdog Timer",

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 676

Quoted 7 lines
drivers/watchdog/hpwdt.c +3 -3
-	 * First let's find out if we are on an iLO2 server. We will
+	 * First let's find out if we are on an iLO2+ server. We will
 
-		dev_warn(&dev->dev,
-			"This server does not have an iLO2 ASIC.\n");
+		dev_warn(&dev->dev, "This server does not have an iLO ASIC"
+			 " version 2 or greater.\n");

dev_warn(&dev->dev,

	"This server does not have an iLO2+ ASIC.\n");

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 690

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-			"Unable to detect the iLO2 server memory.\n");
+			"Unable to detect the iLO server memory.\n");

"Unable to detect the iLO2+ server memory.\n");

For the rest I'm still reviewing the code.

Kind regards,
Wim.

#12 lore raw

Re: [PATCH 09/15] Despecificate driver from iLO2

In reply to Wim Van Sebroeck
Quoted 9 lines · Wim Van Sebroeck

Hi Dan,

Quoted 4 lines

This driver supports both iLO2 and iLO3, but our user-visible strings currently only reference iLO2. Let's just call it "iLO" to avoid having to update strings for each iLO generation. This driver doesn't support iLO ASICs prior to iLO2, but that is sufficiently explained in Kconfig.

Just a thought: Wouldn't it be more consistent if it's called iLO2+ everywhere?

works for me :)

Quoted 20 lines

drivers/watchdog/Kconfig config IT87_WDT · line 559

Quoted 3 lines
drivers/watchdog/Kconfig +1 -1
-	tristate "HP Proliant iLO 2 Hardware Watchdog Timer"
+	tristate "HP Proliant iLO Hardware Watchdog Timer"

would be: tristate "HP Proliant iLO2+ Hardware Watchdog Timer"

drivers/watchdog/hpwdt.c static const struct watchdog_info ident = { · line 560

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-	.identity = "HP iLO2 HW Watchdog Timer",
+	.identity = "HP iLO HW Watchdog Timer",

and: .identity = "HP iLO2+ HW Watchdog Timer",

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 676

Quoted 7 lines
drivers/watchdog/hpwdt.c +3 -3
-	 * First let's find out if we are on an iLO2 server. We will
+	 * First let's find out if we are on an iLO2+ server. We will
 
-		dev_warn(&dev->dev,
-			"This server does not have an iLO2 ASIC.\n");
+		dev_warn(&dev->dev, "This server does not have an iLO ASIC"
+			 " version 2 or greater.\n");

dev_warn(&dev->dev,

Quoted 8 lines
	"This server does not have an iLO2+ ASIC.\n");

drivers/watchdog/hpwdt.c static int __devinit hpwdt_init_one(struct pci_dev *dev, · line 690

Quoted 2 lines
drivers/watchdog/hpwdt.c +1 -1
-			"Unable to detect the iLO2 server memory.\n");
+			"Unable to detect the iLO server memory.\n");

"Unable to detect the iLO2+ server memory.\n");

For the rest I'm still reviewing the code.

Thanks - I'll make this change in my local git tree for now and resubmit after you've completed the review.

Signature · 1 line
dann frazier | ProLiant Linux
#13 lore raw

PATCH 10/15 Fix a typo

In reply to dann frazier
---
 drivers/watchdog/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/watchdog/Kconfig +1 -1
index cde31f9..fc3d6b5 100644
@@ -560,7 +560,7 @@ config HP_WATCHDOG
 	depends on X86
 	help
 	  A software monitoring watchdog and NMI sourcing driver. This driver
-	  will detect lockups and provide stack trace. Also, when an NMI
+	  will detect lockups and provide a 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.
Signature · 1 line
1.7.1
#14 lore raw

PATCH 11/15 Make x86 assembly ifdef guard more strict

In reply to dann frazier

The 32-bit assembly is guarded by an #ifndef CONFIG_X86_64. Kconfig prevents us from building this driver on !X86, so that happens to suffice - but we should really lock it down to #ifdef CONFIG_X86_32.

---
 drivers/watchdog/hpwdt.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)
drivers/watchdog/hpwdt.c +5 -7
index a6b37fe..f46e4f2 100644
@@ -136,7 +136,7 @@ static struct cmn_registers cmn_regs;
 extern asmlinkage void asminline_call(struct cmn_registers *pi86Regs,
 						unsigned long *pRomEntry);
 
-#ifndef CONFIG_X86_64
+#ifdef CONFIG_X86_32
 /* --32 Bit Bios------------------------------------------------------------ */
 
 #define HPWDT_ARCH	32
@@ -325,8 +325,9 @@ static int __devinit detect_cru_service(void)
 	iounmap(p);
 	return rc;
 }
-
-#else
+/* ------------------------------------------------------------------------- */
+#endif /* CONFIG_X86_32 */
+#ifdef CONFIG_X86_64
 /* --64 Bit Bios------------------------------------------------------------ */
 
 #define HPWDT_ARCH	64
@@ -404,10 +405,7 @@ static int __devinit detect_cru_service(void)
 	/* if cru_rom_addr has been set then we found a CRU service */
 	return ((cru_rom_addr != NULL) ? 0 : -ENODEV);
 }
-
-/* ------------------------------------------------------------------------- */
-
-#endif
+#endif /* CONFIG_X86_64 */
 
 /*
  *	Watchdog operations
Signature · 1 line
1.7.1
#15 lore raw

PATCH 12/15 Construct status message w/ kasprintf and emit it with dev_info

In reply to dann frazier

Constructing the string dynamically w/ kasprintf will make it easier to ifdef-out parts of it. Also, this is for a device, so let's use dev_info.

---
 drivers/watchdog/hpwdt.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)
drivers/watchdog/hpwdt.c +12 -8
index f46e4f2..482785e 100644
@@ -658,6 +658,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 					const struct pci_device_id *ent)
 {
 	int retval;
+	char *buf;
 
 	/*
 	 * Check if we can do NMI sourcing or not
@@ -741,14 +742,16 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 		goto error_misc_register;
 	}
 
-	printk(KERN_INFO
-		"hp Watchdog Timer Driver: %s"
-		", timer margin: %d seconds (nowayout=%d)"
-		", allow kernel dump: %s (default = 0/OFF)"
-		", priority: %s (default = 0/LAST).\n",
-		HPWDT_VERSION, soft_margin, nowayout,
-		(allow_kdump == 0) ? "OFF" : "ON",
-		(priority == 0) ? "LAST" : "FIRST");
+	buf = kasprintf(GFP_KERNEL, "hp Watchdog Timer Driver: %s"
+			", timer margin: %d seconds (nowayout=%d)"
+			", allow kernel dump: %s (default = 0/OFF)"
+			", priority: %s (default = 0/LAST)",
+			HPWDT_VERSION, soft_margin, nowayout,
+			(allow_kdump == 0) ? "OFF" : "ON",
+			(priority == 0) ? "LAST" : "FIRST");
+	if (!buf)
+		goto error_nomem;
+	dev_info(&dev->dev, "%s.\n", buf);
 
 	return 0;
 
@@ -761,6 +764,7 @@ error_get_cru:
 	pci_iounmap(dev, pci_mem_addr);
 error_pci_iomap:
 	pci_disable_device(dev);
+error_nomem:
 	return retval;
 }
 
Signature · 1 line
1.7.1
#16 lore raw

Re: [PATCH 12/15] Construct status message w/ kasprintf and emit it with dev_info

Quoted 3 lines · dann frazier

Constructing the string dynamically w/ kasprintf will make it easier to ifdef-out parts of it. Also, this is for a device, so let's use dev_info.

A coworker caught a silly mistake in this one - I missed freeing the buf allocated by kasprintf.

Here's a fixed patch.

Construct status message w/ kasprintf and emit it with dev_info

Constructing the string dynamically w/ kasprintf will make it easier to ifdef-out parts of it. Also, this is for a device, so let's use dev_info.

drivers/watchdog/hpwdt.c +13 -8
index f46e4f2..f03078d 100644
@@ -658,6 +658,7 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 					const struct pci_device_id *ent)
 {
 	int retval;
+	char *buf;
 
 	/*
 	 * Check if we can do NMI sourcing or not
@@ -741,14 +742,17 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 		goto error_misc_register;
 	}
 
-	printk(KERN_INFO
-		"hp Watchdog Timer Driver: %s"
-		", timer margin: %d seconds (nowayout=%d)"
-		", allow kernel dump: %s (default = 0/OFF)"
-		", priority: %s (default = 0/LAST).\n",
-		HPWDT_VERSION, soft_margin, nowayout,
-		(allow_kdump == 0) ? "OFF" : "ON",
-		(priority == 0) ? "LAST" : "FIRST");
+	buf = kasprintf(GFP_KERNEL, "hp Watchdog Timer Driver: %s"
+			", timer margin: %d seconds (nowayout=%d)"
+			", allow kernel dump: %s (default = 0/OFF)"
+			", priority: %s (default = 0/LAST)",
+			HPWDT_VERSION, soft_margin, nowayout,
+			(allow_kdump == 0) ? "OFF" : "ON",
+			(priority == 0) ? "LAST" : "FIRST");
+	if (!buf)
+		goto error_nomem;
+	dev_info(&dev->dev, "%s.\n", buf);
+	kfree(buf);
 
 	return 0;
 
@@ -761,6 +765,7 @@ error_get_cru:
 	pci_iounmap(dev, pci_mem_addr);
 error_pci_iomap:
 	pci_disable_device(dev);
+error_nomem:
 	return retval;
 }
 
#17 lore raw

PATCH 13/15 Use "decoding" instead of "sourcing"

In reply to dann frazier

The term "decoding" more clearly explains what hpwdt is doing. It isn't just finding the source of the interrupt, but rather aids in decoding what the interrupt means.

---
 drivers/watchdog/hpwdt.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)
drivers/watchdog/hpwdt.c +10 -10
index 482785e..00aea69 100644
@@ -127,7 +127,7 @@ static struct pci_device_id hpwdt_devices[] = {
 };
 MODULE_DEVICE_TABLE(pci, hpwdt_devices);
 
-static unsigned int hpwdt_nmi_sourcing;
+static unsigned int hpwdt_nmi_decoding;
 static unsigned int priority;		/* hpwdt at end of die_notify list */
 static DEFINE_SPINLOCK(rom_lock);
 static void *cru_rom_addr;
@@ -466,7 +466,7 @@ static int hpwdt_pretimeout(struct notifier_block *nb, unsigned long ulReason,
 	if (ulReason != DIE_NMI && ulReason != DIE_NMI_IPI)
 		goto out;
 
-	if (!hpwdt_nmi_sourcing)
+	if (!hpwdt_nmi_decoding)
 		goto out;
 
 	spin_lock_irqsave(&rom_lock, rom_pl);
@@ -633,23 +633,23 @@ static struct notifier_block die_notifier = {
  */
 
 #ifdef ARCH_HAS_NMI_WATCHDOG
-static void __devinit hpwdt_check_nmi_sourcing(struct pci_dev *dev)
+static void __devinit hpwdt_check_nmi_decoding(struct pci_dev *dev)
 {
 	/*
 	 * If nmi_watchdog is turned off then we can turn on
-	 * our nmi sourcing capability.
+	 * our nmi decoding capability.
 	 */
 	if (!nmi_watchdog_active())
-		hpwdt_nmi_sourcing = 1;
+		hpwdt_nmi_decoding = 1;
 	else
-		dev_warn(&dev->dev, "NMI sourcing is disabled. To enable this "
+		dev_warn(&dev->dev, "NMI decoding is disabled. To enable this "
 			"functionality you must reboot with nmi_watchdog=0 "
 			"and load the hpwdt driver with priority=1.\n");
 }
 #else
-static void __devinit hpwdt_check_nmi_sourcing(struct pci_dev *dev)
+static void __devinit hpwdt_check_nmi_decoding(struct pci_dev *dev)
 {
-	dev_warn(&dev->dev, "NMI sourcing is disabled. "
+	dev_warn(&dev->dev, "NMI decoding is disabled. "
 		"Your kernel does not support a NMI Watchdog.\n");
 }
 #endif
@@ -661,9 +661,9 @@ static int __devinit hpwdt_init_one(struct pci_dev *dev,
 	char *buf;
 
 	/*
-	 * Check if we can do NMI sourcing or not
+	 * Check if we can do NMI decoding or not
 	 */
-	hpwdt_check_nmi_sourcing(dev);
+	hpwdt_check_nmi_decoding(dev);
 
 	/*
 	 * First let's find out if we are on an iLO2+ server. We will
Signature · 1 line
1.7.1
#18 lore raw

PATCH 14/15 Make NMI decoding a compile-time option

In reply to dann frazier

hpwdt is quite functional without the NMI decoding feature. This change lets users disable the NMI portion at compile-time via the new HPWDT_NMI_DECODING config option.

---
 drivers/watchdog/Kconfig |   20 ++++++++++++++------
 drivers/watchdog/hpwdt.c |   43 ++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 52 insertions(+), 11 deletions(-)
drivers/watchdog/Kconfig +14 -6
index fc3d6b5..3d77697 100644
@@ -560,12 +560,20 @@ config HP_WATCHDOG
 	depends on X86
 	help
 	  A software monitoring watchdog and NMI sourcing driver. This driver
-	  will detect lockups and provide a 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.
+	  will detect lockups and provide a stack trace. 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.
+
+if HP_WATCHDOG
+
+config HPWDT_NMI_DECODING
+       bool "NMI decoding support for the HP ProLiant iLO Hardware Watchdog Timer"
+       help
+	 When an NMI occurs this feature will make the necessary BIOS calls to
+	 log the cause of the NMI.
+
+endif
 
 config SC1200_WDT
 	tristate "National Semiconductor PC87307/PC97307 (ala SC1200) Watchdog"
drivers/watchdog/hpwdt.c +38 -5

168 lines not on this page · raw message

Signature · 1 line
1.7.1
#19 lore raw

PATCH 15/15 Bump version to 1.2.0

In reply to dann frazier

Making NMI sourcing a compile-time option is probably a significant- enough change to warrant a minor version bump.

---
 drivers/watchdog/hpwdt.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/watchdog/hpwdt.c +1 -1
index 68f5e37..e008788 100644
@@ -39,7 +39,7 @@
 #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128)
 #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000)
 #define HPWDT_MAX_TIMER	TICKS_TO_SECS(65535)
-#define HPWDT_VERSION			"1.1.1"
+#define HPWDT_VERSION			"1.2.0"
 
 #ifdef CONFIG_HPWDT_NMI_DECODING
 #define PCI_BIOS32_SD_VALUE		0x5F32335F	/* "_32_" */
Signature · 1 line
1.7.1
Acked-by on the v1 series
#20 lore raw
In reply to dann frazier
Quoted 18 lines

-----Original Message-----
From: Frazier, Daniel Kent (ProLiant Linux)
Sent: Tuesday, July 27, 2010 6:51 PM
To: Wim Van Sebroeck
Cc: [email protected]; Mingarelli, Thomas
Subject: [PATCH 00/15] hpwdt: make NMI code a config option (+ other cleanup)

hwpdt includes an NMI-decoding feature, but the watchdog interface is quite
usable without it. This patchset makes it possible to build hpwdt without the
NMI functionality, as well as some general cleanup.

 Kconfig |   22 +++++--
 hpwdt.c |  181 ++++++++++++++++++++++++++++++++++++----------------------
------
 2 files changed, 119 insertions(+), 84 deletions(-)
#21 lore raw
In reply to dann frazier

Hi Dan,

Quoted 3 lines

hwpdt includes an NMI-decoding feature, but the watchdog interface is quite usable without it. This patchset makes it possible to build hpwdt without the NMI functionality, as well as some general cleanup.

Looking at the overall overview we have:
watchdog: hpwdt (1/3): Introduce SECS_TO_TICKS() macro
watchdog: hpwdt (2/3): allow full range of timer values supported by hardware
watchdog: hpwdt (3/3): implement WDIOC_GETTIMELEFT
[PATCH 01/15] hpwdt_pretimeout reorganization
[PATCH 02/15] remove unnecessary includes
[PATCH 03/15] include spinlock.h
[PATCH 04/15] add include for linux/bitops.h
[PATCH 05/15] Group together includes specific to NMI sourcing [PATCH 06/15] Group options that affect watchdog behavior together [PATCH 07/15] Group defines only used by NMI sourcing together [PATCH 08/15] Group declarations specific to NMI sourcing together [PATCH 09/15] Despecificate driver from iLO2
[PATCH 10/15] Fix a typo
[PATCH 11/15] Make x86 assembly ifdef guard more strict
[PATCH 12/15] Construct status message w/ kasprintf and emit it with dev_info [PATCH 13/15] Use "decoding" instead of "sourcing"
[PATCH 14/15] Make NMI decoding a compile-time option
[PATCH 15/15] Bump version to 1.2.0

When I look closer I see that:
* Some of the clean-up stuff changes things that were introduced in the first 3 (timer) patches.
Since these patches are not in mainline yet, it would be better to directly do it there.
(Which means that you don't need patch 7 anymore).
* The clean-up of includes (2, 3, 4 and maybe 5) can be a single patch.
* Patch 10 is correct but since you change the Kconfig help text in patch 14 anyway,
I would incorporate that in patch 14. Same for patch 15 -> this should be combined with patch 14 also.
* Personally I prefer to do the general clean-up first and then do the different changes for the NMI part.
* I don't like the ifdef's in the init and exit procedures. A procedure/function that is defined for both cases is the way that we should go here. (see patch 14).

So overall: patches look good, but let's re-order the patches a bit (so that we first clean-up the driver and then add the NMI related changes (If we ever need to revert some things then we at least have a clean-driver before we start bisecting the NMI changes)). And secondly: let's try to have the ifdef's out of the init and exit procedures.

If you can look at how we can get rid of the ifdef's in init and exit, then I will reorder the patches and change the 3 timer patches and put that allready in a git tree.

Kind regards,
Wim.

#22 lore raw

Hi Dan,

Quoted 4 lines

So overall: patches look good, but let's re-order the patches a bit (so that we first clean-up the driver and then add the NMI related changes (If we ever need to revert some things then we at least have a clean-driver before we start bisecting the NMI changes)). And secondly: let's try to have the ifdef's out of the init and exit procedures.

If you can look at how we can get rid of the ifdef's in init and exit, then I will reorder the patches and change the 3 timer patches and put that allready in a git tree.

I reorganised the sequence of patches. I'll sent them to you for verification (and will put a copy in linux-watchdog mailing list).

the patches now look like:
watchdog: hpwdt (1/12): clean-up include-files.
watchdog: hpwdt (2/12): Group options that affect watchdog behavior together
watchdog: hpwdt (3/12): Group NMI sourcing specific items together
watchdog: hpwdt (4/12): Despecificate driver from iLO2
watchdog: hpwdt (5/12): Make x86 assembly ifdef guard more strict
watchdog: hpwdt (6/12): Introduce SECS_TO_TICKS() macro
watchdog: hpwdt (7/12): allow full range of timer values supported by hardware
watchdog: hpwdt (8/12): implement WDIOC_GETTIMELEFT
watchdog: hpwdt (9/12): hpwdt_pretimeout reorganization
watchdog: hpwdt (10/12): Construct status message w/ kasprintf and emit it with dev_info
watchdog: hpwdt (11/12): Use "decoding" instead of "sourcing"
watchdog: hpwdt (12/12): Make NMI decoding a compile-time option

(patch 12 can still be improved).

Kind regards,
Wim.

#23 lore raw
Quoted 23 lines · Wim Van Sebroeck

Hi Dan,

Quoted 4 lines

So overall: patches look good, but let's re-order the patches a bit (so that we first clean-up the driver and then add the NMI related changes (If we ever need to revert some things then we at least have a clean-driver before we start bisecting the NMI changes)). And secondly: let's try to have the ifdef's out of the init and exit procedures.

If you can look at how we can get rid of the ifdef's in init and exit, then I will reorder the patches and change the 3 timer patches and put that allready in a git tree.

I reorganised the sequence of patches. I'll sent them to you for verification (and will put a copy in linux-watchdog mailing list).

the patches now look like:
watchdog: hpwdt (1/12): clean-up include-files.
watchdog: hpwdt (2/12): Group options that affect watchdog behavior together
watchdog: hpwdt (3/12): Group NMI sourcing specific items together
watchdog: hpwdt (4/12): Despecificate driver from iLO2
watchdog: hpwdt (5/12): Make x86 assembly ifdef guard more strict
watchdog: hpwdt (6/12): Introduce SECS_TO_TICKS() macro
watchdog: hpwdt (7/12): allow full range of timer values supported by hardware
watchdog: hpwdt (8/12): implement WDIOC_GETTIMELEFT
watchdog: hpwdt (9/12): hpwdt_pretimeout reorganization
watchdog: hpwdt (10/12): Construct status message w/ kasprintf and emit it with dev_info
watchdog: hpwdt (11/12): Use "decoding" instead of "sourcing"
watchdog: hpwdt (12/12): Make NMI decoding a compile-time option

Quoted 1 line

(patch 12 can still be improved).

Thanks! I'll work on the #ifdef'ing & get you a new #12

Signature · 1 line
dann frazier | ProLiant Linux
#24 lore raw

Hi Dan,

Quoted 7 lines
Quoted 5 lines

watchdog: hpwdt (10/12): Construct status message w/ kasprintf and emit it with dev_info
watchdog: hpwdt (11/12): Use "decoding" instead of "sourcing"
watchdog: hpwdt (12/12): Make NMI decoding a compile-time option

(patch 12 can still be improved).

Thanks! I'll work on the #ifdef'ing & get you a new #12

I did some changes in the last 3 patches:
I removed patch 10, made patch 11 patch 10 and added and extra patch that moves the nmi decoding init and exit functions in seperate modules. I'll sent you the 3 new patches. Just let me know if they are OK.

Kind regards,
Wim.

#25 lore raw
Quoted 6 lines · Wim Van Sebroeck

Hi Dan,

Quoted 4 lines
Quoted 4 lines

watchdog: hpwdt (10/12): Construct status message w/ kasprintf and emit it with dev_info
watchdog: hpwdt (11/12): Use "decoding" instead of "sourcing"
watchdog: hpwdt (12/12): Make NMI decoding a compile-time option

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

(patch 12 can still be improved).

Thanks! I'll work on the #ifdef'ing & get you a new #12

I did some changes in the last 3 patches:
I removed patch 10, made patch 11 patch 10 and added and extra patch that moves the nmi decoding init and exit functions in seperate modules. I'll sent you the 3 new patches. Just let me know if they are OK.

Yes, they look very much like the changes I was preparing - but I got sidetracked by vacation before I could test :) I pulled your tree & ran a few sanity tests - looks good. Thanks for doing this!

Signature · 1 line
dann frazier | ProLiant Linux