Skip to contentSkip to conversation

ipmi: add new IPMI nmi watchdog handling

PATCH In review Corey Minyard 3 participants 8 messages Feb 14, 2007 – Feb 19, 2007 IPMI

lore
Share & tools
lore
#0 lore raw

PATCH 4/4 ipmi: add new IPMI nmi watchdog handling

Convert over to the new NMI handling for getting IPMI watchdog timeouts via an NMI. This add config options to know if there is the ability to receive NMIs and if it has an NMI post processing call. Then it modifies the IPMI watchdog to take advantage of this so that it can know if an NMI comes in.

It also adds testing that the IPMI NMI watchdog works.

arch/i386/Kconfig.debug +4 -0
Index: linux-2.6.19-rc6/arch/i386/Kconfig.debug
===================================================================
@@ -4,6 +4,10 @@ config TRACE_IRQFLAGS_SUPPORT
 	bool
 	default y
 
+config HAVE_STANDARD_NOTIFY_DIE
+	bool
+	default y
+
 source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
arch/x86_64/Kconfig.debug +4 -0
Index: linux-2.6.19-rc6/arch/x86_64/Kconfig.debug
===================================================================
@@ -4,6 +4,10 @@ config TRACE_IRQFLAGS_SUPPORT
 	bool
 	default y
 
+config HAVE_STANDARD_NOTIFY_DIE
+	bool
+	default y
+
 source "lib/Kconfig.debug"
 
 config DEBUG_RODATA
arch/i386/kernel/traps.c +5 -0
Index: linux-2.6.19-rc6/arch/i386/kernel/traps.c
===================================================================
@@ -804,6 +804,11 @@ static __kprobes void default_do_nmi(str
 		 */
 		if (nmi_watchdog_tick(regs, reason))
 			return;
+#endif
+		if (notify_die(DIE_NMI_POST, "nmi_post", regs, reason, 2, 0)
+							== NOTIFY_STOP)
+			return;
+#ifdef CONFIG_X86_LOCAL_APIC
 		if (!do_nmi_callback(regs, smp_processor_id()))
 #endif
 			unknown_nmi_error(reason, regs);
arch/x86_64/kernel/traps.c +2 -0
Index: linux-2.6.19-rc6/arch/x86_64/kernel/traps.c
===================================================================
@@ -835,6 +835,8 @@ asmlinkage __kprobes void default_do_nmi
 		 */
 		if (nmi_watchdog_tick(regs,reason))
 			return;
+		if (notify_die(DIE_NMI_POST, "nmi_post", regs, reason, 2, 0)
+								== NOTIFY_STOP)
 		if (!do_nmi_callback(regs,cpu))
 			unknown_nmi_error(reason, regs);
 
include/asm-i386/kdebug.h +3 -0
Index: linux-2.6.19-rc6/include/asm-i386/kdebug.h
===================================================================
@@ -38,9 +38,12 @@ enum die_val {
 	DIE_GPF,
 	DIE_CALL,
 	DIE_NMI_IPI,
+	DIE_NMI_POST,
 	DIE_PAGE_FAULT,
 };
 
+#define HAVE_DIE_NMI_POST
+
 static inline int notify_die(enum die_val val, const char *str,
 			struct pt_regs *regs, long err, int trap, int sig)
 {
include/asm-x86_64/kdebug.h +3 -0
Index: linux-2.6.19-rc6/include/asm-x86_64/kdebug.h
===================================================================
@@ -33,9 +33,12 @@ enum die_val {
 	DIE_GPF,
 	DIE_CALL,
 	DIE_NMI_IPI,
+	DIE_NMI_POST,
 	DIE_PAGE_FAULT,
 };
 
+#define HAVE_DIE_NMI_POST
+
 static inline int notify_die(enum die_val val, const char *str,
 			struct pt_regs *regs, long err, int trap, int sig)
 {
drivers/char/ipmi/ipmi_watchdog.c +78 -35

199 lines not on this page · raw message

#1 lore raw
Quoted 16 lines · On Wed, 14 Feb 2007 14:12:57 -0600 Corey Minyard <[email protected]> wrote:

Convert over to the new NMI handling for getting IPMI watchdog timeouts via an NMI. This add config options to know if there is the ability to receive NMIs and if it has an NMI post processing call. Then it modifies the IPMI watchdog to take advantage of this so that it can know if an NMI comes in.

It also adds testing that the IPMI NMI watchdog works.

Index: linux-2.6.19-rc6/arch/i386/Kconfig.debug
===================================================================

arch/i386/Kconfig.debug config TRACE_IRQFLAGS_SUPPORT · line 10

Quoted 7 lines
arch/i386/Kconfig.debug +4 -0
@@ -4,6 +4,10 @@ config TRACE_IRQFLAGS_SUPPORT
 	bool
 	default y
 
+config HAVE_STANDARD_NOTIFY_DIE
+	bool
+	default y
+

This is all fairly unpleasant.

What architecture is preventing us from using DIE_NMI_POST on all architectures which support ipmi? ia64?

It would be better to simply require that all ipmi-using architectures implement notify_die(DIE_NMI_POST, ...).

#2 lore raw
Quoted 7 lines · Andrew Morton

This is all fairly unpleasant.

What architecture is preventing us from using DIE_NMI_POST on all architectures which support ipmi? ia64?

It would be better to simply require that all ipmi-using architectures implement notify_die(DIE_NMI_POST, ...).

We're starting to see IPMI creeping on powerpc as well, and we don't have an NMI.

Paul.

#3 lore raw
Quoted 4 lines · On Thu, 15 Feb 2007 15:05:56 +1100 Paul Mackerras <[email protected]> wrote:
Quoted 2 lines · Andrew Morton

This is all fairly unpleasant.

Quoted 9 lines
Quoted 5 lines

What architecture is preventing us from using DIE_NMI_POST on all architectures which support ipmi? ia64?

It would be better to simply require that all ipmi-using architectures implement notify_die(DIE_NMI_POST, ...).

We're starting to see IPMI creeping on powerpc as well, and we don't have an NMI.

Sure, but you could implement the registration function. I mean, you _would_ call the NMI callback if you could, right ;)

As it stands, this change is pretty gruesome...

#4 lore raw
Quoted 11 lines · Andrew Morton
Quoted 8 lines · On Thu, 15 Feb 2007 15:05:56 +1100 Paul Mackerras <[email protected]> wrote:
Quoted 5 lines · Andrew Morton

This is all fairly unpleasant.

What architecture is preventing us from using DIE_NMI_POST on all architectures which support ipmi? ia64?

Quoted 6 lines
Quoted 6 lines
Quoted 3 lines

It would be better to simply require that all ipmi-using architectures implement notify_die(DIE_NMI_POST, ...).

We're starting to see IPMI creeping on powerpc as well, and we don't have an NMI.

PowerPC could have an NMI, at least on many of the processors, if manufacturers would wire in the MCP line and use it as an NMI.

Quoted 7 lines
Quoted 1 line

Sure, but you could implement the registration function. I mean, you _would_ call the NMI callback if you could, right ;)

As it stands, this change is pretty gruesome...

Yes, it's certainly not ideal. Most architectures do not have asm/kdebug.h, which was the reason for CONFIG_HAVE_STANDARD_NOTIFY_DIE. I know there are IPMI implementations on x86, ia64, ARM, MIPS, and PowerPC.

So I see the following options besides what's already there:

1) add asm/kdebug.h and DIE_NMI_POST to everything that might have an IPMI implementation.
2) use CONFIG_X86 to tell if NMI will work, since that's the only thing it will work on at the present.

I don't have any way to know how different systems have implemented that feature, so I can't actually implement it for the various architectures (plus I don't have any of those boards). So maybe #2 is the best?

-Corey

#5 lore raw
Quoted 10 lines · On Thu, 15 Feb 2007 09:49:15 -0600 Corey Minyard <[email protected]> wrote:

So I see the following options besides what's already there:

1) add asm/kdebug.h and DIE_NMI_POST to everything that might have an IPMI implementation.
2) use CONFIG_X86 to tell if NMI will work, since that's the only thing it will work on at the present.

I don't have any way to know how different systems have implemented that feature, so I can't actually implement it for the various architectures (plus I don't have any of those boards). So maybe #2 is the best?

I tend to think that #1 is the best option - it keeps things consistent and it gives arch/board maintainers a framework in which to add the
support code at their leisure. But it's something which would be best
worked through with the affected arch maintainers, please.

Which architectures are we talking about here? ia64 and ppc?

#6 lore raw
Quoted 12 lines · Andrew Morton
Quoted 7 lines · On Thu, 15 Feb 2007 09:49:15 -0600 Corey Minyard <[email protected]> wrote:

So I see the following options besides what's already there:

1) add asm/kdebug.h and DIE_NMI_POST to everything that might have an IPMI implementation.
2) use CONFIG_X86 to tell if NMI will work, since that's the only thing it will work on at the present.

I don't have any way to know how different systems have implemented that feature, so I can't actually implement it for the various architectures (plus I don't have any of those boards). So maybe #2 is the best?

Quoted 7 lines

I tend to think that #1 is the best option - it keeps things consistent and it gives arch/board maintainers a framework in which to add the
support code at their leisure. But it's something which would be best
worked through with the affected arch maintainers, please.

Which architectures are we talking about here? ia64 and ppc?

I'm not 100% sure, to tell you there truth. I know there are ARM, PPC, x86, SPARC, ia64, and MIPS systems that have IPMI. But you can stick it on anything, really. I'd like to be able to have basic support work without having to add arch-specific things for one feature of the driver.

-Corey

#7 lore raw
In reply to Andrew Morton
Quoted 14 lines · Andrew Morton
Quoted 10 lines · On Thu, 15 Feb 2007 09:49:15 -0600 Corey Minyard <[email protected]> wrote:

So I see the following options besides what's already there:

1) add asm/kdebug.h and DIE_NMI_POST to everything that might have an IPMI implementation.
2) use CONFIG_X86 to tell if NMI will work, since that's the only thing it will work on at the present.

I don't have any way to know how different systems have implemented that feature, so I can't actually implement it for the various architectures (plus I don't have any of those boards). So maybe #2 is the best?

Quoted 6 lines

I tend to think that #1 is the best option - it keeps things consistent and it gives arch/board maintainers a framework in which to add the
support code at their leisure. But it's something which would be best
worked through with the affected arch maintainers, please.

Which architectures are we talking about here? ia64 and ppc?

Reduce the "gruesomness" of the IPMI NMI watchdog handling.

Basically, I've looked at this and thought about it a while, and the only reasonable architecture that will currently support this is x86. Anything else is just a pipe dream and the implementation would be quite different and difficult to predict. So just make this x86-only for now and remove all the junk that is no longer necessary.

Suitable for merging into the previous patch.

arch/i386/Kconfig.debug +0 -4
Index: linux-2.6.20/arch/i386/Kconfig.debug
===================================================================
@@ -4,10 +4,6 @@ config TRACE_IRQFLAGS_SUPPORT
 	bool
 	default y
 
-config HAVE_STANDARD_NOTIFY_DIE
-	bool
-	default y
-
 source "lib/Kconfig.debug"
 
 config EARLY_PRINTK
arch/x86_64/Kconfig.debug +0 -4
Index: linux-2.6.20/arch/x86_64/Kconfig.debug
===================================================================
@@ -4,10 +4,6 @@ config TRACE_IRQFLAGS_SUPPORT
 	bool
 	default y
 
-config HAVE_STANDARD_NOTIFY_DIE
-	bool
-	default y
-
 source "lib/Kconfig.debug"
 
 config DEBUG_RODATA
drivers/char/ipmi/ipmi_watchdog.c +17 -8
Index: linux-2.6.20/drivers/char/ipmi/ipmi_watchdog.c
===================================================================
@@ -51,8 +51,17 @@
 #include <linux/ctype.h>
 #include <linux/delay.h>
 #include <asm/atomic.h>
-#ifdef CONFIG_HAVE_STANDARD_NOTIFY_DIE
+
+#ifdef CONFIG_X86
+/* This is ugly, but I've determined that x86 is the only architecture
+   that can reasonably support the IPMI NMI watchdog timeout at this
+   time.  If another architecture adds this capability somehow, it
+   will have to be a somewhat different mechanism and I have no idea
+   how it will work.  So in the unlikely event that another
+   architecture supports this, we can figure out a good generic
+   mechanism for it at that time. */
 #include <asm/kdebug.h>
+#define HAVE_DIE_NMI_POST
 #endif
 
 #define	PFX "IPMI Watchdog: "
@@ -364,6 +373,10 @@ static int i_ipmi_set_timeout(struct ipm
 	int                               hbnow = 0;
 
 
+	/* These can be cleared as we are setting the timeout. */
+	ipmi_start_timer_on_heartbeat = 0;
+	pretimeout_since_last_heartbeat = 0;
+
 	data[0] = 0;
 	WDOG_SET_TIMER_USE(data[0], WDOG_TIMER_USE_SMS_OS);
 
@@ -438,13 +451,12 @@ static int ipmi_set_timeout(int do_heart
 
 	wait_for_completion(&set_timeout_wait);
 
+	mutex_unlock(&set_timeout_lock);
+
 	if ((do_heartbeat == IPMI_SET_TIMEOUT_FORCE_HB)
 	    || ((send_heartbeat_now)
 		&& (do_heartbeat == IPMI_SET_TIMEOUT_HB_IF_NECESSARY)))
-	{
 		rv = ipmi_heartbeat();
-	}
-	mutex_unlock(&set_timeout_lock);
 
 out:
 	return rv;
@@ -524,12 +536,10 @@ static int ipmi_heartbeat(void)
 	int                               rv;
 	struct ipmi_system_interface_addr addr;
 
-	if (ipmi_ignore_heartbeat) {
+	if (ipmi_ignore_heartbeat)
 		return 0;
-	}
 
 	if (ipmi_start_timer_on_heartbeat) {
-		ipmi_start_timer_on_heartbeat = 0;
 		ipmi_watchdog_state = action_val;
 		return ipmi_set_timeout(IPMI_SET_TIMEOUT_FORCE_HB);
 	} else if (pretimeout_since_last_heartbeat) {
@@ -537,7 +547,6 @@ static int ipmi_heartbeat(void)
 		   We don't want to set the action, though, we want to
 		   leave that alone (thus it can't be combined with the
 		   above operation. */
-		pretimeout_since_last_heartbeat = 0;
 		return ipmi_set_timeout(IPMI_SET_TIMEOUT_HB_IF_NECESSARY);
 	}
 
include/asm-i386/kdebug.h +0 -2
Index: linux-2.6.20/include/asm-i386/kdebug.h
===================================================================
@@ -42,8 +42,6 @@ enum die_val {
 	DIE_PAGE_FAULT,
 };
 
-#define HAVE_DIE_NMI_POST
-
 static inline int notify_die(enum die_val val, const char *str,
 			struct pt_regs *regs, long err, int trap, int sig)
 {
include/asm-x86_64/kdebug.h +0 -2
Index: linux-2.6.20/include/asm-x86_64/kdebug.h
===================================================================
@@ -37,8 +37,6 @@ enum die_val {
 	DIE_PAGE_FAULT,
 };
 
-#define HAVE_DIE_NMI_POST
-
 static inline int notify_die(enum die_val val, const char *str,
 			struct pt_regs *regs, long err, int trap, int sig)
 {