Ignore:
Timestamp:
Apr 21, 2016, 5:52:19 AM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.