Hi all, Please find attached a patch to close a race between the e500 PowerPC decrementer wrapping and the associated tick interrupt handler doing its thing.
The issue came up in the users@ list: http://lists.rtems.org/pipermail/users/2014-November/028362.html With these changes and not without, the spnsext01 test passes on the MVME3100. -- Nick Withers Embedded Systems Programmer Department of Nuclear Physics, Research School of Physics and Engineering The Australian National University (CRICOS: 00120C)
>From 9c21d107fa7fc109663f97d4a07fbc7f184d02bd Mon Sep 17 00:00:00 2001 From: Nick Withers <nick.with...@anu.edu.au> Date: Fri, 14 Nov 2014 11:49:18 +1100 Subject: [PATCH] Correct a race condition between the e500 core decrementer wrapping and the tick interrupt being handled. This corrects a "time-going-backwards" problem. The decrementer is now manually reset in the tick handler, as for the non-e500 case --- c/src/lib/libbsp/powerpc/shared/clock/p_clock.c | 4 ---- c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c | 32 ++----------------------- 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/c/src/lib/libbsp/powerpc/shared/clock/p_clock.c b/c/src/lib/libbsp/powerpc/shared/clock/p_clock.c index 1ff7ca0..15b0abf 100644 --- a/c/src/lib/libbsp/powerpc/shared/clock/p_clock.c +++ b/c/src/lib/libbsp/powerpc/shared/clock/p_clock.c @@ -17,7 +17,6 @@ #include <bsp.h> #include <bsp/irq.h> #include <libcpu/c_clock.h> -#include <libcpu/cpuIdent.h> static rtems_irq_connect_data clockIrqData; static rtems_irq_connect_data clockIrqData = { @@ -36,8 +35,5 @@ int BSP_disconnect_clock_handler(void) int BSP_connect_clock_handler(void) { - if ( ppc_cpu_is_bookE() ) - clockIrqData.hdl = clockIsrBookE; - return BSP_install_rtems_irq_handler(&clockIrqData); } diff --git a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c index f14acab..d1ce441 100644 --- a/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c +++ b/c/src/lib/libcpu/powerpc/mpc6xx/clock/c_clock.c @@ -34,7 +34,6 @@ SPR_RW(BOOKE_TCR) SPR_RW(BOOKE_TSR) -SPR_RW(BOOKE_DECAR) extern int BSP_connect_clock_handler (void); @@ -71,8 +70,6 @@ void clockOn(void* unused) PPC_Set_decrementer( Clock_Decrementer_value ); if ( ppc_cpu_is_bookE() ) { - _write_BOOKE_DECAR( Clock_Decrementer_value ); - rtems_interrupt_disable(l); /* clear pending/stale irq */ @@ -143,30 +140,6 @@ void clockIsr(void *unused) } while ( decr < 0 ); } -/* - * Clock_isr_bookE - * - * This is the clock tick interrupt handler - * for bookE CPUs. For efficiency reasons we - * provide a separate handler rather than - * checking the CPU type each time. - */ -void clockIsrBookE(void *unused) -{ - /* Note: TSR bit has already been cleared in the exception handler */ - - /* - * The driver has seen another tick. - */ - - Clock_driver_ticks += 1; - - /* - * Real Time Clock counter/timer is set to automatically reload. - */ - clock_handler(); -} - int clockIsOn(void* unused) { uint32_t msr_value; @@ -230,15 +203,14 @@ rtems_device_driver Clock_initialize( */ PPC_Set_decrementer( (unsigned)-1 ); - /* On a bookE CPU the decrementer works differently. It doesn't - * count past zero but we can enable auto-reload :-) + /* + * On a bookE CPU the decrementer works differently */ if ( ppc_cpu_is_bookE() ) { rtems_interrupt_disable(l); tcr = _read_BOOKE_TCR(); - tcr |= BOOKE_TCR_ARE; tcr &= ~BOOKE_TCR_DIE; _write_BOOKE_TCR(tcr); -- 2.1.2
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel