Changeset 615


Ignore:
Timestamp:
Jul 15, 2015, 6:17:41 PM (9 years ago)
Author:
bellefin
Message:

Introduce mmc distributed lock
The locks are distributed in the kernel heaps (one lock in each cluster) and there is a global table in the kernel data segment which contains the addresses of all the locks.
The _mmc_boot_mode variable is defined in boot.c and kernel_init.c and defines which kind of lock is used.
The distributed locks are initialized inside the kernel_init() function.

Location:
soft/giet_vm
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/giet_boot/boot.c

    r590 r615  
    164164unsigned int        _tty0_boot_mode = 1;
    165165
     166// boot code does not use distributed locks to protect MMC
     167__attribute__((section(".kdata")))
     168unsigned int        _mmc_boot_mode = 1;
     169
    166170// boot code does not uses a lock to protect HBA command allocator
    167171__attribute__((section(".kdata")))
  • soft/giet_vm/giet_drivers/mmc_driver.c

    r545 r615  
    3939
    4040///////////////////////////////////////////////////////////////////////////////
    41 // Distributed locks protecting MMC components (one per cluster)
    42 ///////////////////////////////////////////////////////////////////////////////
     41// Locks protecting MMC components (one per cluster)
     42// There are two kinds of lock: the _mmc_lock table contains all the locks and
     43// and is stored in the kernel data segment, whereas the _mmc_distributed_lock
     44// contains the addresses of locks which are distributed in every cluster (each
     45// cluster contains the lock which protects its own mmc_component).
     46// The global variable mmc_boot_mode define the type of lock which is used,
     47// and must be defined in both kernel_init.c and boot.c files.
     48// - the boot code must use a spin_lock because the kernel heap is not set.
     49// - the kernel code can use a sqt_lock when the kernel heap is set.
     50///////////////////////////////////////////////////////////////////////////////
     51
     52extern unsigned int  _mmc_boot_mode;
    4353
    4454__attribute__((section(".kdata")))
    45 spin_lock_t  _mmc_lock[X_SIZE][Y_SIZE]  __attribute__((aligned(64)));
     55spin_lock_t           _mmc_lock[X_SIZE][Y_SIZE]  __attribute__((aligned(64)));
     56
     57__attribute__((section(".kdata")))
     58spin_lock_t*          _mmc_distributed_lock[X_SIZE][Y_SIZE];
     59
     60//////////////////////////////////////////////////////////////////////////////
     61// This function initializes the distributed locks stored in the kernel heaps
     62//////////////////////////////////////////////////////////////////////////////
     63
     64void _mmc_init_locks()
     65{
     66    unsigned int cx;    // cluster X coordinate
     67    unsigned int cy;    // cluster Y coordinate
     68   
     69    for ( cx = 0 ; cx < X_SIZE ; cx++ )
     70    {
     71        for ( cy = 0 ; cy < Y_SIZE ; cy++ )
     72        {
     73            _mmc_distributed_lock[cx][cy] = _remote_malloc( sizeof(spin_lock_t), cx, cy );
     74            _spin_lock_init( _mmc_distributed_lock[cx][cy] );
     75        }
     76    }
     77}
    4678
    4779///////////////////////////////////////////////////////////////////////////////
     
    105137
    106138    // get the lock protecting exclusive access to MEMC
    107     _spin_lock_acquire( &_mmc_lock[x][y] );
     139    if ( _mmc_boot_mode ) _spin_lock_acquire( &_mmc_lock[x][y] );
     140    else                  _spin_lock_acquire( _mmc_distributed_lock[x][y] );
    108141
    109142    // write inval arguments
     
    114147
    115148    // release the lock
    116     _spin_lock_release( &_mmc_lock[x][y] );
     149    if ( _mmc_boot_mode ) _spin_lock_release( &_mmc_lock[x][y] );
     150    else                  _spin_lock_release( _mmc_distributed_lock[x][y] );
    117151}
    118152
     
    140174
    141175    // get the lock protecting exclusive access to MEMC
    142     _spin_lock_acquire( &_mmc_lock[x][y] );
     176    if ( _mmc_boot_mode ) _spin_lock_acquire( &_mmc_lock[x][y] );
     177    else                  _spin_lock_acquire( _mmc_distributed_lock[x][y] );
    143178
    144179    // write inval arguments
     
    149184
    150185    // release the lock
    151     _spin_lock_release( &_mmc_lock[x][y] );
     186    if ( _mmc_boot_mode ) _spin_lock_release( &_mmc_lock[x][y] );
     187    else                  _spin_lock_release( _mmc_distributed_lock[x][y] );
    152188}
    153189
  • soft/giet_vm/giet_drivers/mmc_driver.h

    r496 r615  
    1111#include <hard_config.h>
    1212#include <kernel_locks.h>
     13#include <kernel_malloc.h>
    1314
    1415///////////////////////////////////////////////////////////////////////////////////
     
    124125///////////////////////////////////////////////////////////////////////////////////
    125126
     127extern void _mmc_init_locks();
     128
    126129extern unsigned int _mmc_instrument( unsigned int x,
    127130                                     unsigned int y,
  • soft/giet_vm/giet_kernel/kernel_init.c

    r592 r615  
    113113unsigned int   _tty0_boot_mode = 0;
    114114
     115// Kernel uses distributed locks to protect MMC   
     116__attribute__((section(".kdata")))
     117unsigned int   _mmc_boot_mode = 0;
     118
    115119// Kernel uses sqt_lock to protect command allocator in HBA       
    116120__attribute__((section(".kdata")))
     
    161165#if GIET_DEBUG_INIT
    162166_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes kernel heap init\n", x, y, p );
     167#endif
     168        //////  distributed lock for MMC
     169        _mmc_init_locks();
     170
     171#if GIET_DEBUG_INIT
     172_nolock_printf("\n[DEBUG KINIT] P[%d,%d,%d] completes MMC distributed lock init\n", x , y , p );
    163173#endif
    164174        //////  distributed lock for TTY0
Note: See TracChangeset for help on using the changeset viewer.