From patchwork Mon Nov 12 04:12:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Finn Thain X-Patchwork-Id: 10678105 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9FDC15A6 for ; Mon, 12 Nov 2018 04:47:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9ED1E2A126 for ; Mon, 12 Nov 2018 04:47:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C6862A133; Mon, 12 Nov 2018 04:47:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id F0F1C2A126 for ; Mon, 12 Nov 2018 04:47:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Date:Subject:From: References:In-Reply-To:Message-Id:To:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=un7XbYKmdKhjiFV6KMt3YpjdxVId3vVqa3iCKXqyl+g=; b=YA/9qQ3tE2SBvS +ydxMDpI20F/U6gTc5aK/qsyUyanmFncrvGMaJnqibxcqOdpZv93yCKO6eapw19HJJqhl0tUaeR5h 9VKTklmy3SsGj8WmaOoztfSEVqMNZavSfK0yV/zD01xvd5VW8x+5S7IzWxaZw7qESHqRVlqlOd5NR Oo57TPasMFFjK6pPc9vUfzrjyJIAZMQvaE0gg4OYs61ErWRRGwlWdZK4W8BG0Yk0Q6LpfkvhTVw6Q 39Mo8VR+opjHekMfypSqBl0Xo5tqWhLFPLKtMrB4AkUvghKl00472qY3YoiUcevSwtOoBLCGKTTVU 6oT2EvFKYkieMGpYdhrw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gM483-0002vY-Nn; Mon, 12 Nov 2018 04:47:15 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gM481-0002v7-OJ for linux-arm-kernel@bombadil.infradead.org; Mon, 12 Nov 2018 04:47:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Date:Subject:From:References: In-Reply-To:Message-Id:Cc:To:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=knFLxFndB5uwvkRvkOlOqI5gihPaOHO/Bi96zV/qzpA=; b=m+ufS07bL/7c/d/0dsNvGeURV rooxOS0IYYiZfYKVAMa2KVOhWdl7YbLISkIqBcmEwibjDFn4vsGvsttPJ5VQbeRo2nGBQOdExTk6q QRbrVogSxlA3T9zkm0RoBWvigfOC45twbmWdUMSzxL/Lp3wuPz2UMi8pPHTuI5BsUL0bv5GzVmRYL GUnfDerw2JXsPPw3VQvSooaUh0cD9wSBc3gqrhLzvChKfC691LRULioW23hltEyFYya4WrDpOrd5J r+0pNQTIDtrGEUMPewmM4mOmiGrXaGRgdriUJ6rG0xGTTnn4sEfPsdlB76V3YYE7AnXY6Kni1dwSE i455Wqo4g==; Received: from kvm5.telegraphics.com.au ([98.124.60.144]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gM47y-0007sc-K5 for linux-arm-kernel@lists.infradead.org; Mon, 12 Nov 2018 04:47:12 +0000 Received: by kvm5.telegraphics.com.au (Postfix, from userid 502) id 75868297D8; Sun, 11 Nov 2018 23:46:55 -0500 (EST) To: Geert Uytterhoeven , Russell King Message-Id: In-Reply-To: References: From: Finn Thain Subject: [RFC PATCH 01/13] arm: Fix mutual exclusion in arch_gettimeoffset Date: Mon, 12 Nov 2018 15:12:39 +1100 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181112_044710_742767_CB463780 X-CRM114-Status: UNSURE ( 9.31 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Arnd Bergmann , Daniel Lezcano , Stephen N Chivers , linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, John Stultz , Thomas Gleixner , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Implementations of arch_gettimeoffset are generally not re-entrant and assume that interrupts have been disabled. Unfortunately this pre-condition got broken in v2.6.32. Fixes: 5cfc8ee0bb51 ("ARM: convert arm to arch_gettimeoffset()") Signed-off-by: Finn Thain --- arch/arm/mach-ebsa110/core.c | 5 +++++ arch/arm/mach-rpc/time.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/arch/arm/mach-ebsa110/core.c b/arch/arm/mach-ebsa110/core.c index 688e5fed49a7..479f89a1accf 100644 --- a/arch/arm/mach-ebsa110/core.c +++ b/arch/arm/mach-ebsa110/core.c @@ -160,12 +160,17 @@ static void __init ebsa110_init_early(void) */ static u32 ebsa110_gettimeoffset(void) { + unsigned long flags; unsigned long offset, count; + local_irq_save(flags); + __raw_writeb(0x40, PIT_CTRL); count = __raw_readb(PIT_T1); count |= __raw_readb(PIT_T1) << 8; + local_irq_restore(flags); + /* * If count > COUNT, make the number negative. */ diff --git a/arch/arm/mach-rpc/time.c b/arch/arm/mach-rpc/time.c index 2689771c1d38..852bb3801638 100644 --- a/arch/arm/mach-rpc/time.c +++ b/arch/arm/mach-rpc/time.c @@ -29,9 +29,12 @@ static u32 ioc_timer_gettimeoffset(void) { + unsigned long flags; unsigned int count1, count2, status; long offset; + local_irq_save(flags); + ioc_writeb (0, IOC_T0LATCH); barrier (); count1 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8); @@ -42,6 +45,8 @@ static u32 ioc_timer_gettimeoffset(void) barrier (); count2 = ioc_readb(IOC_T0CNTL) | (ioc_readb(IOC_T0CNTH) << 8); + local_irq_restore(flags); + offset = count2; if (count2 < count1) { /*