Changeset 9c3bae11 in rtems


Ignore:
Timestamp:
Apr 21, 2016, 5:52:19 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
6a46d99
Parents:
84a53988
git-author:
Sebastian Huber <sebastian.huber@…> (04/21/16 05:52:19)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/22/16 07:25:10)
Message:

rtems: Avoid Giant lock for dual ported memory

There is no need for an ISR lock since the Dual_ported_memory_Control is
immutable after initialization. ISR disable is enough for deletion
safety on uni-processor configurations.

Update #2555.

Location:
cpukit/rtems
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/rtems/include/rtems/rtems/dpmemimpl.h

    r84a53988 r9c3bae11  
    6767}
    6868
    69 /**
    70  *  @brief Maps port IDs to port control blocks.
    71  *
    72  *  This function maps port IDs to port control blocks.  If ID
    73  *  corresponds to a local port, then it returns the_port control
    74  *  pointer which maps to ID and location is set to OBJECTS_LOCAL.
    75  *  Global ports are not supported, thus if ID  does not map to a
    76  *  local port, location is set to OBJECTS_ERROR and the_port is
    77  *  undefined.
    78  */
    79 RTEMS_INLINE_ROUTINE Dual_ported_memory_Control *_Dual_ported_memory_Get (
    80   Objects_Id         id,
    81   Objects_Locations *location
     69RTEMS_INLINE_ROUTINE Dual_ported_memory_Control *_Dual_ported_memory_Get(
     70  Objects_Id        id,
     71  ISR_lock_Context *lock_context
    8272)
    8373{
    8474  return (Dual_ported_memory_Control *)
    85      _Objects_Get( &_Dual_ported_memory_Information, id, location );
     75    _Objects_Get_local( id, &_Dual_ported_memory_Information, lock_context );
    8676}
    8777
  • cpukit/rtems/src/dpmemdelete.c

    r84a53988 r9c3bae11  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/rtems/status.h>
    23 #include <rtems/rtems/support.h>
    24 #include <rtems/score/address.h>
    2521#include <rtems/rtems/dpmemimpl.h>
    26 #include <rtems/score/thread.h>
    2722
    2823rtems_status_code rtems_port_delete(
     
    3025)
    3126{
    32   Dual_ported_memory_Control          *the_port;
    33   Objects_Locations                    location;
     27  Dual_ported_memory_Control *the_port;
     28  ISR_lock_Context            lock_context;
    3429
    3530  _Objects_Allocator_lock();
    36   the_port = _Dual_ported_memory_Get( id, &location );
    37   switch ( location ) {
     31  the_port = _Dual_ported_memory_Get( id, &lock_context );
    3832
    39     case OBJECTS_LOCAL:
    40       _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
    41       _Objects_Put( &the_port->Object );
    42       _Dual_ported_memory_Free( the_port );
    43       _Objects_Allocator_unlock();
    44       return RTEMS_SUCCESSFUL;
    45 
    46 #if defined(RTEMS_MULTIPROCESSING)
    47     case OBJECTS_REMOTE:        /* this error cannot be returned */
    48 #endif
    49     case OBJECTS_ERROR:
    50       break;
     33  if ( the_port == NULL ) {
     34    _Objects_Allocator_unlock();
     35    return RTEMS_INVALID_ID;
    5136  }
    5237
     38  _Objects_Close( &_Dual_ported_memory_Information, &the_port->Object );
     39  _ISR_lock_ISR_enable( &lock_context );
     40  _Dual_ported_memory_Free( the_port );
    5341  _Objects_Allocator_unlock();
    54 
    55   return RTEMS_INVALID_ID;
     42  return RTEMS_SUCCESSFUL;
    5643}
  • cpukit/rtems/src/dpmemexternal2internal.c

    r84a53988 r9c3bae11  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/rtems/status.h>
    23 #include <rtems/rtems/support.h>
     21#include <rtems/rtems/dpmemimpl.h>
    2422#include <rtems/score/address.h>
    25 #include <rtems/rtems/dpmemimpl.h>
    26 #include <rtems/score/thread.h>
    2723
    2824rtems_status_code rtems_port_external_to_internal(
     
    3228)
    3329{
    34   Dual_ported_memory_Control          *the_port;
    35   Objects_Locations                    location;
    36   uint32_t                             ending;
     30  Dual_ported_memory_Control *the_port;
     31  ISR_lock_Context            lock_context;
     32  uint32_t                    ending;
    3733
    38   if ( !internal )
     34  if ( internal == NULL ) {
    3935    return RTEMS_INVALID_ADDRESS;
    40 
    41   the_port = _Dual_ported_memory_Get( id, &location );
    42   switch ( location ) {
    43     case OBJECTS_LOCAL:
    44       ending = _Addresses_Subtract( external, the_port->external_base );
    45       if ( ending > the_port->length )
    46         *internal = external;
    47       else
    48         *internal = _Addresses_Add_offset( the_port->internal_base,
    49                                            ending );
    50       _Objects_Put( &the_port->Object );
    51       return RTEMS_SUCCESSFUL;
    52 
    53 #if defined(RTEMS_MULTIPROCESSING)
    54     case OBJECTS_REMOTE:        /* this error cannot be returned */
    55 #endif
    56     case OBJECTS_ERROR:
    57       break;
    5836  }
    5937
    60   return RTEMS_INVALID_ID;
     38  the_port = _Dual_ported_memory_Get( id, &lock_context );
     39
     40  if ( the_port == NULL ) {
     41    return RTEMS_INVALID_ID;
     42  }
     43
     44  ending = _Addresses_Subtract( external, the_port->external_base );
     45
     46  if ( ending > the_port->length ) {
     47    *internal = external;
     48  } else {
     49    *internal = _Addresses_Add_offset( the_port->internal_base, ending );
     50  }
     51
     52  _ISR_lock_ISR_enable( &lock_context );
     53  return RTEMS_SUCCESSFUL;
    6154}
  • cpukit/rtems/src/dpmeminternal2external.c

    r84a53988 r9c3bae11  
    1919#endif
    2020
    21 #include <rtems/system.h>
    22 #include <rtems/rtems/status.h>
    23 #include <rtems/rtems/support.h>
     21#include <rtems/rtems/dpmemimpl.h>
    2422#include <rtems/score/address.h>
    25 #include <rtems/rtems/dpmemimpl.h>
    26 #include <rtems/score/thread.h>
    2723
    2824rtems_status_code rtems_port_internal_to_external(
     
    3228)
    3329{
    34   Dual_ported_memory_Control          *the_port;
    35   Objects_Locations                    location;
    36   uint32_t                             ending;
     30  Dual_ported_memory_Control *the_port;
     31  ISR_lock_Context            lock_context;
     32  uint32_t                    ending;
    3733
    38   if ( !external )
     34  if ( external == NULL ) {
    3935    return RTEMS_INVALID_ADDRESS;
    40 
    41   the_port = _Dual_ported_memory_Get( id, &location );
    42   switch ( location ) {
    43 
    44     case OBJECTS_LOCAL:
    45       ending = _Addresses_Subtract( internal, the_port->internal_base );
    46       if ( ending > the_port->length )
    47         *external = internal;
    48       else
    49         *external = _Addresses_Add_offset( the_port->external_base,
    50                                            ending );
    51       _Objects_Put( &the_port->Object );
    52       return RTEMS_SUCCESSFUL;
    53 
    54 #if defined(RTEMS_MULTIPROCESSING)
    55     case OBJECTS_REMOTE:        /* this error cannot be returned */
    56 #endif
    57     case OBJECTS_ERROR:
    58       break;
    5936  }
    6037
    61   return RTEMS_INVALID_ID;
     38  the_port = _Dual_ported_memory_Get( id, &lock_context );
     39
     40  if ( the_port == NULL ) {
     41    return RTEMS_INVALID_ID;
     42  }
     43
     44  ending = _Addresses_Subtract( internal, the_port->internal_base );
     45
     46  if ( ending > the_port->length ) {
     47    *external = internal;
     48  } else {
     49    *external = _Addresses_Add_offset( the_port->external_base, ending );
     50  }
     51
     52  _ISR_lock_ISR_enable( &lock_context );
     53  return RTEMS_SUCCESSFUL;
    6254}
Note: See TracChangeset for help on using the changeset viewer.