[PATCH 2/2] bsp/atsam: Add SDRAM IS42S16320F-7BL.
From: Christian Mauderer --- c/src/lib/libbsp/arm/atsam/configure.ac | 12 +++- c/src/lib/libbsp/arm/atsam/startup/ram-config.c | 41 + 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/c/src/lib/libbsp/arm/atsam/configure.ac b/c/src/lib/libbsp/arm/atsam/configure.ac index 1297367..83c64b4 100644 --- a/c/src/lib/libbsp/arm/atsam/configure.ac +++ b/c/src/lib/libbsp/arm/atsam/configure.ac @@ -50,6 +50,16 @@ AC_ARG_ENABLE( esac], [AC_DEFINE([__SAMV71Q21__],[1],[chip variant]) INTFLASH=0x0020 ; INTSRAM=0x0006]) +AC_ARG_ENABLE( +[sdram], +[AS_HELP_STRING([--enable-sdram],[select a SDRAM variant (default is42s16100e-7bli)])], +[case "${enableval}" in + is42s16100e-7bli) AC_DEFINE([__SDRAM_IS42S16100E_7BLI__],[1],[SDRAM variant]) EXTSDRAM=0x0020 ;; + is42s16320f-7bl) AC_DEFINE([__SDRAM_IS42S16320F_7BL__],[1],[SDRAM variant]) EXTSDRAM=0x0400 ;; + *) AC_MSG_ERROR([bad value ${enableval} for SDRAM variant]) ;; +esac], +[AC_DEFINE([__SDRAM_IS42S16100E_7BLI__],[1],[SDRAM variant]) EXTSDRAM=0x0020]) + RTEMS_BSPOPTS_SET([BOARD_MAINOSC],[*],[1200]) RTEMS_BSPOPTS_HELP([BOARD_MAINOSC],[Main oscillator frequency in Hz (default 12MHz)]) @@ -76,7 +86,7 @@ AC_ARG_VAR([$1],[$2])dnl ATSAM_LINKCMD([ATSAM_MEMORY_TCM_SIZE],[size of tightly coupled memories (TCM) in bytes],[0x]) ATSAM_LINKCMD([ATSAM_MEMORY_INTFLASH_SIZE],[size of internal flash in bytes],[${INTFLASH}]) ATSAM_LINKCMD([ATSAM_MEMORY_INTSRAM_SIZE],[size of internal SRAM in bytes],[${INTSRAM}]) -ATSAM_LINKCMD([ATSAM_MEMORY_SDRAM_SIZE],[size of external SDRAM in bytes],[0x0020]) +ATSAM_LINKCMD([ATSAM_MEMORY_SDRAM_SIZE],[size of external SDRAM in bytes],[${EXTSDRAM}]) ATSAM_LINKCMD([ATSAM_MEMORY_QSPIFLASH_SIZE],[size of QSPI flash in bytes],[0x0020]) AC_CONFIG_FILES([ diff --git a/c/src/lib/libbsp/arm/atsam/startup/ram-config.c b/c/src/lib/libbsp/arm/atsam/startup/ram-config.c index 65060a7..e957107 100644 --- a/c/src/lib/libbsp/arm/atsam/startup/ram-config.c +++ b/c/src/lib/libbsp/arm/atsam/startup/ram-config.c @@ -12,10 +12,13 @@ * http://www.rtems.org/license/LICENSE. */ +#include #include #include +#if defined __SDRAM_IS42S16100E_7BLI__ const struct BOARD_Sdram_Config BOARD_Sdram_Config = { + /* FIXME: a lot of these values should be calculated using CPU frequency */ .sdramc_tr = 1562, .sdramc_cr = SDRAMC_CR_NC_COL8 /* 8 column bits */ @@ -32,3 +35,41 @@ const struct BOARD_Sdram_Config BOARD_Sdram_Config = { .sdramc_mdr = SDRAMC_MDR_MD_SDRAM, .sdramc_cfr1 = SDRAMC_CFR1_UNAL_SUPPORTED | SDRAMC_CFR1_TMRD(2) }; + +#elif defined __SDRAM_IS42S16320F_7BL__ +#define CLOCK_CYCLES_FROM_NS_MAX(ns) \ +(((ns) * (BOARD_MCK / 1000ul / 1000ul)) / 1000ul) +#define CLOCK_CYCLES_FROM_NS_MIN(ns) (CLOCK_CYCLES_FROM_NS_MAX(ns) + 1) + +const struct BOARD_Sdram_Config BOARD_Sdram_Config = { + /* 8k refresh cycles every 64ms => 7.8125us */ + .sdramc_tr = CLOCK_CYCLES_FROM_NS_MAX(7812ul), + .sdramc_cr = + SDRAMC_CR_NC_COL10 +| SDRAMC_CR_NR_ROW13 +| SDRAMC_CR_CAS_LATENCY3 +| SDRAMC_CR_NB_BANK4 +| SDRAMC_CR_DBW +/* t_WR = 30ns min (t_RC - t_RP - t_RCD; + * see data sheet November 2015 page 55); + * add some security margin */ +| SDRAMC_CR_TWR(CLOCK_CYCLES_FROM_NS_MIN(40)) +| SDRAMC_CR_TRC_TRFC(CLOCK_CYCLES_FROM_NS_MIN(60)) +| SDRAMC_CR_TRP(CLOCK_CYCLES_FROM_NS_MIN(15)) +| SDRAMC_CR_TRCD(CLOCK_CYCLES_FROM_NS_MIN(15)) +| SDRAMC_CR_TRAS(CLOCK_CYCLES_FROM_NS_MIN(37)) +| SDRAMC_CR_TXSR(CLOCK_CYCLES_FROM_NS_MIN(67)), + .sdramc_mdr = SDRAMC_MDR_MD_SDRAM, + .sdramc_cfr1 = SDRAMC_CFR1_UNAL_SUPPORTED | + SDRAMC_CFR1_TMRD(CLOCK_CYCLES_FROM_NS_MIN(14)) +}; + +#if CLOCK_CYCLES_FROM_NS_MIN(67) > 0xF + /* Prevent the fields to be out of range by checking the one with the biggest + * value. */ + #error SDRAM calculation does not work for the selected clock frequency +#endif + +#else + #error SDRAM not supported. +#endif -- 2.9.3 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
atsam-bsp: Allow to use different SDRAM
Hello, this patch set allows to use a different SDRAM in the atsam BSP. Similar to the CPU, the SDRAM-type can be selected using a --enable-sdram=xxx configure option. Kind regards Christian Mauderer ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/2] bsp/atsam: Move ram init values to structure.
From: Christian Mauderer --- c/src/lib/libbsp/arm/atsam/Makefile.am | 1 + .../libraries/libboard/include/board_memories.h| 10 +++ .../libraries/libboard/source/board_memories.c | 13 + c/src/lib/libbsp/arm/atsam/startup/ram-config.c| 34 ++ 4 files changed, 58 insertions(+) create mode 100644 c/src/lib/libbsp/arm/atsam/startup/ram-config.c diff --git a/c/src/lib/libbsp/arm/atsam/Makefile.am b/c/src/lib/libbsp/arm/atsam/Makefile.am index 2cfd227..8f4ab1c 100644 --- a/c/src/lib/libbsp/arm/atsam/Makefile.am +++ b/c/src/lib/libbsp/arm/atsam/Makefile.am @@ -398,6 +398,7 @@ libbsp_a_SOURCES += startup/pin-config.c libbsp_a_SOURCES += startup/power.c libbsp_a_SOURCES += startup/power-rtc.c libbsp_a_SOURCES += startup/power-clock.c +libbsp_a_SOURCES += startup/ram-config.c # IRQ libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c diff --git a/c/src/lib/libbsp/arm/atsam/libraries/libboard/include/board_memories.h b/c/src/lib/libbsp/arm/atsam/libraries/libboard/include/board_memories.h index 30767cd..3e63d94 100644 --- a/c/src/lib/libbsp/arm/atsam/libraries/libboard/include/board_memories.h +++ b/c/src/lib/libbsp/arm/atsam/libraries/libboard/include/board_memories.h @@ -43,6 +43,16 @@ extern void BOARD_ConfigureSdram(void); extern uint32_t BOARD_SdramValidation(uint32_t baseAddr, uint32_t size); +#ifdef __rtems__ +struct BOARD_Sdram_Config { + uint32_t sdramc_tr; + uint32_t sdramc_cr; + uint32_t sdramc_mdr; + uint32_t sdramc_cfr1; +}; + +extern const struct BOARD_Sdram_Config BOARD_Sdram_Config; +#endif /* __rtems__ */ #endif /* #ifndef BOARD_MEMORIES_H */ diff --git a/c/src/lib/libbsp/arm/atsam/libraries/libboard/source/board_memories.c b/c/src/lib/libbsp/arm/atsam/libraries/libboard/source/board_memories.c index 01ecd8e..4c55cbd 100644 --- a/c/src/lib/libbsp/arm/atsam/libraries/libboard/source/board_memories.c +++ b/c/src/lib/libbsp/arm/atsam/libraries/libboard/source/board_memories.c @@ -167,6 +167,7 @@ void BOARD_ConfigureSdram(void) /* 1. SDRAM features must be set in the configuration register: asynchronous timings (TRC, TRAS, etc.), number of columns, rows, CAS latency, and the data bus width. */ +#ifndef __rtems__ SDRAMC->SDRAMC_CR = SDRAMC_CR_NC_COL8 // 8 column bits | SDRAMC_CR_NR_ROW11 // 12 row bits (4K) @@ -180,13 +181,20 @@ void BOARD_ConfigureSdram(void) 5) // Active Command to read/Write Command delay time 21ns min | SDRAMC_CR_TRAS(9) // Command period (ACT to PRE) 42ns min | SDRAMC_CR_TXSR(15U); // Exit self-refresh to active time 70ns Min +#else /* __rtems__ */ + SDRAMC->SDRAMC_CR = BOARD_Sdram_Config.sdramc_cr; +#endif /* __rtems__ */ /* 2. For mobile SDRAM, temperature-compensated self refresh (TCSR), drive strength (DS) and partial array self refresh (PASR) must be set in the Low Power Register. */ /* 3. The SDRAM memory type must be set in the Memory Device Register.*/ +#ifndef __rtems__ SDRAMC->SDRAMC_MDR = SDRAMC_MDR_MD_SDRAM; +#else /* __rtems__ */ + SDRAMC->SDRAMC_MDR = BOARD_Sdram_Config.sdramc_mdr; +#endif /* __rtems__ */ /* 4. A minimum pause of 200 ��s is provided to precede any signal toggle.*/ for (i = 0; i < 10; i++); @@ -254,7 +262,12 @@ void BOARD_ConfigureSdram(void) with the value 1562(15.625 ��s x 100 MHz) or 781(7.81 ��s x 100 MHz). */ // For IS42S16100E, 2048 refresh cycle every 32ms, every 15.625 ��s /* ((32 x 10(^-3))/2048) x150 x (10^6) */ +#ifndef __rtems__ SDRAMC->SDRAMC_TR = 1562; SDRAMC->SDRAMC_CFR1 |= SDRAMC_CFR1_UNAL; +#else /* __rtems__ */ + SDRAMC->SDRAMC_TR = BOARD_Sdram_Config.sdramc_tr; + SDRAMC->SDRAMC_CFR1 = BOARD_Sdram_Config.sdramc_cfr1; +#endif /* __rtems__ */ /* After initialization, the SDRAM devices are fully functional. */ } diff --git a/c/src/lib/libbsp/arm/atsam/startup/ram-config.c b/c/src/lib/libbsp/arm/atsam/startup/ram-config.c new file mode 100644 index 000..65060a7 --- /dev/null +++ b/c/src/lib/libbsp/arm/atsam/startup/ram-config.c @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Dornierstr. 4 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#include +#include + +const struct BOARD_Sdram_Config BOARD_Sdram_Config = { + .sdramc_tr = 1562, + .sdramc_cr = + SDRAMC_CR_NC_COL8 /* 8 column bits */ +| SDRAMC_CR_NR_ROW11 /* 12 row bits (4K) */ +| SDRAMC_CR_CAS_LATENCY3 /* CAS Latency 3 */ +| SDRAMC_CR_NB_BANK2 /* 2 banks */ +| SDRAMC_CR_DBW /* 16 bit */ +| SDRAMC_CR_TWR(5) +| SDRAMC_CR_TRC
Re: RPi SD card Driver
Hello Mudit, your patch set looks quite good in general. Could you please remove the superfluous white space additions and guard all changes with the __rtems__ markers. Please add the import versions of your new files to the "FreeBSD version of imported files and directories" libbsd.txt section. I don't think we need a new test program. Does the media01 test work on your board? On 28/08/16 06:39, Mudit Jain wrote: Hi all, Good News !! I have successfully moved my changes on top of the recent MMC stack update to use the FreeBSD trunk, 2016-08-23, 9fe7c416e6abb28b1398fd3e5687099846800cfd The GitHub Link : https://github.com/spark1729/rtems-libbsd/commits/RPI_SD_LIBBSD Sebastian, if you can review the commits, then I will push it as patches. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH v3 1/7] Imported files for driver: bcm283x_dwcotg
Hello Deval, please rebase your patches to the latest libbsd version which uses: == FreeBSD version of imported files and directories . sys/dev/dwc/*, trunk, 2015-03-26, cfc3df2b8f708ce8494d9d556e3472a5c8c21b8a . sys/dev/mmc/*, trunk, 2016-08-23, 9fe7c416e6abb28b1398fd3e5687099846800cfd . sys/dev/usb/*, trunk, 2016-08-23, 9fe7c416e6abb28b1398fd3e5687099846800cfd . *, stable/9, 2015-04-08, 99a648a912e81e29d9c4c159cbbe263462f2d719 -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Rework thread priority management
This patch set reworks the thread priority management. The main goals are 1. an enhanced implementation of the priority inheritance protocol, and 2. support for the OMIP locking protocol. Instead of the current and real priority values in combination with the resource count use thread priority nodes which contribute to the overall thread priority. The actual priority of a thread is now an aggregation of priority nodes. The thread priority aggregation for the home scheduler instance of a thread consists of at least one priority node, which is normally the real priority of the thread. The locking protocols (e.g. priority ceiling and priority inheritance), rate-monotonic period objects and the POSIX sporadic server add, change and remove priority nodes. A thread changes its priority now immediately, e.g. priority changes are not deferred until the thread releases its last resource. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/8] score: Simplify thread queue acquire/release
--- cpukit/posix/include/rtems/posix/condimpl.h| 7 ++-- cpukit/posix/include/rtems/posix/psignalimpl.h | 10 ++ cpukit/rtems/src/semdelete.c | 4 +-- cpukit/rtems/src/semflush.c| 4 +-- cpukit/rtems/src/semsetpriority.c | 4 +-- cpukit/score/include/rtems/score/corebarrierimpl.h | 10 ++ cpukit/score/include/rtems/score/coremsgimpl.h | 15 ++-- cpukit/score/include/rtems/score/coremuteximpl.h | 10 ++ cpukit/score/include/rtems/score/corerwlockimpl.h | 10 ++ cpukit/score/include/rtems/score/coresemimpl.h | 10 ++ cpukit/score/include/rtems/score/mrspimpl.h| 7 ++-- cpukit/score/include/rtems/score/threadimpl.h | 10 +++--- cpukit/score/include/rtems/score/threadqimpl.h | 42 -- cpukit/score/src/threadqenqueue.c | 4 +-- cpukit/score/src/threadqfirst.c| 8 ++--- cpukit/score/src/threadrestart.c | 5 +-- 16 files changed, 68 insertions(+), 92 deletions(-) diff --git a/cpukit/posix/include/rtems/posix/condimpl.h b/cpukit/posix/include/rtems/posix/condimpl.h index 70a0707..fc4cfd3 100644 --- a/cpukit/posix/include/rtems/posix/condimpl.h +++ b/cpukit/posix/include/rtems/posix/condimpl.h @@ -68,10 +68,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Acquire_critical( Thread_queue_Context *queue_context ) { - _Thread_queue_Acquire_critical( -&the_cond->Wait_queue, -&queue_context->Lock_context - ); + _Thread_queue_Acquire_critical( &the_cond->Wait_queue, queue_context ); } RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( @@ -79,7 +76,7 @@ RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release( Thread_queue_Context *queue_context ) { - _Thread_queue_Release( &the_cond->Wait_queue, &queue_context->Lock_context ); + _Thread_queue_Release( &the_cond->Wait_queue, queue_context ); } /** diff --git a/cpukit/posix/include/rtems/posix/psignalimpl.h b/cpukit/posix/include/rtems/posix/psignalimpl.h index 62c1a85..3da 100644 --- a/cpukit/posix/include/rtems/posix/psignalimpl.h +++ b/cpukit/posix/include/rtems/posix/psignalimpl.h @@ -77,20 +77,14 @@ RTEMS_INLINE_ROUTINE void _POSIX_signals_Acquire( Thread_queue_Context *queue_context ) { - _Thread_queue_Acquire( -&_POSIX_signals_Wait_queue, -&queue_context->Lock_context - ); + _Thread_queue_Acquire( &_POSIX_signals_Wait_queue, queue_context ); } RTEMS_INLINE_ROUTINE void _POSIX_signals_Release( Thread_queue_Context *queue_context ) { - _Thread_queue_Release( -&_POSIX_signals_Wait_queue, -&queue_context->Lock_context - ); + _Thread_queue_Release( &_POSIX_signals_Wait_queue, queue_context ); } /** diff --git a/cpukit/rtems/src/semdelete.c b/cpukit/rtems/src/semdelete.c index fa0c25a..a9fb863 100644 --- a/cpukit/rtems/src/semdelete.c +++ b/cpukit/rtems/src/semdelete.c @@ -46,7 +46,7 @@ rtems_status_code rtems_semaphore_delete( _Thread_queue_Acquire_critical( &the_semaphore->Core_control.Wait_queue, -&queue_context.Lock_context +&queue_context ); switch ( the_semaphore->variant ) { @@ -81,7 +81,7 @@ rtems_status_code rtems_semaphore_delete( if ( status != STATUS_SUCCESSFUL ) { _Thread_queue_Release( &the_semaphore->Core_control.Wait_queue, - &queue_context.Lock_context + &queue_context ); _Objects_Allocator_unlock(); return _Status_Get( status ); diff --git a/cpukit/rtems/src/semflush.c b/cpukit/rtems/src/semflush.c index 3970d22..b7e8786 100644 --- a/cpukit/rtems/src/semflush.c +++ b/cpukit/rtems/src/semflush.c @@ -39,7 +39,7 @@ rtems_status_code rtems_semaphore_flush( rtems_id id ) _Thread_queue_Acquire_critical( &the_semaphore->Core_control.Wait_queue, -&queue_context.Lock_context +&queue_context ); _Thread_queue_Context_set_MP_callout( &queue_context, @@ -51,7 +51,7 @@ rtems_status_code rtems_semaphore_flush( rtems_id id ) case SEMAPHORE_VARIANT_MRSP: _Thread_queue_Release( &the_semaphore->Core_control.Wait_queue, -&queue_context.Lock_context +&queue_context ); return RTEMS_NOT_DEFINED; #endif diff --git a/cpukit/rtems/src/semsetpriority.c b/cpukit/rtems/src/semsetpriority.c index 5c331bb..f992d99 100644 --- a/cpukit/rtems/src/semsetpriority.c +++ b/cpukit/rtems/src/semsetpriority.c @@ -54,7 +54,7 @@ static rtems_status_code _Semaphore_Set_priority( _Thread_queue_Acquire_critical( &the_semaphore->Core_control.Wait_queue, -&queue_context->Lock_context +queue_context ); switch ( the_semaphore->variant ) { @@ -108,7 +108,7 @@ static rtems_status_code _Semaphore_Set_priority( _Thread_queue_Release( &the_semaphore->Core_control.Wait_queue, -&queue_context->Lock_context +queue_context ); *old_priority_p = _RTEMS_Priority_From_core( scheduler, old
[PATCH 2/8] score: Introduce Thread_queue_Lock_context
Introduce Thread_queue_Lock_context to contain the context necessary for thread queue lock and thread wait lock acquire/release operations to reduce the Thread_Control size. --- cpukit/libnetworking/rtems/rtems_glue.c | 4 +- cpukit/posix/include/rtems/posix/barrierimpl.h | 2 +- cpukit/posix/include/rtems/posix/mqueueimpl.h| 2 +- cpukit/posix/include/rtems/posix/posixapi.h | 14 ++- cpukit/posix/include/rtems/posix/semaphoreimpl.h | 2 +- cpukit/posix/src/condwaitsupp.c | 4 +- cpukit/posix/src/mqueuerecvsupp.c| 4 +- cpukit/posix/src/mqueuesendsupp.c| 2 +- cpukit/posix/src/pthreadgetschedparam.c | 2 +- cpukit/posix/src/pthreadjoin.c | 18 ++-- cpukit/posix/src/semunlink.c | 2 +- cpukit/rtems/include/rtems/rtems/barrierimpl.h | 7 +- cpukit/rtems/include/rtems/rtems/messageimpl.h | 2 +- cpukit/rtems/include/rtems/rtems/semimpl.h | 2 +- cpukit/rtems/src/semcreate.c | 2 +- cpukit/rtems/src/tasksetscheduler.c | 6 +- cpukit/score/include/rtems/score/coremuteximpl.h | 6 +- cpukit/score/include/rtems/score/mrspimpl.h | 20 ++-- cpukit/score/include/rtems/score/threadimpl.h| 80 +--- cpukit/score/include/rtems/score/threadq.h | 112 --- cpukit/score/include/rtems/score/threadqimpl.h | 12 +-- cpukit/score/src/apimutexlock.c | 2 +- cpukit/score/src/apimutexunlock.c| 2 +- cpukit/score/src/condition.c | 26 +++--- cpukit/score/src/coremsgbroadcast.c | 2 +- cpukit/score/src/coremutexseize.c| 2 +- cpukit/score/src/futex.c | 6 +- cpukit/score/src/mpci.c | 4 +- cpukit/score/src/mutex.c | 6 +- cpukit/score/src/semaphore.c | 6 +- cpukit/score/src/threadqenqueue.c| 52 ++- cpukit/score/src/threadqflush.c | 6 +- cpukit/score/src/threadrestart.c | 2 +- testsuites/sptests/spintrcritical22/init.c | 2 +- testsuites/tmtests/tm26/task1.c | 2 +- 35 files changed, 237 insertions(+), 188 deletions(-) diff --git a/cpukit/libnetworking/rtems/rtems_glue.c b/cpukit/libnetworking/rtems/rtems_glue.c index 2fca0e0..9a7f82f 100644 --- a/cpukit/libnetworking/rtems/rtems_glue.c +++ b/cpukit/libnetworking/rtems/rtems_glue.c @@ -375,7 +375,7 @@ rtems_bsdnet_semaphore_obtain (void) if (!the_networkSemaphore) rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); _Thread_queue_Context_initialize(&queue_context); - _ISR_lock_ISR_disable(&queue_context.Lock_context); + _ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context); _Thread_queue_Context_set_no_timeout( &queue_context ); status = _CORE_recursive_mutex_Seize ( &the_networkSemaphore->Core_control.Mutex.Recursive, @@ -409,7 +409,7 @@ rtems_bsdnet_semaphore_release (void) if (!the_networkSemaphore) rtems_panic ("rtems-net: network sema obtain: network not initialised\n"); _Thread_queue_Context_initialize(&queue_context); - _ISR_lock_ISR_disable(&queue_context.Lock_context); + _ISR_lock_ISR_disable(&queue_context.Lock_context.Lock_context); status = _CORE_recursive_mutex_Surrender( &the_networkSemaphore->Core_control.Mutex.Recursive, _Thread_Executing, diff --git a/cpukit/posix/include/rtems/posix/barrierimpl.h b/cpukit/posix/include/rtems/posix/barrierimpl.h index 2fbc2f9..fae66a6 100644 --- a/cpukit/posix/include/rtems/posix/barrierimpl.h +++ b/cpukit/posix/include/rtems/posix/barrierimpl.h @@ -71,7 +71,7 @@ RTEMS_INLINE_ROUTINE POSIX_Barrier_Control *_POSIX_Barrier_Get( _Thread_queue_Context_initialize( queue_context ); return (POSIX_Barrier_Control *) _Objects_Get( (Objects_Id) *barrier, -&queue_context->Lock_context, +&queue_context->Lock_context.Lock_context, &_POSIX_Barrier_Information ); } diff --git a/cpukit/posix/include/rtems/posix/mqueueimpl.h b/cpukit/posix/include/rtems/posix/mqueueimpl.h index 62ddbef..500 100644 --- a/cpukit/posix/include/rtems/posix/mqueueimpl.h +++ b/cpukit/posix/include/rtems/posix/mqueueimpl.h @@ -114,7 +114,7 @@ RTEMS_INLINE_ROUTINE POSIX_Message_queue_Control *_POSIX_Message_queue_Get( _Thread_queue_Context_initialize( queue_context ); return (POSIX_Message_queue_Control *) _Objects_Get( id, -&queue_context->Lock_context, +&queue_context->Lock_context.Lock_context, &_POSIX_Message_queue_Information ); } diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h index fabde4d..12baa75 100644 --- a/cpukit/posix/include/rtems/p
[PATCH 4/8] score: Move scheduler node to own header file
This makes it possible to add scheduler nodes to structures defined in . Update #2556. --- cpukit/score/Makefile.am | 1 + cpukit/score/include/rtems/score/scheduler.h | 159 --- cpukit/score/include/rtems/score/schedulernode.h | 188 +++ cpukit/score/include/rtems/score/thread.h| 7 +- cpukit/score/preinstall.am | 4 + 5 files changed, 196 insertions(+), 163 deletions(-) create mode 100644 cpukit/score/include/rtems/score/schedulernode.h diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 4a07cbe..c12820b 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -72,6 +72,7 @@ include_rtems_score_HEADERS += include/rtems/score/schedulercbs.h include_rtems_score_HEADERS += include/rtems/score/schedulercbsimpl.h include_rtems_score_HEADERS += include/rtems/score/scheduleredf.h include_rtems_score_HEADERS += include/rtems/score/scheduleredfimpl.h +include_rtems_score_HEADERS += include/rtems/score/schedulernode.h include_rtems_score_HEADERS += include/rtems/score/schedulerpriority.h include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityimpl.h include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmp.h diff --git a/cpukit/score/include/rtems/score/scheduler.h b/cpukit/score/include/rtems/score/scheduler.h index 0a6d682..bbb4e37 100644 --- a/cpukit/score/include/rtems/score/scheduler.h +++ b/cpukit/score/include/rtems/score/scheduler.h @@ -19,8 +19,6 @@ #ifndef _RTEMS_SCORE_SCHEDULER_H #define _RTEMS_SCORE_SCHEDULER_H -#include -#include #include #if defined(__RTEMS_HAVE_SYS_CPUSET_H__) && defined(RTEMS_SMP) #include @@ -44,8 +42,6 @@ struct Per_CPU_Control; typedef struct Scheduler_Control Scheduler_Control; -typedef struct Scheduler_Node Scheduler_Node; - #if defined(RTEMS_SMP) typedef Thread_Control * Scheduler_Void_or_thread; @@ -223,161 +219,6 @@ struct Scheduler_Control { uint32_t name; }; -#if defined(RTEMS_SMP) -/** - * @brief State to indicate potential help for other threads. - * - * @dot - * digraph state { - * y [label="HELP YOURSELF"]; - * ao [label="HELP ACTIVE OWNER"]; - * ar [label="HELP ACTIVE RIVAL"]; - * - * y -> ao [label="obtain"]; - * y -> ar [label="wait for obtain"]; - * ao -> y [label="last release"]; - * ao -> r [label="wait for obtain"]; - * ar -> r [label="timeout"]; - * ar -> ao [label="timeout"]; - * } - * @enddot - */ -typedef enum { - /** - * @brief This scheduler node is solely used by the owner thread. - * - * This thread owns no resources using a helping protocol and thus does not - * take part in the scheduler helping protocol. No help will be provided for - * other thread. - */ - SCHEDULER_HELP_YOURSELF, - - /** - * @brief This scheduler node is owned by a thread actively owning a resource. - * - * This scheduler node can be used to help out threads. - * - * In case this scheduler node changes its state from ready to scheduled and - * the thread executes using another node, then an idle thread will be - * provided as a user of this node to temporarily execute on behalf of the - * owner thread. Thus lower priority threads are denied access to the - * processors of this scheduler instance. - * - * In case a thread actively owning a resource performs a blocking operation, - * then an idle thread will be used also in case this node is in the - * scheduled state. - */ - SCHEDULER_HELP_ACTIVE_OWNER, - - /** - * @brief This scheduler node is owned by a thread actively obtaining a - * resource currently owned by another thread. - * - * This scheduler node can be used to help out threads. - * - * The thread owning this node is ready and will give away its processor in - * case the thread owning the resource asks for help. - */ - SCHEDULER_HELP_ACTIVE_RIVAL, - - /** - * @brief This scheduler node is owned by a thread obtaining a - * resource currently owned by another thread. - * - * This scheduler node can be used to help out threads. - * - * The thread owning this node is blocked. - */ - SCHEDULER_HELP_PASSIVE -} Scheduler_Help_state; -#endif - -/** - * @brief Scheduler node for per-thread data. - */ -struct Scheduler_Node { -#if defined(RTEMS_SMP) - /** - * @brief Chain node for usage in various scheduler data structures. - * - * Strictly this is the wrong place for this field since the data structures - * to manage scheduler nodes belong to the particular scheduler - * implementation. Currently all SMP scheduler implementations use chains. - * The node is here to simplify things, just like the object node in the - * thread control block. It may be replaced with a union to add a red-black - * tree node in the future. - */ - Chain_Node Node; - - /** - * @brief The thread using this node. - */ - Thread_Control *user; - - /** - * @brief The help state of th
[PATCH 7/8] score: Introduce _Thread_Get_priority()
Avoid direct access to thread internal data fields. --- cpukit/libmisc/capture/capture.h | 2 +- cpukit/libmisc/cpuuse/cpuusagetop.c| 8 ++-- cpukit/libmisc/monitor/mon-task.c | 2 +- cpukit/posix/src/killinfo.c| 12 ++-- cpukit/posix/src/pthread.c | 6 +++--- cpukit/posix/src/pthreadsetschedparam.c| 2 +- cpukit/posix/src/pthreadsetschedprio.c | 2 +- cpukit/rtems/src/tasksetpriority.c | 4 ++-- cpukit/score/include/rtems/score/coremuteximpl.h | 2 +- cpukit/score/include/rtems/score/mrspimpl.h| 4 ++-- cpukit/score/include/rtems/score/schedulersimpleimpl.h | 6 -- cpukit/score/include/rtems/score/threadimpl.h | 18 ++ cpukit/score/src/mpci.c| 2 +- cpukit/score/src/schedulercbsunblock.c | 8 +--- cpukit/score/src/scheduleredfreleasejob.c | 4 ++-- cpukit/score/src/scheduleredfunblock.c | 2 +- cpukit/score/src/schedulerpriorityunblock.c| 2 +- cpukit/score/src/schedulersimpleunblock.c | 10 ++ cpukit/score/src/threadchangepriority.c| 4 ++-- cpukit/score/src/threadqops.c | 4 ++-- cpukit/score/src/threadrestart.c | 4 ++-- cpukit/score/src/threadsetpriority.c | 2 +- testsuites/smptests/smpscheduler03/init.c | 2 +- testsuites/sptests/sp34/changepri.c| 6 -- testsuites/sptests/sp35/priinv.c | 18 ++ 25 files changed, 84 insertions(+), 52 deletions(-) diff --git a/cpukit/libmisc/capture/capture.h b/cpukit/libmisc/capture/capture.h index b22b735..0f3635c 100644 --- a/cpukit/libmisc/capture/capture.h +++ b/cpukit/libmisc/capture/capture.h @@ -903,7 +903,7 @@ rtems_capture_task_real_priority (rtems_tcb* tcb) static inline rtems_task_priority rtems_capture_task_curr_priority (rtems_tcb* tcb) { - return tcb->current_priority; + return _Thread_Get_priority (tcb); } /** diff --git a/cpukit/libmisc/cpuuse/cpuusagetop.c b/cpukit/libmisc/cpuuse/cpuusagetop.c index aa2b74c..ccf32de 100644 --- a/cpukit/libmisc/cpuuse/cpuusagetop.c +++ b/cpukit/libmisc/cpuuse/cpuusagetop.c @@ -264,8 +264,12 @@ task_usage(Thread_Control* thread, void* arg) if (thread->real_priority > data->tasks[j]->real_priority) continue; case RTEMS_TOP_SORT_CURRENT_PRI: - if (thread->current_priority > data->tasks[j]->current_priority) + if ( +_Thread_Get_priority( thread ) + > _Thread_Get_priority( data->tasks[j] ) + ) { continue; + } case RTEMS_TOP_SORT_ID: if (thread->Object.id < data->tasks[j]->Object.id) continue; @@ -478,7 +482,7 @@ rtems_cpuusage_top_thread (rtems_task_argument arg) thread->Object.id, name, thread->real_priority, - thread->current_priority); + _Thread_Get_priority(thread)); usage = data->usage[i]; current_usage = data->current_usage[i]; diff --git a/cpukit/libmisc/monitor/mon-task.c b/cpukit/libmisc/monitor/mon-task.c index eedba3e..af376d5 100644 --- a/cpukit/libmisc/monitor/mon-task.c +++ b/cpukit/libmisc/monitor/mon-task.c @@ -52,7 +52,7 @@ rtems_monitor_task_canonical( canonical_task->stack = rtems_thread->Start.Initial_stack.area; canonical_task->stack_size = rtems_thread->Start.Initial_stack.size; canonical_task->cpu = _Per_CPU_Get_index( _Thread_Get_CPU( rtems_thread ) ); -canonical_task->priority = rtems_thread->current_priority; +canonical_task->priority = _Thread_Get_priority( rtems_thread ); canonical_task->events = api->Event.pending_events; /* * FIXME: make this optionally cpu_time_executed diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c index 2e7bacb..7cf74eb 100644 --- a/cpukit/posix/src/killinfo.c +++ b/cpukit/posix/src/killinfo.c @@ -220,7 +220,7 @@ int _POSIX_signals_Send( printk("\n 0x%08x/0x%08x %d/%d 0x%08x 1", the_thread->Object.id, ((interested) ? interested->Object.id : 0), - the_thread->current_priority, interested_priority, + _Thread_Get_priority( the_thread ), interested_priority, the_thread->current_state ); #endif @@ -229,7 +229,7 @@ int _POSIX_signals_Send( * If this thread is of lower priority than the interested thread, * go on to the next thread. */ - if ( the_thread->current_priority > interested_priority ) + if ( _Thread_Get_priority( the_thread ) > interested_priority ) continue; DEBUG_STEP("2"); @@ -256,9 +256,9 @@ int _POSIX_sig
[PATCH 3/8] score: Optimize thread queue enqueue
Optimize the enqueue to empty thread queue case. --- cpukit/score/src/threadqops.c | 47 +++ 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/cpukit/score/src/threadqops.c b/cpukit/score/src/threadqops.c index 41506bf..1545f29 100644 --- a/cpukit/score/src/threadqops.c +++ b/cpukit/score/src/threadqops.c @@ -45,27 +45,30 @@ static void _Thread_queue_Do_nothing_extract( static Thread_queue_Heads *_Thread_queue_Queue_enqueue( Thread_queue_Queue *queue, Thread_Control *the_thread, - void ( *initialize )( Thread_queue_Heads * ), + void ( *initialize )( Thread_queue_Heads *, Thread_Control * ), void ( *enqueue )( Thread_queue_Heads *, Thread_Control * ) ) { - Thread_queue_Heads *heads = queue->heads; - Thread_queue_Heads *spare_heads = the_thread->Wait.spare_heads; + Thread_queue_Heads *heads; + Thread_queue_Heads *spare_heads; + heads = queue->heads; + spare_heads = the_thread->Wait.spare_heads; the_thread->Wait.spare_heads = NULL; if ( heads == NULL ) { _Assert( spare_heads != NULL ); _Assert( _Chain_Is_empty( &spare_heads->Free_chain ) ); + heads = spare_heads; queue->heads = heads; -( *initialize )( heads ); +_Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node ); +( *initialize )( heads, the_thread ); + } else { +_Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node ); +( *enqueue )( heads, the_thread ); } - _Chain_Prepend_unprotected( &heads->Free_chain, &spare_heads->Free_node ); - - ( *enqueue )( heads, the_thread ); - return heads; } @@ -92,10 +95,11 @@ static void _Thread_queue_Queue_extract( } static void _Thread_queue_FIFO_do_initialize( - Thread_queue_Heads *heads + Thread_queue_Heads *heads, + Thread_Control *the_thread ) { - _Chain_Initialize_empty( &heads->Heads.Fifo ); + _Chain_Initialize_one( &heads->Heads.Fifo, &the_thread->Wait.Node.Chain ); } static void _Thread_queue_FIFO_do_enqueue( @@ -235,14 +239,22 @@ static void _Thread_queue_Priority_priority_change( } static void _Thread_queue_Priority_do_initialize( - Thread_queue_Heads *heads + Thread_queue_Heads *heads, + Thread_Control *the_thread ) { + Thread_queue_Priority_queue *priority_queue; + + priority_queue = _Thread_queue_Priority_queue( heads, the_thread ); + #if defined(RTEMS_SMP) - _Chain_Initialize_empty( &heads->Heads.Fifo ); -#else - _RBTree_Initialize_empty( &heads->Heads.Priority.Queue ); + _Chain_Initialize_one( &heads->Heads.Fifo, &priority_queue->Node ); #endif + + _RBTree_Initialize_one( +&priority_queue->Queue, +&the_thread->Wait.Node.RBTree + ); } static void _Thread_queue_Priority_do_enqueue( @@ -250,9 +262,10 @@ static void _Thread_queue_Priority_do_enqueue( Thread_Control *the_thread ) { - Thread_queue_Priority_queue *priority_queue = -_Thread_queue_Priority_queue( heads, the_thread ); - Priority_Control current_priority; + Thread_queue_Priority_queue *priority_queue; + Priority_Control current_priority; + + priority_queue = _Thread_queue_Priority_queue( heads, the_thread ); #if defined(RTEMS_SMP) if ( _RBTree_Is_empty( &priority_queue->Queue ) ) { -- 1.8.4.5 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 6/8] score: Add scheduler node implementation header
Update #2556. --- cpukit/score/Makefile.am | 1 + cpukit/score/include/rtems/score/schedulerimpl.h | 100 --- cpukit/score/include/rtems/score/schedulernode.h | 6 - .../score/include/rtems/score/schedulernodeimpl.h | 134 + cpukit/score/include/rtems/score/threadimpl.h | 1 + cpukit/score/preinstall.am | 4 + 6 files changed, 140 insertions(+), 106 deletions(-) create mode 100644 cpukit/score/include/rtems/score/schedulernodeimpl.h diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index c12820b..f18af7d 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -73,6 +73,7 @@ include_rtems_score_HEADERS += include/rtems/score/schedulercbsimpl.h include_rtems_score_HEADERS += include/rtems/score/scheduleredf.h include_rtems_score_HEADERS += include/rtems/score/scheduleredfimpl.h include_rtems_score_HEADERS += include/rtems/score/schedulernode.h +include_rtems_score_HEADERS += include/rtems/score/schedulernodeimpl.h include_rtems_score_HEADERS += include/rtems/score/schedulerpriority.h include_rtems_score_HEADERS += include/rtems/score/schedulerpriorityimpl.h include_rtems_score_HEADERS += include/rtems/score/schedulerprioritysmp.h diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index 0832360..bbad6e0 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -110,15 +110,6 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_own_node( #endif } -#if defined(RTEMS_SMP) -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_user( - const Scheduler_Node *node -) -{ - return node->user; -} -#endif - ISR_LOCK_DECLARE( extern, _Scheduler_Lock ) /** @@ -779,82 +770,6 @@ RTEMS_INLINE_ROUTINE Scheduler_Node *_Scheduler_Thread_get_node( return the_thread->Scheduler.node; } -RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( - Scheduler_Node *node, - Thread_Control *the_thread, - Priority_Control priority -) -{ - node->owner = the_thread; - - node->Priority.value = priority; - node->Priority.prepend_it = false; - -#if defined(RTEMS_SMP) - node->user = the_thread; - node->help_state = SCHEDULER_HELP_YOURSELF; - node->idle = NULL; - node->accepts_help = the_thread; - _SMP_sequence_lock_Initialize( &node->Priority.Lock ); -#else - (void) the_thread; -#endif -} - -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( - const Scheduler_Node *node -) -{ - return node->owner; -} - -RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( - Scheduler_Node *node, - bool *prepend_it_p -) -{ - Priority_Control priority; - bool prepend_it; - -#if defined(RTEMS_SMP) - unsigned int seq; - - do { -seq = _SMP_sequence_lock_Read_begin( &node->Priority.Lock ); -#endif - -priority = node->Priority.value; -prepend_it = node->Priority.prepend_it; - -#if defined(RTEMS_SMP) - } while ( _SMP_sequence_lock_Read_retry( &node->Priority.Lock, seq ) ); -#endif - - *prepend_it_p = prepend_it; - - return priority; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_priority( - Scheduler_Node *node, - Priority_Control new_priority, - bool prepend_it -) -{ -#if defined(RTEMS_SMP) - unsigned int seq; - - seq = _SMP_sequence_lock_Write_begin( &node->Priority.Lock ); -#endif - - node->Priority.value = new_priority; - node->Priority.prepend_it = prepend_it; - -#if defined(RTEMS_SMP) - _SMP_sequence_lock_Write_end( &node->Priority.Lock, seq ); -#endif -} - RTEMS_INLINE_ROUTINE void _Scheduler_Thread_set_priority( Thread_Control *the_thread, Priority_Control new_priority, @@ -893,21 +808,6 @@ typedef void ( *Scheduler_Release_idle_thread )( Thread_Control*idle ); -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle( - const Scheduler_Node *node -) -{ - return node->idle; -} - -RTEMS_INLINE_ROUTINE void _Scheduler_Node_set_user( - Scheduler_Node *node, - Thread_Control *user -) -{ - node->user = user; -} - RTEMS_INLINE_ROUTINE void _Scheduler_Thread_set_node( Thread_Control *the_thread, Scheduler_Node *node diff --git a/cpukit/score/include/rtems/score/schedulernode.h b/cpukit/score/include/rtems/score/schedulernode.h index 63d86e6..293887c 100644 --- a/cpukit/score/include/rtems/score/schedulernode.h +++ b/cpukit/score/include/rtems/score/schedulernode.h @@ -205,12 +205,6 @@ typedef struct { } Priority; } Scheduler_Node; -#define SCHEDULER_NODE_OF_WAIT_CHAIN_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.Chain ) - -#define SCHEDULER_NODE_OF_WAIT_RBTREE_NODE( node ) \ - RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.RBTree ) - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/cpukit/score/include/rtems/score/schedulernodeimpl.h b/cpukit/score/include/rtems/score/s
[PATCH 5/8] score: Move thread wait node to scheduler node
Update #2556. --- cpukit/posix/src/killinfo.c | 5 +- cpukit/score/include/rtems/score/schedulerimpl.h | 17 +- cpukit/score/include/rtems/score/schedulernode.h | 40 - cpukit/score/include/rtems/score/thread.h| 217 +++ cpukit/score/include/rtems/score/threadimpl.h| 6 - cpukit/score/src/thread.c| 1 + cpukit/score/src/threadmp.c | 11 ++ cpukit/score/src/threadqflush.c | 10 +- cpukit/score/src/threadqops.c| 69 +-- 9 files changed, 226 insertions(+), 150 deletions(-) diff --git a/cpukit/posix/src/killinfo.c b/cpukit/posix/src/killinfo.c index b7f0354..2e7bacb 100644 --- a/cpukit/posix/src/killinfo.c +++ b/cpukit/posix/src/killinfo.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -150,8 +151,10 @@ int _POSIX_signals_Send( for ( the_node = _Chain_First( the_chain ); !_Chain_Is_tail( the_chain, the_node ) ; the_node = the_node->next ) { + Scheduler_Node *scheduler_node; - the_thread = THREAD_CHAIN_NODE_TO_THREAD( the_node ); + scheduler_node = SCHEDULER_NODE_OF_WAIT_CHAIN_NODE( the_node ); + the_thread = _Scheduler_Node_get_owner( scheduler_node ); api = the_thread->API_Extensions[ THREAD_API_POSIX ]; #if defined(DEBUG_SIGNAL_PROCESSING) diff --git a/cpukit/score/include/rtems/score/schedulerimpl.h b/cpukit/score/include/rtems/score/schedulerimpl.h index 1c5a697..0832360 100644 --- a/cpukit/score/include/rtems/score/schedulerimpl.h +++ b/cpukit/score/include/rtems/score/schedulerimpl.h @@ -785,13 +785,14 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( Priority_Control priority ) { + node->owner = the_thread; + node->Priority.value = priority; node->Priority.prepend_it = false; #if defined(RTEMS_SMP) node->user = the_thread; node->help_state = SCHEDULER_HELP_YOURSELF; - node->owner = the_thread; node->idle = NULL; node->accepts_help = the_thread; _SMP_sequence_lock_Initialize( &node->Priority.Lock ); @@ -800,6 +801,13 @@ RTEMS_INLINE_ROUTINE void _Scheduler_Node_do_initialize( #endif } +RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( + const Scheduler_Node *node +) +{ + return node->owner; +} + RTEMS_INLINE_ROUTINE Priority_Control _Scheduler_Node_get_priority( Scheduler_Node *node, bool *prepend_it_p @@ -885,13 +893,6 @@ typedef void ( *Scheduler_Release_idle_thread )( Thread_Control*idle ); -RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_owner( - const Scheduler_Node *node -) -{ - return node->owner; -} - RTEMS_INLINE_ROUTINE Thread_Control *_Scheduler_Node_get_idle( const Scheduler_Node *node ) diff --git a/cpukit/score/include/rtems/score/schedulernode.h b/cpukit/score/include/rtems/score/schedulernode.h index 6153624..63d86e6 100644 --- a/cpukit/score/include/rtems/score/schedulernode.h +++ b/cpukit/score/include/rtems/score/schedulernode.h @@ -123,11 +123,6 @@ typedef struct { Scheduler_Help_state help_state; /** - * @brief The thread owning this node. - */ - struct _Thread_Control *owner; - - /** * @brief The idle thread claimed by this node in case the help state is * SCHEDULER_HELP_ACTIVE_OWNER. * @@ -146,6 +141,35 @@ typedef struct { #endif /** + * @brief Thread wait support block. + */ + struct { +/** + * @brief Node for thread queues. + * + * Each scheduler node can be enqueued on a thread queue on behalf of the + * thread owning the scheduler node. The scheduler node reflects the + * priority of the thread within the corresponding scheduler instance. + */ +union { + /** + * @brief A node for chains. + */ + Chain_Node Chain; + + /** + * @brief A node for red-black trees. + */ + RBTree_Node RBTree; +} Node; + } Wait; + + /** + * @brief The thread owning this node. + */ + struct _Thread_Control *owner; + + /** * @brief The thread priority information used by the scheduler. * * The thread priority is manifest in two independent areas. One area is the @@ -181,6 +205,12 @@ typedef struct { } Priority; } Scheduler_Node; +#define SCHEDULER_NODE_OF_WAIT_CHAIN_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.Chain ) + +#define SCHEDULER_NODE_OF_WAIT_RBTREE_NODE( node ) \ + RTEMS_CONTAINER_OF( node, Scheduler_Node, Wait.Node.RBTree ) + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/cpukit/score/include/rtems/score/thread.h b/cpukit/score/include/rtems/score/thread.h index 19b52cd..a5faad3 100644 --- a/cpukit/score/include/rtems/score/thread.h +++ b/cpukit/score/include/rtems/score/thread.h @@ -210,6 +210,96 @@ typedef struct { void*tls_area; } Thread_Start_information; +#if defined(RTEMS_SMP) +/** + * @brief The thread s
[PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP
Locking can be used only when RTEMS reaches multitasking state _System_state_Is_up( _System_state_Get() ) --- c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 14 ++ 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c index 6c01d62..f7c8c36 100644 --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c @@ -19,6 +19,7 @@ #include #include #include +#include #include @@ -57,16 +58,21 @@ static rtems_status_code rpi_select_pin_function( /* Calculate the pin function select register address. */ volatile uint32_t *pin_addr = (uint32_t *) BCM2835_GPIO_REGS_BASE + (pin / 10); - uint32_t reg_old; uint32_t reg_new; + int use_locks; rtems_interrupt_lock_context lock_context; - rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context); - reg_new = reg_old = *pin_addr; + use_locks = _System_state_Is_up( _System_state_Get() ); + if ( use_locks ) +rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context); + + reg_new = *pin_addr; reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin); reg_new |= SELECT_PIN_FUNCTION(type, pin); *pin_addr = reg_new; - rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context); + + if ( use_locks ) +rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context); return RTEMS_SUCCESSFUL; } -- 1.9.1 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP
The interrupt locks are simple interrupt disable/enable or spin locks. So, they always work. - Pavel Pisa schrieb: > > Locking can be used only when RTEMS reaches multitasking state > _System_state_Is_up( _System_state_Get() ) > --- > c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c | 14 ++ > 1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c > b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c > index 6c01d62..f7c8c36 100644 > --- a/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c > +++ b/c/src/lib/libbsp/arm/raspberrypi/gpio/rpi-gpio.c > @@ -19,6 +19,7 @@ > #include > #include > #include > +#include > > #include > > @@ -57,16 +58,21 @@ static rtems_status_code rpi_select_pin_function( >/* Calculate the pin function select register address. */ >volatile uint32_t *pin_addr = (uint32_t *) BCM2835_GPIO_REGS_BASE + > (pin / 10); > - uint32_t reg_old; >uint32_t reg_new; > + int use_locks; >rtems_interrupt_lock_context lock_context; > > - rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context); > - reg_new = reg_old = *pin_addr; > + use_locks = _System_state_Is_up( _System_state_Get() ); > + if ( use_locks ) > +rtems_interrupt_lock_acquire(&rtems_gpio_bsp_lock, &lock_context); > + > + reg_new = *pin_addr; >reg_new &= ~SELECT_PIN_FUNCTION(RPI_ALT_FUNC_MASK, pin); >reg_new |= SELECT_PIN_FUNCTION(type, pin); >*pin_addr = reg_new; > - rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context); > + > + if ( use_locks ) > +rtems_interrupt_lock_release(&rtems_gpio_bsp_lock, &lock_context); > >return RTEMS_SUCCESSFUL; > } > -- > 1.9.1 > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.huber at embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP
Hello Sebastian, On Tuesday 06 of September 2016 20:33:08 Sebastian Huber wrote: > The interrupt locks are simple interrupt disable/enable or spin locks. So, > they always work. Allmost, on UP they are simple local IRQ disable. But on SMP they are spinlock combined with IRQ disable. But spinlock requires that corresponding memory location is initialized. It is initialized to 0,0 as ticked lock or combination with some debug/non-zero information depending on RTEMS_DEBUG, RTEMS_PROFILING etc. The locks ends in BSS for zero case and I expect that it is source of my problems. I have experienced hard lock of RPi BSP on rpi_select_pin_function() in SMP build when I use it in bsp_start_hook_0(), this is before bsp_start_copy_sections(). I use that for hacking to enable JTAG early in boot for BSP debugging https://github.com/ppisa/rtems/blob/rtems-rpi-devel-160621/c/src/lib/libbsp/arm/raspberrypi/startup/bspstarthooks.c#L85 I am sure that deadlock has been in rpi_select_pin_function(). Removing JTAG setup helped. I am sure that skipping locks would help. But you are right that I have not analyzed where _System_state_Is_up( _System_state_Get() ) global variable is placed. If it is in BSS then it is only matter of luck that it does not match system up state when BSS is not initialized yet. So value of patch for real BSP use case is questionable. My use case is corner or even more obscure and can be solved by setup in u-boot or definition of the function variant without locking. Anyway, thanks for review. I expect that you are quite overloaded after return from vacations but I would be really happy if you can say your comments/ACK/NACK to the rest or RPi SMP series in next days. There is that problem with generic RTL, caches on ARM and RPi BSP mostly unusable with actual firmaware on 4.11 branch. I understand, that my proposal of backport of most of related fixes from master to 4.11 is sensitive question. Again your income/voting to debate (ideally with Joel, Chris and Gedare) could help in steering 4.11 branch. Best wishes, Pavel PS: Congratulation to "Rework thread priority management". This is big/fundamental step forward for RTEMS. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: Rework thread priority management
I will try to read this code, but probably not until Friday. One question from the high-level description, can you clarify what "aggregation" means? Maybe this comes clear in one of the patches. Gedare On Tue, Sep 6, 2016 at 8:40 AM, Sebastian Huber wrote: > This patch set reworks the thread priority management. The main goals are > > 1. an enhanced implementation of the priority inheritance protocol, and > > 2. support for the OMIP locking protocol. > > Instead of the current and real priority values in combination with the > resource count use thread priority nodes which contribute to the overall > thread > priority. > > The actual priority of a thread is now an aggregation of priority nodes. > The thread priority aggregation for the home scheduler instance of a > thread consists of at least one priority node, which is normally the > real priority of the thread. The locking protocols (e.g. priority > ceiling and priority inheritance), rate-monotonic period objects and the > POSIX sporadic server add, change and remove priority nodes. > > A thread changes its priority now immediately, e.g. priority changes are > not deferred until the thread releases its last resource. > > ___ > devel mailing list > devel@rtems.org > http://lists.rtems.org/mailman/listinfo/devel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 1/2] libdl: Add ARM C++ relocation record support.
Closes #2767 --- cpukit/libdl/include/arch/arm/machine/elf_machdep.h | 3 ++- cpukit/libdl/rtl-mdreloc-arm.c | 17 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cpukit/libdl/include/arch/arm/machine/elf_machdep.h b/cpukit/libdl/include/arch/arm/machine/elf_machdep.h index 78c88b5..8f01d05 100644 --- a/cpukit/libdl/include/arch/arm/machine/elf_machdep.h +++ b/cpukit/libdl/include/arch/arm/machine/elf_machdep.h @@ -80,7 +80,8 @@ #define R_ARM_ALU_SBREL_19_12 36 #define R_ARM_ALU_SBREL_27_20 37 #define R_ARM_V4BX40 -#define R_ARM_PREL31 41 +#define R_ARM_TARGET2 41 +#define R_ARM_PREL31 42 #define R_ARM_MOVW_ABS_NC 43 #define R_ARM_MOVT_ABS44 diff --git a/cpukit/libdl/rtl-mdreloc-arm.c b/cpukit/libdl/rtl-mdreloc-arm.c index 692c829..84d58e3 100644 --- a/cpukit/libdl/rtl-mdreloc-arm.c +++ b/cpukit/libdl/rtl-mdreloc-arm.c @@ -52,6 +52,15 @@ isThumb(Elf_Word symvalue) else return false; } +static inline Elf_SOff +sign_extend31(Elf_Addr val) +{ + if (0x4000 & val) +return ~((Elf_Addr)0x7fff) | (0x7fff & val); + else +return 0x7fff & val; +} + bool rtems_rtl_elf_rel_resolve_sym (Elf_Word type) { @@ -165,12 +174,16 @@ rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, case R_TYPE(REL32): /* word32 (S + A) | T - P */ case R_TYPE(ABS32): /* word32 (S + A) | T */ case R_TYPE(GLOB_DAT): /* word32 (S + A) | T */ +case R_TYPE(PREL31):/* word32 (S + A) | T - P */ +case R_TYPE(TARGET2): /* Equivalent to ABS32 */ if (__predict_true(RELOC_ALIGNED_P(where))) { tmp = *where + symvalue; if (isThumb(symvalue)) tmp |= 1; if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32)) tmp -= (Elf_Addr)where; +else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31)) + tmp -= sign_extend31((Elf_Addr)where); *where = tmp; } else { tmp = load_ptr(where) + symvalue; @@ -178,11 +191,13 @@ rtems_rtl_elf_relocate_rel (const rtems_rtl_obj_t* obj, tmp |= 1; if (ELF_R_TYPE(rel->r_info) == R_TYPE(REL32)) tmp -= (Elf_Addr)where; +else if (ELF_R_TYPE(rel->r_info) == R_TYPE(PREL31)) + tmp -= sign_extend31((Elf_Addr)where); store_ptr(where, tmp); } if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC)) -printf ("rtl: REL32/ABS32/GLOB_DAT %p @ %p in %s", +printf ("rtl: REL32/ABS32/GLOB_DAT/PREL31/TARGET2 %p @ %p in %s", (void *)tmp, where, rtems_rtl_obj_oname (obj)); break; -- 2.4.6 ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
[PATCH 2/2] testsuite: Add libdl/dl05 reloc test.
--- testsuites/libtests/Makefile.am |2 +- testsuites/libtests/configure.ac |1 + testsuites/libtests/dl05/Makefile.am | 50 ++ testsuites/libtests/dl05/dl-cpp.cpp | 14 + testsuites/libtests/dl05/dl-load.c | 47 ++ testsuites/libtests/dl05/dl-load.h | 25 + testsuites/libtests/dl05/dl-o5.cpp | 19 + testsuites/libtests/dl05/dl05.doc| 24 + testsuites/libtests/dl05/dl05.scn| 1281 ++ testsuites/libtests/dl05/init.c | 82 +++ 10 files changed, 1544 insertions(+), 1 deletion(-) create mode 100644 testsuites/libtests/dl05/Makefile.am create mode 100644 testsuites/libtests/dl05/dl-cpp.cpp create mode 100644 testsuites/libtests/dl05/dl-load.c create mode 100644 testsuites/libtests/dl05/dl-load.h create mode 100644 testsuites/libtests/dl05/dl-o5.cpp create mode 100644 testsuites/libtests/dl05/dl05.doc create mode 100644 testsuites/libtests/dl05/dl05.scn create mode 100644 testsuites/libtests/dl05/init.c diff --git a/testsuites/libtests/Makefile.am b/testsuites/libtests/Makefile.am index effed07..dbd96cb 100644 --- a/testsuites/libtests/Makefile.am +++ b/testsuites/libtests/Makefile.am @@ -48,7 +48,7 @@ endif if DLTESTS _SUBDIRS += dl01 dl02 dl03 if HAS_CXX -_SUBDIRS += dl04 +_SUBDIRS += dl04 dl05 endif endif diff --git a/testsuites/libtests/configure.ac b/testsuites/libtests/configure.ac index 31afcae..9093cba 100644 --- a/testsuites/libtests/configure.ac +++ b/testsuites/libtests/configure.ac @@ -128,6 +128,7 @@ dl01/Makefile dl02/Makefile dl03/Makefile dl04/Makefile +dl05/Makefile dumpbuf01/Makefile ftp01/Makefile gxx01/Makefile diff --git a/testsuites/libtests/dl05/Makefile.am b/testsuites/libtests/dl05/Makefile.am new file mode 100644 index 000..d63f355 --- /dev/null +++ b/testsuites/libtests/dl05/Makefile.am @@ -0,0 +1,50 @@ +rtems_tests_PROGRAMS = dl05 +dl05_SOURCES = init.c dl-load.c dl-cpp.cpp dl-tar.c dl-tar.h + +BUILT_SOURCES = dl-tar.c dl-tar.h + +dist_rtems_tests_DATA = dl05.scn dl05.doc + +include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg +include $(top_srcdir)/../automake/compile.am +include $(top_srcdir)/../automake/leaf.am + +AM_CPPFLAGS += -I$(top_srcdir)/../support/include + +LINK_OBJS = $(dl05_OBJECTS) +LINK_LIBS = $(dl05_LDLIBS) + +dl-o5.o: dl-o5.cpp + +dl.tar: dl-o5.o + @rm -f $@ + $(PAX) -w -f $@ $< +CLEANFILES += dl.tar + +dl-tar.c: dl.tar + $(BIN2C) -C $< $@ +CLEANFILES += dl-tar.c + +dl-tar.h: dl.tar + $(BIN2C) -H $< $@ +CLEANFILES += dl-tar.h + +dl05.pre$(EXEEXT): $(dl05_OBJECTS) $(dl05_DEPENDENCIES) + @rm -f dl05.pre$(EXEEXT) + $(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ + -o $(basename $@)$(EXEEXT) $(LINK_OBJS) $(LINK_LIBS) + rm -f dl05.pre.ralf + +dl05.pre: dl05.pre$(EXEEXT) + mv $< $@ +CLEANFILES += dl05.pre + +dl-sym.o: dl05.pre + rtems-syms -e -c "$(CFLAGS)" -o $@ $< + +dl05$(EXEEXT): $(dl05_OBJECTS) $(dl05_DEPENDENCIES) dl-sym.o + @rm -f dl05$(EXEEXT) + $(LINK.cc) $(CPU_CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \ + -o $(basename $@)$(EXEEXT) $(LINK_OBJS) dl-sym.o $(LINK_LIBS) + +include $(top_srcdir)/../automake/local.am diff --git a/testsuites/libtests/dl05/dl-cpp.cpp b/testsuites/libtests/dl05/dl-cpp.cpp new file mode 100644 index 000..fcb9e0a --- /dev/null +++ b/testsuites/libtests/dl05/dl-cpp.cpp @@ -0,0 +1,14 @@ +/* + * The base image needs this to include the RTTI data. + */ +#include +#include +#include "dl-load.h" +void exception_base(bool istrue) +{ + printf("exception_base called\n"); + if (istrue) + { +throw std::runtime_error("dummy call to link in symbols"); + } +} diff --git a/testsuites/libtests/dl05/dl-load.c b/testsuites/libtests/dl05/dl-load.c new file mode 100644 index 000..f94317d --- /dev/null +++ b/testsuites/libtests/dl05/dl-load.c @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2016 Chris Johns . All rights reserved. + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.org/license/LICENSE. + */ + +#ifdef HAVE_CONFIG_H + #include "config.h" +#endif + +#include "tmacros.h" + +#include + +#include + +#include + +#include "dl-load.h" + +int dl_load_test(void) +{ + void* handle; + const char* err; + void(*func)(void); + + rtems_rtl_trace_set_mask(RTEMS_RTL_TRACE_ALL); + handle = dlopen("/dl-o5.o", RTLD_GLOBAL | RTLD_NOW); + err = dlerror(); + if (err != NULL) +printf("dlopen: %s\n", err); + rtems_test_assert(handle != NULL); + func = dlsym(handle, "exception_dl"); + err = dlerror (); + if (err) +printf ("dlsym: %s\n", err); + rtems_test_assert(func != NULL); + + exception_base(false); + func(); + + rtems_test_assert(dlclose(handle) == 0); + + return 0; +} diff --git a/testsuites/libtests/dl05/dl-load.h b/testsuites/libtests/dl05/dl-load.h new file mode 100644 index 000..98f4154 --- /dev/null +++ b/test
Re: Rework thread priority management
The new thread priority data structures are: /** * @brief The priority node to build up a priority aggregation. */ typedef struct { /** * @brief Node component for a chain or red-black tree. */ union { Chain_Node Chain; RBTree_Node RBTree; } Node; /** * @brief The priority value of this node. */ Priority_Control priority; } Priority_Node; /** * @brief The priority action type. */ typedef enum { PRIORITY_ACTION_ADD, PRIORITY_ACTION_CHANGE, PRIORITY_ACTION_REMOVE, PRIORITY_ACTION_INVALID } Priority_Action_type; typedef struct Priority_Aggregation Priority_Aggregation; /** * @brief The priority aggregation. */ struct Priority_Aggregation { /** * @brief A priority node reflection the overall priority of the aggregation. * * May be used to add this aggregation to another aggregation to build up a * recursive priority scheme. */ Priority_Node Node; /** * @brief A red-black tree to contain priority nodes contributing to the * overall priority of the this priority aggregation. */ RBTree_Control Contributors; #if defined(RTEMS_SMP) /** * @brief The scheduler instance of this priority aggregation. */ const struct Scheduler_Control *scheduler; #endif /** * @brief A priority action block to manage priority node additions, changes * and removals. */ struct { #if defined(RTEMS_SMP) /** * @brief The next priority aggregation in the action chain. */ Priority_Aggregation *next; #endif /** * @brief The priority node of the action. */ Priority_Node *node; /** * @brief The type of the action. */ Priority_Action_type type; } Action; }; /** * @brief A set of priority actions. */ typedef struct { /** * @brief The first action of a priority action chain. */ Priority_Aggregation *actions; } Priority_Actions; A thread priority is now a basically a priority queue. On 07/09/16 03:44, Gedare Bloom wrote: I will try to read this code, but probably not until Friday. One question from the high-level description, can you clarify what "aggregation" means? Maybe this comes clear in one of the patches. Gedare On Tue, Sep 6, 2016 at 8:40 AM, Sebastian Huber wrote: This patch set reworks the thread priority management. The main goals are 1. an enhanced implementation of the priority inheritance protocol, and 2. support for the OMIP locking protocol. Instead of the current and real priority values in combination with the resource count use thread priority nodes which contribute to the overall thread priority. The actual priority of a thread is now an aggregation of priority nodes. The thread priority aggregation for the home scheduler instance of a thread consists of at least one priority node, which is normally the real priority of the thread. The locking protocols (e.g. priority ceiling and priority inheritance), rate-monotonic period objects and the POSIX sporadic server add, change and remove priority nodes. A thread changes its priority now immediately, e.g. priority changes are not deferred until the thread releases its last resource. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP
Hello Pavel, On 06/09/16 21:48, Pavel Pisa wrote: Hello Sebastian, On Tuesday 06 of September 2016 20:33:08 Sebastian Huber wrote: The interrupt locks are simple interrupt disable/enable or spin locks. So, they always work. Allmost, on UP they are simple local IRQ disable. But on SMP they are spinlock combined with IRQ disable. But spinlock requires that corresponding memory location is initialized. It is initialized to 0,0 as ticked lock or combination with some debug/non-zero information depending on RTEMS_DEBUG, RTEMS_PROFILING etc. The locks ends in BSS for zero case and I expect that it is source of my problems. if you want to use something before the BSS initialization, then you can move it to the BSP_START_DATA_SECTION section or explicitly initialize it, e.g. in your case via rtems_interrupt_lock_initialize(). The rest of the patch series looks good. The smpfatal08 test is quite a hack since it re-defines some global SMP support functions locally. In order to support this, the ARM BSPs must place the _CPU_SMP_Start_processor() function as the only global function into the bspsmp.c file. -- Sebastian Huber, embedded brains GmbH Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG. ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel
Re: [PATCH 11 minor addeum] arm/raspberrypi: GPIO - using RTEMS interrupt lock during BSP
Hello Sebastian, On Wednesday 07 of September 2016 07:33:36 Sebastian Huber wrote: > Hello Pavel, > > On 06/09/16 21:48, Pavel Pisa wrote: > > Hello Sebastian, > > > > On Tuesday 06 of September 2016 20:33:08 Sebastian Huber wrote: > >> The interrupt locks are simple interrupt disable/enable or spin locks. > >> So, they always work. > > > > Allmost, on UP they are simple local IRQ disable. > > But on SMP they are spinlock combined with IRQ disable. > > But spinlock requires that corresponding memory location is initialized. > > It is initialized to 0,0 as ticked lock or combination with some > > debug/non-zero information depending on RTEMS_DEBUG, RTEMS_PROFILING etc. > > The locks ends in BSS for zero case and I expect that it is source of > > my problems. > > if you want to use something before the BSS initialization, then you can > move it to the BSP_START_DATA_SECTION section or explicitly initialize > it, e.g. in your case via rtems_interrupt_lock_initialize(). I skip this patch. I have found one other corner case for it usefullens and it is changing value of output pins to safe state during BSP fatal handling. If other CPU hard-faults when holding spinlock then fatal handler can block. But again artificially constructed case. > The rest of the patch series looks good. Thanks > The smpfatal08 test is quite a hack since it re-defines some global SMP > support functions locally. In order to support this, the ARM BSPs must > place the _CPU_SMP_Start_processor() function as the only global > function into the bspsmp.c file. I expected that CFLAGS_OPTIMIZE_V += -ffunction-sections -fdata-sections in BSP and linker -Wl,--gc-section could/sould resolve that. So should I divide bspsmp.c into two files? For example, bspsmp-startcpu.c, bspsmp-init.c. What about uint32_t _CPU_SMP_Initialize(void) { uint32_t cpu_count = (uint32_t)bsp_processor_count; if ( cpu_count > 4 ) cpu_count = 4; return cpu_count; } void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) { /* Do nothing */ } void _CPU_SMP_Prepare_start_multitasking( void ) { /* Do nothing */ } void _CPU_SMP_Send_interrupt( uint32_t target_cpu_index ) { /* Generates IPI */ BCM2835_REG(BCM2836_MAILBOX_3_WRITE_SET_BASE + 0x10 * target_cpu_index) = 0x1; } should they go to the same compilation unit as _CPU_SMP_Start_processor or bspsmp-init.c separate one. Or I should not care about smpfatal08 or add required symbol to it. Best wishes, Pavel ___ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel