Skip to contentSkip to conversation

Don't panic when EEH_MAX_FAILS is exceeded

PATCH In review Mike Mason 5 participants 9 messages Jul 20, 2008 – Jul 21, 2008

Subsystems (2)
lore
Share & tools
lore

Mike Mason

author
#0 lore raw

PATCH 1/1 Don't panic when EEH_MAX_FAILS is exceeded

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh. Although performance will be affected and the device may not recover, the system is still running, which at the very least, should allow for a more graceful shutdown. The panic() is now wrapped in a DEBUG statement for development purposes. The patch also removes the msleep() within a spinlock, which is not allowed.

arch/powerpc/platforms/pseries/eeh.c +0 -0
@@ -75,9 +75,9 @@
 */
 

/* If a device driver keeps reading an MMIO register in an interrupt
- * handler after a slot isolation event has occurred, we assume it
- * is broken and panic. This sets the threshold for how many read
- * attempts we allow before panicking.
+ * handler after a slot isolation event, it might be broken.
+ * This sets the threshold for how many read attempts we allow
+ * before printing an error message.
*/
#define EEH_MAX_FAILS 2100000

@@ -470,6 +470,7 @@

	unsigned long flags;
	struct pci_dn *pdn;
	int rc = 0;

+ const char *location;

	total_mmio_ffs++;

@@ -509,18 +510,24 @@

	rc = 1;
	if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
		pdn->eeh_check_count ++;

- if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
- printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
- pdn->eeh_check_count);
+ if (pdn->eeh_check_count % EEH_MAX_FAILS == 0) {
+ location = (char *) of_get_property(dn, "ibm,loc-code", NULL);
+ printk (KERN_ERR "EEH: %d reads ignored for recovering device at "
+ "location=%s driver=%s pci addr=%s\n",
+ pdn->eeh_check_count, location,
+ dev->driver->name, pci_name(dev));
+ printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n",
+ dev->driver->name);
+#ifdef DEBUG

			dump_stack();
-			msleep(5000);
-			
+
			/* re-read the slot reset state */
			if (read_slot_reset_state(pdn, rets) != 0)
				rets[0] = -1;	/* reset state unknown */

			/* If we are here, then we hit an infinite loop. Stop. */
			panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
+#endif
		}
		goto dn_unlock;
	}
#1 lore raw
Quoted 7 lines · On Sun, 20 Jul 2008 11:28:36 -0700 "Mike Mason" <[email protected]> wrote:

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh. Although performance will be affected and the device may not recover, the system is still running, which at the very least, should allow for a more graceful shutdown. The panic() is now wrapped in a DEBUG statement for development purposes. The patch also removes the msleep() within a spinlock, which is not allowed.

Why can you not msleep within a spinlock? And when was this change brought in?

Cheers,
Sean

#2 lore raw
Quoted 11 lines · Sean MacLennan
Quoted 7 lines · On Sun, 20 Jul 2008 11:28:36 -0700 "Mike Mason" <[email protected]> wrote:

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh. Although performance will be affected and the device may not recover, the system is still running, which at the very least, should allow for a more graceful shutdown. The panic() is now wrapped in a DEBUG statement for development purposes. The patch also removes the msleep() within a spinlock, which is not allowed.

Quoted 2 lines

Why can you not msleep within a spinlock? And when was this change brought in?

Giving up the cpu while holding a spinlock risks locking up the system in the worst case -- if another task tries to acquire the held lock it can spin indefinitely.

#3 lore raw
Quoted 8 lines · On Sun, 20 Jul 2008 15:17:08 -0500 "Nathan Lynch" <[email protected]> wrote:
Quoted 2 lines · Sean MacLennan

Why can you not msleep within a spinlock? And when was this change brought in?

Giving up the cpu while holding a spinlock risks locking up the system in the worst case -- if another task tries to acquire the held lock it can spin indefinitely.

I guess I am too x86 centric. On the x86 an msleep does not give up the CPU. It does a busy wait.

So what sleep do you use on the PowerPC when you need a delay for hardware reasons?

Cheers,
Sean

#4 lore raw

Hi Sean,

Quoted 3 lines · On Sun, 20 Jul 2008 23:47:56 -0400 Sean MacLennan <[email protected]>…

I guess I am too x86 centric. On the x86 an msleep does not give up the CPU. It does a busy wait.

I think you must be thinking of mdelay().

Signature · 3 lines
Cheers,
Stephen Rothwell                    [email protected]
http://www.canb.auug.org.au/~sfr/
#5 lore raw
Quoted 1 line · On Mon, 21 Jul 2008 14:09:46 +1000 "Stephen Rothwell" <[email protected]>…

I think you must be thinking of mdelay().

Correct you are! I didn't even know there was an msleep() so I just mapped it to mdelay() ;)

I'll have to look at msleep() though, there are places we could use it.

Cheers,
Sean

#6 lore raw
In reply to Mike Mason

Review

Quoted 10 lines · Mike Mason

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh. Although performance will be affected and the device may not recover, the system is still running, which at the very least, should allow for a more graceful shutdown. The panic() is now wrapped in a DEBUG statement for development purposes. The patch also removes the msleep() within a spinlock, which is not allowed.

(quoted diff) +0 -0
@@ -509,18 +510,24 @@

For ease of review, please try to use diff -p to generate patches.

Review line 514

Quoted 8 lines
(quoted diff) +2 -3
 	rc = 1;
 	if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
 		pdn->eeh_check_count ++;
-		if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
-			printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
-			        pdn->eeh_check_count);
+		if (pdn->eeh_check_count % EEH_MAX_FAILS == 0) {
+			location = (char *) of_get_property(dn, "ibm,loc-code", NULL);

Unneeded cast here, I think.

Quoted 8 lines
(quoted diff) +7 -0
+			printk (KERN_ERR "EEH: %d reads ignored for recovering device at "
+				"location=%s driver=%s pci addr=%s\n",
+				pdn->eeh_check_count, location,
+				dev->driver->name, pci_name(dev));
+			printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n",
+				dev->driver->name);
+#ifdef DEBUG
 			dump_stack();

Review line 530

Quoted 10 lines
(quoted diff) +2 -2
-			msleep(5000);
-			
+
 			/* re-read the slot reset state */
 			if (read_slot_reset_state(pdn, rets) != 0)
 				rets[0] = -1;	/* reset state unknown */
 
 			/* If we are here, then we hit an infinite loop. Stop. */
 			panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
+#endif

While I tend to agree that panic() is unnecessary, don't we want a stack dump unconditionally (i.e. not bracketed in #ifdef DEBUG)?

I'd prefer just removing the code instead of adding #ifdef's in the middle of this function. eeh.c needs less #ifdef DEBUG, not more :)

Acked-by
#7 lore raw

2008/7/20 Nathan Lynch <[email protected]>:

Quoted 7 lines
Quoted 4 lines · Mike Mason

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh.

Quoted 6 lines
Quoted 3 lines
                      /* re-read the slot reset state */
                      if (read_slot_reset_state(pdn, rets) != 0)
                              rets[0] = -1;   /* reset state unknown */

While I tend to agree that panic() is unnecessary, don't we want a stack dump unconditionally (i.e. not bracketed in #ifdef DEBUG)?

Probably. This stack trace would reveal a point inside the inf loop, which can then be analyzed and fixed.

Quoted 2 lines

I'd prefer just removing the code instead of adding #ifdef's in the middle of this function. eeh.c needs less #ifdef DEBUG, not more :)

I didn't know that there was a lot of ifdef DEBUG in there. Yes, we don't need an ifdef DEBUG for this.

Pending these changes, I'd happily add:

--linas

author Acked-by Linas Vepstas on v1 1/1
#8 lore raw
In reply to Mike Mason

Here's a repost of the patch with the suggested changes.

This patch changes the EEH_MAX_FAILS action from panic to printing an error message. Panicking under under this condition is too harsh. Although performance will be affected and the device may not recover, the system is still running, which at the very least should allow for a more graceful shutdown. The patch also removes the msleep() within a spinlock, which can lead to a deadlock and is not recommended.

arch/powerpc/platforms/pseries/eeh.c +0 -0
@@ -75,9 +75,9 @@
 */
 

/* If a device driver keeps reading an MMIO register in an interrupt
- * handler after a slot isolation event has occurred, we assume it
- * is broken and panic. This sets the threshold for how many read
- * attempts we allow before panicking.
+ * handler after a slot isolation event, it might be broken.
+ * This sets the threshold for how many read attempts we allow
+ * before printing an error message.
*/
#define EEH_MAX_FAILS 2100000

@@ -470,6 +470,7 @@ int eeh_dn_check_failure(struct device_n

	unsigned long flags;
	struct pci_dn *pdn;
	int rc = 0;

+ const char *location;

	total_mmio_ffs++;

@@ -509,18 +510,15 @@ int eeh_dn_check_failure(struct device_n

	rc = 1;
	if (pdn->eeh_mode & EEH_MODE_ISOLATED) {
		pdn->eeh_check_count ++;

- if (pdn->eeh_check_count >= EEH_MAX_FAILS) {
- printk (KERN_ERR "EEH: Device driver ignored %d bad reads, panicing\n",
- pdn->eeh_check_count);
+ if (pdn->eeh_check_count % EEH_MAX_FAILS == 0) {
+ location = of_get_property(dn, "ibm,loc-code", NULL);
+ printk (KERN_ERR "EEH: %d reads ignored for recovering device at "
+ "location=%s driver=%s pci addr=%s\n",
+ pdn->eeh_check_count, location,
+ dev->driver->name, pci_name(dev));
+ printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n",

+				dev->driver->name);
			dump_stack();

- msleep(5000);
-
- /* re-read the slot reset state */
- if (read_slot_reset_state(pdn, rets) != 0)
- rets[0] = -1; /* reset state unknown */
-
- /* If we are here, then we hit an infinite loop. Stop. */

-			panic("EEH: MMIO halt (%d) on device:%s\n", rets[0], pci_name(dev));
		}
		goto dn_unlock;
	}