Commit 3da86ee4 authored by Haavard Skinnemoen's avatar Haavard Skinnemoen

[AVR32] Fix atomic_add_unless() and atomic_sub_unless()

These functions depend on "result" being initalized to 0, but "result"
is not included as an input constraint to the inline assembly block
following its initialization, only as an output constraint. Thus gcc
thinks it doesn't need to initialize it, so result ends up undefined
if the "unless" condition is true.

This fixes an oops in sunrpc where the faulty atomics caused
rpciod_up() to not start the workqueue as it should.
Signed-off-by: default avatarHaavard Skinnemoen <hskinnemoen@atmel.com>
parent f3e26984
...@@ -101,7 +101,7 @@ static inline int atomic_sub_unless(atomic_t *v, int a, int u) ...@@ -101,7 +101,7 @@ static inline int atomic_sub_unless(atomic_t *v, int a, int u)
" mov %1, 1\n" " mov %1, 1\n"
"1:" "1:"
: "=&r"(tmp), "=&r"(result), "=o"(v->counter) : "=&r"(tmp), "=&r"(result), "=o"(v->counter)
: "m"(v->counter), "rKs21"(a), "rKs21"(u) : "m"(v->counter), "rKs21"(a), "rKs21"(u), "1"(result)
: "cc", "memory"); : "cc", "memory");
return result; return result;
...@@ -137,7 +137,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u) ...@@ -137,7 +137,7 @@ static inline int atomic_add_unless(atomic_t *v, int a, int u)
" mov %1, 1\n" " mov %1, 1\n"
"1:" "1:"
: "=&r"(tmp), "=&r"(result), "=o"(v->counter) : "=&r"(tmp), "=&r"(result), "=o"(v->counter)
: "m"(v->counter), "r"(a), "ir"(u) : "m"(v->counter), "r"(a), "ir"(u), "1"(result)
: "cc", "memory"); : "cc", "memory");
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment