From patchwork Fri Nov 30 17:06:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Logan Gunthorpe X-Patchwork-Id: 10706847 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 91B1C13A4 for ; Fri, 30 Nov 2018 17:06:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DAEE304BF for ; Fri, 30 Nov 2018 17:06:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71A04304E4; Fri, 30 Nov 2018 17:06:25 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 017FF304BF for ; Fri, 30 Nov 2018 17:06:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A7AE06B5943; Fri, 30 Nov 2018 12:06:16 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9419D6B5946; Fri, 30 Nov 2018 12:06:16 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 60BB66B5946; Fri, 30 Nov 2018 12:06:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-io1-f71.google.com (mail-io1-f71.google.com [209.85.166.71]) by kanga.kvack.org (Postfix) with ESMTP id 1AC2B6B5943 for ; Fri, 30 Nov 2018 12:06:16 -0500 (EST) Received: by mail-io1-f71.google.com with SMTP id u2so6043053iob.7 for ; Fri, 30 Nov 2018 09:06:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :date:message-id:in-reply-to:references:mime-version :content-transfer-encoding:subject; bh=VWinYsjQzvVJqpu4LggXenXz9nexykvqcUZD6g7FExM=; b=Qwel+u9ryJ75o8/ZtGhIJtreYwKMrI7h2xo0bZ3EyVmiu406Wb0zLRFn2w5B8lqyxl awCmIKE4++DbSmALM7+50RHR69qCLaMzrkwHKY5nur9T0IBuMVn4CWeB6Uh5AWbWjpnX cEB4zsNTjFuuhMrsAzWrCnVb2UkWhOXYIeoYhwtFOLvk64dJ1MM+2K1ySZlBxcF4Uy2E 8ca29gEvlD/H4orQfiBUCYdPP+sJuI/P2akaIaHn5SWJ82mVSfu/Xk6g+xeEoGrGksDr KGGf+3Y+DecJXqePT1xdF9y52iOpXNhozuvYcaCs3jgIdqcZ3Q2VWZFuehr+6Yf3GnTi XhOw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com X-Gm-Message-State: AA+aEWZfBPubiEGH/4w1fP8InVMNbm9Y3ZkPHzZZVNnyNi+z+6EmDt2s Muk+45MaxtK5hXL8AXg9O+l6Xh9R/lfkLcz/BkrskYaXnk55vvs7sAONmCrIstOpWbBggEyXA03 zCPZ8r69QsA95oJ80COfChOcyqpT/Hu4UbryRCwCY94iy8jn2TTUZx4hXM6Hw2XgImQ== X-Received: by 2002:a5e:9602:: with SMTP id a2mr5070820ioq.136.1543597575866; Fri, 30 Nov 2018 09:06:15 -0800 (PST) X-Google-Smtp-Source: AFSGD/W4SZ//GswgQNQlusErGbi3dCSdEofb2SpWVV+sYwDaQdNnPsVYB6ngrYnyOc8FWsmpICSe X-Received: by 2002:a5e:9602:: with SMTP id a2mr5070762ioq.136.1543597574843; Fri, 30 Nov 2018 09:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543597574; cv=none; d=google.com; s=arc-20160816; b=iuXVVbotb66SFiFHXDuS1SbOTm2jFAvR4+j3A9pUfxiEEij2dQ5xPRdUGqqaYcjTeR 7KAasv95yNgWtMKFgbWsOBKA5hvw5FENzK4DbKBBhXPUrHEVo+wwLRUWTJD3XbQPk7gb QQrq2bQDvdgLDIbOMD5H331ckvOwNMRzrf+XvImvmLnlO9FacdtDj0jsk4x8JFwzaoV9 VtpLs9caFrED4JGEvFk887DHvwG6ypffW1KthsyBNNoeQVtMTQSXMgw8Hxse7HNtLxLv 7zRXAzgsnSLp6phtwiaxgyL2IimaqeBMcj+IP+JV/AWGWDdGCzpUfhG/ihd2y1XrA5tL ciUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:cc:to:from; bh=VWinYsjQzvVJqpu4LggXenXz9nexykvqcUZD6g7FExM=; b=Fbs632p/z/J0e88VQM8CnZFDe7sWFKQQNdweRn5GLiMhjOoIliJ8+eIbPtvkJwr245 e0tUExvrz0d6D8VqX1Ps1AzivOscfQ++JYlUZ5RzSH5SlX3f5MhOzh6+tENqO/f65O+t XwLAt7Taf5q7/VKd6BbqdeHW7xryE/fb9Xt9caVR3HBgkSN4jFMluIsu+3shi6C5hqfv F9znHB7FvQViUhFqeUlEvYaosPWtA2CysCBHcdgbJ7NiHRYQbUbmdcNdtGau7Gxpv77s swbHQmQn+8oGsEW65WRygPe1Cyy2v9+wQ1vxmBK1gEuj3EKj+MFHvoQhMZ0brDnda1TF MX8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from ale.deltatee.com (ale.deltatee.com. [207.54.116.67]) by mx.google.com with ESMTPS id q6si3545085itj.38.2018.11.30.09.06.14 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Nov 2018 09:06:14 -0800 (PST) Received-SPF: pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) client-ip=207.54.116.67; Authentication-Results: mx.google.com; spf=pass (google.com: domain of gunthorp@deltatee.com designates 207.54.116.67 as permitted sender) smtp.mailfrom=gunthorp@deltatee.com Received: from cgy1-donard.priv.deltatee.com ([172.16.1.31]) by ale.deltatee.com with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gSmEz-0000qm-P2; Fri, 30 Nov 2018 10:06:12 -0700 Received: from gunthorp by cgy1-donard.priv.deltatee.com with local (Exim 4.89) (envelope-from ) id 1gSmEx-0004V6-El; Fri, 30 Nov 2018 10:06:07 -0700 From: Logan Gunthorpe To: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-ntb@googlegroups.com, linux-crypto@vger.kernel.org, linux-mm@kvack.org, Andrew Morton Cc: Arnd Bergmann , Greg Kroah-Hartman , Andy Shevchenko , =?utf-8?q?Horia_Geant=C4=83?= , Logan Gunthorpe , Thomas Gleixner , Kate Stewart , Philippe Ombredanne Date: Fri, 30 Nov 2018 10:06:01 -0700 Message-Id: <20181130170606.17252-2-logang@deltatee.com> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181130170606.17252-1-logang@deltatee.com> References: <20181130170606.17252-1-logang@deltatee.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 172.16.1.31 X-SA-Exim-Rcpt-To: linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-crypto@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, arnd@arndb.de, andy.shevchenko@gmail.com, horia.geanta@nxp.com, logang@deltatee.com, tglx@linutronix.de, gregkh@linuxfoundation.org, kstewart@linuxfoundation.org, pombredanne@nexb.com X-SA-Exim-Mail-From: gunthorp@deltatee.com Subject: [PATCH v24 1/6] iomap: Use non-raw io functions for io{read|write}XXbe X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Fix an asymmetry in the io{read|write}XXbe functions in that the big-endian variants make use of the raw io accessors while the little-endian variants use the regular accessors. Some architectures implement barriers to order against both spinlocks and DMA accesses and for these case, the big-endian variant of the API would not be protected. Thus, change the mmio_XXXXbe macros to use the appropriate swab() function wrapping the regular accessor. This is similar to what was done for PIO. When this code was originally written, barriers in the IO accessors were not common and the accessors simply wrapped the raw functions in a conversion to CPU endianness. Since then, barriers have been added in some architectures and are now missing in the big endian variant of the API. This also manages to silence a few sparse warnings that check for using the correct endian types which the original code did not annotate correctly. Signed-off-by: Logan Gunthorpe Cc: Thomas Gleixner Cc: Kate Stewart Cc: Philippe Ombredanne Cc: Greg Kroah-Hartman Cc: Arnd Bergmann Link: http://lkml.kernel.org/r/CAK8P3a25zQDxyaY3iVv+JmSSzs7F6ssGc+HdBkGs54ZfViX+Fg@mail.gmail.com --- lib/iomap.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/iomap.c b/lib/iomap.c index 541d926da95e..2c293b22569f 100644 --- a/lib/iomap.c +++ b/lib/iomap.c @@ -65,8 +65,8 @@ static void bad_io_access(unsigned long port, const char *access) #endif #ifndef mmio_read16be -#define mmio_read16be(addr) be16_to_cpu(__raw_readw(addr)) -#define mmio_read32be(addr) be32_to_cpu(__raw_readl(addr)) +#define mmio_read16be(addr) swab16(readw(addr)) +#define mmio_read32be(addr) swab32(readl(addr)) #endif unsigned int ioread8(void __iomem *addr) @@ -106,8 +106,8 @@ EXPORT_SYMBOL(ioread32be); #endif #ifndef mmio_write16be -#define mmio_write16be(val,port) __raw_writew(be16_to_cpu(val),port) -#define mmio_write32be(val,port) __raw_writel(be32_to_cpu(val),port) +#define mmio_write16be(val,port) writew(swab16(val),port) +#define mmio_write32be(val,port) writel(swab32(val),port) #endif void iowrite8(u8 val, void __iomem *addr)