From patchwork Mon Jun 29 23:40:51 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Likely X-Patchwork-Id: 29299 X-Patchwork-Delegate: benh@kernel.crashing.org Return-Path: X-Original-To: patchwork-incoming@bilbo.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id BB68BB70A6 for ; Tue, 30 Jun 2009 09:41:30 +1000 (EST) Received: by ozlabs.org (Postfix) id AE9BADDD1C; Tue, 30 Jun 2009 09:41:30 +1000 (EST) Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (bilbo.ozlabs.org [203.10.76.25]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bilbo.ozlabs.org", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id ACA3EDDD1B for ; Tue, 30 Jun 2009 09:41:30 +1000 (EST) Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by bilbo.ozlabs.org (Postfix) with ESMTP id 27F0FB7321 for ; Tue, 30 Jun 2009 09:41:06 +1000 (EST) Received: from ozlabs.org (ozlabs.org [203.10.76.45]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx.ozlabs.org", Issuer "CA Cert Signing Authority" (verified OK)) by bilbo.ozlabs.org (Postfix) with ESMTPS id F1EAEB709C for ; Tue, 30 Jun 2009 09:40:57 +1000 (EST) Received: by ozlabs.org (Postfix) id E128FDDD1B; Tue, 30 Jun 2009 09:40:57 +1000 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mail-px0-f182.google.com (mail-px0-f182.google.com [209.85.216.182]) by ozlabs.org (Postfix) with ESMTP id 6D6C5DDD04 for ; Tue, 30 Jun 2009 09:40:55 +1000 (EST) Received: by pxi12 with SMTP id 12so4006312pxi.17 for ; Mon, 29 Jun 2009 16:40:54 -0700 (PDT) Received: by 10.140.158.17 with SMTP id g17mr982528rve.22.1246318854220; Mon, 29 Jun 2009 16:40:54 -0700 (PDT) Received: from trillian.cg.shawcable.net (S01060016b61d1226.cg.shawcable.net [68.146.92.145]) by mx.google.com with ESMTPS id g22sm1622506rvb.5.2009.06.29.16.40.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 29 Jun 2009 16:40:53 -0700 (PDT) Received: from localhost.localdomain (trillian [127.0.0.1]) by trillian.cg.shawcable.net (Postfix) with ESMTP id 0D18BC89D8; Mon, 29 Jun 2009 17:40:52 -0600 (MDT) From: Grant Likely Subject: [PATCH] powerpc: Fix spin_event_timeout() to be robust over context switches To: linuxppc-dev@ozlabs.org, linux-kernel@vger.kernel.org, timur@freescale.com, jonsmirl@gmail.com Date: Mon, 29 Jun 2009 17:40:51 -0600 Message-ID: <20090629234035.12475.58493.stgit@localhost.localdomain> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org From: Grant Likely Current implementation of spin_event_timeout can be interrupted by an IRQ or context switch after testing the condition, but before checking the timeout. This can cause the loop to report a timeout when the condition actually became true in the middle. This patch adds one final check of the condition upon exit of the loop if the last test of the condition was still false. Signed-off-by: Grant Likely Acked-by: Timur Tabi --- arch/powerpc/include/asm/delay.h | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/include/asm/delay.h b/arch/powerpc/include/asm/delay.h index 1e2eb41..52e4d54 100644 --- a/arch/powerpc/include/asm/delay.h +++ b/arch/powerpc/include/asm/delay.h @@ -63,6 +63,8 @@ extern void udelay(unsigned long usecs); udelay(delay); \ else \ cpu_relax(); \ + if (!__ret) \ + __ret = (condition); \ __ret; \ })