From patchwork Wed Jan 28 09:29:13 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Yoshii X-Patchwork-Id: 4198 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n0S9TPCj022755 for ; Wed, 28 Jan 2009 09:29:25 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752984AbZA1J3Y (ORCPT ); Wed, 28 Jan 2009 04:29:24 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752989AbZA1J3Y (ORCPT ); Wed, 28 Jan 2009 04:29:24 -0500 Received: from mail.renesas.com ([202.234.163.13]:65252 "EHLO mail02.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752914AbZA1J3X (ORCPT ); Wed, 28 Jan 2009 04:29:23 -0500 X-AuditID: ac140385-00000005000002de-7f-4980256c530b Received: from guardian02.idc.renesas.com ([172.20.8.201]) by mail02.idc.renesas.com (sendmail) with ESMTP id n0S9TG86025081; Wed, 28 Jan 2009 18:29:16 +0900 (JST) Received: (from root@localhost) by guardian02.idc.renesas.com with id n0S9TGic027958; Wed, 28 Jan 2009 18:29:16 +0900 (JST) Received: from mta02.idc.renesas.com (localhost [127.0.0.1]) by mta02.idc.renesas.com with ESMTP id n0S9TI6m007185; Wed, 28 Jan 2009 18:29:18 +0900 (JST) Received: from [172.30.8.103] by ims05.idc.renesas.com (Sendmail) with ESMTPA id <0KE600K5GD0POL@ims05.idc.renesas.com>; Wed, 28 Jan 2009 18:29:16 +0900 (JST) Date: Wed, 28 Jan 2009 18:29:13 +0900 From: Takashi Yoshii Subject: Re: [bug report] dead lock (?) occur on ap325 board In-reply-to: <20090127083231.GA7407@linux-sh.org> To: Paul Mundt , morimoto.kuninori@renesas.com, SH-Linux Message-id: <49802569.4000808@renesas.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1 Content-transfer-encoding: 7bit User-Agent: Thunderbird 1.5.0.14 (Windows/20071210) References: <20090126022055.GE17836@linux-sh.org> <20090127083231.GA7407@linux-sh.org> X-Brightmail-Tracker: AAAAAA== Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org 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 --- arch/sh/include/asm/mutex-llsc.h | 21 +++++++++------------ 1 files changed, 9 insertions(+), 12 deletions(-) -- 1.6.0.6 -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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); }