From patchwork Fri Feb 11 22:25:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfgang Denk X-Patchwork-Id: 82841 X-Patchwork-Delegate: albert.aribaud@free.fr Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4B043B71AB for ; Sat, 12 Feb 2011 09:26:09 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BF75528145; Fri, 11 Feb 2011 23:26:05 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zWmcXsMH1RtD; Fri, 11 Feb 2011 23:26:05 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2307C28131; Fri, 11 Feb 2011 23:26:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11B3B28131 for ; Fri, 11 Feb 2011 23:26:01 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0IHVTzdGSAgh for ; Fri, 11 Feb 2011 23:25:59 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-out.m-online.net (mail-out.m-online.net [212.18.0.10]) by theia.denx.de (Postfix) with ESMTP id 0546D28130 for ; Fri, 11 Feb 2011 23:25:57 +0100 (CET) Received: from frontend1.mail.m-online.net (frontend1.mail.intern.m-online.net [192.168.8.180]) by mail-out.m-online.net (Postfix) with ESMTP id 99BE1188B5B8; Fri, 11 Feb 2011 23:25:56 +0100 (CET) X-Auth-Info: nAanGfPV/q0QYhHAFy8XAoDBpkaJvblBlKQBUIFJm0M= Received: from diddl.denx.de (host-80-81-18-216.customer.m-online.net [80.81.18.216]) by smtp-auth.mnet-online.de (Postfix) with ESMTPA id D45D01C001A2; Fri, 11 Feb 2011 23:25:56 +0100 (CET) Received: from gemini.denx.de (unknown [10.0.0.2]) by diddl.denx.de (Postfix) with ESMTP id B3DA3329659C; Fri, 11 Feb 2011 23:25:56 +0100 (CET) Received: by gemini.denx.de (Postfix, from userid 500) id 8EF491519FD; Fri, 11 Feb 2011 23:25:56 +0100 (CET) From: Wolfgang Denk To: u-boot@lists.denx.de Date: Fri, 11 Feb 2011 23:25:48 +0100 Message-Id: <1297463148-6612-1-git-send-email-wd@denx.de> X-Mailer: git-send-email 1.7.4 Subject: [U-Boot] [PATCH] ARM: fix write*() I/O accessors X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Commit 3c0659b "ARM: Avoid compiler optimization for readb, writeb and friends." introduced I/O accessors with memory barriers. Unfortunately the new write*() accessors introduced a bug: The problem is that the argument "v" gets evaluated twice. This breaks code like used here (from "drivers/net/dnet.c"): for (i = 0; i < wrsz; i++) writel(*bufp++, &dnet->regs->TX_DATA_FIFO); Use auxiliary variables to avoid such problems. Signed-off-by: Wolfgang Denk Cc: Albert Aribaud Cc: Alexander Holler Cc: Dirk Behme --- This patch fixes a pretty nasty problem. Everybody who has experienced strange failures on ARM lately should apply it ASAP and re-test. As far as I can tell at least the following drivers are affected: drivers/net/dnet.c: writel(*bufp++, &dnet->regs->TX_DATA_FIFO); drivers/usb/musb/musb_core.c: writeb(*data++, &musbr->fifox[ep]); drivers/mmc/pxa_mmc.c: writel(*src++, MMC_TXFIFO); drivers/mmc/mxcmmc.c: writel(*buf++, &host->base->buffer_access); drivers/spi/davinci_spi.c: writel(data1_reg_val | *txp++, &ds->regs->dat1); Albert, please apply ASAP! arch/arm/include/asm/io.h | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index 3886f15..1fbc531 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -133,9 +133,9 @@ extern inline void __raw_readsl(unsigned int addr, void *data, int longlen) #define __iormb() dmb() #define __iowmb() dmb() -#define writeb(v,c) ({ __iowmb(); __arch_putb(v,c); v; }) -#define writew(v,c) ({ __iowmb(); __arch_putw(v,c); v; }) -#define writel(v,c) ({ __iowmb(); __arch_putl(v,c); v; }) +#define writeb(v,c) ({ u8 __v = v; __iowmb(); __arch_putb(__v,c); __v; }) +#define writew(v,c) ({ u16 __v = v; __iowmb(); __arch_putw(__v,c); __v; }) +#define writel(v,c) ({ u32 __v = v; __iowmb(); __arch_putl(__v,c); __v; }) #define readb(c) ({ u8 __v = __arch_getb(c); __iormb(); __v; }) #define readw(c) ({ u16 __v = __arch_getw(c); __iormb(); __v; })