[Cbe-oss-dev] [PATCH 9/10] MARS: remove separate atomic implementation
Kazunori Asayama
asayama at sm.sony.co.jp
Thu Aug 28 16:29:08 EST 2008
Yuji Mano wrote:
> This removes the atomic.h headers for both host and mpu. Since the atomics are
> now used only in the mutex implementation, we get rid of the extra abstraction
> and use the atomic intrinsics directly in the mutex implementations.
>
> Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
>
(snip)
> --- a/src/mpu/lib/mars_mutex.c
> +++ b/src/mpu/lib/mars_mutex.c
> @@ -35,8 +35,9 @@
> * LIBRARY OR THE USE OR OTHER DEALINGS IN THE LIBRARY.
> */
>
> +#include <spu_mfcio.h>
> +
> #include "mars/mars_mutex.h"
> -#include "mars/mars_atomic.h"
> #include "mars/mars_dma.h"
> #include "mars/mars_error.h"
> #include "mars/mars_debug.h"
> @@ -78,21 +79,33 @@ int mars_mutex_lock_get(uint64_t mutex_e
>
> int status;
>
> - atomic_event_setup();
> + /* clear phantom events and set event mask */
> + if (spu_stat_event_status())
> + spu_write_event_ack(spu_read_event_status());
In this algorithm, even if phantom events are received, status of mutex
is checked again automatically, so I think we have no need to clear such
events here explicitly.
> + spu_write_event_mask(MFC_LLR_LOST_EVENT);
>
> do {
> - atomic_get(mutex, mutex_ea);
> + mfc_getllar(mutex, mutex_ea, 0, 0);
> + mfc_read_atomic_status();
>
> if (mutex->lock == MARS_MUTEX_LOCKED) {
> - atomic_event_wait();
> + spu_read_event_status();
> + spu_write_event_ack(MFC_LLR_LOST_EVENT);
> status = 1;
> } else {
> mutex->lock = MARS_MUTEX_LOCKED;
> - status = atomic_put(mutex, mutex_ea);
> + mfc_putllc(mutex, mutex_ea, 0, 0);
> + status = mfc_read_atomic_status() & MFC_PUTLLC_STATUS;
> }
> } while (status);
>
> - atomic_event_restore();
> + /* clean up any remnant events, as needed */
> + spu_write_event_mask(0);
> +
> + if (spu_stat_event_status()) {
> + spu_read_event_status();
> + spu_write_event_ack(MFC_LLR_LOST_EVENT);
> + }
>
> return MARS_SUCCESS;
> }
>
>
--
(ASAYAMA Kazunori
(asayama at sm.sony.co.jp))
t
More information about the cbe-oss-dev
mailing list