Index: c/src/lib/libbsp/powerpc/gen5200/ChangeLog
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision 49cf70f1d044c57d3d4dff3634377ed2e1cc9002)
+++ c/src/lib/libbsp/powerpc/gen5200/ChangeLog	(revision eabd9f06e73034771d77bb9e8fc7096ce82fd0f5)
@@ -1,2 +1,13 @@
+2008-01-11	Joel Sherrill <joel.sherrill@oarcorp.com>
+
+	* configure.ac, irq/irq.c, startup/bspclean.c, startup/bspstart.c: Add
+	ALLOW_IRQ_NESTING option. The MPC5200 has a settle time after
+	acknowledging the IRQs and currently the BSP does not account for
+	that. After acknowledging an interrupt, it currently gets a second
+	spurious IRQ a significant percentage of the time. Rename to
+	BENCHMARK_IRQ_PROCESSING and get it working again. Under one test
+	load, not nesting interrupts resulted in a 50% reduction in the
+	number of IRQs and an ~30% reduction in time spent in IRQs.
+
 2007-12-18	Joel Sherrill <joel.sherrill@OARcorp.com>
 
Index: c/src/lib/libbsp/powerpc/gen5200/configure.ac
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/configure.ac	(revision 49cf70f1d044c57d3d4dff3634377ed2e1cc9002)
+++ c/src/lib/libbsp/powerpc/gen5200/configure.ac	(revision eabd9f06e73034771d77bb9e8fc7096ce82fd0f5)
@@ -26,4 +26,12 @@
  is turned on.])
 
+RTEMS_BSPOPTS_SET([BENCHMARK_IRQ_PROCESSING],[*],[0])
+RTEMS_BSPOPTS_HELP([BENCHMARK_IRQ_PROCESSING],
+[If defined, enable code to benchmark IRQ processing.])
+
+RTEMS_BSPOPTS_SET([ALLOW_IRQ_NESTING],[*],[1])
+RTEMS_BSPOPTS_HELP([ALLOW_IRQ_NESTING],
+[If defined, allow nested IRQ processing.])
+
 RTEMS_CHECK_NETWORKING
 AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
Index: c/src/lib/libbsp/powerpc/gen5200/irq/irq.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/irq/irq.c	(revision 49cf70f1d044c57d3d4dff3634377ed2e1cc9002)
+++ c/src/lib/libbsp/powerpc/gen5200/irq/irq.c	(revision eabd9f06e73034771d77bb9e8fc7096ce82fd0f5)
@@ -632,5 +632,5 @@
 }
 
-#if defined(TIME_IRQs)
+#if (BENCHMARK_IRQ_PROCESSING == 1)
 #include <stdio.h>
 uint64_t BSP_Starting_TBR;
@@ -689,5 +689,5 @@
   register unsigned int pmce;
   register unsigned int crit_pri_main_mask, per_mask;
-#if defined(TIME_IRQs)
+#if (BENCHMARK_IRQ_PROCESSING == 1)
   uint64_t start, stop, thisTime;
 
@@ -760,8 +760,10 @@
 	      mpc5200.crit_pri_main_mask |= irqMaskTable[irq];
 
+#if (ALLOW_IRQ_NESTING == 1)
               /* enable interrupt nesting */
 	      _CPU_MSR_GET(msr);
 	      new_msr = msr | MSR_EE;
 	      _CPU_MSR_SET(new_msr);
+#endif
 
               /* call the module specific handler and pass the
@@ -770,6 +772,8 @@
               rtems_hdl_tbl[irq].hdl(0);
 
+#if (ALLOW_IRQ_NESTING == 1)
               /* disable interrupt nesting */
               _CPU_MSR_SET(msr);
+#endif
 
               /* restore original interrupt mask */
@@ -797,8 +801,10 @@
                 mpc5200.per_mask |= irqMaskTable[irq];
 
+#if (ALLOW_IRQ_NESTING == 1)
                 /* enable interrupt nesting */
 		_CPU_MSR_GET(msr);
 		new_msr = msr | MSR_EE;
 		_CPU_MSR_SET(new_msr);
+#endif
 
                 /* call the module specific handler and pass
@@ -807,6 +813,8 @@
 		rtems_hdl_tbl[irq].hdl(0);
 
+#if (ALLOW_IRQ_NESTING == 1)
 		/* disable interrupt nesting */
 		_CPU_MSR_SET(msr);
+#endif
 
 		/* restore original interrupt mask */
@@ -884,8 +892,10 @@
                 mpc5200.per_mask |= irqMaskTable[irq];
 
+#if (ALLOW_IRQ_NESTING == 1)
                 /* enable interrupt nesting */
                 _CPU_MSR_GET(msr);
                 new_msr = msr | MSR_EE;
                 _CPU_MSR_SET(new_msr);
+#endif
 
                 /* call the module specific handler and pass the
@@ -893,5 +903,7 @@
                 rtems_hdl_tbl[irq].hdl(rtems_hdl_tbl[irq].handle);
 
+#if (ALLOW_IRQ_NESTING == 1)
                 _CPU_MSR_SET(msr);
+#endif
 
                 /* restore original interrupt mask */
@@ -949,8 +961,10 @@
 	      mpc5200.crit_pri_main_mask |= irqMaskTable[irq];
 
+#if (ALLOW_IRQ_NESTING == 1)
 	      /* enable interrupt nesting */
 	      _CPU_MSR_GET(msr);
 	      new_msr = msr | MSR_EE;
 	      _CPU_MSR_SET(new_msr);
+#endif
 
 	      /* call the module specific handler and pass the specific
@@ -958,6 +972,8 @@
 	      rtems_hdl_tbl[irq].hdl(rtems_hdl_tbl[irq].handle);
 
+#if (ALLOW_IRQ_NESTING == 1)
 	      /* disable interrupt nesting */
 	      _CPU_MSR_SET(msr);
+#endif
 
 	      /* restore original interrupt mask */
@@ -981,8 +997,10 @@
 		mpc5200.per_mask |= irqMaskTable[irq];
 
+#if (ALLOW_IRQ_NESTING == 1)
 		/* enable interrupt nesting */
 		_CPU_MSR_GET(msr);
 		new_msr = msr | MSR_EE;
 		_CPU_MSR_SET(new_msr);
+#endif
 
 		/* call the module specific handler and pass the
@@ -990,6 +1008,8 @@
 		rtems_hdl_tbl[irq].hdl(rtems_hdl_tbl[irq].handle);
 
+#if (ALLOW_IRQ_NESTING == 1)
 		/* disable interrupt nesting */
 		_CPU_MSR_SET(msr);
+#endif
 
 		/* restore original interrupt mask */
@@ -1023,9 +1043,10 @@
 
   } /* end of switch(excNum) */
-#if defined(TIME_IRQs)
+#if (BENCHMARK_IRQ_PROCESSING == 1)
   stop = PPC_Get_timebase_register();
   thisTime = stop - start;
-  if ( thisTime > BSP_Worst_ISR );
-    thisTime = BSP_Worst_ISR;
+  BSP_Total_in_ISR += thisTime;
+  if ( thisTime > BSP_Worst_ISR )
+    BSP_Worst_ISR = thisTime;
 #endif
   return 0;
Index: c/src/lib/libbsp/powerpc/gen5200/startup/bspclean.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/startup/bspclean.c	(revision 49cf70f1d044c57d3d4dff3634377ed2e1cc9002)
+++ c/src/lib/libbsp/powerpc/gen5200/startup/bspclean.c	(revision eabd9f06e73034771d77bb9e8fc7096ce82fd0f5)
@@ -22,5 +22,5 @@
 {
   
- #if defined(TIME_IRQs)
+  #if (BENCHMARK_IRQ_PROCESSING == 1)
   {
     extern void BSP_report_IRQ_Timing(void);
Index: c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c
===================================================================
--- c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c	(revision 49cf70f1d044c57d3d4dff3634377ed2e1cc9002)
+++ c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c	(revision eabd9f06e73034771d77bb9e8fc7096ce82fd0f5)
@@ -66,10 +66,10 @@
 /*   The mmu is unused at this time.                                   */
 /*                                                                     */
-/*   COPYRIGHT (c) 1989-2007.
+/*   COPYRIGHT (c) 1989-2007.                                          */
 /*   On-Line Applications Research Corporation (OAR).                  */
 /*                                                                     */
 /*   The license and distribution terms for this file may be           */
 /*   found in found in the file LICENSE in this distribution or at     */
-/*   http://www.rtems.com/license/LICENSE.                        */
+/*   http://www.rtems.com/license/LICENSE.                             */
 /*                                                                     */
 /*---------------------------------------------------------------------*/
@@ -302,4 +302,8 @@
    */
   Configuration.work_space_start = (void *)&_WorkspaceBase;
+#ifdef SHOW_MORE_INIT_SETTINGS
+  printk( "workspace=%p\n", Configuration.work_space_start );
+  printk( "workspace size=%d\n", Configuration.work_space_size );
+#endif
 
   /*
@@ -308,5 +312,5 @@
   BSP_rtems_irq_mng_init(0);
 
-#if defined(TIME_IRQs)
+#if (BENCHMARK_IRQ_PROCESSING == 1)
   {
     void BSP_initialize_IRQ_Timing(void);
