From: Takashi Yoshii <yoshii.takashi@renesas.com>
To: linux-sh@vger.kernel.org
Subject: Re: [bug report] dead lock (?) occur on ap325 board
Date: Wed, 28 Jan 2009 09:29:13 +0000 [thread overview]
Message-ID: <49802569.4000808@renesas.com> (raw)
In-Reply-To: <uprie4cmj.wl%morimoto.kuninori@renesas.com>
Kunihiro's fix looks good for me.
I have accidentally(?) fixed this one just same way as him.
I don't know why the original code does
> __res |= !__ex_flag;
to combine the results (counter and exception flag).
Logical-OR to scaler value is logically:) wrong.
# And using movt explicitly results stupid code generated anyway.
Because this __ex_flag is from "t" of movco, which means
0: interrupted by int or exp.
1: done successfully.
, it works as "Low-active" signal, and is not easy to handle
as a C-language conditon.
So, I think
int __done, __res;
....
if (unlikely(!done || __res != 0))
is easier to read.
This fixes the deadlock issue Kunihiro reported (by coincident:).
# I'm not sure if this is suitable to be marked as "earlyclobber",
# but I leave it as-is, since nothing bad will occur.
/yoshii
Fix conditon checking expression of __mutex_fastpath_*
Signed-off-by: Takashi YOSHII <yoshii.takashi@renesas.com>
---
arch/sh/include/asm/mutex-llsc.h | 21 +++++++++------------
1 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/arch/sh/include/asm/mutex-llsc.h b/arch/sh/include/asm/mutex-llsc.h
index ee839ee..66f045f 100644
--- a/arch/sh/include/asm/mutex-llsc.h
+++ b/arch/sh/include/asm/mutex-llsc.h
@@ -21,38 +21,36 @@
static inline void
__mutex_fastpath_lock(atomic_t *count, void (*fail_fn)(atomic_t *))
{
- int __ex_flag, __res;
+ int __done, __res;
__asm__ __volatile__ (
"movli.l @%2, %0 \n"
"add #-1, %0 \n"
"movco.l %0, @%2 \n"
"movt %1 \n"
- : "=&z" (__res), "=&r" (__ex_flag)
+ : "=&z" (__res), "=&r" (__done)
: "r" (&(count)->counter)
: "t");
- __res |= !__ex_flag;
- if (unlikely(__res != 0))
+ if (unlikely(!__done || __res != 0))
fail_fn(count);
}
static inline int
__mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
{
- int __ex_flag, __res;
+ int __done, __res;
__asm__ __volatile__ (
"movli.l @%2, %0 \n"
"add #-1, %0 \n"
"movco.l %0, @%2 \n"
"movt %1 \n"
- : "=&z" (__res), "=&r" (__ex_flag)
+ : "=&z" (__res), "=&r" (__done)
: "r" (&(count)->counter)
: "t");
- __res |= !__ex_flag;
- if (unlikely(__res != 0))
+ if (unlikely(!__done || __res != 0))
__res = fail_fn(count);
return __res;
@@ -61,19 +59,18 @@ __mutex_fastpath_lock_retval(atomic_t *count, int (*fail_fn)(atomic_t *))
static inline void
__mutex_fastpath_unlock(atomic_t *count, void (*fail_fn)(atomic_t *))
{
- int __ex_flag, __res;
+ int __done, __res;
__asm__ __volatile__ (
"movli.l @%2, %0 \n\t"
"add #1, %0 \n\t"
"movco.l %0, @%2 \n\t"
"movt %1 \n\t"
- : "=&z" (__res), "=&r" (__ex_flag)
+ : "=&z" (__res), "=&r" (__done)
: "r" (&(count)->counter)
: "t");
- __res |= !__ex_flag;
- if (unlikely(__res <= 0))
+ if (unlikely(!__done || __res <= 0))
fail_fn(count);
}
-- 1.6.0.6
next prev parent reply other threads:[~2009-01-28 9:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-23 9:04 [bug report] dead lock (?) occur on ap325 board morimoto.kuninori
2009-01-26 2:20 ` Paul Mundt
2009-01-26 5:01 ` morimoto.kuninori
2009-01-27 8:26 ` morimoto.kuninori
2009-01-27 8:32 ` Paul Mundt
2009-01-27 8:46 ` morimoto.kuninori
2009-01-27 8:49 ` Paul Mundt
2009-01-28 1:25 ` morimoto.kuninori
2009-01-28 9:29 ` Takashi Yoshii [this message]
2009-01-28 10:03 ` Paul Mundt
2009-01-29 0:34 ` yoshii.takashi
2009-01-29 23:54 ` morimoto.kuninori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49802569.4000808@renesas.com \
--to=yoshii.takashi@renesas.com \
--cc=linux-sh@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox