[Cbe-oss-dev] [PATCH 2/10 v2] MARS: task event flag fix bit clearing
Kazunori Asayama
asayama at sm.sony.co.jp
Fri Aug 29 14:59:01 EST 2008
Yuji Mano wrote:
> This fixes a bug in host-side task event flag where the wait routine was
> clearing the bits even when the clear mode is not set to auto.
>
> This also fixes a bug in mpu-side task event flag where the wait routine was not
> clearing the bits if the event bit was already set at the initial time of call
> without needing to enter the wait state.
>
> Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>
Acked-by: Kazunori Asayama <asayama at sm.sony.co.jp>
>
> ---
> v2:
> - remove unused variable 'bits' in mars_task_event_flag_wait (host)
> - remove random '-' garbage character
>
> src/host/lib/mars_task_event_flag.c | 50 +++++++++++++++---------------------
> src/mpu/lib/mars_task_event_flag.c | 4 ++
> 2 files changed, 25 insertions(+), 29 deletions(-)
>
> --- a/src/host/lib/mars_task_event_flag.c
> +++ b/src/host/lib/mars_task_event_flag.c
> @@ -171,43 +171,35 @@ int mars_task_event_flag_wait(struct mar
> MARS_CHECK_RET(((uintptr_t)event_flag & MARS_TASK_EVENT_FLAG_ALIGN_MASK)
> == 0, MARS_ERROR_ALIGN);
>
> - do {
> - /* check condition based on wait mode */
> - switch (mask_mode) {
> - case MARS_TASK_EVENT_FLAG_MASK_OR:
> + mars_mutex_lock((struct mars_mutex *)event_flag);
> +
> + /* check condition based on wait mode */
> + switch (mask_mode) {
> + case MARS_TASK_EVENT_FLAG_MASK_OR:
> + while ((event_flag->bits | mask) == 0) {
> + mars_mutex_unlock((struct mars_mutex *)event_flag);
> while ((event_flag->bits | mask) == 0)
> sched_yield();
> - break;
> - case MARS_TASK_EVENT_FLAG_MASK_AND:
> + mars_mutex_lock((struct mars_mutex *)event_flag);
> + }
> + break;
> + case MARS_TASK_EVENT_FLAG_MASK_AND:
> + while ((event_flag->bits & mask) != mask) {
> + mars_mutex_unlock((struct mars_mutex *)event_flag);
> while ((event_flag->bits & mask) != mask)
> sched_yield();
> - break;
> + mars_mutex_lock((struct mars_mutex *)event_flag);
> }
> + break;
> + }
>
> - mars_mutex_lock((struct mars_mutex *)event_flag);
> + /* clear event if clear mode is auto */
> + if (event_flag->clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
> + event_flag->bits &= ~mask;
>
> - /* check condition again after locking mutex */
> - switch (mask_mode) {
> - case MARS_TASK_EVENT_FLAG_MASK_OR:
> - if ((event_flag->bits | mask) != 0) {
> - event_flag->bits &= ~mask;
> - mars_mutex_unlock(
> - (struct mars_mutex *)event_flag);
> - return MARS_SUCCESS;
> - }
> - break;
> - case MARS_TASK_EVENT_FLAG_MASK_AND:
> - if ((event_flag->bits & mask) == mask) {
> - event_flag->bits &= ~mask;
> - mars_mutex_unlock(
> - (struct mars_mutex *)event_flag);
> - return MARS_SUCCESS;
> - }
> - break;
> - }
> + mars_mutex_unlock((struct mars_mutex *)event_flag);
>
> - mars_mutex_unlock((struct mars_mutex *)event_flag);
> - } while (1);
> + return MARS_SUCCESS;
> }
>
> int mars_task_event_flag_try_wait(struct mars_task_event_flag *event_flag,
> --- a/src/mpu/lib/mars_task_event_flag.c
> +++ b/src/mpu/lib/mars_task_event_flag.c
> @@ -226,6 +226,10 @@ int mars_task_event_flag_wait(uint64_t e
> return MARS_SUCCESS;
> }
>
> + /* clear event if clear mode is auto */
> + if (event_flag.clear_mode == MARS_TASK_EVENT_FLAG_CLEAR_AUTO)
> + event_flag.bits &= ~mask;
> +
> mars_mutex_unlock_put(event_flag_ea, (struct mars_mutex *)&event_flag);
>
> return MARS_SUCCESS;
>
>
--
(ASAYAMA Kazunori
(asayama at sm.sony.co.jp))
t
More information about the cbe-oss-dev
mailing list