Skip to content

Commit

Permalink
[IA64] Fix bug in ia64 specific down() function
Browse files Browse the repository at this point in the history
Chen, Kenneth W wrote:
> The memory order semantics for include/asm-ia64/semaphore.h:down()
> doesn't look right.  It is using atomic_dec_return, which eventually
> translate into ia64_fetch_and_add() that uses release semantics.
> Shouldn't it use acquire semantics?

Use ia64_fetchadd() instead of atomic_dec_return()

Acked-by: Ken Chen <kenneth.w.chen@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
  • Loading branch information
Zoltan Menyhart authored and Tony Luck committed Jan 17, 2006
1 parent 8d08aed commit 4b16bfb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/asm-ia64/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static inline void
down (struct semaphore *sem)
{
might_sleep();
if (atomic_dec_return(&sem->count) < 0)
if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
__down(sem);
}

Expand All @@ -75,7 +75,7 @@ down_interruptible (struct semaphore * sem)
int ret = 0;

might_sleep();
if (atomic_dec_return(&sem->count) < 0)
if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
ret = __down_interruptible(sem);
return ret;
}
Expand All @@ -85,15 +85,15 @@ down_trylock (struct semaphore *sem)
{
int ret = 0;

if (atomic_dec_return(&sem->count) < 0)
if (ia64_fetchadd(-1, &sem->count.counter, acq) < 1)
ret = __down_trylock(sem);
return ret;
}

static inline void
up (struct semaphore * sem)
{
if (atomic_inc_return(&sem->count) <= 0)
if (ia64_fetchadd(1, &sem->count.counter, rel) <= -1)
__up(sem);
}

Expand Down

0 comments on commit 4b16bfb

Please sign in to comment.