Changeset 53e008b in rtems


Ignore:
Timestamp:
Apr 10, 2014, 1:48:05 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
2ca0a7b
Parents:
198c143
git-author:
Sebastian Huber <sebastian.huber@…> (04/10/14 13:48:05)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/14/14 06:37:04)
Message:

score: SMP initialization changes

Add and use _CPU_SMP_Start_processor(). Add and use
_CPU_SMP_Finalize_initialization(). This makes most
_CPU_SMP_Initialize() functions a bit simpler since we can calculate the
minimum value of the count of processors requested by the application
configuration and the count of physically or virtually available
processors in the high-level code.

The CPU port has now the ability to signal a processor start failure.
With the support for clustered/partitioned scheduling the presence of
particular processors can be configured to be optional or mandatory.
There will be a fatal error only in case mandatory processors are not
present.

The CPU port may use a timeout to monitor the start of a processor.

Files:
12 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c

    r198c143 r53e008b  
    2626}
    2727
    28 uint32_t _CPU_SMP_Initialize(uint32_t configured_cpu_count)
     28uint32_t _CPU_SMP_Initialize(void)
    2929{
    30   rtems_status_code sc;
    31   uint32_t max_cpu_count = arm_gic_irq_processor_count();
    32   uint32_t used_cpu_count = configured_cpu_count < max_cpu_count ?
    33     configured_cpu_count : max_cpu_count;
     30  return arm_gic_irq_processor_count();
     31}
    3432
    35   sc = rtems_interrupt_handler_install(
    36     ARM_GIC_IRQ_SGI_0,
    37     "IPI",
    38     RTEMS_INTERRUPT_UNIQUE,
    39     bsp_inter_processor_interrupt,
    40     NULL
    41   );
    42   assert(sc == RTEMS_SUCCESSFUL);
     33bool _CPU_SMP_Start_processor(uint32_t cpu_index)
     34{
     35  (void) cpu_index;
    4336
    44   return used_cpu_count;
     37  /* Nothing to do */
     38
     39  return true;
     40}
     41
     42void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
     43{
     44  if (cpu_count > 0) {
     45    rtems_status_code sc;
     46
     47    sc = rtems_interrupt_handler_install(
     48      ARM_GIC_IRQ_SGI_0,
     49      "IPI",
     50      RTEMS_INTERRUPT_UNIQUE,
     51      bsp_inter_processor_interrupt,
     52      NULL
     53    );
     54    assert(sc == RTEMS_SUCCESSFUL);
     55  }
    4556}
    4657
    4758void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
    4859{
    49   rtems_status_code sc = arm_gic_irq_generate_software_irq(
     60  arm_gic_irq_generate_software_irq(
    5061    ARM_GIC_IRQ_SGI_0,
    5162    ARM_GIC_IRQ_SOFTWARE_IRQ_TO_ALL_IN_LIST,
  • c/src/lib/libbsp/i386/shared/smp/smp-imps.c

    r198c143 r53e008b  
    787787}
    788788
    789 uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count )
    790 {
    791   int cores;
     789uint32_t _CPU_SMP_Initialize( void )
     790{
    792791  /* XXX need to deal with finding too many cores */
    793792
    794   cores = imps_probe();
    795 
    796   if ( cores > 1 )
     793  return (uint32_t) imps_probe();
     794}
     795
     796bool _CPU_SMP_Start_processor( uint32_t cpu_index )
     797{
     798  (void) cpu_index;
     799
     800  return true;
     801}
     802
     803void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
     804{
     805  if ( cpu_count > 1 )
    797806    ipi_install_irq();
    798   return cores;
    799807}
    800808
  • c/src/lib/libbsp/powerpc/qoriq/startup/smp.c

    r198c143 r53e008b  
    142142}
    143143
    144 uint32_t _CPU_SMP_Initialize(uint32_t configured_cpu_count)
     144uint32_t _CPU_SMP_Initialize(void)
    145145{
    146   rtems_status_code sc;
    147   uint32_t cores = configured_cpu_count < CORE_COUNT ?
    148     configured_cpu_count : CORE_COUNT;
     146  return CORE_COUNT;
     147}
    149148
    150   sc = rtems_interrupt_handler_install(
    151     QORIQ_IRQ_IPI_0,
    152     "IPI",
    153     RTEMS_INTERRUPT_UNIQUE,
    154     bsp_inter_processor_interrupt,
    155     NULL
    156   );
    157   assert(sc == RTEMS_SUCCESSFUL);
     149bool _CPU_SMP_Start_processor(uint32_t cpu_index)
     150{
     151  (void) cpu_index;
    158152
    159   if (cores > 1) {
    160     release_core_1();
     153  release_core_1();
     154
     155  return true;
     156}
     157
     158void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
     159{
     160  if (cpu_count > 1) {
     161    rtems_status_code sc;
     162
     163    sc = rtems_interrupt_handler_install(
     164      QORIQ_IRQ_IPI_0,
     165      "IPI",
     166      RTEMS_INTERRUPT_UNIQUE,
     167      bsp_inter_processor_interrupt,
     168      NULL
     169    );
     170    assert(sc == RTEMS_SUCCESSFUL);
    161171  }
    162 
    163   return cores;
    164172}
    165173
  • c/src/lib/libbsp/shared/smp/smp_stub.c

    r198c143 r53e008b  
    1212#include <rtems/score/cpu.h>
    1313
    14 uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count )
     14uint32_t _CPU_SMP_Initialize( void )
    1515{
    1616  /* return the number of CPUs */
     
    1818}
    1919
     20bool _CPU_SMP_Start_processor( uint32_t cpu_index )
     21{
     22  return true;
     23}
     24
     25void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
     26{
     27}
     28
    2029void _CPU_SMP_Send_interrupt( uint32_t target_processor_index )
    2130{
  • c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c

    r198c143 r53e008b  
    2727}
    2828
    29 void leon3_secondary_cpu_initialize(uint32_t cpu)
     29void leon3_secondary_cpu_initialize(uint32_t cpu_index)
    3030{
    3131  leon3_set_cache_control_register(0x80000F);
    3232  /* Unmask IPI interrupts at Interrupt controller for this CPU */
    33   LEON3_IrqCtrl_Regs->mask[cpu] |= 1 << LEON3_MP_IRQ;
     33  LEON3_IrqCtrl_Regs->mask[cpu_index] |= 1U << LEON3_MP_IRQ;
    3434
    3535  _SMP_Start_multitasking_on_secondary_processor();
    3636}
    3737
    38 uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count )
     38uint32_t _CPU_SMP_Initialize( void )
    3939{
    40   uint32_t max_cpu_count;
    41   uint32_t used_cpu_count;
    42   uint32_t cpu;
    43 
    4440  leon3_set_cache_control_register(0x80000F);
    4541
    46   max_cpu_count = leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
    47   used_cpu_count = configured_cpu_count < max_cpu_count ?
    48     configured_cpu_count : max_cpu_count;
    49 
    50   #if defined(RTEMS_DEBUG)
    51     printk( "Found %d CPUs\n", max_cpu_count );
    52 
    53     if ( max_cpu_count > configured_cpu_count ) {
    54       printk(
    55         "%d CPUs IS MORE THAN CONFIGURED -- ONLY USING %d\n",
    56         max_cpu_count,
    57         configured_cpu_count
    58       );
    59     }
    60   #endif
    61 
    62   if ( used_cpu_count > 1 ) {
     42  if ( rtems_configuration_get_maximum_processors() > 1 ) {
    6343    LEON_Unmask_interrupt(LEON3_MP_IRQ);
    6444    set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_MP_IRQ), 1);
    6545  }
    6646
    67   for ( cpu = 1 ; cpu < used_cpu_count ; ++cpu ) {
    68     #if defined(RTEMS_DEBUG)
    69       printk( "Waking CPU %d\n", cpu );
    70     #endif
     47  return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
     48}
    7149
    72     LEON3_IrqCtrl_Regs->mpstat = 1 << cpu;
    73   }
     50bool _CPU_SMP_Start_processor( uint32_t cpu_index )
     51{
     52  #if defined(RTEMS_DEBUG)
     53    printk( "Waking CPU %d\n", cpu_index );
     54  #endif
    7455
    75   return used_cpu_count;
     56  LEON3_IrqCtrl_Regs->mpstat = 1U << cpu_index;
     57
     58  return true;
     59}
     60
     61void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
     62{
     63  (void) cpu_count;
     64
     65  /* Nothing to do */
    7666}
    7767
  • cpukit/score/cpu/arm/rtems/score/cpu.h

    r198c143 r53e008b  
    468468
    469469#ifdef RTEMS_SMP
    470   uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
     470  uint32_t _CPU_SMP_Initialize( void );
     471
     472  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
     473
     474  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    471475
    472476  static inline uint32_t _CPU_SMP_Get_current_processor( void )
  • cpukit/score/cpu/i386/rtems/score/cpu.h

    r198c143 r53e008b  
    463463
    464464#if defined(RTEMS_SMP)
    465   uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
     465  uint32_t _CPU_SMP_Initialize( void );
     466
     467  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
     468
     469  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    466470
    467471  uint32_t _CPU_SMP_Get_current_processor( void );
  • cpukit/score/cpu/no_cpu/rtems/score/cpu.h

    r198c143 r53e008b  
    14681468   * processor.
    14691469   *
    1470    * This function is invoked on the boot processor by RTEMS during
     1470   * This function is invoked on the boot processor during system
    14711471   * initialization.  All interrupt stacks are allocated at this point in case
    1472    * the CPU port allocates the interrupt stacks.
     1472   * the CPU port allocates the interrupt stacks.  This function is called
     1473   * before _CPU_SMP_Start_processor() or _CPU_SMP_Finalize_initialization() is
     1474   * used.
    14731475   *
    1474    * The CPU port should start secondary processors now.
     1476   * @return The count of physically or virtually available processors.
     1477   * Depending on the configuration the application may use not all processors.
     1478   */
     1479  uint32_t _CPU_SMP_Initialize( void );
     1480
     1481  /**
     1482   * @brief Starts a processor specified by its index.
    14751483   *
    1476    * @param[in] configured_cpu_count The count of processors requested by the
    1477    * application configuration.
     1484   * This function is invoked on the boot processor during system
     1485   * initialization.
    14781486   *
    1479    * @return The count of processors available for the application in the system.
    1480    * This value is less than or equal to the configured count of processors.
     1487   * This function will be called after _CPU_SMP_Initialize().
     1488   *
     1489   * @param[in] cpu_index The processor index.
     1490   *
     1491   * @retval true Successful operation.
     1492   * @retval false Unable to start this processor.
    14811493   */
    1482   uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
     1494  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
     1495
     1496  /**
     1497   * @brief Performs final steps of CPU specific SMP initialization in the
     1498   * context of the boot processor.
     1499   *
     1500   * This function is invoked on the boot processor during system
     1501   * initialization.
     1502   *
     1503   * This function will be called after all processors requested by the
     1504   * application have been started.
     1505   *
     1506   * @param[in] cpu_count The minimum value of the count of processors
     1507   * requested by the application configuration and the count of physically or
     1508   * virtually available processors.
     1509   */
     1510  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    14831511
    14841512  /**
  • cpukit/score/cpu/powerpc/rtems/score/cpu.h

    r198c143 r53e008b  
    10351035
    10361036#ifdef RTEMS_SMP
    1037   uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
     1037  uint32_t _CPU_SMP_Initialize( void );
     1038
     1039  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
     1040
     1041  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    10381042
    10391043  static inline uint32_t _CPU_SMP_Get_current_processor( void )
  • cpukit/score/cpu/sparc/rtems/score/cpu.h

    r198c143 r53e008b  
    11621162
    11631163#if defined(RTEMS_SMP)
    1164   uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count );
     1164  uint32_t _CPU_SMP_Initialize( void );
     1165
     1166  bool _CPU_SMP_Start_processor( uint32_t cpu_index );
     1167
     1168  void _CPU_SMP_Finalize_initialization( uint32_t cpu_count );
    11651169
    11661170  #if defined(__leon__)
  • cpukit/score/include/rtems/score/smpimpl.h

    r198c143 r53e008b  
    4949typedef enum {
    5050  SMP_FATAL_SHUTDOWN,
    51   SMP_FATAL_SHUTDOWN_EARLY
     51  SMP_FATAL_SHUTDOWN_EARLY,
     52  SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
    5253} SMP_Fatal_code;
    5354
  • cpukit/score/src/smp.c

    r198c143 r53e008b  
    2727void _SMP_Handler_initialize( void )
    2828{
    29   uint32_t max_cpus = rtems_configuration_get_maximum_processors();
    30   uint32_t cpu;
     29  uint32_t cpu_max = rtems_configuration_get_maximum_processors();
     30  uint32_t cpu_self;
     31  uint32_t cpu_count;
     32  uint32_t cpu_index;
    3133
    32   for ( cpu = 0 ; cpu < max_cpus; ++cpu ) {
    33     Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
     34  for ( cpu_index = 0 ; cpu_index < cpu_max; ++cpu_index ) {
     35    Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu_index );
    3436
    3537    _SMP_ticket_lock_Initialize( &per_cpu->Lock, "per-CPU" );
     
    3941   * Discover and initialize the secondary cores in an SMP system.
    4042   */
    41   max_cpus = _CPU_SMP_Initialize( max_cpus );
    4243
    43   _SMP_Processor_count = max_cpus;
     44  cpu_count = _CPU_SMP_Initialize();
     45  cpu_count = cpu_count < cpu_max ? cpu_count : cpu_max;
     46  _SMP_Processor_count = cpu_count;
     47
     48  cpu_self = _SMP_Get_current_processor();
     49
     50  for ( cpu_index = 0 ; cpu_index < cpu_count; ++cpu_index ) {
     51    if ( cpu_index != cpu_self ) {
     52      bool ok = _CPU_SMP_Start_processor( cpu_index );
     53
     54      if ( !ok ) {
     55        _Terminate(
     56          RTEMS_FATAL_SOURCE_SMP,
     57          false,
     58          SMP_FATAL_START_OF_MANDATORY_PROCESSOR_FAILED
     59        );
     60      }
     61    }
     62  }
     63
     64  _CPU_SMP_Finalize_initialization( cpu_count );
    4465}
    4566
Note: See TracChangeset for help on using the changeset viewer.