diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2011-06-17 12:35:39 -0500 |
---|---|---|
committer | A. Patrick Williams III <iawillia@us.ibm.com> | 2011-06-24 11:30:00 -0500 |
commit | d85739a1ad9e58339f5a58225da2ba5c7476c68b (patch) | |
tree | ae0acc7d51df7c742e8683ee100558ecb8766ff2 /src | |
parent | 74d2fd5773f91470e17009b5da93f9d4a5cb1d5c (diff) | |
download | blackbird-hostboot-d85739a1ad9e58339f5a58225da2ba5c7476c68b.tar.gz blackbird-hostboot-d85739a1ad9e58339f5a58225da2ba5c7476c68b.zip |
Remove heap allocation of xscom mutex.
Since mutexes are simply a uint64 with a static initializer, the xscom mutex
is now a instance variable directly in the cpu object.
Remove unneeded mutex_create function and changed the behavior of
mutex_destroy.
Change-Id: If6e1d1bf0083c32ef9e7502d27678811bdaf7e1e
Reviewed-on: http://gfw160.austin.ibm.com:8080/gerrit/150
Tested-by: Jenkins Server
Reviewed-by: Douglas R. Gilbert <dgilbert@us.ibm.com>
Reviewed-by: Thi N. Tran <thi@us.ibm.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/include/kernel/cpu.H | 2 | ||||
-rw-r--r-- | src/include/sys/sync.h | 15 | ||||
-rw-r--r-- | src/kernel/cpumgr.C | 3 | ||||
-rw-r--r-- | src/lib/sync.C | 12 | ||||
-rw-r--r-- | src/lib/syscall_mmio.C | 25 |
5 files changed, 12 insertions, 45 deletions
diff --git a/src/include/kernel/cpu.H b/src/include/kernel/cpu.H index 0f36dd941..8f6fedb69 100644 --- a/src/include/kernel/cpu.H +++ b/src/include/kernel/cpu.H @@ -36,7 +36,7 @@ struct cpu_t task_t* idle_task; /** XSCOM mutex to serialize access per CPU */ - mutex_t * xscom_mutex; + mutex_t xscom_mutex; }; /** @fn getCpuId diff --git a/src/include/sys/sync.h b/src/include/sys/sync.h index 68b570aec..b6274a0a6 100644 --- a/src/include/sys/sync.h +++ b/src/include/sys/sync.h @@ -51,12 +51,6 @@ void barrier_destroy (barrier_t * i_barrier); void barrier_wait (barrier_t * i_barrier); /** - * Create a mutex and initialize a mutex - * @returns a pointer to the mutex - */ -mutex_t * mutex_create(); - -/** * Initialize a mutex object * @param[out] o_mutex the mutex * @pre an uninitialized mutex object @@ -65,11 +59,12 @@ mutex_t * mutex_create(); void mutex_init(mutex_t * o_mutex); /** - * Destroy a mutex - * @param[in/out] i_mutex The mutex - * @pre mutex must have been created with mutex_create() + * Destroy / Uninitialize a mutex object. + * @param[in] i_mutex The mutex + * @note This does not free the memory associated with the object if the mutex + * was allocated off the heap. */ -void mutex_destroy(mutex_t *& io_mutex); +void mutex_destroy(mutex_t * i_mutex); /** * Obtain a lock on a mutex diff --git a/src/kernel/cpumgr.C b/src/kernel/cpumgr.C index 844f8c44a..27417ef0d 100644 --- a/src/kernel/cpumgr.C +++ b/src/kernel/cpumgr.C @@ -8,6 +8,7 @@ #include <util/singleton.H> #include <arch/ppc.H> #include <kernel/timemgr.H> +#include <sys/sync.h> cpu_t* CpuManager::cv_cpus[CpuManager::MAXCPUS] = { NULL }; @@ -58,7 +59,7 @@ void CpuManager::startCPU(ssize_t i) cpu->scheduler_extra = NULL; cpu->kernel_stack = (void*) (((uint64_t)PageManager::allocatePage(4)) + 16320); - cpu->xscom_mutex = NULL; + cpu->xscom_mutex = (mutex_t)MUTEX_INITIALIZER; // Create idle task. cpu->idle_task = TaskManager::createIdleTask(); diff --git a/src/lib/sync.C b/src/lib/sync.C index a70761eef..093c7f41e 100644 --- a/src/lib/sync.C +++ b/src/lib/sync.C @@ -66,15 +66,6 @@ void barrier_wait (barrier_t * i_barrier) //----------------------------------------------------------------------------- -mutex_t * mutex_create() -{ - mutex_t * m = new mutex_t; - mutex_init(m); - return m; -} - -//----------------------------------------------------------------------------- - void mutex_init(mutex_t * o_mutex) { o_mutex->iv_val = 0; @@ -85,8 +76,7 @@ void mutex_init(mutex_t * o_mutex) void mutex_destroy(mutex_t *& i_mutex) { - delete i_mutex; - i_mutex = NULL; + i_mutex->iv_val = ~0; return; } diff --git a/src/lib/syscall_mmio.C b/src/lib/syscall_mmio.C index 91e4e113b..83a4f8f82 100644 --- a/src/lib/syscall_mmio.C +++ b/src/lib/syscall_mmio.C @@ -34,26 +34,7 @@ mutex_t * mmio_xscom_mutex() // Ensure task is pinned. assert(task->affinity_pinned); - - // Get mutex from cpu structure. - mutex_t * mutex = task->cpu->xscom_mutex; - - // Create mutex if not created. - if (NULL == mutex) - { - mutex = mutex_create(); - - // Atomically update xscom_mutex with new mutex. - if (!__sync_bool_compare_and_swap(&task->cpu->xscom_mutex, NULL, mutex)) - { - // Failed, some other thread beat us to it. - - // Destroy mutex and get one created by other thread in the - // meantime. - mutex_destroy(mutex); - mutex = task->cpu->xscom_mutex; - } - } - - return mutex; + + // Return mutex from cpu structure. + return &task->cpu->xscom_mutex; } |